OTB  9.0.0
Orfeo Toolbox
otbSarBrightnessFunction.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 otbSarBrightnessFunction_hxx
23 #define otbSarBrightnessFunction_hxx
24 
26 #include "itkNumericTraits.h"
27 
28 namespace otb
29 {
30 
34 template <class TInputImage, class TCoordRep>
36 {
42 
43  m_Noise->SetConstantValue(0.0);
44  m_EnableNoise = true;
45  m_AntennaPatternNewGain->SetConstantValue(1.0);
46  m_AntennaPatternOldGain->SetConstantValue(1.0);
47  m_RangeSpreadLoss->SetConstantValue(1.0);
48 }
49 
53 template <class TInputImage, class TCoordRep>
55 {
56  Superclass::SetInputImage(ptr);
57  m_Noise->SetInputImage(ptr);
58  m_AntennaPatternNewGain->SetInputImage(ptr);
59  m_AntennaPatternOldGain->SetInputImage(ptr);
60  m_RangeSpreadLoss->SetInputImage(ptr);
61 }
63 
67 template <class TInputImage, class TCoordRep>
68 void SarBrightnessFunction<TInputImage, TCoordRep>::PrintSelf(std::ostream& os, itk::Indent indent) const
69 {
70  this->Superclass::PrintSelf(os, indent);
71  if (m_Noise)
72  {
73  os << indent << "Noise:\n";
74  m_Noise->Print(os, indent.GetNextIndent());
75  }
76  if (m_AntennaPatternNewGain)
77  {
78  os << indent << "AntennaPatternNewGain:\n";
79  m_AntennaPatternNewGain->Print(os, indent.GetNextIndent());
80  }
81  if (m_AntennaPatternOldGain)
82  {
83  os << indent << "AntennaPatternOldGain:\n";
84  m_AntennaPatternOldGain->Print(os, indent.GetNextIndent());
85  }
86  if (m_RangeSpreadLoss)
87  {
88  os << indent << "RangeSpreadLoss:\n";
89  m_RangeSpreadLoss->Print(os, indent.GetNextIndent());
90  }
91 }
93 
97 template <class TInputImage, class TCoordRep>
99 {
100  RealType result;
101  result = itk::NumericTraits<RealType>::Zero;
102 
103  if (!this->GetInputImage())
104  {
105  return (itk::NumericTraits<OutputType>::max());
106  }
107 
108  if (!this->IsInsideBuffer(index))
109  {
110  return (itk::NumericTraits<OutputType>::max());
111  }
112 
113 
114  FunctorRealType noise = itk::NumericTraits<FunctorRealType>::Zero;
115  FunctorRealType antennaPatternNewGain = itk::NumericTraits<FunctorRealType>::Zero;
116  FunctorRealType antennaPatternOldGain = itk::NumericTraits<FunctorRealType>::Zero;
117  FunctorRealType rangeSpreadLoss = itk::NumericTraits<FunctorRealType>::Zero;
118 
119  if (m_EnableNoise)
120  {
121  noise = static_cast<FunctorRealType>(m_Noise->EvaluateAtIndex(index));
122  }
123  antennaPatternNewGain = static_cast<FunctorRealType>(m_AntennaPatternNewGain->EvaluateAtIndex(index));
124  antennaPatternOldGain = static_cast<FunctorRealType>(m_AntennaPatternOldGain->EvaluateAtIndex(index));
125  rangeSpreadLoss = static_cast<FunctorRealType>(m_RangeSpreadLoss->EvaluateAtIndex(index));
126 
127  FunctorType functor;
128  if (m_EnableNoise)
129  {
130  functor.SetNoise(noise);
131  }
132  functor.SetScale(m_Scale);
133  functor.SetAntennaPatternNewGain(antennaPatternNewGain);
134  functor.SetAntennaPatternOldGain(antennaPatternOldGain);
135  functor.SetRangeSpreadLoss(rangeSpreadLoss);
136 
137  const std::complex<float> pVal = this->GetInputImage()->GetPixel(index);
138  const RealType value = std::sqrt((pVal.real() * pVal.real()) + (pVal.imag() * pVal.imag()));
139 
140  result = functor(value);
141 
142  return static_cast<OutputType>(result);
143 }
144 
145 } // end namespace otb
146 
147 #endif
otb::SarBrightnessFunction::m_EnableNoise
bool m_EnableNoise
Definition: otbSarBrightnessFunction.h:158
otb::Functor::SarBrightnessFunctor::SetNoise
void SetNoise(RealType value)
Definition: otbSarBrightnessFunctor.h:74
otb::Functor::SarBrightnessFunctor::SetAntennaPatternNewGain
void SetAntennaPatternNewGain(RealType value)
Definition: otbSarBrightnessFunctor.h:98
otb::SarBrightnessFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbSarBrightnessFunction.hxx:68
otb::Functor::SarBrightnessFunctor::SetRangeSpreadLoss
void SetRangeSpreadLoss(RealType value)
Definition: otbSarBrightnessFunctor.h:122
otb::SarBrightnessFunction::m_AntennaPatternOldGain
ParametricFunctionPointer m_AntennaPatternOldGain
Definition: otbSarBrightnessFunction.h:160
otb::SarParametricMapFunction::New
static Pointer New()
otb::SarBrightnessFunction::RealType
double RealType
Definition: otbSarBrightnessFunction.h:77
otb::Functor::SarBrightnessFunctor::SetAntennaPatternOldGain
void SetAntennaPatternOldGain(RealType value)
Definition: otbSarBrightnessFunctor.h:110
otb::Functor::SarBrightnessFunctor
Compute the brightness value. .
Definition: otbSarBrightnessFunctor.h:42
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SarBrightnessFunction::m_AntennaPatternNewGain
ParametricFunctionPointer m_AntennaPatternNewGain
Definition: otbSarBrightnessFunction.h:159
otb::SarBrightnessFunction::SarBrightnessFunction
SarBrightnessFunction()
Definition: otbSarBrightnessFunction.hxx:35
otb::SarBrightnessFunction::m_Noise
ParametricFunctionPointer m_Noise
Definition: otbSarBrightnessFunction.h:157
otb::SarBrightnessFunction::OutputType
Superclass::OutputType OutputType
Definition: otbSarBrightnessFunction.h:68
otb::SarBrightnessFunction::InputImageType
TInputImage InputImageType
Definition: otbSarBrightnessFunction.h:63
otb::Functor::SarBrightnessFunctor::SetScale
void SetScale(RealType value)
Definition: otbSarBrightnessFunctor.h:86
otb::SarBrightnessFunction::m_RangeSpreadLoss
ParametricFunctionPointer m_RangeSpreadLoss
Definition: otbSarBrightnessFunction.h:161
otb::SarBrightnessFunction::FunctorRealType
FunctorType::RealType FunctorRealType
Definition: otbSarBrightnessFunction.h:79
otbSarBrightnessFunction.h
otb::SarBrightnessFunction::SetInputImage
void SetInputImage(const InputImageType *ptr) override
Definition: otbSarBrightnessFunction.hxx:54
otb::SarBrightnessFunction::EvaluateAtIndex
OutputType EvaluateAtIndex(const IndexType &index) const override
Definition: otbSarBrightnessFunction.hxx:98
otb::SarBrightnessFunction::IndexType
Superclass::IndexType IndexType
Definition: otbSarBrightnessFunction.h:69