Medical Imaging Interaction Toolkit  2018.4.99-6ca56567
Medical Imaging Interaction Toolkit

This subcategory includes adaptor classes for the integration of algorithms from other toolkits, especially ITK. More...

Collaboration diagram for Adaptor Classes:

Classes

class  mitk::AccessByItkException
 Exception class thrown in AccessByItk macros. More...
 
class  mitk::ImageToItk< TOutputImage >
 
class  mitk::ITKImageImport< TInputImage >
 Pipelined import of itk::Image. More...
 

Macros

#define AccessByItk(mitkImage, itkImageTypeFunction)
 Access a MITK image by an ITK image. More...
 
#define AccessFixedPixelTypeByItk(mitkImage, itkImageTypeFunction, pixelTypeSeq)
 Access a mitk-image with known pixeltype (but unknown dimension) by an itk-image. More...
 
#define AccessFixedDimensionByItk(mitkImage, itkImageTypeFunction, dimension)
 Access a mitk-image with known dimension by an itk-image. More...
 
#define AccessFixedTypeByItk(mitkImage, itkImageTypeFunction, pixelTypeSeq, dimSeq)
 Access a mitk-image with known type (pixel type and dimension) by an itk-image. More...
 
#define AccessByItk_n(mitkImage, itkImageTypeFunction, va_tuple)
 Access a MITK image by an ITK image with one or more parameters. More...
 
#define AccessFixedPixelTypeByItk_n(mitkImage, itkImageTypeFunction, pixelTypeSeq, va_tuple)
 Access a mitk-image with known pixeltype (but unknown dimension) by an itk-image with one or more parameters. More...
 
#define AccessFixedDimensionByItk_n(mitkImage, itkImageTypeFunction, dimension, va_tuple)
 Access a mitk-image with known dimension by an itk-image with one or more parameters. More...
 
#define AccessVectorFixedDimensionByItk_n(mitkImage, itkImageTypeFunction, dimension, va_tuple)
 Access a vector mitk-image with known dimension by a ITK vector image with one or more parameters. More...
 
#define AccessFixedTypeByItk_n(mitkImage, itkImageTypeFunction, pixelTypeSeq, dimSeq, va_tuple)
 Access a mitk-image with known type (pixel type and dimension) by an itk-image with one or more parameters. More...
 
#define AccessTwoImagesFixedDimensionByItk(mitkImage1, mitkImage2, itkImageTypeFunction, dimension)
 Access two mitk-images with known dimension by itk-images. More...
 
#define InstantiateAccessFunctionForFixedType(itkImgFunc, pixelTypeSeq, dimSeq)
 Instantiate access function for the given pixel types and dimensions. More...
 
#define InstantiateAccessFunction(itkImgFunc)
 Instantiate access function for all datatypes and dimensions. More...
 
#define InstantiateAccessFunctionForFixedDimension(itkImgFunc, dim)
 Instantiate access function for all datatypes and a specific dimension. More...
 
#define InstantiateAccessFunctionForFixedPixelType(itkImgFunc, pixelTypeSeq)
 Instantiate access function for all given pixel types and all dimensions. More...
 
#define InstantiateAccessFunctionForIntegralPixelTypes(itkImgFunc)
 Instantiate access function for integral datatypes and all dimensions. More...
 
#define InstantiateAccessFunctionForFloatingPixelTypes(itkImgFunc)
 Instantiate access function for floating point datatypes and all dimensions. More...
 

Functions

