Commit 37437170 authored by Guillaume Pasero's avatar Guillaume Pasero

Merge branch '1622-extractroi-inversed-extent' into 'develop'

Resolve "Extract ROI extent mode produces wrong output"

Closes #1622

See merge request !204
parents 5dac9867 ff8d0c2b
......@@ -61,6 +61,12 @@ public:
typedef ExtractROIFilterType::InputImageType ImageType;
protected:
ExtractROI()
: m_IsExtentInverted(false)
{
}
private:
void
DoInit() override
......@@ -424,10 +430,11 @@ private:
inImage->TransformPhysicalPointToIndex(ulp_out,uli);
inImage->TransformPhysicalPointToIndex(lrp_out,lri);
}
SetParameterInt( "startx", uli[0]);
SetParameterInt( "starty", uli[1]);
SetParameterInt( "sizex", lri[0] - uli[0] + 1);
SetParameterInt( "sizey", lri[1] - uli[1] + 1);
m_IsExtentInverted = ( lri[0] < uli[0] || lri[1] < uli[1] );
SetParameterInt( "startx", uli[0]);
SetParameterInt( "starty", uli[1]);
SetParameterInt( "sizex", lri[0] - uli[0] + 1);
SetParameterInt( "sizey", lri[1] - uli[1] + 1);
}
void
......@@ -786,6 +793,13 @@ private:
SetParameterInt("sizey",lri[1]-uli[1]);
}
else if( GetParameterString( "mode" ) == "extent" )
{
if(m_IsExtentInverted)
{
otbAppLogFATAL(<< "Extent coordinates are inverted!");
}
}
if ( !CropRegionOfInterest() )
otbAppLogWARNING(<<"Could not extract the ROI as it is out of the "
......@@ -806,6 +820,9 @@ private:
SetParameterOutputImage("out", extractROIFilter->GetOutput());
RegisterPipeline();
}
/** flag to check if given extent was inverted */
bool m_IsExtentInverted;
};
}
......
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