OTB  9.0.0
Orfeo Toolbox
otbSarRadiometricCalibrationFunction.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 
22 #ifndef otbSarRadiometricCalibrationFunction_hxx
23 #define otbSarRadiometricCalibrationFunction_hxx
24 
26 #include "itkNumericTraits.h"
27 
28 namespace otb
29 {
33 template <class TInputImage, class TCoordRep>
35  : m_Scale(1.0),
36  m_EnableNoise(false),
37  m_RescalingFactor(1.0),
38  m_ApplyAntennaPatternGain(true),
39  m_ApplyIncidenceAngleCorrection(true),
40  m_ApplyRangeSpreadLossCorrection(true),
41  m_ApplyLookupDataCorrection(false),
42  m_ApplyRescalingFactor(false)
43 {
44  /* initialize parametric functions */
51 
52  /* initialize default values in paramerticFunction instances */
53  m_Noise->SetConstantValue(0.0);
54  m_AntennaPatternNewGain->SetConstantValue(1.0);
55  m_AntennaPatternOldGain->SetConstantValue(1.0);
56  m_IncidenceAngle->SetConstantValue(CONST_PI_2);
57  m_RangeSpreadLoss->SetConstantValue(1.0);
58 }
59 
63 template <class TInputImage, class TCoordRep>
65 {
66  Superclass::SetInputImage(ptr);
67  m_Noise->SetInputImage(ptr);
68  m_IncidenceAngle->SetInputImage(ptr);
69  m_AntennaPatternNewGain->SetInputImage(ptr);
70  m_AntennaPatternOldGain->SetInputImage(ptr);
71  m_RangeSpreadLoss->SetInputImage(ptr);
72 }
74 
78 template <class TInputImage, class TCoordRep>
79 void SarRadiometricCalibrationFunction<TInputImage, TCoordRep>::PrintSelf(std::ostream& os, itk::Indent indent) const
80 {
81  this->Superclass::PrintSelf(os, indent);
82 }
83 
84 /* Function: EvaluateAtIndex. This computes the required values for each pixel
85 * whose index is given in indexType argument. To convert index to point it uses
86 * InputImage::TransformIndexToPhysicalPoint(). IncidenceAngle and similar are
87 * computed based on this calculated point in SarParametricFunction */
88 template <class TInputImage, class TCoordRep>
91 {
92 
93  if (!this->IsInsideBuffer(index))
94  {
95  itkDebugMacro(<< "ERROR with IsInsideBuffer");
96  return (itk::NumericTraits<OutputType>::max());
97  }
98 
99  /* convert index to point */
100  PointType point;
101  if (m_ApplyAntennaPatternGain || m_ApplyIncidenceAngleCorrection || m_ApplyRangeSpreadLossCorrection)
102  this->GetInputImage()->TransformIndexToPhysicalPoint(index, point);
103 
113  const std::complex<float> pVal = this->GetInputImage()->GetPixel(index);
114  const RealType digitalNumber = std::sqrt((pVal.real() * pVal.real()) + (pVal.imag() * pVal.imag()));
115 
116  RealType sigma = m_Scale * digitalNumber * digitalNumber;
117 
119  if (m_EnableNoise)
120  {
121  sigma -= static_cast<RealType>(m_Noise->Evaluate(point));
122  }
123 
125  if (m_ApplyIncidenceAngleCorrection)
126  {
127  sigma *= std::sin(static_cast<RealType>(m_IncidenceAngle->Evaluate(point)));
128  }
129 
131  if (m_ApplyAntennaPatternGain)
132  {
133  sigma *= static_cast<RealType>(m_AntennaPatternNewGain->Evaluate(point));
134  sigma /= static_cast<RealType>(m_AntennaPatternOldGain->Evaluate(point));
135  }
137 
139  if (m_ApplyRangeSpreadLossCorrection)
140  {
141  sigma *= static_cast<RealType>(m_RangeSpreadLoss->Evaluate(point));
142  }
143 
146  if (m_ApplyLookupDataCorrection)
147  {
148  if (m_EnableNoise && m_NoiseLut)
149  {
150  sigma = std::max(0., sigma - m_NoiseLut->GetValue(index[0], index[1]));
151  }
152 
153  RealType lutVal = static_cast<RealType>(m_Lut->GetValue(index[0], index[1]));
154 
155  sigma /= lutVal * lutVal;
156  }
157 
159  if (m_ApplyRescalingFactor)
160  {
161  sigma /= m_RescalingFactor;
162  }
163 
164  if (sigma < 0.0)
165  {
166  sigma = 0.0;
167  }
168 
169  return static_cast<OutputType>(sigma);
170 }
171 
172 } // end namespace otb
173 
174 #endif
otb::SarRadiometricCalibrationFunction::m_AntennaPatternOldGain
ParametricFunctionPointer m_AntennaPatternOldGain
Definition: otbSarRadiometricCalibrationFunction.h:216
otb::SarRadiometricCalibrationFunction::IndexType
Superclass::IndexType IndexType
Definition: otbSarRadiometricCalibrationFunction.h:70
otb::SarRadiometricCalibrationFunction::RealType
double RealType
Definition: otbSarRadiometricCalibrationFunction.h:77
otb::SarParametricMapFunction::New
static Pointer New()
otbSarRadiometricCalibrationFunction.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SarRadiometricCalibrationFunction::m_IncidenceAngle
ParametricFunctionPointer m_IncidenceAngle
Definition: otbSarRadiometricCalibrationFunction.h:217
otb::SarRadiometricCalibrationFunction::PointType
Superclass::PointType PointType
Definition: otbSarRadiometricCalibrationFunction.h:72
otb::SarRadiometricCalibrationFunction::EvaluateAtIndex
OutputType EvaluateAtIndex(const IndexType &index) const override
Definition: otbSarRadiometricCalibrationFunction.hxx:90
otb::CONST_PI_2
constexpr double CONST_PI_2
Definition: otbMath.h:50
otb::SarRadiometricCalibrationFunction::m_Noise
ParametricFunctionPointer m_Noise
Definition: otbSarRadiometricCalibrationFunction.h:214
otb::SarRadiometricCalibrationFunction::m_RangeSpreadLoss
ParametricFunctionPointer m_RangeSpreadLoss
Definition: otbSarRadiometricCalibrationFunction.h:218
otb::SarRadiometricCalibrationFunction::m_AntennaPatternNewGain
ParametricFunctionPointer m_AntennaPatternNewGain
Definition: otbSarRadiometricCalibrationFunction.h:215
otb::SarRadiometricCalibrationFunction::SarRadiometricCalibrationFunction
SarRadiometricCalibrationFunction()
Definition: otbSarRadiometricCalibrationFunction.hxx:34
otb::SarRadiometricCalibrationFunction::InputImageType
TInputImage InputImageType
Definition: otbSarRadiometricCalibrationFunction.h:64
otb::SarRadiometricCalibrationFunction::OutputType
Superclass::OutputType OutputType
Definition: otbSarRadiometricCalibrationFunction.h:69
otb::SarRadiometricCalibrationFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbSarRadiometricCalibrationFunction.hxx:79
otb::SarRadiometricCalibrationFunction::SetInputImage
void SetInputImage(const InputImageType *ptr) override
Definition: otbSarRadiometricCalibrationFunction.hxx:64