ITK  4.3.0
Insight Segmentation and Registration Toolkit
itkConvertPixelBuffer.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkConvertPixelBuffer_h
19 #define __itkConvertPixelBuffer_h
20 
21 #include "itkObject.h"
22 #include "itkNumericTraits.h"
23 
24 namespace itk
25 {
39 template<
40  typename InputPixelType,
41  typename OutputPixelType,
42  class OutputConvertTraits
43  >
45 {
46 public:
47 
49  typedef typename OutputConvertTraits::ComponentType OutputComponentType;
51 
53  static void Convert(InputPixelType *inputData,
54  int inputNumberOfComponents,
55  OutputPixelType *outputData, size_t size);
56 
57  static void ConvertVectorImage(InputPixelType *inputData,
58  int inputNumberOfComponents,
59  OutputPixelType *outputData, size_t size);
60 
61 protected:
65  static void ConvertGrayToGray(InputPixelType *inputData,
66  OutputPixelType *outputData, size_t size);
67 
72  static void ConvertRGBToGray(InputPixelType *inputData,
73  OutputPixelType *outputData, size_t size);
74 
79  static void ConvertRGBAToGray(InputPixelType *inputData,
80  OutputPixelType *outputData, size_t size);
81 
82  static void ConvertMultiComponentToGray(InputPixelType *inputData,
83  int inputNumberOfComponents,
84  OutputPixelType *outputData,
85  size_t size);
86 
91  static void ConvertGrayToRGB(InputPixelType *inputData,
92  OutputPixelType *outputData, size_t size);
93 
95  static void ConvertRGBToRGB(InputPixelType *inputData,
96  OutputPixelType *outputData, size_t size);
97 
99  static void ConvertRGBAToRGB(InputPixelType *inputData,
100  OutputPixelType *outputData, size_t size);
101 
110  static void ConvertMultiComponentToRGB(InputPixelType *inputData,
111  int inputNumberOfComponents,
112  OutputPixelType *outputData,
113  size_t size);
114 
116  static void ConvertGrayToRGBA(InputPixelType *inputData,
117  OutputPixelType *outputData, size_t size);
118 
119  static void ConvertRGBToRGBA(InputPixelType *inputData,
120  OutputPixelType *outputData, size_t size);
121 
122  static void ConvertRGBAToRGBA(InputPixelType *inputData,
123  OutputPixelType *outputData, size_t size);
124 
125  static void ConvertMultiComponentToRGBA(InputPixelType *inputData,
126  int inputNumberOfComponents,
127  OutputPixelType *outputData,
128  size_t size);
129 
133  static void ConvertTensor6ToTensor6(InputPixelType *inputData,
134  OutputPixelType *outputData, size_t size);
135 
136  static void ConvertTensor9ToTensor6(InputPixelType *inputData,
137  OutputPixelType *outputData, size_t size);
138 
140  static void ConvertGrayToComplex(InputPixelType *inputData,
141  OutputPixelType *OutputData, size_t size);
142 
143  static void ConvertComplexToComplex(InputPixelType *inputData,
144  OutputPixelType *outputData, size_t size);
145 
146  static void ConvertMultiComponentToComplex(InputPixelType *inputData,
147  int inputNumberOfComponents,
148  OutputPixelType *outputData, size_t size);
149 
150 private:
153 
160  template <typename PixelType>
161  static double MaxAlpha(PixelType &) { return static_cast<double>(NumericTraits<PixelType>::max()); }
162  static double MaxAlpha(double &) { return static_cast<double>(NumericTraits<double>::One); }
163  static double MaxAlpha(float &) { return static_cast<double>(NumericTraits<float>::One); }
165 
166 };
167 } //namespace ITK
168 
169 #ifndef ITK_MANUAL_INSTANTIATION
170 #include "itkConvertPixelBuffer.hxx"
171 #endif
172 
173 #endif // __itkConvertPixelBuffer_h
174