Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
Medical Imaging Interaction Toolkit
mitkImageCastPart4.cpp
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 #include <mitkImageCast.txx>
14 
15 #include <itkDiffusionTensor3D.h>
16 #include <itkRGBPixel.h>
17 
18 namespace mitk
19 {
20  typedef itk::Image<itk::RGBPixel<unsigned char>, 2> itkImageRGBUC2;
21  typedef itk::Image<itk::DiffusionTensor3D<float>, 2> itkImageDTIF2;
22  typedef itk::Image<itk::DiffusionTensor3D<double>, 2> itkImageDTID2;
23 
24  template <>
26  {
27  typedef itkImageRGBUC2 ItkOutputImageType;
28  AccessFixedTypeByItk_1(mitkImage,
30  (itk::RGBPixel<unsigned char>),
31  (ItkOutputImageType::ImageDimension),
32  itkOutputImage);
33  }
34  template <>
36  {
37  typedef itkImageDTIF2 ItkOutputImageType;
38  AccessFixedTypeByItk_1(mitkImage,
40  (itk::DiffusionTensor3D<float>),
41  (ItkOutputImageType::ImageDimension),
42  itkOutputImage);
43  }
44  template <>
46  {
47  typedef itkImageDTID2 ItkOutputImageType;
48  AccessFixedTypeByItk_1(mitkImage,
50  (itk::DiffusionTensor3D<double>),
51  (ItkOutputImageType::ImageDimension),
52  itkOutputImage);
53  }
54 
55  typedef itk::Image<itk::RGBPixel<unsigned char>, 3> itkImageRGBUC3;
56  typedef itk::Image<itk::DiffusionTensor3D<float>, 3> itkImageDTIF3;
57  typedef itk::Image<itk::DiffusionTensor3D<double>, 3> itkImageDTID3;
58 
59  template <>
61  {
62  typedef itkImageRGBUC3 ItkOutputImageType;
63  AccessFixedTypeByItk_1(mitkImage,
65  (itk::RGBPixel<unsigned char>),
66  (ItkOutputImageType::ImageDimension),
67  itkOutputImage);
68  }
69  template <>
71  {
72  typedef itkImageDTIF3 ItkOutputImageType;
73  AccessFixedTypeByItk_1(mitkImage,
75  (itk::DiffusionTensor3D<float>),
76  (ItkOutputImageType::ImageDimension),
77  itkOutputImage);
78  }
79  template <>
81  {
82  typedef itkImageDTID3 ItkOutputImageType;
83  AccessFixedTypeByItk_1(mitkImage,
85  (itk::DiffusionTensor3D<double>),
86  (ItkOutputImageType::ImageDimension),
87  itkOutputImage);
88  }
89 
90 #define TYPE_VECS(HUN) \
91  TYPE_TEN_VECS(HUN) \
92  TYPE_TEN_VECS(HUN + 10) \
93  TYPE_TEN_VECS(HUN + 20) \
94  TYPE_TEN_VECS(HUN + 30) \
95  TYPE_TEN_VECS(HUN + 40) \
96  TYPE_TEN_VECS(HUN + 50) \
97  TYPE_TEN_VECS(HUN + 60) \
98  TYPE_TEN_VECS(HUN + 70) \
99  TYPE_TEN_VECS(HUN + 80) \
100  TYPE_TEN_VECS(HUN + 90)
101 
102 #define TYPE_TEN_VECS(HUN) \
103  TYPE_N_VEC(HUN + 1) \
104  TYPE_N_VEC(HUN + 2) \
105  TYPE_N_VEC(HUN + 3) \
106  TYPE_N_VEC(HUN + 4) \
107  TYPE_N_VEC(HUN + 5) \
108  TYPE_N_VEC(HUN + 6) \
109  TYPE_N_VEC(HUN + 7) \
110  TYPE_N_VEC(HUN + 8) \
111  TYPE_N_VEC(HUN + 9) \
112  TYPE_N_VEC(HUN + 10)
113 
114 #define TYPE_N_VEC(N_DIRS) \
115  _TYPE_N_VEC(N_DIRS, double) \
116  _TYPE_N_VEC(N_DIRS, float) \
117  _TYPE_N_VEC(N_DIRS, short)
118 
119 #define _TYPE_N_VEC(N_DIRS, PIXTYPE) \
120  template <> \
121  void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, \
122  itk::SmartPointer<itk::Image<itk::Vector<PIXTYPE, N_DIRS>, 2>> &itkOutputImage) \
123  \
124  { \
125  typedef itk::Vector<PIXTYPE, N_DIRS> VECTORTYPE; \
126  typedef itk::Image<VECTORTYPE, 2> ItkOutputImageType2; \
127  AccessFixedTypeByItk_1( \
128  mitkImage, _CastToItkImage2Access, (VECTORTYPE), (ItkOutputImageType2::ImageDimension), itkOutputImage); \
129  } \
130  template <> \
131  void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, \
132  itk::SmartPointer<itk::Image<itk::Vector<PIXTYPE, N_DIRS>, 3>> &itkOutputImage) \
133  \
134  { \
135  typedef itk::Vector<PIXTYPE, N_DIRS> VECTORTYPE; \
136  typedef itk::Image<VECTORTYPE, 3> ItkOutputImageType3; \
137  AccessFixedTypeByItk_1( \
138  mitkImage, _CastToItkImage2Access, (VECTORTYPE), (ItkOutputImageType3::ImageDimension), itkOutputImage); \
139  }
140 
141  // the following lines allow for fixed-size vector images up to a certain size limit
142  // (commented out for shorter compile times)
143 
144  // TYPE_VECS(000)
145  // TYPE_VECS(100)
146  // TYPE_VECS(200)
147  // TYPE_VECS(300)
148  // TYPE_VECS(400)
149  // TYPE_VECS(500)
150  // TYPE_VECS(600)
151  // TYPE_VECS(700)
152 
153  // allow for fixed-size vectors of specific length
154  // (inspired by itkPointshell.cpp, precompiled ODF configs)
155  // TYPE_TEN_VECS(0)
156  // TYPE_N_VEC(11)
157  // TYPE_N_VEC(12)
175 
176 #ifndef DOXYGEN_SKIP
177 
178 #endif // DOXYGEN_SKIP
179 }
itk::Image< itk::DiffusionTensor3D< float >, 2 > itkImageDTIF2
itk::Image< itk::DiffusionTensor3D< double >, 3 > itkImageDTID3
#define MITKCORE_EXPORT
itk::Image< itk::RGBPixel< unsigned char >, 2 > itkImageRGBUC2
DataCollection - Class to facilitate loading/accessing structured data.
#define TYPE_N_VEC(N_DIRS)
itk::Image< itk::DiffusionTensor3D< float >, 3 > itkImageDTIF3
itk::Image< itk::DiffusionTensor3D< double >, 2 > itkImageDTID2
#define AccessFixedTypeByItk_1(mitkImage, itkImageTypeFunction, pixelTypeSeq, dimSeq, arg1)
Image class for storing images.
Definition: mitkImage.h:72
void _CastToItkImage2Access(const itk::Image< TPixel, VImageDimension > *itkInputImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
void MITKCORE_EXPORT CastToItkImage(const mitk::Image *mitkImage, itk::SmartPointer< ItkOutputImageType > &itkOutputImage)
Cast an mitk::Image to an itk::Image with a specific type.
itk::Image< itk::RGBPixel< unsigned char >, 3 > itkImageRGBUC3