template<typename ItkOutputImageType >
void MITKCORE_EXPORT mitk::CastToItkImage (const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
 Cast an mitk::Image to an itk::Image with a specific type. More...
 
template<typename TPixelType , unsigned int VImageDimension>
void MITKCORE_EXPORT mitk::CastToItkImage (const mitk::Image *mitkImage, itk::SmartPointer< itk::VectorImage< TPixelType, VImageDimension >> &itkOutputImage)
 Cast an mitk::Image to an itk::VectorImage with a specific type. More...
 
template<typename ItkOutputImageType >
void mitk::CastToMitkImage (const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
 Cast an itk::Image (with a specific type) to an mitk::Image. More...
 
template<typename ItkOutputImageType >
void mitk::CastToMitkImage (const ItkOutputImageType *itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
 Cast an itk::Image (with a specific type) to an mitk::Image. More...
 
template<typename TPixel , unsigned int VDimension>
ImageTypeTrait< TPixel, VDimension >::ImageType::Pointer mitk::ImageToItkImage (mitk::Image *mitkImage)
 Convert a MITK image to an ITK image. More...
 
template<typename TPixel , unsigned int VDimension>
ImageTypeTrait< TPixel, VDimension >::ImageType::ConstPointer mitk::ImageToItkImage (const mitk::Image *mitkImage)
 Convert a MITK image to an ITK image. More...
 
template<typename ItkOutputImageType >
Image::Pointer mitk::ImportItkImage (const itk::SmartPointer< ItkOutputImageType > &itkimage, const BaseGeometry *geometry=nullptr, bool update=true)
 Imports an itk::Image (with a specific type) as an mitk::Image.Instantiates instance of ITKImageImport. mitk::ITKImageImport does not cast pixel types etc., it just imports image data. If you get a compile error, try image.GetPointer(). More...
 
template<typename ItkOutputImageType >
Image::Pointer mitk::ImportItkImage (const ItkOutputImageType *itkimage, const BaseGeometry *geometry=nullptr, bool update=true)
 Imports an itk::Image (with a specific type) as an mitk::Image.Instantiates instance of ITKImageImport mitk::ITKImageImport does not cast pixel types etc., it just imports image data. If you get a compile error, try image.GetPointer(). More...
 
template<typename ItkOutputImageType >
Image::Pointer mitk::GrabItkImageMemory (itk::SmartPointer< ItkOutputImageType > &itkimage, mitk::Image *mitkImage=nullptr, const BaseGeometry *geometry=nullptr, bool update=true)
 Grabs the memory of an itk::Image (with a specific type) and puts it into an mitk::Image.The memory is managed by the mitk::Image after calling this function. The itk::Image remains valid until the mitk::Image decides to free the memory. More...
 
template<typename ItkOutputImageType >
Image::Pointer mitk::GrabItkImageMemory (ItkOutputImageType *itkimage, mitk::Image *mitkImage=nullptr, const BaseGeometry *geometry=nullptr, bool update=true)
 Grabs the memory of an itk::Image (with a specific type) and puts it into an mitk::Image.The memory is managed by the mitk::Image after calling this function. The itk::Image remains valid until the mitk::Image decides to free the memory. More...
 

Detailed Description

This subcategory includes adaptor classes for the integration of algorithms from other toolkits, especially ITK.

The task of most of the classes in this category is to deal with the conversion between the (templated) itk::Image and the (not-templated) mitk::Image. Methods for conversion are provided for both directions:

Care has to be taken regarding the involved coordinate systems, see ITK image vs MITK coordinate systems.

For limitations on ITK-type conversion see the section Limitations.

VTK-based access to MITK images is straightforward: simply ask your mitk::Image for a vtkImageData by calling Image:GetVtkImageData. Similarily, to get a vtkPolyData from the MITK class for storing surfaces, mitk::Surface, call Surface::GetVtkPolyData.

MITK to ITK adaptors

Pixel type and dimension of MITK images can be specified at run time whereas ITK images are templated over the pixel type and the dimension, thus in ITK both need to be specified at compile time.

There two different situations, which are covered in the following sub-sections:

Converting MITK images to ITK images with known type

If you know the type (pixel type and dimension) of the MITK image you have two options:

Thus, mitk::CastToItkImage is the more powerful variant: here it is sufficient that you know what you want to have (the ITK data type), to which the MITK image will be casted, if needed.

Accessing an MITK image as an ITK image (type unkown)

If you do not know the pixel type/dimension of an MITK image in advance and the ITK image should have the same (unkown) type, e.g., to run a filter on the MITK image data, we cannot really convert to one ITK image. This is simply, because we cannot instantiate an itk::Image object with unkown pixel type/dimension.

Nevertheless, MITK provides a way to access an MITK image as if it was an ITK image of unkown type. To do so, first define an access method, which is templated as an ITK image is:

template<typename TPixel, unsigned int VImageDimension>
MyAccessMethod(itk::Image<TPixel, VImageDimension>* itkImage)
{
...
}

If you don't understand this template syntax, we need to refer you to an C++ text book. Understanding template syntax is crucial to successfully using ITK.

To call this templated method with an (untemplated) mitk::Image, you can use the AccessByItk macro (or one of its variants) from mitkImageAccessByItk.h. This macro checks for the actual image type of the mitk::Image and does any neccessary conversions. This works for all configured pixel types (default is char, unsigned char, short, unsigned short, int, unsigned int, float, and double) and dimensions (default is 2 and 3). You can change the considered default pixel types and dimensions by modifying the CMake variables MITK_ACCESSBYITK_*.

AccessByItk(mitkImage, MyAccessMethod)

An example is given in Step6Page.

The AccessBy... macros create quite a lot of code: the user defined access method has to be compiled for all considered pixel types times the supported dimensions (default is 2 and 3). Therefore, depending on the complexity of the access method, some compilers may run into problems with memory. One workaround is to use explicit instantiation and distribute it on multiple files. The macro InstantiateAccessFunction and its variants are for this purpose. An example is again given in Step6Page. Another workaround is to reduce the created code by fixing either the type (AccessFixedTypeByItk) or dimension (AccessFixedDimensionByItk).

There is one variant of AccessByItk... for passing additional parameters to the access-function, called AccessFixedTypeByItk_n.

mitkImage.h

mitkImageCast.h

mitkImageToItk.h

mitkITKImageImport.h

ITK to MITK adaptors

Converting ITK images to MITK is easier than the other way round. Basically, you have three options:

ITK image vs MITK coordinate systems

Converting coordinates from the ITK physical coordinate system (which does not support rotated images) to the MITK world coordinate system should be performed via the Geometry3D of the Image, see mitk::Geometry3D::WorldToItkPhysicalPoint.

Limitations

The MITK to ITK adaptors for unspecified types have to do type multiplexing at compile time. This is done for a limited number of pixel types and dimensions, defined during the CMake configuration process.

Especially, color image types are not multiplexed. This is because many algorithms do not support color images (e.g. with data type itk::RGBPixel) because they do not have a scalar data type. If your algorithm do support color and you want to multiplex over all scalar as well as the color data type, try the following:

try
{
AccessFixedPixelTypeByItk(myMitkImageThatMaybeColor, // The MITK image which may be a color image
myAlgorithmFunction, // The template method being able to handle color
MITK_ACCESSBYITK_PIXEL_TYPES_SEQ // The default pixel type sequence
(itk::RGBPixel<unsigned char>) // The additional type sequence
)
}
{
// add error handling here
}

Macro Definition Documentation

◆ AccessByItk

#define AccessByItk (   mitkImage,
  itkImageTypeFunction 
)

Access a MITK image by an ITK image.

Define a templated function or method (itkImageTypeFunction) within which the mitk-image (mitkImage) is accessed:

template < typename TPixel, unsigned int VImageDimension >
void ExampleFunction( itk::Image<TPixel, VImageDimension>* itkImage );

The itk::Image passed to the function/method has the same data-pointer as the mitk-image. Depending on the const-ness of the mitkImage, your templated access function needs to take a const or non-const itk::Image pointer and you will get read-only or full read/write access to the data vector of the mitk-image using the itk-image.

Example code using the access function above:

mitk::Image* inputMitkImage = ...
try
{
AccessByItk(inputMitkImage, ExampleFunction);
}
{
// mitk::Image is of wrong pixel type or dimension,
// insert error handling here
}
Parameters
mitkImageThe MITK input image.
itkImageTypeFunctionThe templated access-function to be called.
Exceptions
mitk::AccessByItkExceptionIf mitkImage is of unsupported pixel type or dimension.
Note
If your inputMitkImage is an mitk::Image::Pointer, use inputMitkImage.GetPointer()
If you need to pass additional parameters to your access-function (itkImageTypeFunction), use AccessByItk_n.
If you know the dimension of your input mitk-image, it is better to use AccessFixedDimensionByItk (less code is generated).
See also
AccessFixedDimensionByItk
AccessFixedTypeByItk
AccessFixedPixelTypeByItk
AccessByItk_n

Definition at line 188 of file mitkImageAccessByItk.h.

Referenced by mitk::LabelSetImage::AddLayer(), mitk::LabelSetImage::ClearBuffer(), QmitkAdaptiveRegionGrowingToolGUI::ConfirmSegmentation(), mitk::ImageToUnstructuredGridFilter::GenerateData(), mitk::MRNormTwoRegionsBasedFilter::GenerateData(), mitk::MRNormLinearStatisticBasedFilter::GenerateData(), mitk::MaskImageFilter::GenerateData(), mitk::IgnorePixelMaskGenerator::GetMask(), and mitk::LabelSetImage::Initialize().

◆ AccessByItk_n

#define AccessByItk_n (   mitkImage,
  itkImageTypeFunction,
  va_tuple 
)

Access a MITK image by an ITK image with one or more parameters.

Define a templated function or method (itkImageTypeFunction) with one ore more additional parameters, within which the mitk-image (mitkImage) is accessed:

template < typename TPixel, unsigned int VImageDimension >
void ExampleFunction( itk::Image<TPixel, VImageDimension>* itkImage, SomeType param);

The itk::Image passed to the function/method has the same data-pointer as the mitk-image. So you have full read- and write- access to the data vector of the mitk-image using the itk-image. Call by:

SomeType param = ...
mitk::Image* inputMitkImage = ...
try
{
AccessByItk_n(inputMitkImage, ExampleFunction, (param));
}
{
// mitk::Image is of wrong pixel type or dimension,
// insert error handling here
}
Parameters
va_tupleA variable length tuple containing the arguments to be passed to the access function itkImageTypeFunction, e.g. ("first", 2, THIRD).
mitkImageThe MITK input image.
itkImageTypeFunctionThe templated access-function to be called.
Exceptions
mitk::AccessByItkExceptionIf mitkImage is of unsupported pixel type or dimension.
Note
If your inputMitkImage is an mitk::Image::Pointer, use inputMitkImage.GetPointer()
If you know the dimension of your input mitk-image, it is better to use AccessFixedDimensionByItk_n (less code is generated).
See also
AccessFixedDimensionByItk_n
AccessFixedTypeByItk_n
AccessFixedPixelTypeByItk_n
AccessByItk

Definition at line 372 of file mitkImageAccessByItk.h.

Referenced by mitk::ArithmeticOperation::Abs(), mitk::ArithmeticOperation::Acos(), mitk::ArithmeticOperation::Add(), mitk::ArithmeticOperation::Asin(), mitk::ArithmeticOperation::Atan(), mitk::HistogramGenerator::ComputeHistogram(), mitk::ArithmeticOperation::Cos(), mitk::ArithmeticOperation::Divide(), mitk::ROIBasedParameterFitImageGenerator::DoFitAndGetResults(), mitk::ArithmeticOperation::Exp(), mitk::ArithmeticOperation::ExpNeg(), mitk::OtsuSegmentationFilter::GenerateData(), mitk::CorrectorAlgorithm::GenerateData(), mitk::TransformationOperation::LaplacianOfGaussian(), mitk::ArithmeticOperation::Log10(), mitk::ImageMappingHelper::map(), mitk::MaskCleaningOperation::MaskOutlierFiltering(), mitk::ArithmeticOperation::Multiply(), mitk::TransformationOperation::MultiResolution(), mitk::MaskCleaningOperation::RangeBasedMasking(), mitk::TransformationOperation::ResampleImage(), mitk::TransformationOperation::ResampleMask(), mitk::ArithmeticOperation::Sin(), mitk::ArithmeticOperation::Sqrt(), mitk::ArithmeticOperation::Square(), mitk::ArithmeticOperation::Subtract(), mitk::ArithmeticOperation::Tan(), mitk::BinaryThresholdTool::UpdatePreview(), mitk::BinaryThresholdULTool::UpdatePreview(), and mitk::TransformationOperation::WaveletForward().

◆ AccessFixedDimensionByItk

#define AccessFixedDimensionByItk (   mitkImage,
  itkImageTypeFunction,
  dimension 
)

