46 template <
typename FILTER_TYPE,
typename OIMAGE_TYPE>
49 MLint usedFilteringDim,
59 if ((outIndex <0) || (usedFilteringDim < 0)){
66 typename OIMAGE_TYPE::Pointer filterOutput = filterPointer->GetOutput(
static_cast<unsigned int>(outIndex));
77 typename OIMAGE_TYPE::RegionType itkOutBox = ITKRegionFromMLSubImgBox<OIMAGE_TYPE>(outBox);
78 filterOutput->SetRequestedRegion(itkOutBox);
81 filterPointer->Update();
84 typename OIMAGE_TYPE::PixelType* dataPtr = filterOutput->GetBufferPointer();
87 SubImageBox outSubImgBox = MLSubImgBoxFromITKRegion<OIMAGE_TYPE>(filterOutput->GetBufferedRegion());
96 for (
MLint d=usedFilteringDim; d<6; ++d){
98 const size_t sizeTDimIdx =
static_cast<size_t>(d);
103 outSubImgBox.
v1[sizeTDimIdx] = outBox.
v1[sizeTDimIdx];
104 outSubImgBox.
v2[sizeTDimIdx] = outBox.
v2[sizeTDimIdx];
110 catch( itk::ExceptionObject & e ){
137 template <
typename FILTER_TYPE,
typename IN_IMAGE_TYPE>
143 MLint numActiveInputs)
150 if ((outIndex < 0) || (inIndex < 0) || (inIndex >= numActiveInputs)){
156 "",
"Returning empty box",
163 typename IN_IMAGE_TYPE::RegionType region =
164 ITKRegionFromMLSubImgBox<IN_IMAGE_TYPE>(outBox);
167 for (
MLint inps=0; inps < numActiveInputs; ++inps){
169 typename IN_IMAGE_TYPE::RegionType largestPossibleRegion =
173 typename IN_IMAGE_TYPE::Pointer m_Image = IN_IMAGE_TYPE::New();
174 m_Image->SetRegions(largestPossibleRegion);
175 filterPointer->SetInput(
static_cast<unsigned int>(inps), m_Image);
181 const unsigned int uOutIdx =
static_cast<unsigned int>(outIndex);
182 filterPointer->GetOutput(uOutIdx)->SetRequestedRegion(region);
183 filterPointer->GetOutput(uOutIdx)->UpdateOutputInformation();
184 filterPointer->GetOutput(uOutIdx)->PropagateRequestedRegion();
185 typename IN_IMAGE_TYPE::RegionType inReg =
186 filterPointer->GetInput(
static_cast<unsigned int>(inIndex))->GetRequestedRegion();
187 SubImageBox retRegion = MLSubImgBoxFromITKRegion<IN_IMAGE_TYPE>(inReg);
190 catch( itk::ExceptionObject & e )
207 template <
typename FILTER_TYPE,
typename OUT_IMAGE_TYPE>
217 typename OUT_IMAGE_TYPE::RegionType region =
224 filterPointer->GetOutput()->SetRequestedRegion(region);
225 filterPointer->GetOutput()->UpdateOutputInformation();
226 filterPointer->GetOutput()->PropagateRequestedRegion();
229 typename OUT_IMAGE_TYPE::RegionType outRegion =
230 filterPointer->GetOutput()->GetLargestPossibleRegion();
233 SubImageBox retRegion = MLSubImgBoxFromITKRegion<OUT_IMAGE_TYPE>(outRegion);
236 catch( itk::ExceptionObject & e )
252 template <
typename FILTER_TYPE,
typename OUT_IMAGE_TYPE,
typename IN_IMAGE_TYPE>
263 typename OUT_IMAGE_TYPE::RegionType region =
267 for (
int inps=0; inps < numImageInputs; ++inps){
271 typename IN_IMAGE_TYPE::RegionType largestPossibleRegion =
272 ITKRegionFromMLSubImgBox<IN_IMAGE_TYPE>(inSubImgBox);
275 typename IN_IMAGE_TYPE::Pointer m_Image = IN_IMAGE_TYPE::New();
277 m_Image->SetRegions(largestPossibleRegion);
278 filterPointer->SetInput(
static_cast<unsigned int>(inps), m_Image);
280 catch( itk::ExceptionObject & e )
291 filterPointer->GetOutput()->SetRequestedRegion(region);
292 filterPointer->GetOutput()->UpdateOutputInformation();
293 filterPointer->GetOutput()->PropagateRequestedRegion();
296 typename OUT_IMAGE_TYPE::RegionType outRegion =
297 filterPointer->GetOutput()->GetLargestPossibleRegion();
300 SubImageBox retRegion = MLSubImgBoxFromITKRegion<OUT_IMAGE_TYPE>(outRegion);
303 catch( itk::ExceptionObject & e )
SubImageBox getBoxFromImageExtent() const
Returns size of image as box with origin 0.
ImageVector getImageExtent() const
Returns the extent of the (sub)image.
Base class for an image processing module of the ML.
PagedImage * getInputImage(MLint inputIndex, bool getReal=false) const
Returns the output image of the module connected to input inputIndex.
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
const SubImageBox & getBox() const
Returns the box describing the origin/extent of the subimage.
void translate(const VectorType &offsetVector)
Shifts the whole box by an offset given by offsetVector.
VectorType v1
Corner v1 of the subimage region (included in region).
static TSubImageBox< intT > intersect(const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
Returns the overlapping region of subimage regions box1 and box2.
VectorType v2
Corner v2 of the subimage region (also included in region!).
#define ML_UNKNOWN_EXCEPTION
An unknown exception was detected and caught; this usually means that something for an unknown reason...
#define ITKML_TYPENAME
Define it empty. In some cases VC++6 does not accept "typename" where non WIN32 compilers do.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
ML_UTILS_EXPORT void MLPrintAndNotify(MLMessageType messageType, const char *libraryPrefix, const char *fPrefix, const char *functionName, const char *reason, const char *handling, const char *file, int line, MLErrorCode errCode)
Core error printing function which can be used by other applications.
SubImageBox determineImageFilterOutImageRegionTN(typename FILTER_TYPE::Pointer &filterPointer, Module &module, int numImageInputs)
Calculates the maximum extent of the ITK output image for 0 inputs and returns it as SubImageBox.
SubImageBox determineImageFilterInRegionTN(typename FILTER_TYPE::Pointer &filterPointer, Module &module, MLint inIndex, const SubImageBox &outBox, MLint outIndex, MLint numActiveInputs)
Calculates required input regions for any number of filter inputs.
SubImageBox determineImageFilterOutImageRegionT0(typename FILTER_TYPE::Pointer &filterPointer, Module &module)
Calculates the maximum extent of the ITK output image for 0 inputs and returns it as SubImageBox.
void testFunc_determineImageFilterOutImageRegionT0()
Test function for debugging purposes.
MLITK_SUPPORT_EXPORT void copyITKDataBufferToMLSubImg(void *itkData, size_t itkDataTypeSize, const SubImageBox &itkBox, SubImage &outSubImg)
Unpack ITK data buffer to an ML subimage and convert data formats if necessary.
TSubImageBox< MLint > SubImageBox
Define the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type.
bool processDataWithITKFilterAndFillOutSubImg(typename FILTER_TYPE::Pointer &filterPointer, int outIndex, MLint usedFilteringDim, const ImageVector &shift, const SubImageBox &outImgBox, SubImage &outSubImg, Module &module)
Takes the output image of the filter pointed to by filterPointer, and copies overlapping contents int...
void testFunc_processDataWithITKFilterAndFillOutSubImg()
Test function for debugging purposes.
void testFunc_determineImageFilterInRegionTN()
Test function for debugging purposes.
void testFunc_determineImageFilterOutImageRegionTN()
Test function for debugging purposes.
MLITK_SUPPORT_EXPORT void postITKException(const itk::ExceptionObject &e, const Module *module, MLMessageType messageType, const std::string &handling="")
Sends all available information from the ITKException itkException to the ML error handler.
TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.