Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkImageCast.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkImageCast_h
14 #define mitkImageCast_h
15 
16 #include <MitkCoreExports.h>
17 #include <mitkImage.h>
18 
19 #include <itkImage.h>
20 #include <itkVectorImage.h>
21 
22 namespace mitk
23 {
24 #ifndef DOXYGEN_SKIP
25  template <typename TPixel, unsigned int VImageDimension, class ItkOutputImageType>
26  void _CastToItkImage2Access(const itk::Image<TPixel, VImageDimension> *itkInputImage,
28 
29  template <typename TPixel, unsigned int VImageDimension, class ItkOutputImageType>
30  void _CastToItkImage2Access(const itk::VectorImage<TPixel, VImageDimension> *itkInputImage,
32 #endif // DOXYGEN_SKIP
33 
52  template <typename ItkOutputImageType>
53  extern void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage,
55 
66  template <typename TPixelType, unsigned int VImageDimension>
68  const mitk::Image *mitkImage, itk::SmartPointer<itk::VectorImage<TPixelType, VImageDimension>> &itkOutputImage);
69 
81  template <typename ItkOutputImageType>
83  itk::SmartPointer<mitk::Image> &mitkoutputimage)
84  {
85  CastToMitkImage(itkimage.GetPointer(), mitkoutputimage);
86  }
87 
99  template <typename ItkOutputImageType>
100  void CastToMitkImage(const ItkOutputImageType *itkimage, itk::SmartPointer<mitk::Image> &mitkoutputimage)
101  {
102  if (mitkoutputimage.IsNull())
103  {
104  mitkoutputimage = mitk::Image::New();
105  }
106  mitkoutputimage->InitializeByItk(itkimage);
107  mitkoutputimage->SetChannel(itkimage->GetBufferPointer());
108  }
109 }
110 
111 #endif
#define MITKCORE_EXPORT
Image class for storing multi-dimensional medical image data.
Definition: mitkImage.h:76
static Pointer New()
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
void CastToMitkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, itk::SmartPointer< mitk::Image > &mitkoutputimage)
Cast an itk::Image (with a specific type) to an mitk::Image.
Definition: mitkImageCast.h:82
Find image slices visible on a given plane.
void _CastToItkImage2Access(const itk::Image< TPixel, VImageDimension > *itkInputImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)