Commit 680b62bc authored by Cresson Remi's avatar Cresson Remi

ADD: the super Superimpose application

parent cc021213
......@@ -4,3 +4,7 @@ OTB_CREATE_APPLICATION(NAME ClassificationMapMosaic
SOURCES otbClassificationMapMosaic.cxx
LINK_LIBRARIES OTBCommon)
OTB_CREATE_APPLICATION(NAME SuperSuperimpose
SOURCES otbSuperSuperimpose.cxx
LINK_LIBRARIES OTBCommon)
/*
* Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
*
* This file is part of Orfeo Toolbox
*
* https://www.orfeo-toolbox.org/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "otbWrapperApplicationFactory.h"
#include "otbGridResampleImageFilter.h"
#include "otbBCOInterpolateImageFunction.h"
#include "itkNearestNeighborInterpolateImageFunction.h"
namespace otb
{
enum
{
Interpolator_BCO,
Interpolator_NNeighbor,
Interpolator_Linear
};
namespace Wrapper
{
class SuperSuperimpose : public Application
{
public:
/** Standard class typedefs. */
typedef SuperSuperimpose Self;
typedef Application Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Standard macro */
itkNewMacro(Self);
itkTypeMacro(SuperSuperimpose, Application);
typedef itk::LinearInterpolateImageFunction<FloatVectorImageType, double> LinInterpolatorType;
typedef itk::NearestNeighborInterpolateImageFunction<FloatVectorImageType, double> NNInterpolatorType;
typedef otb::BCOInterpolateImageFunction<FloatVectorImageType> BCOInterpolatorType;
typedef otb::GridResampleImageFilter<FloatVectorImageType, FloatVectorImageType> BasicResamplerType;
private:
void DoInit() override
{
SetName("SuperSuperimpose");
SetDescription("Using available image metadata, project one image onto another one");
// Documentation
SetDocName("SuperSuperimpose sensor");
SetDocLongDescription("This application performs the projection of an image into the geometry of another one.");
SetDocLimitations("None");
SetDocAuthors("OTB-Team");
SetDocSeeAlso(" ");
AddDocTag(Tags::Geometry);
AddDocTag("Superimposition");
AddParameter(ParameterType_InputImage, "inr", "Reference input");
SetParameterDescription("inr","The input reference image.");
AddParameter(ParameterType_InputImage, "inm", "The image to reproject");
SetParameterDescription("inm","The image to reproject into the geometry of the reference input.");
AddParameter(ParameterType_OutputImage, "out", "Output image");
SetParameterDescription("out", "Output reprojected image.");
AddParameter(ParameterType_Float, "ratio", "Output image pixel spacing ratio");
AddParameter(ParameterType_Float, "fv", "Fill Value");
SetParameterDescription("fv","Fill value for area outside the reprojected image");
SetDefaultParameterFloat("fv", 0.);
MandatoryOff("fv");
// Interpolators
AddParameter(ParameterType_Choice, "interpolator", "Interpolation");
SetParameterDescription("interpolator","This group of parameters allows defining 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 controlling 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 artifacts.");
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();
// Doc example parameter settings
SetDocExampleParameterValue("inr", "QB_Toulouse_Ortho_PAN.tif");
SetDocExampleParameterValue("inm", "QB_Toulouse_Ortho_XS.tif");
SetDocExampleParameterValue("out", "SuperSuperimposedXS_to_PAN.tif");
SetOfficialDocLink();
}
void DoUpdateParameters() override
{
}
void DoExecute() override
{
// Get the inputs
FloatVectorImageType* refImage = GetParameterImage("inr");
FloatVectorImageType* movingImage = GetParameterImage("inm");
// Resample filter
m_BasicResampler = BasicResamplerType::New();
// Get Interpolator
switch ( GetParameterInt("interpolator") )
{
case Interpolator_Linear:
{
LinInterpolatorType::Pointer interpolator = LinInterpolatorType::New();
m_BasicResampler->SetInterpolator(interpolator);
}
break;
case Interpolator_NNeighbor:
{
NNInterpolatorType::Pointer interpolator = NNInterpolatorType::New();
m_BasicResampler->SetInterpolator(interpolator);
}
break;
case Interpolator_BCO:
{
BCOInterpolatorType::Pointer interpolator = BCOInterpolatorType::New();
interpolator->SetRadius(GetParameterInt("interpolator.bco.radius"));
m_BasicResampler->SetInterpolator(interpolator);
}
break;
}
// Set up output image information
FloatVectorImageType::SpacingType spacing = refImage->GetSignedSpacing();
FloatVectorImageType::IndexType start = refImage->GetLargestPossibleRegion().GetIndex();
FloatVectorImageType::SizeType size = refImage->GetLargestPossibleRegion().GetSize();
FloatVectorImageType::PointType origin = refImage->GetOrigin();
for (int i = 0 ; i < 2 ; i++)
{
spacing[i] *= GetParameterFloat("ratio");
size[i] /= GetParameterFloat("ratio");
origin[i] += 0.5*(spacing[i] - refImage->GetSignedSpacing()[i]);
}
FloatVectorImageType::PixelType defaultValue;
itk::NumericTraits<FloatVectorImageType::PixelType>::SetLength(defaultValue, movingImage->GetNumberOfComponentsPerPixel());
defaultValue.Fill(GetParameterFloat("fv"));
m_BasicResampler->SetInput(movingImage);
m_BasicResampler->SetOutputOrigin(origin);
m_BasicResampler->SetOutputSpacing(spacing);
m_BasicResampler->SetOutputSize(size);
m_BasicResampler->SetOutputStartIndex(start);
m_BasicResampler->SetEdgePaddingValue(defaultValue);
// Set the output image
SetParameterOutputImage("out", m_BasicResampler->GetOutput());
}
BasicResamplerType::Pointer m_BasicResampler;
};
} // end namespace Wrapper
} // end namespace otb
OTB_APPLICATION_EXPORT(otb::Wrapper::SuperSuperimpose)
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