Medical Imaging Interaction Toolkit  2018.4.99-0d336d68
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_HEADER_INCLUDED
14 #define MITKIMAGECAST_H_HEADER_INCLUDED
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 // of MITKIMAGECAST_H_HEADER_INCLUDED
#define MITKCORE_EXPORT
DataCollection - Class to facilitate loading/accessing structured data.
Image class for storing images.
Definition: mitkImage.h:72
static Pointer New()
void _CastToItkImage2Access(const itk::Image< TPixel, VImageDimension > *itkInputImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
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
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.