Orfeo Toolbox  4.0
otbRGBAPixelConverter.txx
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 
19 #ifndef __otbRGBAPixelConverter_txx
20 #define __otbRGBAPixelConverter_txx
21 
22 
23 namespace otb
24 {
25 
26 //Base
27 template <class TInternalInputPixelType, class TOutputPixelType>
28 typename RGBAPixelConverter<TInternalInputPixelType,
29  TOutputPixelType>
30 ::OutputPixelType
31 RGBAPixelConverter<TInternalInputPixelType,
32  TOutputPixelType>
33 ::Convert(InputPixelType input)
34 {
35  double result;
36 
37  result = (
38  ( 2125.0 * static_cast<double>(input[0]) +
39  7154.0 * static_cast<double>(input[1]) +
40  0721.0 * static_cast<double>(input[2])) / 10000.0); //alpha not supported yet
41 
42  return (static_cast<OutputPixelType>(result));
43 }
44 
45 //RGBA to RGBA
46 template <class TInternalInputPixelType, class TInternalOutputPixelType>
47 typename RGBAPixelConverter<TInternalInputPixelType,
49 ::OutputPixelType
50 RGBAPixelConverter<TInternalInputPixelType,
52 ::Convert(InputPixelType input)
53 {
54  OutputPixelType result;
55 
56  result[0] = static_cast<TInternalOutputPixelType>(input[0]);
57  result[1] = static_cast<TInternalOutputPixelType>(input[1]);
58  result[2] = static_cast<TInternalOutputPixelType>(input[2]);
59  result[3] = static_cast<TInternalOutputPixelType>(input[3]);
60 
61  return result;
62 }
63 
64 //RGBA to RGB
65 template <class TInternalInputPixelType, class TInternalOutputPixelType>
66 typename RGBAPixelConverter<TInternalInputPixelType,
68 ::OutputPixelType
69 RGBAPixelConverter<TInternalInputPixelType,
71 ::Convert(InputPixelType input)
72 {
73  OutputPixelType result;
74 
75  result[0] = static_cast<TInternalOutputPixelType>(input[0]);
76  result[1] = static_cast<TInternalOutputPixelType>(input[1]);
77  result[2] = static_cast<TInternalOutputPixelType>(input[2]);
78 
79  return result;
80 }
81 
82 
83 } // end namespace otb
84 
85 
86 #endif

Generated at Sat Mar 8 2014 16:15:59 for Orfeo Toolbox with doxygen 1.8.3.1