Access a mitk-image with known dimension by an itk-image.

For usage, see AccessByItk.

Parameters
dimensionDimension of the mitk-image. If the image has a different dimension, a mitk::AccessByItkException exception is thrown.
mitkImageThe MITK input image.
itkImageTypeFunctionThe templated access-function to be called.
Exceptions
mitk::AccessByItkExceptionIf mitkImage is of unsupported pixel type or dimension.
Note
If you do not know the dimension for sure, use AccessByItk.
See also
AccessByItk
AccessFixedDimensionByItk_n
AccessFixedTypeByItk
AccessFixedPixelTypeByItk

Definition at line 277 of file mitkImageAccessByItk.h.

Referenced by mitk::LabelSetImage::AddLayer(), mitk::VolumeCalculator::ComputeVolume(), doDumping(), mitk::PixelBasedParameterFitImageGenerator::DoFitAndGetResults(), mitk::PixelBasedDescriptionParameterImageGenerator::DoParameterCalculationAndGetResults(), mitk::DiffImageApplier::ExecuteOperation(), mitk::MaskedDynamicImageStatisticsGenerator::Generate(), mitk::ModelSignalImageGenerator::Generate(), mitk::BilateralFilter::GenerateData(), mitk::ImageToContourModelFilter::GenerateData(), mitk::CESTImageNormalizationFilter::GenerateData(), mitk::ToFImageDownsamplingFilter::GenerateData(), mitk::ImageToLiveWireContourFilter::GenerateData(), mitk::ImageToContourFilter::GenerateData(), mitk::ExtractDirectedPlaneImageFilterNew::GenerateData(), mitk::OverwriteDirectedPlaneImageFilter::GenerateData(), mitk::OverwriteSliceImageFilter::GenerateData(), mitk::ExtractImageFilter::GenerateData(), mitk::LabelSetImage::Initialize(), mitk::ConcentrationCurveGenerator::PrepareBaselineImage(), mitk::ImageLiveWireContourModelFilter::SetInput(), mitk::MaskedAlgorithmHelper::SetMasks(), and mitk::CalculateSegmentationVolume::ThreadedUpdateFunction().

◆ AccessFixedDimensionByItk_n

#define AccessFixedDimensionByItk_n (   mitkImage,
  itkImageTypeFunction,
  dimension,
  va_tuple 
)

