Orfeo Toolbox  4.0
otbSurfaceAdjacencyEffect6SCorrectionSchemeFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  Some parts of this code are derived from ITK. See ITKCopyright.txt
14  for details.
15 
16 
17  This software is distributed WITHOUT ANY WARRANTY; without even
18  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19  PURPOSE. See the above copyright notices for more information.
20 
21 =========================================================================*/
22 #ifndef __otbSurfaceAdjacencyEffect6SCorrectionSchemeFilter_h
23 #define __otbSurfaceAdjacencyEffect6SCorrectionSchemeFilter_h
24 
25 #include "itkNumericTraits.h"
26 #include <vector>
29 #include "itkVariableSizeMatrix.h"
32 #include <iomanip>
33 
34 namespace otb
35 {
36 namespace Functor
37 {
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  std::ostringstream oss;
89  oss << std::fixed << std::setprecision(3);
90 
91  // Loop over each component
92  const unsigned int size = outPixel.GetSize();
93  for (unsigned int j = 0; j < size; ++j)
94  {
95  oss.str("");
96  contribution = 0;
97  // Load the current channel ponderation value matrix
98  WeightingMatrixType TempChannelWeighting = m_WeightingValues[j];
99  // Loop over the neighborhood
100  for (unsigned int i = 0; i < neighborhoodSize; ++i)
101  {
102  // Current neighborhood pixel index calculation
103  unsigned int RowIdx = 0;
104  unsigned int ColIdx = 0;
105  RowIdx = i / TempChannelWeighting.Cols();
106  if (RowIdx != 0)
107  {
108  ColIdx = (i + 1) - RowIdx*TempChannelWeighting.Cols() - 1;
109  }
110  else
111  {
112  ColIdx = i;
113  }
114  // Extract the current neighborhood pixel ponderation
115  double idVal = TempChannelWeighting(RowIdx, ColIdx);
116  // Extract the current neighborhood pixel value
117  TOutput tempPix = it.GetPixel(i);
118 
119  contribution += static_cast<double>(tempPix[j]) * idVal;
120 
121  }
122  double temp = static_cast<double>(it.GetCenterPixel()[j]) * m_UpwardTransmittanceRatio[j] + contribution *
123  m_DiffuseRatio[j];
124  oss << temp;
125  outPixel[j] = static_cast<RealValueType>(atof(oss.str().c_str()));
126 
127  //outPixel[j] = static_cast<RealValueType>(it.GetCenterPixel()[j])*m_UpwardTransmittanceRatio[j] + contribution*m_DiffuseRatio[j];
128  }
129  return outPixel;
130  }
131 
132 private:
136 };
137 
138 }
139 
150 template <class TInputImage, class TOutputImage>
152  public UnaryFunctorNeighborhoodImageFilter<TInputImage,
153  TOutputImage,
154  typename Functor::ComputeNeighborhoodContributionFunctor<itk::
155  ConstNeighborhoodIterator
156  <TInputImage>,
157  typename
158  TOutputImage
159  ::PixelType> >
160 {
161 public:
164  typename TOutputImage::PixelType> FunctorType;
165 
171 
174 
175  typedef std::vector<double> DoubleContainerType;
177  itkNewMacro(Self);
178 
181 
183  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
184  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
185 
187  typedef typename InputImageType::PixelType InputPixelType;
188  typedef typename InputImageType::InternalPixelType InputInternalPixelType;
189  typedef typename InputImageType::RegionType InputImageRegionType;
190  typedef typename InputImageType::SizeType SizeType;
191  typedef typename OutputImageType::PixelType OutputPixelType;
192  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
193  typedef typename OutputImageType::RegionType OutputImageRegionType;
194 
200 
203  typedef std::vector<CoefVectorType> FilterFunctionCoefVectorType;
204 
206 
209  typedef typename std::vector<WeightingMatrixType> WeightingValuesContainerType;
210 
213 
215  void SetWindowRadius(unsigned int rad)
216  {
217  this->SetRadius(rad);
218  m_WindowRadius = rad;
219  this->Modified();
220  }
221  itkGetConstReferenceMacro(WindowRadius, unsigned int);
222 
224  itkSetMacro(PixelSpacingInKilometers, double);
225  itkGetMacro(PixelSpacingInKilometers, double);
227  itkSetMacro(ZenithalViewingAngle, double);
228  itkGetMacro(ZenithalViewingAngle, double);
229 
231  void SetAtmosphericRadiativeTerms(AtmosphericRadiativeTermsPointerType atmo)
232  {
233  m_AtmosphericRadiativeTerms = atmo;
234  this->SetNthInput(1, m_AtmosphericRadiativeTerms);
235  m_IsSetAtmosphericRadiativeTerms = true;
236  this->Modified();
237  }
239 
241  itkSetObjectMacro(CorrectionParameters, AtmosphericCorrectionParameters);
242  itkGetObjectMacro(CorrectionParameters, AtmosphericCorrectionParameters);
243 
245  itkSetMacro(AeronetFileName, std::string);
246  itkGetMacro(AeronetFileName, std::string);
247 
249  itkSetMacro(FilterFunctionValuesFileName, std::string);
250  itkGetMacro(FilterFunctionValuesFileName, std::string);
251 
253  void SetFilterFunctionCoef(FilterFunctionCoefVectorType vect)
254  {
255  m_FilterFunctionCoef = vect;
256  this->Modified();
257  }
258  FilterFunctionCoefVectorType GetFilterFunctionCoef()
259  {
260  return m_FilterFunctionCoef;
261  }
262 
264  void ComputeParameters();
266  void GenerateParameters();
268  void UpdateAtmosphericRadiativeTerms();
269 
270 protected:
273  void PrintSelf(std::ostream& os, itk::Indent indent) const;
274 
276  virtual void GenerateOutputInformation();
277 
279  //virtual void BeforeThreadedGenerateData();
280 
282  virtual void Modified();
283 
284 private:
286  unsigned int m_WindowRadius;
301  std::string m_AeronetFileName;
310 };
311 
312 } // end namespace otb
313 
314 #ifndef OTB_MANUAL_INSTANTIATION
316 #endif
317 
318 #endif

Generated at Sat Mar 8 2014 16:21:36 for Orfeo Toolbox with doxygen 1.8.3.1