21 #ifndef otbSurfaceReflectanceToReflectanceFilter_hxx
22 #define otbSurfaceReflectanceToReflectanceFilter_hxx
32 template <
class TInputImage,
class TOutputImage>
34 : m_IsSetAtmosphericRadiativeTerms(false), m_IsSetAtmoCorrectionParameters(false), m_IsSetAcquiCorrectionParameters(false), m_UseGenerateParameters(true)
43 template <
class TInputImage,
class TOutputImage>
46 if (this->GetInput() ==
nullptr)
48 itkExceptionMacro(<<
"Input must be set before updating the atmospheric radiative terms");
52 if (!m_IsSetAtmoCorrectionParameters)
54 itkExceptionMacro(<<
"Atmospheric correction parameters must be provided before updating the atmospheric radiative terms");
58 if (!m_IsSetAcquiCorrectionParameters)
60 const auto & metadata = this->GetInput()->GetImageMetadata();
62 m_AcquiCorrectionParameters = AcquiCorrectionParametersType::New();
67 m_AcquiCorrectionParameters->SetViewingAzimutalAngle(metadata[
MDNum::SatAzimuth]);
75 auto spectralSensitivity = AcquiCorrectionParametersType::InternalWavelengthSpectralBandVectorType::New();
76 for (
const auto & band : metadata.Bands)
79 const auto & axis = spectralSensitivityLUT.Axis[0];
82 std::vector<float> vec(spectralSensitivityLUT.Array.begin(), spectralSensitivityLUT.Array.end());
83 filterFunction->SetFilterFunctionValues(vec);
84 filterFunction->SetMinSpectralValue(axis.Origin);
85 filterFunction->SetMaxSpectralValue(axis.Origin + axis.Spacing * (axis.Size-1));
86 filterFunction->SetUserStep(axis.Spacing);
87 spectralSensitivity->PushBack(filterFunction);
90 m_AcquiCorrectionParameters->SetWavelengthSpectralBand(spectralSensitivity);
96 spectralDummy->Clear();
97 for (
unsigned int i = 0; i < this->GetInput()->GetNumberOfComponentsPerPixel(); ++i)
99 spectralDummy->PushBack(FilterFunctionValuesType::New());
101 m_AcquiCorrectionParameters->SetWavelengthSpectralBand(spectralDummy);
106 m_AtmosphericRadiativeTerms = CorrectionParametersToRadiativeTermsType::Compute(m_AtmoCorrectionParameters, m_AcquiCorrectionParameters);
110 template <
class TInputImage,
class TOutputImage>
113 Superclass::BeforeThreadedGenerateData();
114 if (m_UseGenerateParameters)
115 this->GenerateParameters();
118 template <
class TInputImage,
class TOutputImage>
121 Superclass::Modified();
122 m_FunctorParametersHaveBeenComputed =
false;
125 template <
class TInputImage,
class TOutputImage>
131 for (
unsigned int i = 0; i < m_AtmosphericRadiativeTerms->GetWavelengthSpectralBand().size(); ++i)
135 coef =
static_cast<double>(m_AtmosphericRadiativeTerms->GetTotalGaseousTransmission(i) * m_AtmosphericRadiativeTerms->GetDownwardTransmittance(i) *
136 m_AtmosphericRadiativeTerms->GetUpwardTransmittance(i));
139 res = m_AtmosphericRadiativeTerms->GetIntrinsicAtmosphericReflectance(i);
143 functor.
SetSphericalAlbedo(
static_cast<double>(m_AtmosphericRadiativeTerms->GetSphericalAlbedo(i)));
145 this->GetFunctorVector().push_back(functor);
151 template <
class TInputImage,
class TOutputImage>
155 if (!m_IsSetAtmosphericRadiativeTerms)
157 this->UpdateAtmosphericRadiativeTerms();
158 m_IsSetAtmosphericRadiativeTerms =
true;
161 if (!m_FunctorParametersHaveBeenComputed)
163 this->UpdateFunctors();
164 m_FunctorParametersHaveBeenComputed =
true;