Access a mitk-image with known dimension by an itk-image with one or more parameters.

For usage, see AccessByItk_n.

Parameters
dimensionDimension of the mitk-image. If the image has a different dimension, a mitk::AccessByItkException exception is thrown.
va_tupleA variable length tuple containing the arguments to be passed to the access function itkImageTypeFunction, e.g. ("first", 2, THIRD).
mitkImageThe MITK input image.
itkImageTypeFunctionThe templated access-function to be called.
Exceptions
mitk::AccessByItkExceptionIf mitkImage is of unsupported pixel type or dimension.
Note
If you do not know the dimension for sure, use AccessByItk_n.
See also
AccessByItk_n
AccessFixedDimensionByItk
AccessFixedTypeByItk_n
AccessFixedPixelTypeByItk_n

Definition at line 497 of file mitkImageAccessByItk.h.

Referenced by ComputeIntensityProfile(), mitk::ConvertLabelSetImageToImage(), mitk::LabelSetImage::SetActiveLayer(), mitk::RegEvaluationObject::SetMovingImage(), and mitk::RegEvaluationObject::SetTargetImage().

◆ AccessFixedPixelTypeByItk

#define AccessFixedPixelTypeByItk (   mitkImage,
  itkImageTypeFunction,
  pixelTypeSeq 
)

Access a mitk-image with known pixeltype (but unknown dimension) by an itk-image.

For usage, see AccessByItk.

Parameters
pixelTypeSeqA sequence of pixel types, like (short)(char)(int)
mitkImageThe MITK input image.
itkImageTypeFunctionThe templated access-function to be called.
Exceptions
mitk::AccessByItkExceptionIf mitkImage is of unsupported pixel type or dimension.

If the image has a different pixel type, a mitk::AccessByItkException exception is thrown. If you do not know the pixel type for sure, use AccessByItk.

See also
AccessByItk
AccessFixedDimensionByItk
AccessFixedTypeByItk
AccessFixedPixelTypeByItk_n

Definition at line 213 of file mitkImageAccessByItk.h.

◆ AccessFixedPixelTypeByItk_n

#define AccessFixedPixelTypeByItk_n (   mitkImage,
  itkImageTypeFunction,
  pixelTypeSeq,
  va_tuple 
)

Access a mitk-image with known pixeltype (but unknown dimension) by an itk-image with one or more parameters.

For usage, see AccessByItk_n.

Parameters
va_tupleA variable length tuple containing the arguments to be passed to the access function itkImageTypeFunction, e.g. ("first", 2, THIRD).
pixelTypeSeqA sequence of pixel types, like (short)(char)(int).
mitkImageThe MITK input image.
itkImageTypeFunctionThe templated access-function to be called.
Exceptions
mitk::AccessByItkExceptionIf mitkImage is of unsupported pixel type or dimension.

If the image has a different pixel type, a mitk::AccessByItkException exception is thrown. If you do not know the pixel type for sure, use AccessByItk_n.

See also
AccessByItk_n
AccessFixedDimensionByItk_n
AccessFixedTypeByItk_n
AccessFixedPixelTypeByItk

Definition at line 400 of file mitkImageAccessByItk.h.

Referenced by mitk::ConvertCompositePixelValueToString().

◆ AccessFixedTypeByItk

#define AccessFixedTypeByItk (   mitkImage,
  itkImageTypeFunction,
  pixelTypeSeq,
  dimSeq 
)

Access a mitk-image with known type (pixel type and dimension) by an itk-image.

The provided mitk-image must be in the set of types created by taking the cartesian product of the pixel type sequence and the dimension sequence. For example, a call to

AccessFixedTypeByItk(myMitkImage, MyAccessFunction, (short)(int), (2)(3))

asserts that the type of myMitkImage (pixeltype,dim) is in the set {(short,2),(short,3),(int,2),(int,3)}. For more information, see AccessByItk.

Parameters
pixelTypeSeqA sequence of pixel types, like (short)(char)(int).
dimSeqA sequence of dimensions, like (2)(3).
mitkImageThe MITK input image.
itkImageTypeFunctionThe templated access-function to be called.
Exceptions
mitk::AccessByItkExceptionIf mitkImage is of unsupported pixel type or dimension.

If the image has a different dimension or pixel type, a mitk::AccessByItkException exception is thrown.

Note
If you do not know the dimension for sure, use AccessByItk.
See also
AccessByItk
AccessFixedDimensionByItk
AccessFixedTypeByItk_n
AccessFixedPixelTypeByItk

Definition at line 314 of file mitkImageAccessByItk.h.

Referenced by mitk::ImageToOpenCVImageFilter::GetOpenCVMat().

◆ AccessFixedTypeByItk_n

#define AccessFixedTypeByItk_n (   mitkImage,
  itkImageTypeFunction,
  pixelTypeSeq,
  dimSeq,
  va_tuple 
)

Access a mitk-image with known type (pixel type and dimension) by an itk-image with one or more parameters.

For usage, see AccessFixedTypeByItk.

Parameters
pixelTypeSeqA sequence of pixel types, like (short)(char)(int).
dimSeqA sequence of dimensions, like (2)(3).
va_tupleA variable length tuple containing the arguments to be passed to the access function itkImageTypeFunction, e.g. ("first", 2, THIRD).
mitkImageThe MITK input image.
itkImageTypeFunctionThe templated access-function to be called.
Exceptions
mitk::AccessByItkExceptionIf mitkImage is of unsupported pixel type or dimension.

If the image has a different dimension or pixel type, a mitk::AccessByItkException exception is thrown.

Note
If you do not know the dimension for sure, use AccessByItk_n.
See also
AccessByItk_n
AccessFixedDimensionByItk_n
AccessFixedTypeByItk
AccessFixedPixelTypeByItk_n

Definition at line 554 of file mitkImageAccessByItk.h.

Referenced by main().

◆ AccessTwoImagesFixedDimensionByItk

#define AccessTwoImagesFixedDimensionByItk (   mitkImage1,
  mitkImage2,
  itkImageTypeFunction,
  dimension 
)

Access two mitk-images with known dimension by itk-images.

Define a templated function or method (itkImageTypeFunction) within which the mitk-images (mitkImage1 and mitkImage2) are accessed:

