Commit febd870c authored by Cresson Remi's avatar Cresson Remi

ENH: clip output to moving image roi

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