Commit 343dcabc authored by remi cresson's avatar remi cresson
Browse files

ENH: rainfall time series interpolator (spatial) can be nn/lin

parent 62196f0f
......@@ -40,6 +40,7 @@
// Resample
#include "otbStreamingResampleImageFilter.h"
#include "itkLinearInterpolateImageFunction.h"
#include "itkNearestNeighborInterpolateImageFunction.h"
// Dates
#include "otbDates.h"
......@@ -103,6 +104,7 @@ public:
typedef otb::StreamingResampleImageFilter<FloatVectorImageType,
FloatVectorImageType> ResampleImageFilterType;
typedef itk::LinearInterpolateImageFunction<FloatVectorImageType> LinearInterpolatorType;
typedef itk::NearestNeighborInterpolateImageFunction<FloatVectorImageType> NNInterpolatorType;
/* typedefs for residues processing */
typedef otb::functor::RainfallEstimatedNDVIResiduesFunctor<FloatVectorImageType::PixelType,
......@@ -232,6 +234,12 @@ private:
SetDefaultParameterInt ("rain.reduce.cumul.nbdays", 150); // 150 days ~ 5 months
MandatoryOff ("rain.reduce.cumul.nbdays");
// Method to resample rainfall time series
AddParameter(ParameterType_Choice, "rain.interpolator", "Interpolation");
MandatoryOff("rain.interpolator");
AddChoice("rain.interpolator.linear", "Linear interpolation");
AddChoice("rain.interpolator.nn", "Nearest Neighbor interpolation");
// Output residues
AddParameter(ParameterType_OutputImage, "residues", "Output image for NDVI residues");
SetDefaultOutputPixelType("residues", ImagePixelType_float);
......@@ -474,12 +482,24 @@ private:
// Resample rainfall
LinearInterpolatorType::Pointer linInterpolator = LinearInterpolatorType::New();
NNInterpolatorType::Pointer nnInterpolator = NNInterpolatorType::New();
m_ResampleFilter = ResampleImageFilterType::New();
m_ResampleFilter->SetInput(m_RFCumulReduceFilter->GetOutput());
m_ResampleFilter->SetOutputOrigin(m_NDVIConcatener->GetOutput()->GetOrigin());
m_ResampleFilter->SetOutputSpacing(m_NDVIConcatener->GetOutput()->GetSignedSpacing());
m_ResampleFilter->SetOutputSize(m_NDVIConcatener->GetOutput()->GetLargestPossibleRegion().GetSize());
m_ResampleFilter->SetInterpolator(linInterpolator);
if (HasValue("rain.interpolator") == 0)
{
m_ResampleFilter->SetInterpolator(linInterpolator);
}
else if (HasValue("rain.interpolator") == 1)
{
m_ResampleFilter->SetInterpolator(nnInterpolator);
}
else
{
otbAppLogFATAL("Unknown interpolator type!");
}
// Write reduced rainfall
if (HasValue("rainfcumul"))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment