OTB  9.0.0
Orfeo Toolbox
otbSurfaceReflectanceToReflectanceFilter.h
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 otbSurfaceReflectanceToReflectanceFilter_h
23 #define otbSurfaceReflectanceToReflectanceFilter_h
24 
25 
27 
29 #include "itkMetaDataDictionary.h"
30 // #include "itkFactory.h"
31 namespace otb
32 {
33 namespace Functor
34 {
44 template <class TInput, class TOutput>
45 class ReflectanceToSurfaceReflectanceImageFunctor
46 {
47 public:
48 
51 
53  {
54  m_Coefficient = 1.;
55  m_Residu = 1.;
56  m_SphericalAlbedo = 1.;
57  };
59 
63  void SetSphericalAlbedo(double albedo)
64  {
65  m_SphericalAlbedo = albedo;
66  };
68  {
69  return m_SphericalAlbedo;
70  };
72 
76  void SetCoefficient(double coef)
77  {
78  m_Coefficient = coef;
79  };
80  double GetCoefficient()
81  {
82  return m_Coefficient;
83  };
85 
89  void SetResidu(double res)
90  {
91  m_Residu = res;
92  };
93  double GetResidu()
94  {
95  return m_Residu;
96  };
98 
99  inline TOutput operator()(const TInput& inPixel)
100  {
101  // std::cout << "m_Coefficient "<< m_Coefficient << std::endl;
102  // std::cout << "m_Residu "<< m_Residu << std::endl;
103 
104  TOutput outPixel;
105  // outPixel.first = inPixel.first;
106  double temp, temp1, temp2;
107  // temp = static_cast<double>(inPixel)*m_Coefficient + m_Residu;
108  // temp2 = temp / (1. + m_SphericalAlbedo * temp);
109 
110  temp = 1. - (static_cast<double>(inPixel) * m_SphericalAlbedo);
111  // temp1 = 1/temp;
112 
113  // std::cout << "------------------------------" << std::endl;
114  // std::cout << "B "<< temp << std::endl;
115  // std::cout << "B*residu "<< temp*m_Residu << std::endl;
116  // std::cout << "m_Coefficient*static_cast<double>(inPixel) "<< m_Coefficient*static_cast<double>(inPixel) << std::endl;
117  // std::cout << "albedo "<< m_SphericalAlbedo << std::endl;
118  // std::cout << "all gaz "<< m_Coefficient << std::endl;
119  // std::cout << "residu "<< m_Residu << std::endl;
120  // std::cout << "temp2 "<< temp2 << std::endl;
121  temp2 = m_Residu;
122  // std::cout << "temp2 "<< temp2 << std::endl;
123  temp1 = 1. / temp;
124  // std::cout << "temp1 "<< temp1 << std::endl;
125  temp2 += temp1 * m_Coefficient * static_cast<double>(inPixel);
126  // std::cout << "1-row*S "<< temp << std::endl;
127  // outPixel = std::fabs (static_cast<TOutput>(temp2));
128  outPixel = static_cast<TOutput>(temp2);
129 
130  // std::cout << "in out "<< static_cast<double>(inPixel) << "; " << static_cast<double>(outPixel)<< std::endl;
131  // std::cout <<"plot " << m_Residu << "+" << m_Coefficient << "*(x/(1-x*" << m_SphericalAlbedo << "))" << std::endl;
132  // std::cout << "------------------------------" << std::endl;
133  return outPixel;
134  }
136  bool operator==(const Self& func) const
137  {
138  return ((m_SphericalAlbedo == func.m_SphericalAlbedo) && (m_Coefficient == func.m_Coefficient) && (m_Residu == func.m_Residu));
139  }
140 
142  bool operator!=(const Self& func) const
143  {
144  return ((m_SphericalAlbedo != func.m_SphericalAlbedo) && (m_Coefficient != func.m_Coefficient) && (m_Residu != func.m_Residu));
145  }
146 
147 private:
148  double m_SphericalAlbedo;
149  double m_Coefficient;
150  double m_Residu;
151 };
152 }
165 template <class TInputImage, class TOutputImage>
168  TInputImage, TOutputImage,
169  typename Functor::ReflectanceToSurfaceReflectanceImageFunctor<typename TInputImage::InternalPixelType, typename TOutputImage::InternalPixelType>>
170 {
171 public:
173  itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
174  itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension);
176 
178  typedef TInputImage InputImageType;
179  typedef TOutputImage OutputImageType;
182 
186  typedef itk::SmartPointer<Self> Pointer;
187  typedef itk::SmartPointer<const Self> ConstPointer;
188 
190  itkNewMacro(Self);
191 
194 
196  typedef typename InputImageType::PixelType InputPixelType;
197  typedef typename InputImageType::InternalPixelType InputInternalPixelType;
198  typedef typename InputImageType::RegionType InputImageRegionType;
199  typedef typename OutputImageType::PixelType OutputPixelType;
200  typedef typename OutputImageType::InternalPixelType OutputInternalPixelType;
201  typedef typename OutputImageType::RegionType OutputImageRegionType;
202 
204 
207 
210 
213 
214 
218 
220 
221  typedef itk::MetaDataDictionary MetaDataDictionaryType;
222 
223 
226  {
227  m_AtmosphericRadiativeTerms = atmoRadTerms;
228  this->SetNthInput(1, m_AtmosphericRadiativeTerms);
229  m_IsSetAtmosphericRadiativeTerms = true;
230  this->Modified();
231  }
232  itkGetObjectMacro(AtmosphericRadiativeTerms, AtmosphericRadiativeTermsType);
234 
237  {
238  m_AtmoCorrectionParameters = atmoCorrTerms;
239  this->SetNthInput(2, m_AtmoCorrectionParameters);
240  m_IsSetAtmoCorrectionParameters = true;
241  this->Modified();
242  }
243  itkGetObjectMacro(AtmoCorrectionParameters, AtmoCorrectionParametersType);
245 
248  {
249  m_AcquiCorrectionParameters = acquiCorrTerms;
250  this->SetNthInput(3, m_AcquiCorrectionParameters);
251  m_IsSetAcquiCorrectionParameters = true;
252  this->Modified();
253  }
255 
256 
258  void GenerateParameters();
259 
261  itkSetMacro(UseGenerateParameters, bool);
262  itkGetMacro(UseGenerateParameters, bool);
264 
266  itkSetMacro(IsSetAtmosphericRadiativeTerms, bool);
267  itkGetMacro(IsSetAtmosphericRadiativeTerms, bool);
269 
270 
271 protected:
274 
277 
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 
305 };
306 
307 } // end namespace otb
308 
309 #ifndef OTB_MANUAL_INSTANTIATION
311 #endif
312 
313 #endif
otb::SurfaceReflectanceToReflectanceFilter::AtmoCorrectionParametersType
otb::AtmosphericCorrectionParameters AtmoCorrectionParametersType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:205
otb::SurfaceReflectanceToReflectanceFilter::FilterFunctionValuesType
otb::FilterFunctionValues FilterFunctionValuesType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:215
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::~ReflectanceToSurfaceReflectanceImageFunctor
virtual ~ReflectanceToSurfaceReflectanceImageFunctor()
Definition: otbSurfaceReflectanceToReflectanceFilter.h:58
otb::AtmosphericRadiativeTerms
This class is a vector of AtmosphericRadiativeTermsSingleChannel, it contains all atmospheric radiati...
Definition: otbAtmosphericRadiativeTerms.h:185
otb::SurfaceReflectanceToReflectanceFilter::OutputImageType
TOutputImage OutputImageType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:179
otb::SurfaceReflectanceToReflectanceFilter::AtmosphericRadiativeTermsPointerType
AtmosphericRadiativeTermsType::Pointer AtmosphericRadiativeTermsPointerType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:212
otb::SurfaceReflectanceToReflectanceFilter::Self
SurfaceReflectanceToReflectanceFilter Self
Definition: otbSurfaceReflectanceToReflectanceFilter.h:184
otb::SurfaceReflectanceToReflectanceFilter::m_UseGenerateParameters
bool m_UseGenerateParameters
Definition: otbSurfaceReflectanceToReflectanceFilter.h:301
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::m_Residu
double m_Residu
Definition: otbReflectanceToSurfaceReflectanceImageFilter.h:118
otb::ImageMetadataCorrectionParameters::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbImageMetadataCorrectionParameters.h:52
otb::RadiometryCorrectionParametersToAtmosphericRadiativeTerms
TODO.
Definition: otbRadiometryCorrectionParametersToAtmosphericRadiativeTerms.h:41
otb::SurfaceReflectanceToReflectanceFilter::m_IsSetAcquiCorrectionParameters
bool m_IsSetAcquiCorrectionParameters
Definition: otbSurfaceReflectanceToReflectanceFilter.h:294
otbRadiometryCorrectionParametersToAtmosphericRadiativeTerms.h
otb::SurfaceReflectanceToReflectanceFilter::m_AtmosphericRadiativeTerms
AtmosphericRadiativeTermsPointerType m_AtmosphericRadiativeTerms
Definition: otbSurfaceReflectanceToReflectanceFilter.h:297
otb::SurfaceReflectanceToReflectanceFilter::MetaDataDictionaryType
itk::MetaDataDictionary MetaDataDictionaryType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:221
otb::SurfaceReflectanceToReflectanceFilter::SetAtmosphericRadiativeTerms
void SetAtmosphericRadiativeTerms(AtmosphericRadiativeTermsPointerType atmoRadTerms)
Definition: otbSurfaceReflectanceToReflectanceFilter.h:225
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor
Compute the surface reflectance pixel from a TOA reflectance.
Definition: otbReflectanceToSurfaceReflectanceImageFilter.h:50
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::Self
ReflectanceToSurfaceReflectanceImageFunctor Self
Definition: otbSurfaceReflectanceToReflectanceFilter.h:50
otb::SurfaceReflectanceToReflectanceFilter::OutputImageRegionType
OutputImageType::RegionType OutputImageRegionType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:201
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::SetCoefficient
void SetCoefficient(double coef)
Definition: otbSurfaceReflectanceToReflectanceFilter.h:76
otb::SurfaceReflectanceToReflectanceFilter::m_IsSetAtmoCorrectionParameters
bool m_IsSetAtmoCorrectionParameters
Definition: otbSurfaceReflectanceToReflectanceFilter.h:293
otb::SurfaceReflectanceToReflectanceFilter::m_AtmoCorrectionParameters
AtmoCorrectionParametersPointerType m_AtmoCorrectionParameters
Definition: otbSurfaceReflectanceToReflectanceFilter.h:298
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::GetResidu
double GetResidu()
Definition: otbSurfaceReflectanceToReflectanceFilter.h:93
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::GetSphericalAlbedo
double GetSphericalAlbedo()
Definition: otbSurfaceReflectanceToReflectanceFilter.h:67
otb::FilterFunctionValues
This class contains the values of the filter function for the processed spectral band.
Definition: otbFilterFunctionValues.h:44
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::SetResidu
void SetResidu(double res)
Definition: otbSurfaceReflectanceToReflectanceFilter.h:89
otb::SurfaceReflectanceToReflectanceFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbSurfaceReflectanceToReflectanceFilter.h:187
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::SetSphericalAlbedo
void SetSphericalAlbedo(double albedo)
Definition: otbSurfaceReflectanceToReflectanceFilter.h:63
otb::UnaryImageFunctorWithVectorImageFilter
Applies a functor to a VectorImage.
Definition: otbUnaryImageFunctorWithVectorImageFilter.h:46
otb::SurfaceReflectanceToReflectanceFilter::ValuesVectorType
FilterFunctionValuesType::ValuesVectorType ValuesVectorType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:217
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::GetCoefficient
double GetCoefficient()
Definition: otbSurfaceReflectanceToReflectanceFilter.h:80
otb::SurfaceReflectanceToReflectanceFilter::m_FunctorParametersHaveBeenComputed
bool m_FunctorParametersHaveBeenComputed
Definition: otbSurfaceReflectanceToReflectanceFilter.h:304
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::operator()
TOutput operator()(const TInput &inPixel)
Definition: otbSurfaceReflectanceToReflectanceFilter.h:99
otb::SurfaceReflectanceToReflectanceFilter
Calculates the slope, the orientation incidence and exitance radius values for each pixel.
Definition: otbSurfaceReflectanceToReflectanceFilter.h:166
otb::SurfaceReflectanceToReflectanceFilter::InputImageRegionType
InputImageType::RegionType InputImageRegionType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:198
otb::SurfaceReflectanceToReflectanceFilter::m_AcquiCorrectionParameters
AcquiCorrectionParametersPointerType m_AcquiCorrectionParameters
Definition: otbSurfaceReflectanceToReflectanceFilter.h:299
otb::SurfaceReflectanceToReflectanceFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbSurfaceReflectanceToReflectanceFilter.h:186
otb::FilterFunctionValues::WavelengthSpectralBandType
float WavelengthSpectralBandType
Definition: otbFilterFunctionValues.h:57
otb::SurfaceReflectanceToReflectanceFilter::InputPixelType
InputImageType::PixelType InputPixelType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:193
otb::SurfaceReflectanceToReflectanceFilter::WavelengthSpectralBandVectorType
AcquiCorrectionParametersType::WavelengthSpectralBandVectorType WavelengthSpectralBandVectorType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:219
otb::SurfaceReflectanceToReflectanceFilter::~SurfaceReflectanceToReflectanceFilter
~SurfaceReflectanceToReflectanceFilter() override
Definition: otbSurfaceReflectanceToReflectanceFilter.h:276
otb::SurfaceReflectanceToReflectanceFilter::m_IsSetAtmosphericRadiativeTerms
bool m_IsSetAtmosphericRadiativeTerms
Definition: otbSurfaceReflectanceToReflectanceFilter.h:292
otb::SurfaceReflectanceToReflectanceFilter::AcquiCorrectionParametersType
otb::ImageMetadataCorrectionParameters AcquiCorrectionParametersType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:208
otb::AtmosphericRadiativeTerms::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbAtmosphericRadiativeTerms.h:191
otb::SurfaceReflectanceToReflectanceFilter::OutputPixelType
OutputImageType::PixelType OutputPixelType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:199
otb::SurfaceReflectanceToReflectanceFilter::SetAcquiCorrectionParameters
void SetAcquiCorrectionParameters(AcquiCorrectionParametersPointerType acquiCorrTerms)
Definition: otbSurfaceReflectanceToReflectanceFilter.h:247
otb::SurfaceReflectanceToReflectanceFilter::ValueType
FilterFunctionValuesType::WavelengthSpectralBandType ValueType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:216
otb::AtmosphericCorrectionParameters::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbAtmosphericCorrectionParameters.h:52
otb::SurfaceReflectanceToReflectanceFilter::FunctorType
Functor::ReflectanceToSurfaceReflectanceImageFunctor< typename InputImageType::InternalPixelType, typename OutputImageType::InternalPixelType > FunctorType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:181
otbUnaryImageFunctorWithVectorImageFilter.h
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::ReflectanceToSurfaceReflectanceImageFunctor
ReflectanceToSurfaceReflectanceImageFunctor()
Definition: otbSurfaceReflectanceToReflectanceFilter.h:52
otb::ImageMetadataCorrectionParameters
This class contains all atmospheric correction parameters.
Definition: otbImageMetadataCorrectionParameters.h:46
otb::ImageMetadataCorrectionParameters::WavelengthSpectralBandVectorType
InternalWavelengthSpectralBandVectorType::Pointer WavelengthSpectralBandVectorType
Definition: otbImageMetadataCorrectionParameters.h:62
otbSurfaceReflectanceToReflectanceFilter.hxx
otb::SurfaceReflectanceToReflectanceFilter::OutputInternalPixelType
OutputImageType::InternalPixelType OutputInternalPixelType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:200
otb::SurfaceReflectanceToReflectanceFilter::Superclass
UnaryImageFunctorWithVectorImageFilter< InputImageType, OutputImageType, FunctorType > Superclass
Definition: otbSurfaceReflectanceToReflectanceFilter.h:185
otb::SurfaceReflectanceToReflectanceFilter::SetAtmoCorrectionParameters
void SetAtmoCorrectionParameters(AtmoCorrectionParametersPointerType atmoCorrTerms)
Definition: otbSurfaceReflectanceToReflectanceFilter.h:236
otb::SurfaceReflectanceToReflectanceFilter::AcquiCorrectionParametersPointerType
AcquiCorrectionParametersType::Pointer AcquiCorrectionParametersPointerType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:209
otb::AtmosphericCorrectionParameters
This class contains all atmospheric correction parameters.
Definition: otbAtmosphericCorrectionParameters.h:46
otb::SurfaceReflectanceToReflectanceFilter::InputInternalPixelType
InputImageType::InternalPixelType InputInternalPixelType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:197
otb::SurfaceReflectanceToReflectanceFilter::AtmosphericRadiativeTermsType
otb::AtmosphericRadiativeTerms AtmosphericRadiativeTermsType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:211
otb::SurfaceReflectanceToReflectanceFilter::InputImageType
TInputImage InputImageType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:178
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::m_SphericalAlbedo
double m_SphericalAlbedo
Definition: otbReflectanceToSurfaceReflectanceImageFilter.h:116
otb::SurfaceReflectanceToReflectanceFilter::CorrectionParametersToRadiativeTermsType
otb::RadiometryCorrectionParametersToAtmosphericRadiativeTerms CorrectionParametersToRadiativeTermsType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:203
otb::SurfaceReflectanceToReflectanceFilter::AtmoCorrectionParametersPointerType
AtmoCorrectionParametersType::Pointer AtmoCorrectionParametersPointerType
Definition: otbSurfaceReflectanceToReflectanceFilter.h:206
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::m_Coefficient
double m_Coefficient
Definition: otbReflectanceToSurfaceReflectanceImageFilter.h:117
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::operator!=
bool operator!=(const Self &func) const
Definition: otbSurfaceReflectanceToReflectanceFilter.h:142
otb::FilterFunctionValues::ValuesVectorType
std::vector< WavelengthSpectralBandType > ValuesVectorType
Definition: otbFilterFunctionValues.h:60
otb::Functor::ReflectanceToSurfaceReflectanceImageFunctor::operator==
bool operator==(const Self &func) const
Definition: otbSurfaceReflectanceToReflectanceFilter.h:136