Medical Imaging Interaction Toolkit  2024.06.99-31d3c0df
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 
62  template <typename TPixelType, unsigned int VImageDimension>
63  extern void MITKCORE_EXPORT CastToItkImage(
64  const mitk::Image *mitkImage, itk::SmartPointer<itk::VectorImage<TPixelType, VImageDimension>> &itkOutputImage);
65 
73  template <typename ItkOutputImageType>
75  itk::SmartPointer<mitk::Image> &mitkoutputimage)
76  {
77  CastToMitkImage(itkimage.GetPointer(), mitkoutputimage);
78  }
79 
87  template <typename ItkOutputImageType>
88  void CastToMitkImage(const ItkOutputImageType *itkimage, itk::SmartPointer<mitk::Image> &mitkoutputimage)
89  {
90  if (mitkoutputimage.IsNull())
91  {
92  mitkoutputimage = mitk::Image::New();
93  }
94  mitkoutputimage->InitializeByItk(itkimage);
95  mitkoutputimage->SetChannel(itkimage->GetBufferPointer());
96  }
97 }
98 
99 #endif
mitkImage.h
mitk::Image::New
static Pointer New()
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
itk::SmartPointer
Definition: mitkIFileReader.h:30
mitk::CastToMitkImage
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:74
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::_CastToItkImage2Access
void _CastToItkImage2Access(const itk::Image< TPixel, VImageDimension > *itkInputImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
MitkCoreExports.h
mitk::CastToItkImage
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15