Commit cc021213 authored by Cresson Remi's avatar Cresson Remi

ENH: interpolator can be chose. Default=Linear

parent 5a52766d
......@@ -41,6 +41,11 @@ public:
/** Filters */
typedef otb::ClassificationMosaicArgmaxFilter<FloatVectorImageType, FloatVectorImageType, double> ArgmaxFilterType;
/** Interpolators typedefs */
typedef itk::LinearInterpolateImageFunction<FloatVectorImageType, double> LinearInterpolationType;
typedef itk::NearestNeighborInterpolateImageFunction<FloatVectorImageType, double> NearestNeighborInterpolationType;
typedef otb::BCOInterpolateImageFunction<FloatVectorImageType> BCOInterpolationType;
void DoUpdateParameters()
{
}
......@@ -56,16 +61,62 @@ public:
SetDocAuthors("Remi Cresson");
// Input
AddParameter(ParameterType_InputImageList, "il", "Input classification maps");
// Mode
AddParameter(ParameterType_Choice, "mode", "Fusion mode");
AddChoice("mode.argmax", "Argmax of the averages values");
// Interpolators
AddParameter(ParameterType_Choice, "interpolator", "Interpolation");
SetParameterDescription ("interpolator", "This group of parameters allows to define how the input image will be interpolated during resampling.");
MandatoryOff ("interpolator");
AddChoice ("interpolator.linear", "Linear interpolation");
SetParameterDescription("interpolator.linear", "Linear interpolation leads to average image quality but is quite fast");
AddChoice ("interpolator.nn", "Nearest Neighbor interpolation");
SetParameterDescription("interpolator.nn", "Nearest neighbor interpolation leads to poor image quality, but it is fast.");
AddChoice ("interpolator.bco", "Bicubic interpolation");
SetParameterDescription("interpolator.bco", "Bicubic interpolation leads to great image quality, but it is slow.");
AddParameter(ParameterType_Radius, "interpolator.bco.radius", "Radius for bicubic interpolation");
SetParameterDescription ("interpolator.bco.radius", "Size of the bicubic interpolation filter. If the target pixel size "
"is higher than the input pixel size, increasing this parameter will reduce aliasing artefacts.");
SetDefaultParameterInt ("interpolator.bco.radius", 2);
// Output
AddParameter(ParameterType_OutputImage, "out", "output classification map");
SetDefaultOutputPixelType("out", ImagePixelType_uint8);
}
template <class TMosaicFilter>
void SelectInterpolator(typename TMosaicFilter::Pointer filter)
{
if ( GetParameterString("interpolator").compare("linear") == 0 )
{
LinearInterpolationType::Pointer interpolator = LinearInterpolationType::New();
filter->SetInterpolator(interpolator);
}
else if ( GetParameterString("interpolator").compare("nn") == 0 )
{
NearestNeighborInterpolationType::Pointer interpolator = NearestNeighborInterpolationType::New();
filter->SetInterpolator(interpolator);
}
else if ( GetParameterString("interpolator").compare("bco") == 0 )
{
BCOInterpolationType::Pointer interpolator = BCOInterpolationType::New();
interpolator->SetRadius(GetParameterInt("interpolator.bco.radius") );
filter->SetInterpolator(interpolator);
}
else
{
otbAppLogFATAL("Unknown interpolator: " << GetParameterString("interpolator"))
}
}
void DoExecute()
{
......@@ -73,14 +124,15 @@ public:
FloatVectorImageListType::Pointer inputArray = this->GetParameterImageList("il");
if (GetParameterAsString("mode") == "argmax")
{
{
otbAppLogINFO("Fusion mode is argmax");
m_ArgmaxMosaicFilter = ArgmaxFilterType::New();
for (unsigned int i = 0 ; i < inputArray->Size() ; i++)
{
{
m_ArgmaxMosaicFilter->PushBackInput(inputArray->GetNthElement(i) );
}
}
SelectInterpolator<ArgmaxFilterType>(m_ArgmaxMosaicFilter);
}
SetParameterOutputImage("out", m_ArgmaxMosaicFilter->GetOutput());
......
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