template <typename TPixel1, unsigned int VImageDimension1, typename TPixel2, unsigned int VImageDimension2>
void ExampleFunctionTwoImages(itk::Image<TPixel1, VImageDimension1>* itkImage1, itk::Image<TPixel2,
VImageDimension2>* itkImage2);

The itk::Image passed to the function/method has the same data-pointer as the mitk-image. So you have full read- and write- access to the data vector of the mitk-image using the itk-image. Call by:

mitk::Image* inputMitkImage1 = ...
mitk::Image* inputMitkImage2 = ...
try
{
AccessTwoImagesFixedDimensionByItk(inputMitkImage1, inputMitkImage2, ExampleFunctionTwoImages, 3);
}
{
// mitk::Image arguments are of wrong pixel type or dimension,
// insert error handling here
}
Note
If your inputMitkImage1 or inputMitkImage2 is a mitk::Image::Pointer, use inputMitkImage1.GetPointer().
Parameters
mitkImage1The first MITK input image.
mitkImage1The second MITK input image.
itkImageTypeFunctionThe name of the template access-function to be called.
dimensionDimension of the two mitk-images.
Exceptions
mitk::AccessByItkExceptionIf mitkImage1 and mitkImage2 have different dimensions or one of the images is of unsupported pixel type or dimension.
See also
AccessByItk

Definition at line 681 of file mitkImageAccessByItk.h.

Referenced by mitk::NonStaticArithmeticOperation::CallExecuteTwoImageFilter(), mitk::MAPAlgorithmHelper::CheckData(), mitk::ConcentrationCurveGenerator::ConvertSignalToConcentrationCurve(), mitk::LabelSetImage::InitializeByLabeledImage(), and mitk::MAPAlgorithmHelper::SetData().

◆ AccessVectorFixedDimensionByItk_n

#define AccessVectorFixedDimensionByItk_n (   mitkImage,
  itkImageTypeFunction,
  dimension,
  va_tuple 
)

Access a vector mitk-image with known dimension by a ITK vector image with one or more parameters.

For usage, see AccessByItk_n.

Parameters
dimensionDimension of the mitk-image. If the image has a different dimension, a mitk::AccessByItkException exception is thrown.
va_tupleA variable length tuple containing the arguments to be passed to the access function itkImageTypeFunction, e.g. ("first", 2, THIRD).
mitkImageThe MITK input image.
itkImageTypeFunctionThe templated access-function to be called.
Exceptions
mitk::AccessByItkExceptionIf mitkImage is of unsupported pixel type or dimension.
Note
If you do not know the dimension for sure, use AccessVectorPixelTypeByItk_n.
See also
AccessByItk_n
AccessVectorPixelTypeByItk_n
AccessFixedTypeByItk_n

Definition at line 523 of file mitkImageAccessByItk.h.

Referenced by mitk::BoundingObjectCutter::ComputeData(), and mitk::ConvertImageToLabelSetImage().

◆ InstantiateAccessFunction

#define InstantiateAccessFunction (   itkImgFunc)

Instantiate access function for all datatypes and dimensions.

See also
InstantiateAccessFunctionForFixedType

Definition at line 95 of file mitkInstantiateAccessFunctions.h.

◆ InstantiateAccessFunctionForFixedDimension

#define InstantiateAccessFunctionForFixedDimension (   itkImgFunc,
  dim 
)

Instantiate access function for all datatypes and a specific dimension.

See also
InstantiateAccessFunctionForFixedType
Parameters
itkImgFuncThe custom part of the name of the macro to be called.
dima sequence of dimensions, like (2)(3).

Definition at line 108 of file mitkInstantiateAccessFunctions.h.

◆ InstantiateAccessFunctionForFixedPixelType

#define InstantiateAccessFunctionForFixedPixelType (   itkImgFunc,
  pixelTypeSeq 
)

Instantiate access function for all given pixel types and all dimensions.

See also
InstantiateAccessFunctionForFixedType
Parameters
itkImgFuncThe custom part of the name of the macro to be called.
pixelTypeSeqa sequence of types, like (int)(short)(char).

Definition at line 121 of file mitkInstantiateAccessFunctions.h.

◆ InstantiateAccessFunctionForFixedType

#define InstantiateAccessFunctionForFixedType (   itkImgFunc,
  pixelTypeSeq,
  dimSeq 
)

Instantiate access function for the given pixel types and dimensions.

Iteratively calls a macro named InstantiateAccessFunction_itkImgFunc which you must define and which usually explicitly instantiates your access function.

A call to InstantiateAccessFunctionForFixedPixelType(T, (a)(b), (d)(e)) results in calls

InstantiateAccessFunction_T(a, d)
InstantiateAccessFunction_T(a, e)
InstantiateAccessFunction_T(b, d)
InstantiateAccessFunction_T(b, e)

That is, InstantiateAccessFunction_T is called for the cartesian product of the sequences pixelTypeSeq and dimSeq.

Example:

template<typename TPixel, typename VDimension>
void MyImageAccessFunction(itk::Image<TPixel, VImageDimension>* itkImage)
{ ... }
#define InstantiateAccessFunction_MyImageAccessFunction(pixelType, dim) \
template void MyImageAccessFunction(itk::Image<pixelType,dim>*);
InstantiateAccessFunctionForFixedPixelType(MyImageAccessFunction, (int), (3))

Use this macro once after the definition of your access function. Some compilers have memory problems without the explicit instantiation. You may need to move the access function to a separate file. The CMake macro MITK_MULTIPLEX_PICTYPE can help you with that. See mitk/CMake/mitkMacroMultiplexPicType.cmake for documentation.

Parameters
itkImgFuncThe custom part of the name of the macro to be called.
pixelTypeSeqa sequence of types, like (int)(short)(char).
dimSeqa sequence of dimensions, like (2)(3).

Definition at line 85 of file mitkInstantiateAccessFunctions.h.

◆ InstantiateAccessFunctionForFloatingPixelTypes

#define InstantiateAccessFunctionForFloatingPixelTypes (   itkImgFunc)

Instantiate access function for floating point datatypes and all dimensions.

See also
InstantiateAccessFunctionForFixedType
Parameters
itkImgFuncThe custom part of the name of the macro to be called.

Definition at line 146 of file mitkInstantiateAccessFunctions.h.

◆ InstantiateAccessFunctionForIntegralPixelTypes

