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;
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);
Add beta to the quotient Input over alpha.
void SetBeta(double beta)
void SetAlpha(double alpha)
Call the ImageToRadianceFunctor over the input and the RadianceToReflectanceFunctor to this result.
Functor::ImageToRadianceImageFunctor< TInput, TOutput > ImToLumFunctorType
ImToLumFunctorType m_ImToLumFunctor
Functor::RadianceToReflectanceImageFunctor< TInput, TOutput > LumToReflecFunctorType
void SetSolarIllumination(double solarIllumination)
TOutput operator()(const TInput &inPixel) const
double GetSolarIllumination()
LumToReflecFunctorType m_LumToReflecFunctor
double GetIlluminationCorrectionCoefficient()
ImageToReflectanceImageFunctor()
virtual ~ImageToReflectanceImageFunctor()
void SetUseClamp(bool useClamp)
void SetIlluminationCorrectionCoefficient(double coef)
void SetAlpha(double alpha)
void SetBeta(double beta)
Compute reflectance from the radiance value.
double GetSolarIllumination()
double GetIlluminationCorrectionCoefficient()
void SetUseClamp(bool useClamp)
void SetSolarIllumination(double solarIllumination)
void SetIlluminationCorrectionCoefficient(double coef)
Convert a raw value into a reflectance value.
UnaryImageFunctorWithVectorImageFilter< InputImageType, OutputImageType, FunctorType > Superclass
~ImageToReflectanceImageFilter() override
void BeforeThreadedGenerateData(void) override
bool m_IsSetSolarDistance
Functor::ImageToReflectanceImageFunctor< typename InputImageType::InternalPixelType, typename OutputImageType::InternalPixelType > FunctorType
InputImageType::RegionType InputImageRegionType
TOutputImage OutputImageType
ImageToReflectanceImageFilter Self
virtual double GetElevationSolarAngle() const
itk::VariableLengthVector< double > VectorType
bool m_IsSetFluxNormalizationCoefficient
OutputImageType::InternalPixelType OutputInternalPixelType
virtual void SetElevationSolarAngle(double elevationAngle)
InputImageType::InternalPixelType InputInternalPixelType
double m_FluxNormalizationCoefficient
OutputImageType::RegionType OutputImageRegionType
InputImageType::PixelType InputPixelType
VectorType m_SolarIllumination
OutputImageType::PixelType OutputPixelType
ImageToReflectanceImageFilter()
itk::SmartPointer< Self > Pointer
TInputImage InputImageType
InputImageType::SizeType SizeType
void SetSolarDistance(double value)
itk::SmartPointer< const Self > ConstPointer
double m_ZenithalSolarAngle
void SetFluxNormalizationCoefficient(double coef)
Applies a functor to a VectorImage.
static double GetVarSol(const int day, const int month)
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
constexpr double CONST_PI_180
#define otbMsgDevMacro(x)