OTB  9.0.0
Orfeo Toolbox
otbSarBrightnessToImageFilter.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2022 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 otbSarBrightnessToImageFilter_hxx
23 #define otbSarBrightnessToImageFilter_hxx
24 
26 #include "otbSARMetadata.h"
27 #include <boost/any.hpp>
28 
29 namespace otb
30 {
31 
35 template <class TInputImage, class TOutputImage>
37 {
38 }
39 
40 template <class TInputImage, class TOutputImage>
42 {
43  // will SetInputImage on the function
44  Superclass::BeforeThreadedGenerateData();
45 
47  auto imd = this->GetInput()->GetImageMetadata();
48 
50  std::unique_ptr<SARCalib> sarCalibPtr;
51  if (imd.Has(MDGeom::SARCalib))
52  {
53  sarCalibPtr = std::make_unique<SARCalib>(boost::any_cast<SARCalib>(imd[MDGeom::SARCalib]));
54  }
55  else if ((imd.Bands.size() > 0) && imd.Bands[0].Has(MDGeom::SARCalib))
56  {
57  sarCalibPtr = std::make_unique<SARCalib>(boost::any_cast<SARCalib>(imd.Bands[0][MDGeom::SARCalib]));
58  }
59  else
60  throw std::runtime_error("otbSarBrightnessToImageFilter was not able to fetch the SARCalib metadata.");
62 
63  FunctionPointer function = this->GetFunction();
64 
65  function->SetScale(imd[MDNum::CalScale]);
66 
67  ParametricFunctionPointer noise = function->GetNoise();
68  noise->SetPointSet(sarCalibPtr->radiometricCalibrationNoise);
69  noise->SetPolynomalSize(sarCalibPtr->radiometricCalibrationNoisePolynomialDegree);
70  noise->EvaluateParametricCoefficient();
71 
72  ParametricFunctionPointer antennaPatternNewGain = function->GetAntennaPatternNewGain();
73  antennaPatternNewGain->SetPointSet(sarCalibPtr->radiometricCalibrationAntennaPatternNewGain);
74  antennaPatternNewGain->SetPolynomalSize(sarCalibPtr->radiometricCalibrationAntennaPatternNewGainPolynomialDegree);
75  antennaPatternNewGain->EvaluateParametricCoefficient();
76 
77  ParametricFunctionPointer antennaPatternOldGain = function->GetAntennaPatternOldGain();
78  antennaPatternOldGain->SetPointSet(sarCalibPtr->radiometricCalibrationAntennaPatternOldGain);
79  antennaPatternOldGain->SetPolynomalSize(sarCalibPtr->radiometricCalibrationAntennaPatternOldGainPolynomialDegree);
80  antennaPatternOldGain->EvaluateParametricCoefficient();
81 
82  ParametricFunctionPointer rangeSpreadLoss = function->GetRangeSpreadLoss();
83  rangeSpreadLoss->SetPointSet(sarCalibPtr->radiometricCalibrationRangeSpreadLoss);
84  rangeSpreadLoss->SetPolynomalSize(sarCalibPtr->radiometricCalibrationRangeSpreadLossPolynomialDegree);
85  rangeSpreadLoss->EvaluateParametricCoefficient();
86 
87 #if 0
88  this->Print(std::cout, id);
89 #endif
90 }
91 
92 template <class TInputImage, class TOutputImage>
93 void SarBrightnessToImageFilter<TInputImage, TOutputImage>::PrintSelf(std::ostream& os, itk::Indent indent) const
94 {
95  Superclass::PrintSelf(os, indent);
96 
97  if (this->GetFunction())
98  {
99  os << indent << "Function:\n";
100  this->GetFunction()->Print(os, indent.GetNextIndent());
101  }
102 }
103 
104 
105 } // end namespace otb
106 
107 #endif
otb::SarBrightnessToImageFilter::SarBrightnessToImageFilter
SarBrightnessToImageFilter()
Definition: otbSarBrightnessToImageFilter.hxx:36
otb::MDGeom::SARCalib
@ SARCalib
otb::SARCalib::radiometricCalibrationNoisePolynomialDegree
ArrayType radiometricCalibrationNoisePolynomialDegree
Definition: otbSARMetadata.h:290
otb::SarBrightnessToImageFilter::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbSarBrightnessToImageFilter.hxx:93
otb::SarBrightnessToImageFilter::FunctionPointer
Superclass::FunctionPointer FunctionPointer
Definition: otbSarBrightnessToImageFilter.h:72
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SARCalib::radiometricCalibrationAntennaPatternOldGain
PointSetType::Pointer radiometricCalibrationAntennaPatternOldGain
Definition: otbSARMetadata.h:297
otb::SARCalib::radiometricCalibrationAntennaPatternNewGain
PointSetType::Pointer radiometricCalibrationAntennaPatternNewGain
Definition: otbSARMetadata.h:296
otb::MDNum::CalScale
@ CalScale
otbSARMetadata.h
otb::SARCalib::radiometricCalibrationAntennaPatternNewGainPolynomialDegree
ArrayType radiometricCalibrationAntennaPatternNewGainPolynomialDegree
Definition: otbSARMetadata.h:291
otb::SARCalib::radiometricCalibrationRangeSpreadLoss
PointSetType::Pointer radiometricCalibrationRangeSpreadLoss
Definition: otbSARMetadata.h:299
otb::SARCalib::radiometricCalibrationRangeSpreadLossPolynomialDegree
ArrayType radiometricCalibrationRangeSpreadLossPolynomialDegree
Definition: otbSARMetadata.h:294
otbSarBrightnessToImageFilter.h
otb::SARCalib::radiometricCalibrationAntennaPatternOldGainPolynomialDegree
ArrayType radiometricCalibrationAntennaPatternOldGainPolynomialDegree
Definition: otbSARMetadata.h:292
otb::SarBrightnessToImageFilter::BeforeThreadedGenerateData
void BeforeThreadedGenerateData() override
Definition: otbSarBrightnessToImageFilter.hxx:41
otb::SarBrightnessToImageFilter::ParametricFunctionPointer
FunctionType::ParametricFunctionPointer ParametricFunctionPointer
Definition: otbSarBrightnessToImageFilter.h:75
otb::SARCalib::radiometricCalibrationNoise
PointSetType::Pointer radiometricCalibrationNoise
Definition: otbSARMetadata.h:295