#define InstantiateAccessFunctionForIntegralPixelTypes (   itkImgFunc)

Instantiate access function for integral datatypes and all dimensions.

See also
InstantiateAccessFunctionForFixedType
Parameters
itkImgFuncThe custom part of the name of the macro to be called.

Definition at line 133 of file mitkInstantiateAccessFunctions.h.

Function Documentation

◆ CastToItkImage() [1/2]

template<typename ItkOutputImageType >
void MITKCORE_EXPORT mitk::CastToItkImage ( const mitk::Image mitkImage,
itk::SmartPointer< ItkOutputImageType > &  itkOutputImage 
)

Cast an mitk::Image to an itk::Image with a specific type.

This method casts the pixel types and copies the image memory if necessary. If the requested pixel type is equal to the pixel type of the MITK image, the memory is just referenced.

Usually, you want the ITK image to reference the same image data as the MITK image without any casting. In this case use mitk::ImageToItkImage, which generate less code and is more efficient.

Parameters
mitkImageThe MITK image to be cast to an ITK image
itkOutputImageYou don't have to initialize the itk::Image<..>::Pointer.
See also
mitk::ImageToItkImage

Referenced by mitk::PhotoacousticFilterService::ApplyBmodeFilter(), mitk::USDiPhASImageSource::ApplyBmodeFilter(), mitk::PhotoacousticFilterService::ApplyResampling(), mitk::USDiPhASImageSource::ApplyResampling(), mitk::PhotoacousticFilterService::ApplyResamplingToDim(), mitk::USDiPhASImageSource::ApplyScatteringCompensation(), Assert_ItkVectorImageImportAndCast_ReturnsTrue(), mitk::FastMarchingTool::BuildITKPipeline(), CalculateCoocurenceFeatures(), CalculateFirstOrderHistogramStatistics(), CalculateFirstOrderStatistics(), CalculateGrayLevelNeighbourhoodGreyLevelDifferenceFeatures(), CalculateGrayLevelRunLengthFeatures(), CalculateGreyLevelDistanceZoneFeatures(), CalculateGreyLevelSizeZoneFeatures(), CalculateImageRegionMinMax(), CalculateIntensityPeak(), CalculateLargestDiameter(), CalculateMeanAndStd(), mitk::CalculateGrayValueStatisticsTool::CalculateMinMax(), CalculateVolumeDensityStatistic(), CalculateVolumeStatistic(), CastTo3DItkImage(), mitk::CLUtil::ClosingBinary(), mitk::AutoCropImageFilter::ComputeNewImageBounds(), mitk::LabelSetImage::ConcatenateProcessing(), mitk::FastMarchingTool3D::ConfirmSegmentation(), mitk::FastMarchingTool::ConfirmSegmentation(), QmitkAdaptiveRegionGrowingToolGUI::ConfirmSegmentation(), mitk::ConcentrationCurveGenerator::convertToConcentration(), CreateNewMask(), CreateNoNaNMask(), CreateXRay(), mitk::USDiPhASImageSource::CutOffTop(), DetectSkull(), mitk::MaskedDynamicImageStatisticsGenerator::DoCalculateStatistics(), mitk::DescriptivePharmacokineticBrixModelFactory::DoCreateParameterizer(), mitk::PixelBasedDescriptionParameterImageGenerator::DoParameterCalculation(), mitk::PixelBasedParameterFitImageGenerator::DoParameterFit(), QmitkAdaptiveRegionGrowingToolGUI::EnableControls(), mitk::CompareImageDataFilter::EstimateValueDifference(), ExecuteRangeBasedMasking(), ExecuteRoundImage(), ExtractSlicesFromImages(), mitk::ModelSignalImageGenerator::Generate(), mitk::BoundingObjectToSegmentationFilter::GenerateData(), mitk::BandpassFilter::GenerateData(), mitk::PadImageFilter::GenerateData(), mitk::MaskAndCutRoiImageFilter::GenerateData(), mitk::CorrectorAlgorithm::GenerateData(), generateDescriptiveBrixModel_PixelBased(), GenerateGradientWithDimXImage(), GetEmptyTestImageWithGeometry(), mitk::DataCollection::GetItkImage(), mitk::HotspotMaskGenerator::GetMask(), mitk::USDiPhASImageSource::GetNextRawImage(), mitk::ImageStatisticsCalculator::GetStatistics(), mitk::FastMarchingTool3D::Initialize(), mitk::MRNormTwoRegionsBasedFilter::InternalComputeMask(), mitk::MRNormLinearStatisticBasedFilter::InternalComputeMask(), InternalWritePreviewOnWorkingImage(), mitk::ShapeBasedInterpolationAlgorithm::Interpolate(), mitk::CalculateGrayValueStatisticsTool::ITKHistogramming(), mitk::OverwriteSliceImageFilter::ItkImageProcessing(), mitk::PixelManipulationTool::ITKPixelManipulation(), mitk::CLUtil::itkSampleLabel(), mitk::OverwriteDirectedPlaneImageFilter::ItkSliceOverwriting(), main(), mitk::LabelSetImage::MaskStampProcessing(), mitkImageTest(), mitk::USDiPhASImageSource::MultiplyImage(), Normalize(), mitk::SetRegionTool::OnMousePressed(), QmitkSliceBasedInterpolatorWidget::OnToggleWidgetActivation(), ProcessFeatureImages(), ResampleImageToReferenceFunction(), ResampleMask(), mitk::USDiPhASImageSource::ResampleOutputVertical(), mitk::pa::VolumeManipulator::RescaleImage(), mitk::SurfaceStampImageFilter::SurfaceStampBinaryOutputProcessing(), mitk::SurfaceStampImageFilter::SurfaceStampProcessing(), mitk::DataCollectionSingleImageIterator< TDataType, ImageDimension >::ToBegin(), mitk::DataCollectionImageIterator< TDataType, ImageDimension >::ToBegin(), mitk::CLUtil::Transform(), and VolumeUnderMaskByLabel().

◆ CastToItkImage() [2/2]

template<typename TPixelType , unsigned int VImageDimension>
void MITKCORE_EXPORT mitk::CastToItkImage ( const mitk::Image mitkImage,
itk::SmartPointer< itk::VectorImage< TPixelType, VImageDimension >> &  itkOutputImage 
)

