Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITKIMAGECAST_H_HEADER_INCLUDED
18 #define MITKIMAGECAST_H_HEADER_INCLUDED
19 
20 #include <MitkCoreExports.h>
21 #include <mitkImage.h>
22 
23 #include <itkImage.h>
24 #include <itkVectorImage.h>
25 
26 namespace mitk
27 {
28 #ifndef DOXYGEN_SKIP
29  template <typename TPixel, unsigned int VImageDimension, class ItkOutputImageType>
30  void _CastToItkImage2Access(const itk::Image<TPixel, VImageDimension> *itkInputImage,
32 
33  template <typename TPixel, unsigned int VImageDimension, class ItkOutputImageType>
34  void _CastToItkImage2Access(const itk::VectorImage<TPixel, VImageDimension> *itkInputImage,
36 #endif // DOXYGEN_SKIP
37 
56  template <typename ItkOutputImageType>
57  extern void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage,
59 
66  template <typename TPixelType, unsigned int VImageDimension>
67  extern void MITKCORE_EXPORT CastToItkImage(
68  const mitk::Image *mitkImage, itk::SmartPointer<itk::VectorImage<TPixelType, VImageDimension>> &itkOutputImage);
69 
77  template <typename ItkOutputImageType>
79  itk::SmartPointer<mitk::Image> &mitkoutputimage)
80  {
81  CastToMitkImage(itkimage.GetPointer(), mitkoutputimage);
82  }
83 
91  template <typename ItkOutputImageType>
92  void CastToMitkImage(const ItkOutputImageType *itkimage, itk::SmartPointer<mitk::Image> &mitkoutputimage)
93  {
94  if (mitkoutputimage.IsNull())
95  {
96  mitkoutputimage = mitk::Image::New();
97  }
98  mitkoutputimage->InitializeByItk(itkimage);
99  mitkoutputimage->SetChannel(itkimage->GetBufferPointer());
100  }
101 }
102 
103 #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:76
static Pointer New()
void _CastToItkImage2Access(const itk::Image< TPixel, VImageDimension > *itkInputImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Definition: typeExtension.h:33
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:78
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.