22 #ifndef otbRadianceToReflectanceImageFilter_h
23 #define otbRadianceToReflectanceImageFilter_h
50 template <
class TInput,
class TOutput>
96 temp = std::max(temp, 0.);
97 temp = std::min(temp, 1.);
99 outPixel =
static_cast<TOutput
>(temp);
128 template <
class TInputImage,
class TOutputImage>
131 TInputImage, TOutputImage,
132 typename Functor::RadianceToReflectanceImageFunctor<typename TInputImage::InternalPixelType, typename TOutputImage::InternalPixelType>>
136 itkStaticConstMacro(InputImageDimension,
unsigned int, TInputImage::ImageDimension);
137 itkStaticConstMacro(OutputImageDimension,
unsigned int, TOutputImage::ImageDimension);
166 typedef typename itk::VariableLengthVector<double>
VectorType;
169 typedef typename InputImageType::SizeType
SizeType;
175 itkGetConstReferenceMacro(SolarIllumination,
VectorType);
178 itkSetMacro(ZenithalSolarAngle,
double);
181 itkGetConstReferenceMacro(ZenithalSolarAngle,
double);
186 double zenithalAngle = 90.0 - elevationAngle;
187 if (this->m_ZenithalSolarAngle != zenithalAngle)
189 this->m_ZenithalSolarAngle = zenithalAngle;
197 return 90.0 - this->m_ZenithalSolarAngle;
201 itkSetClampMacro(Day,
int, 1, 31);
204 itkGetConstReferenceMacro(Day,
int);
207 itkSetClampMacro(Month,
int, 1, 12);
210 itkGetConstReferenceMacro(Month,
int);
215 m_FluxNormalizationCoefficient = coef;
216 m_IsSetFluxNormalizationCoefficient =
true;
221 itkGetConstReferenceMacro(FluxNormalizationCoefficient,
double);
226 m_SolarDistance = value;
227 m_IsSetSolarDistance =
true;
232 itkGetConstReferenceMacro(SolarDistance,
double);
235 itkSetMacro(IsSetSolarDistance,
bool);
238 itkGetConstReferenceMacro(IsSetSolarDistance,
bool);
241 itkSetMacro(IsSetFluxNormalizationCoefficient,
bool);
244 itkGetConstReferenceMacro(IsSetFluxNormalizationCoefficient,
bool);
247 itkSetMacro(UseClamp,
bool);
250 itkGetConstReferenceMacro(UseClamp,
bool);
255 : m_ZenithalSolarAngle(120.0),
256 m_FluxNormalizationCoefficient(1.),
259 m_SolarDistance(1.0),
260 m_IsSetFluxNormalizationCoefficient(false),
261 m_IsSetSolarDistance(false),
264 m_SolarIllumination.SetSize(0);
276 const auto & metadata = this->GetInput()->GetImageMetadata();
278 if (m_Day == 0 && (!m_IsSetFluxNormalizationCoefficient) && (!m_IsSetSolarDistance)
284 if (m_Month == 0 && (!m_IsSetFluxNormalizationCoefficient) && (!m_IsSetSolarDistance)
307 if ((m_SolarIllumination.GetSize() != this->GetInput()->GetNumberOfComponentsPerPixel()))
309 itkExceptionMacro(<<
"SolarIllumination parameter should have the same size as the number of bands");
312 this->GetFunctorVector().clear();
314 for (
unsigned int i = 0; i < this->GetInput()->GetNumberOfComponentsPerPixel(); ++i)
317 double coefTemp = 0.;
318 if (m_IsSetFluxNormalizationCoefficient)
320 coefTemp = std::cos(m_ZenithalSolarAngle *
CONST_PI_180) * m_FluxNormalizationCoefficient * m_FluxNormalizationCoefficient;
322 else if (m_IsSetSolarDistance)
324 coefTemp = std::cos(m_ZenithalSolarAngle *
CONST_PI_180) / (m_SolarDistance * m_SolarDistance);
326 else if (m_Day * m_Month != 0 && m_Day < 32 && m_Month < 13)
332 itkExceptionMacro(<<
"Day has to be included between 1 and 31, Month between 1 and 12.");
339 this->GetFunctorVector().push_back(functor);