OTB  10.0.0
Orfeo Toolbox
otbSurfaceAdjacencyEffectCorrectionSchemeFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1999-2011 Insight Software Consortium
3  * Copyright (C) 2005-2024 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 otbSurfaceAdjacencyEffectCorrectionSchemeFilter_h
23 #define otbSurfaceAdjacencyEffectCorrectionSchemeFilter_h
24 
25 #include "itkNumericTraits.h"
26 #include <vector>
28 #include "itkVariableSizeMatrix.h"
30 #include <iomanip>
31 
32 namespace otb
33 {
34 namespace Functor
35 {
45 template <class TNeighIter, class TOutput>
47 {
48 public:
50  {
51  }
53  {
54  }
55 
56  typedef itk::VariableSizeMatrix<double> WeightingMatrixType;
57  typedef typename std::vector<WeightingMatrixType> WeightingValuesContainerType;
58  typedef typename TOutput::RealValueType RealValueType;
59  typedef std::vector<double> DoubleContainerType;
60 
62  {
63  m_WeightingValues = cont;
64  }
65  void SetUpwardTransmittanceRatio(DoubleContainerType& upwardTransmittanceRatio)
66  {
67  m_UpwardTransmittanceRatio = upwardTransmittanceRatio;
68  }
70  {
71  m_DiffuseRatio = diffuseRatio;
72  }
74  {
75  return m_WeightingValues;
76  }
78  {
80  }
82  {
83  return m_DiffuseRatio;
84  }
85 
86  inline TOutput operator()(const TNeighIter& it)
87  {
88  unsigned int neighborhoodSize = it.Size();
89  double contribution = 0.;
90  TOutput outPixel;
91  outPixel.SetSize(it.GetCenterPixel().Size());
92 
93  // Loop over each component
94  const unsigned int size = outPixel.GetSize();
95  for (unsigned int j = 0; j < size; ++j)
96  {
97  contribution = 0;
98  // Load the current channel ponderation value matrix
99  WeightingMatrixType TempChannelWeighting = m_WeightingValues[j];
100  // Loop over the neighborhood
101  for (unsigned int i = 0; i < neighborhoodSize; ++i)
102  {
103  // Current neighborhood pixel index calculation
104  unsigned int RowIdx = 0;
105  unsigned int ColIdx = 0;
106  RowIdx = i / TempChannelWeighting.Cols();
107  ColIdx = i - RowIdx * TempChannelWeighting.Cols();
108 
109  // Extract the current neighborhood pixel ponderation
110  double idVal = TempChannelWeighting(RowIdx, ColIdx);
111  // Extract the current neighborhood pixel value
112  TOutput tempPix = it.GetPixel(i);
113 
114  contribution += static_cast<double>(tempPix[j]) * idVal;
115  }
116 
117  outPixel[j] = static_cast<RealValueType>(it.GetCenterPixel()[j]) * m_UpwardTransmittanceRatio[j] + contribution * m_DiffuseRatio[j];
118  }
119  return outPixel;
120  }
121 
122 private:
126 };
127 }
128 
141 template <class TInputImage, class TOutputImage>
143  : public UnaryFunctorNeighborhoodImageFilter<TInputImage, TOutputImage, typename Functor::ComputeNeighborhoodContributionFunctor<
144  itk::ConstNeighborhoodIterator<TInputImage>, typename TOutputImage::PixelType>>
145 {
146 public:
149 
153  typedef itk::SmartPointer<Self> Pointer;
154  typedef itk::SmartPointer<const Self> ConstPointer;
155 
158 
159  typedef std::vector<double> DoubleContainerType;
161  itkNewMacro(Self);
162 
165 
167  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
168  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
170 
172  typedef typename InputImageType::PixelType InputPixelType;
173  typedef typename InputImageType::InternalPixelType InputInternalPixelType;
174  typedef typename InputImageType::RegionType InputImageRegionType;
175  typedef typename InputImageType::SizeType SizeType;
176  typedef typename OutputImageType::PixelType OutputPixelType;
177  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
178  typedef typename OutputImageType::RegionType OutputImageRegionType;
179 
180 
182 
185 
188 
191 
192 
196 
198 
199  typedef itk::MetaDataDictionary MetaDataDictionaryType;
200 
202  typedef itk::VariableSizeMatrix<double> WeightingMatrixType;
203  typedef typename std::vector<WeightingMatrixType> WeightingValuesContainerType;
204 
206  typedef typename itk::ConstNeighborhoodIterator<InputImageType> NeighborIterType;
207 
209  void SetWindowRadius(unsigned int rad)
210  {
211  this->SetRadius(rad);
212  m_WindowRadius = rad;
213  this->Modified();
214  }
215  itkGetConstReferenceMacro(WindowRadius, unsigned int);
217 
219  itkSetMacro(PixelSpacingInKilometers, double);
220  itkGetMacro(PixelSpacingInKilometers, double);
221 
223  itkSetMacro(ZenithalViewingAngle, double);
224  itkGetMacro(ZenithalViewingAngle, double);
226 
227 
230  {
231  m_AtmosphericRadiativeTerms = atmoRadTerms;
232  this->SetNthInput(1, m_AtmosphericRadiativeTerms);
233  m_IsSetAtmosphericRadiativeTerms = true;
234  this->Modified();
235  }
238 
241  {
242  m_AtmoCorrectionParameters = atmoCorrTerms;
243  this->SetNthInput(2, m_AtmoCorrectionParameters);
244  m_IsSetAtmoCorrectionParameters = true;
245  this->Modified();
246  }
249 
252  {
253  m_AcquiCorrectionParameters = acquiCorrTerms;
254  this->SetNthInput(3, m_AcquiCorrectionParameters);
255  m_IsSetAcquiCorrectionParameters = true;
256  this->Modified();
257  }
260 
261 
263  void GenerateParameters();
264 
265 
267  itkSetMacro(IsSetAtmosphericRadiativeTerms, bool);
268  itkGetMacro(IsSetAtmosphericRadiativeTerms, bool);
269  itkBooleanMacro(IsSetAtmosphericRadiativeTerms);
271 
272 protected:
275  {
276  }
277  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
278 
280  void BeforeThreadedGenerateData() override;
281 
283  void UpdateAtmosphericRadiativeTerms();
284 
286  void UpdateFunctors();
287 
289  void Modified() const override;
290 
291 private:
295 
300 
302  unsigned int m_WindowRadius;
303 
306 
309 
312 
315 };
316 
317 } // end namespace otb
318 
319 #ifndef OTB_MANUAL_INSTANTIATION
321 #endif
322 
323 #endif
This class contains all atmospheric correction parameters.
This class is a vector of AtmosphericRadiativeTermsSingleChannel, it contains all atmospheric radiati...
This class contains the values of the filter function for the processed spectral band.
std::vector< WavelengthSpectralBandType > ValuesVectorType
Unary neighborhood functor to compute the value of a pixel which is a sum of the surrounding pixels v...
void SetUpwardTransmittanceRatio(DoubleContainerType &upwardTransmittanceRatio)
This class contains all atmospheric correction parameters.
InternalWavelengthSpectralBandVectorType::Pointer WavelengthSpectralBandVectorType
Correct the scheme taking care of the surrounding pixels.
void SetAtmoCorrectionParameters(AtmoCorrectionParametersPointerType atmoCorrTerms)
void SetAtmosphericRadiativeTerms(AtmosphericRadiativeTermsPointerType atmoRadTerms)
otb::RadiometryCorrectionParametersToAtmosphericRadiativeTerms CorrectionParametersToRadiativeTermsType
itkGetObjectMacro(AcquiCorrectionParameters, AcquiCorrectionParametersType)
itkGetObjectMacro(AtmoCorrectionParameters, AtmoCorrectionParametersType)
Functor::ComputeNeighborhoodContributionFunctor< itk::ConstNeighborhoodIterator< TInputImage >, typename TOutputImage::PixelType > FunctorType
void SetAcquiCorrectionParameters(AcquiCorrectionParametersPointerType acquiCorrTerms)
UnaryFunctorNeighborhoodImageFilter< TInputImage, TOutputImage, FunctorType > Superclass
itkGetObjectMacro(AtmosphericRadiativeTerms, AtmosphericRadiativeTermsType)
AcquiCorrectionParametersType::WavelengthSpectralBandVectorType WavelengthSpectralBandVectorType
Implements neighborhood-wise generic operation on image.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.