Cast an mitk::Image to an itk::VectorImage with a specific type.

You don't have to initialize the itk::VectorImage<..>::Pointer.

◆ CastToMitkImage() [1/2]

template<typename ItkOutputImageType >
void mitk::CastToMitkImage ( const itk::SmartPointer< ItkOutputImageType > &  itkimage,
itk::SmartPointer< mitk::Image > &  mitkoutputimage 
)

Cast an itk::Image (with a specific type) to an mitk::Image.

CastToMitkImage does not cast pixel types etc., just image data

See also
mitkITKImageImport

Definition at line 74 of file mitkImageCast.h.

Referenced by Assert_ItkVectorImageImportAndCast_ReturnsTrue(), mitk::ConcentrationCurveGenerator::CalculateAverageBaselineImage(), mitk::OtsuTool3D::CalculatePreview(), mitk::CLUtil::ClosingBinary(), mitk::FastMarchingTool::ConfirmSegmentation(), ConvertBackToCorrectPixelType(), ConvertImageToLabelSetImage(), ConvertItkObjectToMitkImage(), CreateNewMask(), DifferenceOfGaussFilter(), mitk::ROIBasedParameterFitImageGenerator::DoImageGeneration(), mitk::DummyLsetFileReader::DoRead(), mitk::RawImageFileReaderService::DoRead(), mitk::DICOMSegmentationIO::DoRead(), ExecuteImageThresholding(), ExecuteImageTypeToDouble(), ExecuteLaplacianOfGaussian(), ExecuteMultiResolution(), ExecuteOneImageFilterWithFunctor(), ExecuteOneImageFilterWithFunctorNonParameter(), ExecuteRangeBasedMasking(), ExecuteRoundImage(), ExecuteSpecificWaveletTransformation(), mitk::NonStaticArithmeticOperation::ExecuteTwoImageFilterWithFunctor(), mitk::MorphologicalOperations::FillHoles(), GaussianFilter(), mitk::ModelSignalImageGenerator::Generate(), mitk::BoundingObjectToSegmentationFilter::GenerateData(), mitk::PadImageFilter::GenerateData(), mitk::MaskAndCutRoiImageFilter::GenerateData(), mitk::CorrectorAlgorithm::GenerateData(), mitk::CreateDistanceImageFromSurfaceFilter::GenerateData(), mitk::ImageGenerationHelper::GenerateDynamicImageMITK(), GenerateGradientWithDimXImage(), HessianOfGaussianFilter(), mitk::LabelSetImageToSurfaceFilter::InternalProcessing(), mitk::Convert2Dto3DImageFilter::ItkConvert2DTo3D(), mitk::AutoCropImageFilter::ITKCrop3DImage(), itkErode2(), mitk::BilateralFilter::ItkImageProcessing(), mitk::ToFImageDownsamplingFilter::ItkImageResampling(), mitk::CLUtil::itkSampleLabel(), LaplacianOfGaussianFilter(), LocalHistograms(), LocalHistograms2(), localStatistic(), main(), mitkImageDimensionConverterTest(), ProcessFeatureImages(), mitk::DicomSeriesReader::ReadPhilips3DDicom(), StartRegionGrowing(), StoreResultImages(), mitk::SurfaceStampImageFilter::SurfaceStampBinaryOutputProcessing(), testGeometryAfterCasting(), mitk::ShowSegmentationAsSmoothedSurface::ThreadedUpdateFunction(), mitk::RawImageFileReader::TypedGenerateData(), mitk::FastMarchingTool3D::Update(), mitk::FastMarchingTool::Update(), and mitk::RTDoseReaderService::~RTDoseReaderService().

◆ CastToMitkImage() [2/2]

template<typename ItkOutputImageType >
void mitk::CastToMitkImage ( const ItkOutputImageType *  itkimage,
itk::SmartPointer< mitk::Image > &  mitkoutputimage 
)

Cast an itk::Image (with a specific type) to an mitk::Image.

CastToMitkImage does not cast pixel types etc., just image data

See also
mitkITKImageImport

Definition at line 88 of file mitkImageCast.h.

References mitk::Image::New().

◆ GrabItkImageMemory() [1/2]

template<typename ItkOutputImageType >
Image::Pointer mitk::GrabItkImageMemory ( itk::SmartPointer< ItkOutputImageType > &  itkimage,
mitk::Image mitkImage = nullptr,
const BaseGeometry geometry = nullptr,
bool  update = true 
)

Grabs the memory of an itk::Image (with a specific type) and puts it into an mitk::Image.The memory is managed by the mitk::Image after calling this function. The itk::Image remains valid until the mitk::Image decides to free the memory.

Parameters
updateif true, fill mitk::Image, which will execute the up-stream pipeline connected to the input itk::Image. Otherwise you need to make sure that Update() is called on the mitk::Image before its data is being used, e.g., by connecting it to an mitk-pipeline and call Update of a downstream filter at some time.
See also
ImportItkImage

Referenced by mitk::PhotoacousticFilterService::ApplyBmodeFilter(), mitk::USDiPhASImageSource::ApplyBmodeFilter(), mitk::PhotoacousticFilterService::ApplyResampling(), mitk::USDiPhASImageSource::ApplyResampling(), mitk::PhotoacousticFilterService::ApplyResamplingToDim(), mitk::USDiPhASImageSource::ApplyScatteringCompensation(), mitk::PlanarFigureMaskGenerator::CheckPlanarFigureIsNotTilted(), mitk::FeatureBasedEdgeDetectionFilter::ContourSearch(), mitk::OpenCVToMitkImageFilter::ConvertCVMatToMitkImage(), CreateNoNaNMask(), mitk::USDiPhASImageSource::CutOffTop(), mitk::CompareImageDataFilter::EstimateValueDifference(), ExtractSlicesFromImages(), mitk::BandpassFilter::GenerateData(), mitk::ExtractDirectedPlaneImageFilterNew::GenerateOutputInformation(), GetEmptyTestImageWithGeometry(), mitk::HotspotMaskGenerator::GetHotspotIndex(), mitk::USDiPhASImageSource::GetNextRawImage(), mitk::IgnorePixelMaskGenerator::InternalCalculateMask(), mitk::ShapeBasedInterpolationAlgorithm::Interpolate(), mitk::ExtractImageFilter::ItkImageProcessing(), ItkThresholdFilter(), mitk::FeatureBasedEdgeDetectionFilter::ITKThresholding(), mitk::WatershedTool::ITKWatershed(), mitk::USDiPhASImageSource::MultiplyImage(), mitk::SetRegionTool::OnMousePressed(), ResampleImage(), ResampleImageToReferenceFunction(), ResampleMask(), mitk::USDiPhASImageSource::ResampleOutputVertical(), mitk::pa::VolumeManipulator::RescaleImage(), mitk::RegionGrowingTool::StartRegionGrowing(), mitk::FeatureBasedEdgeDetectionFilter::ThreadedClosing(), and mitk::CLUtil::Transform().

