OTB  6.7.0
Orfeo Toolbox
otbSarRadiometricCalibrationToImageFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 #ifndef otbSarRadiometricCalibrationToImageFilter_hxx
23 #define otbSarRadiometricCalibrationToImageFilter_hxx
24 
28 
29 namespace otb
30 {
31 
35 template<class TInputImage, class TOutputImage>
38 : m_LookupSelected(0)
39 {
40 
41 }
42 
43 template<class TInputImage, class TOutputImage>
44 void
47 {
48  Superclass::GenerateOutputInformation();
49 
50  // Retrieving input/output pointers
51  InputImagePointer inputPtr = this->GetInput();
52 
53  if (inputPtr.IsNull())
54  {
55  itkExceptionMacro(<< "At least one input is missing."
56  << " Input is missing :" << inputPtr.GetPointer() )
57  }
58 
59  OutputImagePointer outputPtr = this->GetOutput();
60  if (outputPtr.IsNull())
61  {
62  itkExceptionMacro(<< "At least one output is missing."
63  << " Output is missing :" << outputPtr.GetPointer() )
64  }
65 }
66 
67 template<class TInputImage, class TOutputImage>
68 void
70 ::BeforeThreadedGenerateData()
71 {
72  // will SetInputImage on the function
73  Superclass::BeforeThreadedGenerateData();
74 
79  this->GetInput()->GetMetaDataDictionary());
80 
82  FunctionPointer function = this->GetFunction();
83 
91  bool apply = imageMetadataInterface->HasCalibrationLookupDataFlag();
92  /* Below lines will toggle the necessary flags which can help skip some
93  * computation. For example, if there is lookup value and ofcourse antenna
94  * pattern gain is not required. Even if we try to compute the value with
95  * SarParametricFunction we get 1. This is the safe side. But as we are so sure
96  * we skip all those calls to EvaluateParametricCoefficient and also the
97  * Evaluate(). For the function the value is 1 by default.
98  */
99  function->SetApplyAntennaPatternGain(!apply);
100  function->SetApplyIncidenceAngleCorrection(!apply);
101  function->SetApplyRangeSpreadLossCorrection(!apply);
102  function->SetApplyRescalingFactor(!apply);
103  function->SetApplyLookupDataCorrection(apply);
104 
105  function->SetScale(imageMetadataInterface->GetRadiometricCalibrationScale());
106 
107  /* Compute noise if enabled */
108  if( function->GetEnableNoise())
109  {
111  noise = function->GetNoise();
112  noise->SetPointSet(imageMetadataInterface->GetRadiometricCalibrationNoise());
113  noise->SetPolynomalSize(imageMetadataInterface->GetRadiometricCalibrationNoisePolynomialDegree());
114  noise->EvaluateParametricCoefficient();
115  }
116 
117  /* Compute old and new antenna pattern gain */
118  if(function->GetApplyAntennaPatternGain())
119  {
120  ParametricFunctionPointer antennaPatternNewGain;
121  antennaPatternNewGain = function->GetAntennaPatternNewGain();
122  antennaPatternNewGain->SetPointSet(imageMetadataInterface->GetRadiometricCalibrationAntennaPatternNewGain());
123  antennaPatternNewGain->SetPolynomalSize(imageMetadataInterface->GetRadiometricCalibrationAntennaPatternNewGainPolynomialDegree());
124  antennaPatternNewGain->EvaluateParametricCoefficient();
125 
126  ParametricFunctionPointer antennaPatternOldGain;
127  antennaPatternOldGain = function->GetAntennaPatternOldGain();
128  antennaPatternOldGain->SetPointSet(imageMetadataInterface->GetRadiometricCalibrationAntennaPatternOldGain());
129  antennaPatternOldGain->SetPolynomalSize(imageMetadataInterface->GetRadiometricCalibrationAntennaPatternOldGainPolynomialDegree());
130  antennaPatternOldGain->EvaluateParametricCoefficient();
131  }
132 
133  /* Compute incidence angle */
134  if (function->GetApplyIncidenceAngleCorrection())
135  {
136  ParametricFunctionPointer incidenceAngle;
137  incidenceAngle = function->GetIncidenceAngle();
138  incidenceAngle->SetPointSet(imageMetadataInterface->GetRadiometricCalibrationIncidenceAngle());
139  incidenceAngle->SetPolynomalSize(imageMetadataInterface->GetRadiometricCalibrationIncidenceAnglePolynomialDegree());
140  incidenceAngle->EvaluateParametricCoefficient();
141  }
142 
143  /* Compute Range spread Loss */
144  if (function->GetApplyRangeSpreadLossCorrection())
145  {
146  ParametricFunctionPointer rangeSpreadLoss;
147  rangeSpreadLoss = function->GetRangeSpreadLoss();
148  rangeSpreadLoss->SetPointSet(imageMetadataInterface->GetRadiometricCalibrationRangeSpreadLoss());
149  rangeSpreadLoss->SetPolynomalSize(imageMetadataInterface->GetRadiometricCalibrationRangeSpreadLossPolynomialDegree());
150  rangeSpreadLoss->EvaluateParametricCoefficient();
151  }
152 
161  if (function->GetApplyLookupDataCorrection())
162  {
163  function->SetCalibrationLookupData(imageMetadataInterface->GetCalibrationLookupData(this->GetLookupSelected()));
164  }
165 
167  if (function->GetApplyRescalingFactor())
168  {
169  function->SetRescalingFactor(imageMetadataInterface->GetRescalingFactor());
170  }
171 }
173 
174 } // end namespace otb
175 
176 #endif
TResult apply(TGeometry *geometry, TFunctor functor)
static SarImageMetadataInterfacePointerType CreateIMI(const MetaDataDictionaryType &dict)
InputImageType::Pointer InputImagePointer
Evaluates the SarRadiometricCalibrationFunction onto a source image The BeforeThreadedGenerateData cr...
OutputImageType::Pointer OutputImagePointer