Skip to content
Snippets Groups Projects
Commit 12fa0395 authored by Manuel Grizonnet's avatar Manuel Grizonnet
Browse files

BUG:in case where no relative spectral is available use constant values(1) between 0.3 and 1

parent 2457c454
No related branches found
No related tags found
No related merge requests found
......@@ -170,6 +170,10 @@ public:
typedef FilterFunctionValuesType::ValuesVectorType CoefVectorType;
typedef std::vector<CoefVectorType> FilterFunctionCoefVectorType;
typedef ObjectList<FilterFunctionValues> InternalWavelengthSpectralBandVectorType;
typedef InternalWavelengthSpectralBandVectorType::Pointer WavelengthSpectralBandVectorType;
typedef itk::MetaDataDictionary MetaDataDictionaryType;
/** Get/Set Atmospheric Radiative Terms. */
......@@ -195,12 +199,12 @@ public:
itkGetMacro(FilterFunctionValuesFileName, std::string);
/** Get/Set Filter function coef. */
void SetFilterFunctionCoef(FilterFunctionCoefVectorType vect)
void SetFilterFunctionCoef(WavelengthSpectralBandVectorType vect)
{
m_FilterFunctionCoef = vect;
this->Modified();
}
FilterFunctionCoefVectorType GetFilterFunctionCoef() const
WavelengthSpectralBandVectorType GetFilterFunctionCoef() const
{
return m_FilterFunctionCoef;
}
......@@ -245,7 +249,7 @@ private:
/** Path to an filter function values file. */
std::string m_FilterFunctionValuesFileName;
/** Contains the filter function values (each element is a vector and represents the values for each channel) */
FilterFunctionCoefVectorType m_FilterFunctionCoef;
WavelengthSpectralBandVectorType m_FilterFunctionCoef;
/** Enable/Disable GenerateParameters in GenerateOutputInformation.
* Useful for image view that call GenerateOutputInformation each time you move the full area.
*/
......
......@@ -31,21 +31,22 @@ namespace otb
template <class TInputImage, class TOutputImage>
ReflectanceToSurfaceReflectanceImageFilter<TInputImage, TOutputImage>
::ReflectanceToSurfaceReflectanceImageFilter() :
m_IsSetAtmosphericRadiativeTerms(false),
m_AeronetFileName(""),
m_FilterFunctionValuesFileName(""),
m_UseGenerateParameters(true)
{
m_IsSetAtmosphericRadiativeTerms(false),
m_AeronetFileName(""),
m_FilterFunctionValuesFileName(""),
m_UseGenerateParameters(true)
{
m_AtmosphericRadiativeTerms = AtmosphericRadiativeTerms::New();
m_CorrectionParameters = AtmosphericCorrectionParameters::New();
m_FilterFunctionCoef.clear();
}
m_FilterFunctionCoef = InternalWavelengthSpectralBandVectorType::New();
m_FilterFunctionCoef->Clear();
}
template <class TInputImage, class TOutputImage>
void
ReflectanceToSurfaceReflectanceImageFilter<TInputImage, TOutputImage>
::UpdateAtmosphericRadiativeTerms()
{
{
if (this->GetInput() == NULL)
{
itkExceptionMacro(<< "Input must be set before updating the atmospheric radiative terms");
......@@ -95,68 +96,52 @@ ReflectanceToSurfaceReflectanceImageFilter<TInputImage, TOutputImage>
{
m_CorrectionParameters->LoadFilterFunctionValue(m_FilterFunctionValuesFileName);
}
// the user has set the filter function values
else if (m_CorrectionParameters->GetWavelengthSpectralBand()->Size() !=
this->GetInput()->GetNumberOfComponentsPerPixel())
//case where filter function values are not read from an ascii file
else
{
bool ffvfOK = true;
if (m_FilterFunctionCoef.size() == 0) ffvfOK = false;
else if (m_FilterFunctionCoef.size() != this->GetInput()->GetNumberOfComponentsPerPixel())
itkExceptionMacro(
<< "Function Values and Input image size mismatch");
for (unsigned int i = 0; i < this->GetInput()->GetNumberOfComponentsPerPixel(); i++)
if (m_FilterFunctionCoef->Size() == 0)
{
FilterFunctionValuesType::Pointer functionValues = FilterFunctionValuesType::New();
if (ffvfOK)
std::cout << "use dummy filter" << std::endl;
for (unsigned int i = 0; i < this->GetInput()->GetNumberOfComponentsPerPixel(); ++i)
{
functionValues->SetFilterFunctionValues(m_FilterFunctionCoef[i]);
}
else // if no ffvf set, compute the step to be sure that the valueswavelength are between min and max and 1 as coef
{
functionValues->SetMinSpectralValue(imageMetadataInterface->GetFirstWavelengths()[i]);
functionValues->SetMaxSpectralValue(imageMetadataInterface->GetLastWavelengths()[i]);
//By default the function values size is 3, set the step to feet with min and max spectral value
functionValues->SetUserStep((functionValues->GetMaxSpectralValue() - functionValues->GetMinSpectralValue()) / 2.);
m_FilterFunctionCoef->PushBack(FilterFunctionValues::New());
}
m_CorrectionParameters->SetWavelengthSpectralBandWithIndex(i, functionValues);
}
m_CorrectionParameters->SetWavelengthSpectralBand(m_FilterFunctionCoef);
Parameters2RadiativeTermsPointerType param2Terms = Parameters2RadiativeTermsType::New();
param2Terms->SetInput(m_CorrectionParameters);
param2Terms->Update();
m_AtmosphericRadiativeTerms = param2Terms->GetOutput();
}
Parameters2RadiativeTermsPointerType param2Terms = Parameters2RadiativeTermsType::New();
param2Terms->SetInput(m_CorrectionParameters);
param2Terms->Update();
m_AtmosphericRadiativeTerms = param2Terms->GetOutput();
}
}
template <class TInputImage, class TOutputImage>
void
ReflectanceToSurfaceReflectanceImageFilter<TInputImage, TOutputImage>
::GenerateOutputInformation()
{
{
Superclass::GenerateOutputInformation();
if (m_UseGenerateParameters) this->GenerateParameters();
}
}
template <class TInputImage, class TOutputImage>
void
ReflectanceToSurfaceReflectanceImageFilter<TInputImage, TOutputImage>
::GenerateAtmosphericRadiativeTerms()
{
Parameters2RadiativeTermsPointerType param2Terms = Parameters2RadiativeTermsType::New();
param2Terms->SetInput(m_CorrectionParameters);
param2Terms->Update();
m_AtmosphericRadiativeTerms = param2Terms->GetOutput();
}
{
Parameters2RadiativeTermsPointerType param2Terms = Parameters2RadiativeTermsType::New();
param2Terms->SetInput(m_CorrectionParameters);
param2Terms->Update();
m_AtmosphericRadiativeTerms = param2Terms->GetOutput();
}
template <class TInputImage, class TOutputImage>
void
ReflectanceToSurfaceReflectanceImageFilter<TInputImage, TOutputImage>
::UpdateFunctors()
{
{
if (this->GetInput() == NULL)
{
itkExceptionMacro(<< "Input must be set before updating the functors");
......@@ -184,13 +169,13 @@ ReflectanceToSurfaceReflectanceImageFilter<TInputImage, TOutputImage>
this->GetFunctorVector().push_back(functor);
}
}
}
template <class TInputImage, class TOutputImage>
void
ReflectanceToSurfaceReflectanceImageFilter<TInputImage, TOutputImage>
::GenerateParameters()
{
{
if (!m_IsSetAtmosphericRadiativeTerms)
{
this->UpdateAtmosphericRadiativeTerms();
......@@ -198,7 +183,7 @@ ReflectanceToSurfaceReflectanceImageFilter<TInputImage, TOutputImage>
}
this->UpdateFunctors();
}
}
}
......
......@@ -26,10 +26,10 @@ namespace otb
FilterFunctionValues
::FilterFunctionValues()
{
m_MinSpectralValue = 0;
m_MinSpectralValue = 0.3;
m_MaxSpectralValue = 1;
// Fill with 1. Size 3 for 6S interpolation
m_FilterFunctionValues = ValuesVectorType(3, 1.);
m_FilterFunctionValues = ValuesVectorType(280, 1.);
m_UserStep = 0.0025;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment