22 #include <itkComposeImageFilter.h>
23 #include <itkExtractImageFilter.h>
24 #include <itkImageDuplicator.h>
25 #include <itkVectorIndexSelectionCastImageFilter.h>
27 template <
typename TPixel,
unsigned int VDimension>
32 typedef itk::Image<TPixel, VDimension>
ImageType;
33 typedef itk::ComposeImageFilter<ImageType> ComposeFilterType;
34 typedef itk::ImageDuplicator<ImageType> DuplicatorType;
36 auto numberOfLayers = labelSetImage->GetNumberOfLayers();
38 if (numberOfLayers > 1)
41 auto activeLayer = labelSetImage->GetActiveLayer();
43 for (decltype(numberOfLayers) layer = 0; layer < numberOfLayers; ++layer)
45 auto layerImage = mitk::ImageToItkImage<TPixel, VDimension>(
46 layer != activeLayer ? labelSetImage->GetLayerImage(layer) : labelSetImage);
48 vectorImageComposer->SetInput(layer, layerImage);
51 vectorImageComposer->Update();
58 auto layerImage = mitk::ImageToItkImage<TPixel, VDimension>(labelSetImage);
61 duplicator->SetInputImage(layerImage);
74 if (labelSetImage->GetNumberOfLayers() > 0)
76 if (labelSetImage->GetDimension() == 4)
89 template <
typename TPixel,
unsigned int VDimensions>
94 typedef itk::Image<TPixel, VDimensions>
ImageType;
95 typedef itk::VectorIndexSelectionCastImageFilter<VectorImageType, ImageType> VectorIndexSelectorType;
99 auto numberOfLayers = image->GetVectorLength();
100 for (decltype(numberOfLayers) layer = 0; layer < numberOfLayers; ++layer)
103 layerSelector->SetInput(image);
104 layerSelector->SetIndex(layer);
105 layerSelector->Update();
112 labelSetImage->InitializeByLabeledImage(layerImage);
116 labelSetImage->AddLayer(layerImage);
125 if (image.IsNotNull())
127 if (image->GetChannelDescriptor().GetPixelType().GetPixelType() == itk::ImageIOBase::VECTOR)
129 if (4 == image->GetDimension())
141 labelSetImage->InitializeByLabeledImage(image);
145 return labelSetImage;
MITKMULTILABEL_EXPORT Image::Pointer ConvertLabelSetImageToImage(LabelSetImage::ConstPointer labelSetImage)
Convert mitk::LabelSetImage to mitk::Image (itk::VectorImage)
itk::Image< unsigned char, 3 > ImageType
#define AccessFixedDimensionByItk_n(mitkImage, itkImageTypeFunction, dimension, va_tuple)
Access a mitk-image with known dimension by an itk-image with one or more parameters.
static void ConvertLabelSetImageToImage(const itk::Image< TPixel, VDimension > *, mitk::LabelSetImage::ConstPointer labelSetImage, mitk::Image::Pointer &image)
MITKMULTILABEL_EXPORT LabelSetImage::Pointer ConvertImageToLabelSetImage(Image::Pointer image)
Convert mitk::Image to mitk::LabelSetImage, templating and differentation between itk::Image and itk:...
Image::Pointer 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 ITKImageImpor...
#define AccessVectorPixelTypeByItk_n(mitkImage, itkImageTypeFunction, va_tuple)
Access a vector mitk::Image by an ITK vector image with one or more parameters.
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
#define AccessByItk_2(mitkImage, itkImageTypeFunction, arg1, arg2)
static void ConvertImageToLabelSetImage(const itk::VectorImage< TPixel, VDimensions > *image, mitk::LabelSetImage::Pointer &labelSetImage)
#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...
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.