22 #ifndef otbImageToReflectanceImageFilter_h
23 #define otbImageToReflectanceImageFilter_h
45 template <
class TInput,
class TOutput>
137 template <
class TInputImage,
class TOutputImage>
140 TInputImage, TOutputImage,
141 typename Functor::ImageToReflectanceImageFunctor<typename TInputImage::InternalPixelType, typename TOutputImage::InternalPixelType>>
145 itkStaticConstMacro(InputImageDimension,
unsigned int, TInputImage::ImageDimension);
146 itkStaticConstMacro(OutputImageDimension,
unsigned int, TOutputImage::ImageDimension);
174 typedef typename itk::VariableLengthVector<double>
VectorType;
177 typedef typename InputImageType::SizeType
SizeType;
195 itkGetConstReferenceMacro(SolarIllumination,
VectorType);
198 itkSetMacro(ZenithalSolarAngle,
double);
201 itkGetConstReferenceMacro(ZenithalSolarAngle,
double);
204 itkSetMacro(UseClamp,
bool);
207 itkGetConstReferenceMacro(UseClamp,
bool);
212 double zenithalAngle = 90.0 - elevationAngle;
213 if (this->m_ZenithalSolarAngle != zenithalAngle)
215 this->m_ZenithalSolarAngle = zenithalAngle;
223 return 90.0 - this->m_ZenithalSolarAngle;
229 m_FluxNormalizationCoefficient = coef;
230 m_IsSetFluxNormalizationCoefficient =
true;
238 m_SolarDistance = value;
239 m_IsSetSolarDistance =
true;
244 itkGetConstReferenceMacro(SolarDistance,
double);
247 itkSetMacro(IsSetSolarDistance,
bool);
250 itkGetConstReferenceMacro(IsSetSolarDistance,
bool);
253 itkSetClampMacro(Day,
int, 1, 31);
256 itkGetConstReferenceMacro(Day,
int);
259 itkSetClampMacro(Month,
int, 1, 12);
262 itkGetConstReferenceMacro(Month,
int);
267 : m_ZenithalSolarAngle(120.),
268 m_FluxNormalizationCoefficient(1.),
270 m_IsSetFluxNormalizationCoefficient(false),
273 m_SolarDistance(1.0),
274 m_IsSetSolarDistance(false)
278 m_SolarIllumination.SetSize(0);
290 const auto & metadata = this->GetInput()->GetImageMetadata();
302 if (m_Day == 0 && (!m_IsSetFluxNormalizationCoefficient) && (!m_IsSetSolarDistance)
308 if (m_Month == 0 && (!m_IsSetFluxNormalizationCoefficient) && (!m_IsSetSolarDistance)
333 if ((m_Alpha.GetSize() != this->GetInput()->GetNumberOfComponentsPerPixel()) || (m_Beta.GetSize() != this->GetInput()->GetNumberOfComponentsPerPixel()) ||
334 (m_SolarIllumination.GetSize() != this->GetInput()->GetNumberOfComponentsPerPixel()))
336 itkExceptionMacro(<<
"Alpha, Beta and SolarIllumination parameters should have the same size as the number of bands");
339 this->GetFunctorVector().clear();
340 for (
unsigned int i = 0; i < this->GetInput()->GetNumberOfComponentsPerPixel(); ++i)
343 double coefTemp = 0.;
345 if (m_IsSetFluxNormalizationCoefficient)
347 coefTemp = std::cos(m_ZenithalSolarAngle *
CONST_PI_180) * m_FluxNormalizationCoefficient * m_FluxNormalizationCoefficient;
349 else if (m_IsSetSolarDistance)
351 coefTemp = std::cos(m_ZenithalSolarAngle *
CONST_PI_180) / (m_SolarDistance * m_SolarDistance);
353 else if (m_Day * m_Month != 0 && m_Day < 32 && m_Month < 13)
359 itkExceptionMacro(<<
"Day has to be included between 1 and 31, Month between 1 and 12.");
367 this->GetFunctorVector().push_back(functor);