OTB  9.0.0
Orfeo Toolbox
otbAmplitudePhaseToRGBFunctor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 
63  ~AmplitudePhaseToRGBFunctor() = default;
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
otb::CONST_PI
constexpr double CONST_PI
Definition: otbMath.h:49
otb::Functor::AmplitudePhaseToRGBFunctor::RGBComponentType
RGBPixelType::ValueType RGBComponentType
Definition: otbAmplitudePhaseToRGBFunctor.h:54
otb::Functor::AmplitudePhaseToRGBFunctor::m_Maximum
ScalarType m_Maximum
Definition: otbAmplitudePhaseToRGBFunctor.h:101
otb::Functor::AmplitudePhaseToRGBFunctor::SetMaximum
void SetMaximum(ScalarType max)
Definition: otbAmplitudePhaseToRGBFunctor.h:65
otbMath.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::AmplitudePhaseToRGBFunctor::operator()
TOutput operator()(const TInput1 &amplitude, const TInput2 &coherence, const TInput3 &phase) const
Definition: otbAmplitudePhaseToRGBFunctor.h:75
otb::Functor::AmplitudePhaseToRGBFunctor::HSVToRGBFunctorType
HSVToRGBFunctor< RGBPixelType > HSVToRGBFunctorType
Definition: otbAmplitudePhaseToRGBFunctor.h:55
otb::CONST_2PI
constexpr double CONST_2PI
Definition: otbMath.h:55
otb::Functor::AmplitudePhaseToRGBFunctor
Function object to compute a color representation of a radar image.
Definition: otbAmplitudePhaseToRGBFunctor.h:50
otb::Functor::AmplitudePhaseToRGBFunctor::AmplitudePhaseToRGBFunctor
AmplitudePhaseToRGBFunctor()
Definition: otbAmplitudePhaseToRGBFunctor.h:58
otb::Functor::HSVToRGBFunctor< RGBPixelType >
otb::Functor::AmplitudePhaseToRGBFunctor::ScalarType
TInput1 ScalarType
Definition: otbAmplitudePhaseToRGBFunctor.h:56
otb::Functor::AmplitudePhaseToRGBFunctor::m_HSVToRGBFunctor
HSVToRGBFunctorType m_HSVToRGBFunctor
Definition: otbAmplitudePhaseToRGBFunctor.h:102
itk
Definition: otbNoDataHelper.h:31
otb::Functor::AmplitudePhaseToRGBFunctor::m_Minimum
ScalarType m_Minimum
Definition: otbAmplitudePhaseToRGBFunctor.h:100
otb::Functor::AmplitudePhaseToRGBFunctor::SetMinimum
void SetMinimum(ScalarType min)
Definition: otbAmplitudePhaseToRGBFunctor.h:70
otb::Functor::AmplitudePhaseToRGBFunctor::RGBPixelType
TOutput RGBPixelType
Definition: otbAmplitudePhaseToRGBFunctor.h:53
otbScalarToRainbowRGBPixelFunctor.h