OTB  9.0.0
Orfeo Toolbox
otbTerraSarBrightnessFunctor.hxx
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 #ifndef otbTerraSarBrightnessFunctor_hxx
22 #define otbTerraSarBrightnessFunctor_hxx
23 
25 
26 #include "itkNumericTraits.h"
27 
28 namespace otb
29 {
30 namespace Functor
31 {
32 
33 template <class TInput, class TOutput>
35 {
36  m_CalibrationFactor = itk::NumericTraits<double>::Zero;
37  m_ResultsInDecibels = false;
38  m_DefaultValue = 0.00001; // Default value is 10^-5
39 }
40 
41 template <class TInput, class TOutput>
43 {
44  // Formula: Beta^0 = Ks * |DN|^2
45 
46  // First, square the input pixel
47  double squareInPix = std::pow(static_cast<double>(inPix), 2.);
48 
49  // Then apply the calibration factor
50  double beta = m_CalibrationFactor * squareInPix;
51 
52  if (beta <= 0)
53  beta = m_DefaultValue;
54 
55  // Results in decibels case
56  if (m_ResultsInDecibels)
57  {
58  beta = 10 * std::log10(beta);
59  }
60 
61  return static_cast<TOutput>(beta);
62 }
63 
64 template <class TInput, class TOutput>
65 std::complex<TOutput> TerraSarBrightnessFunctor<TInput, TOutput>::operator()(const std::complex<TInput>& inPix)
66 {
67  // First, extract modulus and phase
68  double modulus = std::sqrt(inPix.real() * inPix.real() + inPix.imag() * inPix.imag());
69  double phase = std::atan2(inPix.imag(), inPix.real());
70 
71  // Then, calibrate the modulus
72  double beta = this->operator()(modulus);
73 
74  // Last, put back the phase
75  std::complex<TOutput> out(std::polar(beta, phase));
76 
77  return out;
78 }
79 
80 } // namespace Functor
81 
82 } // namespace otb
83 #endif
otbTerraSarBrightnessFunctor.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::TerraSarBrightnessFunctor::operator()
TOutput operator()(const TInput &inPix)
Definition: otbTerraSarBrightnessFunctor.hxx:42
otb::Functor::TerraSarBrightnessFunctor::TerraSarBrightnessFunctor
TerraSarBrightnessFunctor()
Definition: otbTerraSarBrightnessFunctor.hxx:34