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