Commit febd870c authored by Cresson Remi's avatar Cresson Remi

ENH: clip output to moving image roi

parent f5b939f8
......@@ -10,11 +10,14 @@
=========================================================================*/
#include "otbWrapperApplicationFactory.h"
#include "otbGridResampleImageFilter.h"
#include "otbStreamingResampleImageFilter.h"
#include "otbBCOInterpolateImageFunction.h"
#include "itkNearestNeighborInterpolateImageFunction.h"
#include "otbRegionComparator.h"
#include "otbMultiChannelExtractROI.h"
namespace otb
{
......@@ -45,8 +48,8 @@ public:
typedef itk::LinearInterpolateImageFunction<FloatVectorImageType, double> LinInterpolatorType;
typedef itk::NearestNeighborInterpolateImageFunction<FloatVectorImageType, double> NNInterpolatorType;
typedef otb::BCOInterpolateImageFunction<FloatVectorImageType> BCOInterpolatorType;
typedef otb::GridResampleImageFilter<FloatVectorImageType, FloatVectorImageType> BasicResamplerType;
typedef otb::MultiChannelExtractROI<FloatVectorImageType::InternalPixelType,FloatVectorImageType::InternalPixelType> ExtractROIFilterType;
typedef otb::StreamingResampleImageFilter<FloatVectorImageType, FloatVectorImageType> BasicResamplerType;
private:
void DoInit() override
......@@ -111,13 +114,13 @@ private:
}
void DoUpdateParameters() override
{
{
}
}
void DoExecute() override
{
{
// Get the inputs
FloatVectorImageType* refImage = GetParameterImage("inr");
FloatVectorImageType* movingImage = GetParameterImage("inm");
......@@ -173,13 +176,25 @@ private:
m_BasicResampler->SetOutputSize(size);
m_BasicResampler->SetOutputStartIndex(start);
m_BasicResampler->SetEdgePaddingValue(defaultValue);
m_BasicResampler->UpdateOutputInformation();
// Keep only overlap
otb::RegionComparator<FloatVectorImageType, FloatVectorImageType> comparator;
comparator.SetImage1(m_BasicResampler->GetOutput());
comparator.SetImage2(movingImage);
// Initialize ROI extract filters
m_ExtractROI = ExtractROIFilterType::New();
m_ExtractROI->SetInput(m_BasicResampler->GetOutput());
m_ExtractROI->SetExtractionRegion(comparator.GetOverlapInImage1Indices());
// Set the output image
SetParameterOutputImage("out", m_BasicResampler->GetOutput());
SetParameterOutputImage("out", m_ExtractROI->GetOutput());
}
BasicResamplerType::Pointer m_BasicResampler;
}
BasicResamplerType::Pointer m_BasicResampler;
ExtractROIFilterType::Pointer m_ExtractROI;
};
} // end namespace Wrapper
......
......@@ -7,6 +7,7 @@ otb_module(MLUtils
OTBApplicationEngine
Mosaic
SimpleExtractionTools
OTBProjection
TEST_DEPENDS
OTBTestKernel
......
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