Skip to content
Snippets Groups Projects
Commit 928adeaf authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

BUG: #1534: support cases where input largest doesn't start at (0,0)

parent 8e770af9
No related branches found
No related tags found
No related merge requests found
...@@ -468,7 +468,6 @@ ImageFileWriter<TInputImage> ...@@ -468,7 +468,6 @@ ImageFileWriter<TInputImage>
*/ */
inputPtr->UpdateOutputInformation(); inputPtr->UpdateOutputInformation();
InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion(); InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion();
typename TInputImage::PointType origin = inputPtr->GetOrigin();
/** Parse region size modes */ /** Parse region size modes */
if(m_FilenameHelper->BoxIsSet()) if(m_FilenameHelper->BoxIsSet())
...@@ -485,9 +484,7 @@ ImageFileWriter<TInputImage> ...@@ -485,9 +484,7 @@ ImageFileWriter<TInputImage>
size[0] = boxVector[2]; // size along X size[0] = boxVector[2]; // size along X
size[1] = boxVector[3]; // size along Y size[1] = boxVector[3]; // size along Y
inputRegion.SetSize(size); inputRegion.SetSize(size);
inputRegion.SetIndex(start);
m_ShiftOutputIndex = start;
inputRegion.SetIndex(m_ShiftOutputIndex);
if (!inputRegion.Crop(inputPtr->GetLargestPossibleRegion())) if (!inputRegion.Crop(inputPtr->GetLargestPossibleRegion()))
{ {
...@@ -501,11 +498,9 @@ ImageFileWriter<TInputImage> ...@@ -501,11 +498,9 @@ ImageFileWriter<TInputImage>
e.SetDataObject(inputPtr); e.SetDataObject(inputPtr);
throw e; throw e;
} }
inputPtr->TransformIndexToPhysicalPoint(inputRegion.GetIndex(), origin);
otbLogMacro(Info,<<"Writing user defined region ["<<start[0]<<", "<<start[0]+size[0]-1<<"]x["<<start[1]<<", "<<start[1]+size[1]<<"]"); otbLogMacro(Info,<<"Writing user defined region ["<<start[0]<<", "<<start[0]+size[0]-1<<"]x["<<start[1]<<", "<<start[1]+size[1]<<"]");
} }
m_ShiftOutputIndex = inputRegion.GetIndex();
/** /**
* Determine of number of pieces to divide the input. This will be the * Determine of number of pieces to divide the input. This will be the
...@@ -544,6 +539,8 @@ ImageFileWriter<TInputImage> ...@@ -544,6 +539,8 @@ ImageFileWriter<TInputImage>
// //
// Setup the ImageIO with information from inputPtr // Setup the ImageIO with information from inputPtr
// //
typename TInputImage::PointType origin;
inputPtr->TransformIndexToPhysicalPoint(inputRegion.GetIndex(), origin);
const typename TInputImage::SpacingType& spacing = inputPtr->GetSpacing(); const typename TInputImage::SpacingType& spacing = inputPtr->GetSpacing();
const typename TInputImage::DirectionType& direction = inputPtr->GetDirection(); const typename TInputImage::DirectionType& direction = inputPtr->GetDirection();
m_ImageIO->SetNumberOfDimensions(TInputImage::ImageDimension); m_ImageIO->SetNumberOfDimensions(TInputImage::ImageDimension);
...@@ -665,7 +662,7 @@ ImageFileWriter<TInputImage> ...@@ -665,7 +662,7 @@ ImageFileWriter<TInputImage>
//Reset global shift on input region (box parameter) //Reset global shift on input region (box parameter)
//It allows calling multiple update over the writer //It allows calling multiple update over the writer
m_ShiftOutputIndex.Fill(0); m_ShiftOutputIndex = inputPtr->GetLargestPossibleRegion().GetIndex();
} }
...@@ -721,10 +718,7 @@ ImageFileWriter<TInputImage> ...@@ -721,10 +718,7 @@ ImageFileWriter<TInputImage>
InputImageRegionType ioRegion; InputImageRegionType ioRegion;
// No shift of the ioRegion from the buffered region is expected // No shift of the ioRegion from the buffered region is expected
typename InputImageRegionType::IndexType tmpIndex;
tmpIndex.Fill(0);
itk::ImageIORegionAdaptor<TInputImage::ImageDimension>:: itk::ImageIORegionAdaptor<TInputImage::ImageDimension>::
//Convert(m_ImageIO->GetIORegion(), ioRegion, tmpIndex);
Convert(m_ImageIO->GetIORegion(), ioRegion, m_ShiftOutputIndex); Convert(m_ImageIO->GetIORegion(), ioRegion, m_ShiftOutputIndex);
InputImageRegionType bufferedRegion = input->GetBufferedRegion(); InputImageRegionType bufferedRegion = input->GetBufferedRegion();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment