ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkConvertPixelBuffer.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkConvertPixelBuffer_h
00019 #define __itkConvertPixelBuffer_h
00020 
00021 #include "itkObject.h"
00022 #include "itkNumericTraits.h"
00023 
00024 namespace itk
00025 {
00039 template<
00040   typename InputPixelType,
00041   typename OutputPixelType,
00042   class OutputConvertTraits
00043   >
00044 class ConvertPixelBuffer
00045 {
00046 public:
00047 
00049   typedef typename OutputConvertTraits::ComponentType OutputComponentType;
00050   typedef ConvertPixelBuffer                          Self;
00051 
00053   static void Convert(InputPixelType *inputData,
00054                       int inputNumberOfComponents,
00055                       OutputPixelType *outputData, size_t size);
00056 
00057   static void ConvertVectorImage(InputPixelType *inputData,
00058                                  int inputNumberOfComponents,
00059                                  OutputPixelType *outputData, size_t size);
00060 
00061 protected:
00065   static void ConvertGrayToGray(InputPixelType *inputData,
00066                                 OutputPixelType *outputData, size_t size);
00067 
00072   static void ConvertRGBToGray(InputPixelType *inputData,
00073                                OutputPixelType *outputData, size_t size);
00074 
00079   static void ConvertRGBAToGray(InputPixelType *inputData,
00080                                 OutputPixelType *outputData, size_t size);
00081 
00082   static void ConvertMultiComponentToGray(InputPixelType *inputData,
00083                                           int inputNumberOfComponents,
00084                                           OutputPixelType *outputData,
00085                                           size_t size);
00086 
00091   static void ConvertGrayToRGB(InputPixelType *inputData,
00092                                OutputPixelType *outputData, size_t size);
00093 
00095   static void ConvertRGBToRGB(InputPixelType *inputData,
00096                               OutputPixelType *outputData, size_t size);
00097 
00099   static void ConvertRGBAToRGB(InputPixelType *inputData,
00100                                OutputPixelType *outputData, size_t size);
00101 
00110   static void ConvertMultiComponentToRGB(InputPixelType *inputData,
00111                                          int inputNumberOfComponents,
00112                                          OutputPixelType *outputData,
00113                                          size_t size);
00114 
00116   static void ConvertGrayToRGBA(InputPixelType *inputData,
00117                                 OutputPixelType *outputData, size_t size);
00118 
00119   static void ConvertRGBToRGBA(InputPixelType *inputData,
00120                                OutputPixelType *outputData, size_t size);
00121 
00122   static void ConvertRGBAToRGBA(InputPixelType *inputData,
00123                                 OutputPixelType *outputData, size_t size);
00124 
00125   static void ConvertMultiComponentToRGBA(InputPixelType *inputData,
00126                                           int inputNumberOfComponents,
00127                                           OutputPixelType *outputData,
00128                                           size_t size);
00129 
00133   static void ConvertTensor6ToTensor6(InputPixelType *inputData,
00134                                       OutputPixelType *outputData, size_t size);
00135 
00136   static void ConvertTensor9ToTensor6(InputPixelType *inputData,
00137                                       OutputPixelType *outputData, size_t size);
00138 
00140   static void ConvertGrayToComplex(InputPixelType *inputData,
00141                                    OutputPixelType *OutputData, size_t size);
00142 
00143   static void ConvertComplexToComplex(InputPixelType *inputData,
00144                                       OutputPixelType *outputData, size_t size);
00145 
00146   static void ConvertMultiComponentToComplex(InputPixelType *inputData,
00147                                              int inputNumberOfComponents,
00148                                              OutputPixelType *outputData, size_t size);
00149 
00150 private:
00151   ConvertPixelBuffer();
00152   ~ConvertPixelBuffer();
00153 
00160   template <typename PixelType>
00161   static double MaxAlpha(PixelType &) { return static_cast<double>(NumericTraits<PixelType>::max()); }
00162   static double MaxAlpha(double &) {  return static_cast<double>(NumericTraits<double>::One); }
00163   static double MaxAlpha(float &) {  return static_cast<double>(NumericTraits<float>::One); }
00165 
00166 };
00167 } //namespace ITK
00168 
00169 #ifndef ITK_MANUAL_INSTANTIATION
00170 #include "itkConvertPixelBuffer.hxx"
00171 #endif
00172 
00173 #endif // __itkConvertPixelBuffer_h
00174