OTB  6.5.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-2017 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:
51 
53  typedef typename std::vector<WeightingMatrixType> WeightingValuesContainerType;
54  typedef typename TOutput::RealValueType RealValueType;
55  typedef std::vector<double> DoubleContainerType;
56 
58  {
59  m_WeightingValues = cont;
60  }
61  void SetUpwardTransmittanceRatio(DoubleContainerType upwardTransmittanceRatio)
62  {
63  m_UpwardTransmittanceRatio = upwardTransmittanceRatio;
64  }
66  {
67  m_DiffuseRatio = diffuseRatio;
68  }
70  {
71  return m_WeightingValues;
72  }
74  {
76  }
78  {
79  return m_DiffuseRatio;
80  }
81 
82  inline TOutput operator ()(const TNeighIter& it)
83  {
84  unsigned int neighborhoodSize = it.Size();
85  double contribution = 0.;
86  TOutput outPixel;
87  outPixel.SetSize(it.GetCenterPixel().Size());
88 
89  // Loop over each component
90  const unsigned int size = outPixel.GetSize();
91  for (unsigned int j = 0; j < size; ++j)
92  {
93  contribution = 0;
94  // Load the current channel ponderation value matrix
95  WeightingMatrixType TempChannelWeighting = m_WeightingValues[j];
96  // Loop over the neighborhood
97  for (unsigned int i = 0; i < neighborhoodSize; ++i)
98  {
99  // Current neighborhood pixel index calculation
100  unsigned int RowIdx = 0;
101  unsigned int ColIdx = 0;
102  RowIdx = i / TempChannelWeighting.Cols();
103  ColIdx = i - RowIdx*TempChannelWeighting.Cols();
104 
105  // Extract the current neighborhood pixel ponderation
106  double idVal = TempChannelWeighting(RowIdx, ColIdx);
107  // Extract the current neighborhood pixel value
108  TOutput tempPix = it.GetPixel(i);
109 
110  contribution += static_cast<double>(tempPix[j]) * idVal;
111 
112  }
113 
114  outPixel[j] = static_cast<RealValueType>(it.GetCenterPixel()[j]) *m_UpwardTransmittanceRatio[j]
115  + contribution * m_DiffuseRatio[j];
116  }
117  return outPixel;
118  }
119 
120 private:
124 };
125 
126 }
127 
140 template <class TInputImage, class TOutputImage>
143  TInputImage,
144  TOutputImage,
145  typename Functor::ComputeNeighborhoodContributionFunctor<itk::
146  ConstNeighborhoodIterator <TInputImage>,
147  typename TOutputImage::PixelType> >
148 {
149 public:
152  typename TOutputImage::PixelType> FunctorType;
153 
159 
160  typedef typename Superclass::InputImageType InputImageType;
161  typedef typename Superclass::OutputImageType OutputImageType;
162 
163  typedef std::vector<double> DoubleContainerType;
165  itkNewMacro(Self);
166 
169 
171  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
172  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
174 
176  typedef typename InputImageType::PixelType InputPixelType;
177  typedef typename InputImageType::InternalPixelType InputInternalPixelType;
178  typedef typename InputImageType::RegionType InputImageRegionType;
180  typedef typename OutputImageType::PixelType OutputPixelType;
181  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
182  typedef typename OutputImageType::RegionType OutputImageRegionType;
183 
184 
186 
189 
192 
195 
196 
200 
202 
204 
207  typedef typename std::vector<WeightingMatrixType> WeightingValuesContainerType;
208 
211 
213  void SetWindowRadius(unsigned int rad)
214  {
215  this->SetRadius(rad);
216  m_WindowRadius = rad;
217  this->Modified();
218  }
219  itkGetConstReferenceMacro(WindowRadius, unsigned int);
221 
223  itkSetMacro(PixelSpacingInKilometers, double);
224  itkGetMacro(PixelSpacingInKilometers, double);
225 
227  itkSetMacro(ZenithalViewingAngle, double);
228  itkGetMacro(ZenithalViewingAngle, double);
230 
231 
234  {
235  m_AtmosphericRadiativeTerms = atmoRadTerms;
236  this->SetNthInput(1, m_AtmosphericRadiativeTerms);
237  m_IsSetAtmosphericRadiativeTerms = true;
238  this->Modified();
239  }
240  itkGetObjectMacro(AtmosphericRadiativeTerms, AtmosphericRadiativeTermsType);
242 
245  {
246  m_AtmoCorrectionParameters = atmoCorrTerms;
247  this->SetNthInput(2, m_AtmoCorrectionParameters);
248  m_IsSetAtmoCorrectionParameters = true;
249  this->Modified();
250  }
251  itkGetObjectMacro(AtmoCorrectionParameters, AtmoCorrectionParametersType);
253 
256  {
257  m_AcquiCorrectionParameters = acquiCorrTerms;
258  this->SetNthInput(3, m_AcquiCorrectionParameters);
259  m_IsSetAcquiCorrectionParameters = true;
260  this->Modified();
261  }
262  itkGetObjectMacro(AcquiCorrectionParameters, AcquiCorrectionParametersType);
264 
265 
267  void GenerateParameters();
268 
269 
271  itkSetMacro(IsSetAtmosphericRadiativeTerms, bool);
272  itkGetMacro(IsSetAtmosphericRadiativeTerms, bool);
273  itkBooleanMacro(IsSetAtmosphericRadiativeTerms);
275 
276 protected:
279  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
280 
282  void BeforeThreadedGenerateData() override;
283 
285  void UpdateAtmosphericRadiativeTerms();
286 
288  void UpdateFunctors();
289 
291  void Modified() const override;
292 
293 private:
294 
298 
303 
305  unsigned int m_WindowRadius;
306 
309 
312 
315 
318 };
319 
320 } // end namespace otb
321 
322 #ifndef OTB_MANUAL_INSTANTIATION
324 #endif
325 
326 #endif
itk::Size< Monteverdi_DIMENSION > SizeType
Definition: mvdTypes.h:146
Functor::ComputeNeighborhoodContributionFunctor< itk::ConstNeighborhoodIterator< TInputImage >, typename TOutputImage::PixelType > FunctorType
AcquiCorrectionParametersType::WavelengthSpectralBandVectorType WavelengthSpectralBandVectorType
Implements neighborhood-wise generic operation on image.
This class contains all atmospheric correction parameters.
void SetAtmoCorrectionParameters(AtmoCorrectionParametersPointerType atmoCorrTerms)
This class contains all atmospheric correction parameters.
Correct the scheme taking care of the surrounding pixels.
UnaryFunctorNeighborhoodImageFilter< TInputImage, TOutputImage, FunctorType > Superclass
otb::RadiometryCorrectionParametersToAtmosphericRadiativeTerms CorrectionParametersToRadiativeTermsType
unsigned int Cols() const
std::vector< WavelengthSpectralBandType > ValuesVectorType
void SetUpwardTransmittanceRatio(DoubleContainerType upwardTransmittanceRatio)
Unary neighborhood functor to compute the value of a pixel which is a sum of the surrounding pixels v...
This class is a vector of AtmosphericRadiativeTermsSingleChannel, it contains all atmospheric radiati...
void SetAcquiCorrectionParameters(AcquiCorrectionParametersPointerType acquiCorrTerms)
This class contains the values of the filter function for the processed spectral band.
void SetAtmosphericRadiativeTerms(AtmosphericRadiativeTermsPointerType atmoRadTerms)