Commit 2df70eaa authored by Cédric Traizet's avatar Cédric Traizet

Merge branch '2046-superimpose-crash' into 'develop'

BUG: #2046 Add an epsilon margin to compute the m_ReachableOutputRegion

Closes #2046

See merge request !714
parents 5d8e5f7c 823608ae
Pipeline #5070 passed with stages
in 31 minutes and 58 seconds
......@@ -54,7 +54,7 @@ Julien Malik <julien.malik@c-s.fr> Julien Malik <julien.m
Julien Michel <julien.michel@cnes.fr>
Julien Michel <julien.michel@cnes.fr> Julien Michel <julien.michel@c-s.fr>
Julien Michel <julien.michel@cnes.fr> Julien Michel <julien.michel@orfeo-toolbox.org>
Julien Osman <julien.osman@c-s.fr>
Julien Osman <julien.osman@csgroup.eu> Julien Osman <julien.osman@c-s.fr>
Laurențiu Nicola <lnicola@dend.ro> Laurentiu Nicola <lnicola@dend.ro>
Laurențiu Nicola <lnicola@dend.ro> Laurențiu Nicola <grayshade@gmail.com>
Luc Hermitte <luc.hermitte@c-s.fr> Luc Hermitte <luc.hermitte@cnes.fr>
......
......@@ -192,6 +192,7 @@ private:
NNInterpolatorType::Pointer interpolator = NNInterpolatorType::New();
m_Resampler->SetInterpolator(interpolator);
m_BasicResampler->SetInterpolator(interpolator);
m_BasicResampler->SetInterpolationMargin(1e-9);
}
break;
case Interpolator_BCO:
......
......@@ -367,3 +367,13 @@ otb_test_application(NAME apTvPrSuperimpose_phr
VALID --compare-image ${EPSILON_7}
${BASELINE}/apTvPrSuperimposePHR.tif
${TEMP}/apTvPrSuperimposePHR.tif)
otb_test_application(NAME apTvPrSuperimpose_phr_nn
APP Superimpose
OPTIONS -inr ${INPUTDATA}/phr_pan.tif
-inm ${INPUTDATA}/phr_xs.tif
-interpolator nn
-out ${TEMP}/apTvPrSuperimposePHR_nn.tif int16
VALID --compare-image ${EPSILON_7}
${BASELINE}/apTvPrSuperimposePHR_nn.tif
${TEMP}/apTvPrSuperimposePHR_nn.tif)
......@@ -124,6 +124,9 @@ public:
itkGetMacro(CheckOutputBounds, bool);
itkBooleanMacro(CheckOutputBounds);
itkSetMacro(InterpolationMargin, double);
itkGetMacro(InterpolationMargin, double);
itkSetObjectMacro(Interpolator, InterpolatorType);
itkGetObjectMacro(Interpolator, InterpolatorType);
......@@ -190,6 +193,8 @@ private:
OutputPixelType m_EdgePaddingValue; // Default pixel value
double m_InterpolationMargin;
bool m_CheckOutputBounds; // Shall we check
// output bounds when
// casting?
......
......@@ -42,6 +42,7 @@ GridResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecision>::Grid
m_OutputSpacing(),
m_EdgePaddingValue(),
m_CheckOutputBounds(true),
m_InterpolationMargin(0.0),
m_Interpolator(),
m_ReachableOutputRegion()
{
......@@ -227,7 +228,6 @@ void GridResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecision>:
// Compute the padding due to the interpolator
IndexType inUL = this->GetInput()->GetBufferedRegion().GetIndex();
IndexType inLR = this->GetInput()->GetBufferedRegion().GetIndex() + this->GetInput()->GetBufferedRegion().GetSize();
inLR[0] -= 1;
......@@ -246,9 +246,9 @@ void GridResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecision>:
this->GetInput()->TransformIndexToPhysicalPoint(inUL, inULp);
this->GetInput()->TransformIndexToPhysicalPoint(inLR, inLRp);
inULp -= 0.5 * this->GetInput()->GetSignedSpacing();
inLRp += 0.5 * this->GetInput()->GetSignedSpacing();
inULp -= (0.5 - m_InterpolationMargin) * this->GetInput()->GetSignedSpacing();
inLRp += (0.5 - m_InterpolationMargin) * this->GetInput()->GetSignedSpacing();
ContinuousInputIndexType outUL;
ContinuousInputIndexType outLR;
this->GetOutput()->TransformPhysicalPointToContinuousIndex(inULp, outUL);
......@@ -265,6 +265,8 @@ void GridResampleImageFilter<TInputImage, TOutputImage, TInterpolatorPrecision>:
m_ReachableOutputRegion.SetIndex(outputIndex);
m_ReachableOutputRegion.SetSize(outputSize);
otbMsgDevMacro(<< "ReachableOutputRegion: " << m_ReachableOutputRegion);
}
template <typename TInputImage, typename TOutputImage, typename TInterpolatorPrecision>
......
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