OTB  10.0.0
Orfeo Toolbox
otbAmplitudePhaseToRGBFunctor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 otbAmplitudePhaseToRGBFunctor_h
23 #define otbAmplitudePhaseToRGBFunctor_h
24 
26 #include "otbMath.h"
27 
28 namespace otb
29 {
30 
31 namespace Functor
32 {
49 template <class TInput1, class TInput2 = TInput1, class TInput3 = TInput1, class TOutput = TInput1>
51 {
52 public:
53  typedef TOutput RGBPixelType;
54  typedef typename RGBPixelType::ValueType RGBComponentType;
56  typedef TInput1 ScalarType;
57 
59  :
60  m_Minimum(0), m_Maximum(itk::NumericTraits<ScalarType>::max())
61  {};
62 
64 
66  {
67  this->m_Maximum = max;
68  }
69 
71  {
72  this->m_Minimum = min;
73  }
74 
75  inline TOutput operator()(const TInput1& amplitude, const TInput2& coherence, const TInput3& phase) const
76  {
77  // std::cout << amplitude << " - " << phase << std::endl;
78  double hinc;
79  hinc = 0.6 / (CONST_2PI);
80 
81  double hue, sat, val;
82 
83  hue = 0.6 - (phase + CONST_PI) * hinc;
84  sat = 0.6 * coherence + 0.3;
85  val = itk::NumericTraits<RGBComponentType>::max() / 2 * ((amplitude - m_Minimum) / (m_Maximum - m_Minimum) + 1.0);
86 
87  if (amplitude < m_Minimum)
88  {
89  val = 0;
90  }
91  if (amplitude > m_Maximum)
92  {
93  val = itk::NumericTraits<RGBComponentType>::max();
94  }
95 
96  return m_HSVToRGBFunctor(hue, sat, val);
97  }
98 
99 private:
103 };
104 }
105 }
106 #endif
Function object to compute a color representation of a radar image.
TOutput operator()(const TInput1 &amplitude, const TInput2 &coherence, const TInput3 &phase) const
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
constexpr double CONST_PI
Definition: otbMath.h:49
constexpr double CONST_2PI
Definition: otbMath.h:55