Orfeo Toolbox  3.16
otbVisualizationPixelTraits.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbVisualizationPixelTraits_h
19 #define __otbVisualizationPixelTraits_h
20 
22 #include "itkRGBPixel.h"
23 #include "itkRGBAPixel.h"
24 
25 namespace otb
26 {
34 public:
35 
37  template<class TScalarTypeInput, class TScalarTypeOutput>
38  static void Convert(const itk::VariableLengthVector<TScalarTypeInput>& in, TScalarTypeOutput& out)
39  {
40  out = in[0];
41  }
42 
43  template<class TScalarTypeInput, class TScalarTypeOutput>
44  static void Convert(TScalarTypeInput in, itk::VariableLengthVector<TScalarTypeOutput>& out)
45  {
46  out.SetSize(1);
47  out[0] = in;
48  }
49 
50  template<class TScalarTypeInput, class TScalarTypeOutput>
53  {
54  out = in;
55  }
56 
57  template<class TScalarTypeInput, class TScalarTypeOutput>
59  {
60  out[0] = in[0];
61  if (in.Size() >= 2) out[1] = in[1]; else out[1] = 0;
62  if (in.Size() >= 3) out[2] = in[2]; else out[2] = 0;
63 
64  }
65 
66  template<class TScalarTypeInput, class TScalarTypeOutput>
68  {
69  out.SetSize(3);
70  out[0] = in[0];
71  out[1] = in[1];
72  out[2] = in[2];
73  }
74 
75  template<class TScalarTypeInput, class TScalarTypeOutput>
77  {
78  out[0] = in[0];
79  if (in.Size() >= 2) out[1] = in[1]; else out[1] = 0;
80  if (in.Size() >= 3) out[2] = in[2]; else out[2] = 0;
81 
82  }
83 
84  template<class TScalarTypeInput, class TScalarTypeOutput>
86  {
87  out.SetSize(3);
88  out[0] = in[0];
89  out[1] = in[1];
90  out[2] = in[2];
91  }
92 
94  template<class TScalarTypeInput>
96  {
97  return in.Size();
98  }
99 
100  template<class TScalarTypeInput>
101  static unsigned int PixelSize(const itk::RGBPixel<TScalarTypeInput>&)
102  {
103  return 3;
104  }
105 
106  template<class TScalarTypeInput>
107  static unsigned int PixelSize(const itk::RGBAPixel<TScalarTypeInput>&)
108  {
109  return 4;
110  }
111 
112  template<class TScalarTypeInput>
113  static unsigned int PixelSize(const TScalarTypeInput)
114  {
115  return 1;
116  }
117 
118  //To be continued
119 };
120 
121 }
122 
123 #endif

Generated at Sun Feb 3 2013 00:55:09 for Orfeo Toolbox with doxygen 1.8.1.1