◆ GrabItkImageMemory() [2/2]

template<typename ItkOutputImageType >
Image::Pointer mitk::GrabItkImageMemory ( ItkOutputImageType *  itkimage,
mitk::Image mitkImage = nullptr,
const BaseGeometry geometry = nullptr,
bool  update = true 
)

Grabs the memory of an itk::Image (with a specific type) and puts it into an mitk::Image.The memory is managed by the mitk::Image after calling this function. The itk::Image remains valid until the mitk::Image decides to free the memory.

Parameters
updateif true, fill mitk::Image, which will execute the up-stream pipeline connected to the input itk::Image. Otherwise you need to make sure that Update() is called on the mitk::Image before its data is being used, e.g., by connecting it to an mitk-pipeline and call Update of a downstream filter at some time.
See also
ImportItkImage

◆ ImageToItkImage() [1/2]

template<typename TPixel , unsigned int VDimension>
ImageTypeTrait<TPixel, VDimension>::ImageType::Pointer mitk::ImageToItkImage ( mitk::Image mitkImage)

Convert a MITK image to an ITK image.

This method creates a itk::Image representation for the given MITK image, referencing the MITK image memory. If the provided template arguments do not match the type of the MITK image, an exception is thrown.

The MITK image is locked for read/write access as long as the returned itk::Image object exists. See ImageToItkImage(const mitk::Image*) for read-only access.

Template Parameters
TPixelThe pixel type of the ITK image
VDimensionThe image dimension of the ITK image
Parameters
mitkImageThe MITK image which is to be converted to an ITK image
Returns
An ITK image representation for the given MITK image
Exceptions
mitk::Exceptionif the pixel type or dimension does not match the MITK image type or if the MITK image is already locked for read or write access.
See also
ImageToItkImage(const mitk::Image*)
CastToItkImage

Definition at line 132 of file mitkImageToItk.h.

◆ ImageToItkImage() [2/2]

template<typename TPixel , unsigned int VDimension>
ImageTypeTrait<TPixel, VDimension>::ImageType::ConstPointer mitk::ImageToItkImage ( const mitk::Image mitkImage)

Convert a MITK image to an ITK image.

This method creates a itk::Image representation for the given MITK image, referencing the MITK image memory. If the provided template arguments do not match the type of the MITK image, an exception is thrown.

The MITK image is locked for read access as long as the returned itk::Image object exists. See ImageToItkImage(mitk::Image*) for read and write access.

Template Parameters
TPixelThe pixel type of the ITK image
VDimensionThe image dimension of the ITK image
Parameters
mitkImageThe MITK image which is to be converted to an ITK image
Returns
An ITK image representation for the given MITK image
Exceptions
mitk::Exceptionif the pixel type or dimension does not match the MITK image type or if the MITK image is already locked for write access.
See also
ImageToItkImage(mitk::Image*)
CastToItkImage

Definition at line 167 of file mitkImageToItk.h.

◆ ImportItkImage() [1/2]

template<typename ItkOutputImageType >
Image::Pointer mitk::ImportItkImage ( const itk::SmartPointer< ItkOutputImageType > &  itkimage,
const BaseGeometry geometry = nullptr,
bool  update = true 
)

Imports an itk::Image (with a specific type) as an mitk::Image.Instantiates instance of ITKImageImport. mitk::ITKImageImport does not cast pixel types etc., it just imports image data. If you get a compile error, try image.GetPointer().

Parameters
updateif true, fill mitk::Image, which will execute the up-stream pipeline connected to the input itk::Image. Otherwise you need to make sure that Update() is called on the mitk::Image before its data is being used, e.g., by connecting it to an mitk-pipeline and call Update of a downstream filter at some time.
See also
itk::Image::CastToMitkImage

Referenced by Assert_ItkImageImportRandomValuesSucceded_ReturnsTrue(), Assert_ItkImageImportSucceded_ReturnsTrue(), Assert_ItkVectorImageImportAndCast_ReturnsTrue(), ConvertLabelSetImageToImage(), mitk::ConcentrationCurveGenerator::convertToConcentration(), CreateXRay(), DetectSkull(), mitk::ModelSignalImageGenerator::Generate(), mitk::ImageToPointCloudFilter::GenerateData(), GetEmptyTestImageWithGeometry(), main(), Normalize(), QmitkAdaptiveRegionGrowingToolGUI::RunSegmentation(), mitk::NonBlockingAlgorithm::SetItkImageAsMITKImagePointerParameter(), and mitk::PickingTool::StartRegionGrowing().

◆ ImportItkImage() [2/2]

template<typename ItkOutputImageType >
Image::Pointer mitk::ImportItkImage ( const ItkOutputImageType *  itkimage,
const BaseGeometry geometry = nullptr,
bool  update = true 
)

Imports an itk::Image (with a specific type) as an mitk::Image.Instantiates instance of ITKImageImport mitk::ITKImageImport does not cast pixel types etc., it just imports image data. If you get a compile error, try image.GetPointer().

Parameters
updateif true, fill mitk::Image, which will execute the up-stream pipeline connected to the input itk::Image. Otherwise you need to make sure that Update() is called on the mitk::Image before its data is being used, e.g., by connecting it to an mitk-pipeline and call Update of a downstream filter at some time.
Note
If the source (itk image) and the target (mitk image) do not share the same scope, the mitk::GrabItkImageMemory function has to be used instead. Otherwise the image memory managed by the itk image is lost at a scope level change. This affects especially the usage in combination with AccessByItk macros as in following example code

which calls an ITK-like filter

See also
itk::Image::CastToMitkImage
GrabItkImageMemory