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

Generated at Sat Mar 8 2014 16:22:07 for Orfeo Toolbox with doxygen 1.8.3.1