OTB  7.1.0
Orfeo Toolbox
otbRGBAPixelConverter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 
22 #ifndef otbRGBAPixelConverter_hxx
23 #define otbRGBAPixelConverter_hxx
24 
25 #include "otbRGBAPixelConverter.h"
26 
27 namespace otb
28 {
29 
30 // Base
31 template <class TInternalInputPixelType, class TOutputPixelType>
34 {
35  double result;
36 
37  result = ((2125.0 * static_cast<double>(input[0]) + 7154.0 * static_cast<double>(input[1]) + 0721.0 * static_cast<double>(input[2])) /
38  10000.0); // alpha not supported yet
39 
40  return (static_cast<OutputPixelType>(result));
41 }
42 
43 // RGBA to RGBA
44 template <class TInternalInputPixelType, class TInternalOutputPixelType>
47 {
48  OutputPixelType result;
49 
50  result[0] = static_cast<TInternalOutputPixelType>(input[0]);
51  result[1] = static_cast<TInternalOutputPixelType>(input[1]);
52  result[2] = static_cast<TInternalOutputPixelType>(input[2]);
53  result[3] = static_cast<TInternalOutputPixelType>(input[3]);
54 
55  return result;
56 }
57 
58 // RGBA to RGB
59 template <class TInternalInputPixelType, class TInternalOutputPixelType>
62 {
63  OutputPixelType result;
64 
65  result[0] = static_cast<TInternalOutputPixelType>(input[0]);
66  result[1] = static_cast<TInternalOutputPixelType>(input[1]);
67  result[2] = static_cast<TInternalOutputPixelType>(input[2]);
68 
69  return result;
70 }
71 
72 
73 } // end namespace otb
74 
75 
76 #endif
Convert an itk::RGBApixel<InternalType> into another pixel type.
OutputPixelType Convert(InputPixelType input)
TOutputPixelType OutputPixelType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
itk::RGBAPixel< TInternalInputPixelType > InputPixelType