Skip to content
Snippets Groups Projects
Commit 105ef369 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: add interpolator choice in Superimpose application

parent 53d15e0f
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,10 @@ ...@@ -19,7 +19,10 @@
#include "otbWrapperApplicationFactory.h" #include "otbWrapperApplicationFactory.h"
#include "otbGenericRSResampleImageFilter.h" #include "otbGenericRSResampleImageFilter.h"
#include "itkLinearInterpolateImageFunction.h"
#include "otbBCOInterpolateImageFunction.h" #include "otbBCOInterpolateImageFunction.h"
#include "itkNearestNeighborInterpolateImageFunction.h"
// Elevation handler // Elevation handler
#include "otbWrapperElevationParametersHandler.h" #include "otbWrapperElevationParametersHandler.h"
...@@ -27,6 +30,13 @@ ...@@ -27,6 +30,13 @@
namespace otb namespace otb
{ {
enum
{
Interpolator_BCO,
Interpolator_NNeighbor,
Interpolator_Linear
};
namespace Wrapper namespace Wrapper
{ {
...@@ -46,7 +56,15 @@ public: ...@@ -46,7 +56,15 @@ public:
typedef unsigned short int PixelType; typedef unsigned short int PixelType;
typedef otb::BCOInterpolateImageFunction<FloatVectorImageType> InterpolatorType; typedef itk::LinearInterpolateImageFunction
<FloatVectorImageType,
double> LinInterpolatorType;
typedef itk::NearestNeighborInterpolateImageFunction
<FloatVectorImageType,
double> NNInterpolatorType;
typedef otb::BCOInterpolateImageFunction
<FloatVectorImageType> BCOInterpolatorType;
typedef otb::GenericRSResampleImageFilter<FloatVectorImageType, typedef otb::GenericRSResampleImageFilter<FloatVectorImageType,
FloatVectorImageType> ResamplerType; FloatVectorImageType> ResamplerType;
...@@ -77,13 +95,31 @@ private: ...@@ -77,13 +95,31 @@ private:
AddParameter(ParameterType_Float, "lms", "Spacing of the deformation field"); AddParameter(ParameterType_Float, "lms", "Spacing of the deformation field");
SetParameterDescription("lms","Generate a coarser deformation field with the given spacing"); SetParameterDescription("lms","Generate a coarser deformation field with the given spacing");
SetDefaultParameterFloat("lms", 4.); SetDefaultParameterFloat("lms", 4.);
MandatoryOff("lms");
AddParameter(ParameterType_OutputImage, "out", "Output image"); AddParameter(ParameterType_OutputImage, "out", "Output image");
SetParameterDescription("out","Output reprojected image."); SetParameterDescription("out","Output reprojected image.");
// Interpolators
AddParameter(ParameterType_Choice, "interpolator", "Interpolation");
SetParameterDescription("interpolator","This group of parameters allows to define how the input image will be interpolated during resampling.");
AddChoice("interpolator.bco", "Bicubic interpolation");
SetParameterDescription("interpolator.bco", "Bicubic interpolation leads to very good image quality but is slow.");
AddParameter(ParameterType_Radius, "interpolator.bco.radius", "Radius for bicubic interpolation");
SetParameterDescription("interpolator.bco.radius","This parameter allows to control the 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);
AddChoice("interpolator.nn", "Nearest Neighbor interpolation");
SetParameterDescription("interpolator.nn","Nearest neighbor interpolation leads to poor image quality, but it is very fast.");
AddChoice("interpolator.linear", "Linear interpolation");
SetParameterDescription("interpolator.linear","Linear interpolation leads to average image quality but is quite fast");
AddRAMParameter(); AddRAMParameter();
MandatoryOff("lms");
// Doc example parameter settings // Doc example parameter settings
SetDocExampleParameterValue("inr", "QB_Toulouse_Ortho_PAN.tif"); SetDocExampleParameterValue("inr", "QB_Toulouse_Ortho_PAN.tif");
SetDocExampleParameterValue("inm", "QB_Toulouse_Ortho_XS.tif"); SetDocExampleParameterValue("inm", "QB_Toulouse_Ortho_XS.tif");
...@@ -103,10 +139,32 @@ private: ...@@ -103,10 +139,32 @@ private:
FloatVectorImageType* movingImage = GetParameterImage("inm"); FloatVectorImageType* movingImage = GetParameterImage("inm");
// Resample filter // Resample filter
m_Resampler = ResamplerType::New(); m_Resampler = ResamplerType::New();
m_Interpolator = InterpolatorType::New();
m_Interpolator->SetRadius(2); // Get Interpolator
m_Resampler->SetInterpolator(m_Interpolator); switch ( GetParameterInt("interpolator") )
{
case Interpolator_Linear:
{
LinInterpolatorType::Pointer interpolator = LinInterpolatorType::New();
m_Resampler->SetInterpolator(interpolator);
}
break;
case Interpolator_NNeighbor:
{
NNInterpolatorType::Pointer interpolator = NNInterpolatorType::New();
m_Resampler->SetInterpolator(interpolator);
}
break;
case Interpolator_BCO:
{
BCOInterpolatorType::Pointer interpolator = BCOInterpolatorType::New();
interpolator->SetRadius(GetParameterInt("interpolator.bco.radius"));
m_Resampler->SetInterpolator(interpolator);
}
break;
}
// Setup the DEM Handler // Setup the DEM Handler
otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev"); otb::Wrapper::ElevationParametersHandler::SetupDEMHandlerFromElevationParameters(this,"elev");
...@@ -152,7 +210,6 @@ private: ...@@ -152,7 +210,6 @@ private:
} }
ResamplerType::Pointer m_Resampler; ResamplerType::Pointer m_Resampler;
InterpolatorType::Pointer m_Interpolator;
}; };
} // end namespace Wrapper } // end namespace Wrapper
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment