Commit f55c18be authored by remi cresson's avatar remi cresson

FIX: update image origin

parent 9ce7fad6
......@@ -468,6 +468,9 @@ ImageFileWriter<TInputImage>
*/
inputPtr->UpdateOutputInformation();
InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion();
typename TInputImage::PointType origin = inputPtr->GetOrigin();
const typename TInputImage::SpacingType& spacing = inputPtr->GetSpacing();
const typename TInputImage::DirectionType& direction = inputPtr->GetDirection();
/** Parse region size modes */
if(m_FilenameHelper->BoxIsSet())
......@@ -483,7 +486,6 @@ ImageFileWriter<TInputImage>
start[1] = boxVector[1]; // first index on Y
size[0] = boxVector[2]; // size along X
size[1] = boxVector[3]; // size along Y
inputRegion.SetSize(size);
m_ShiftOutputIndex = start;
......@@ -501,6 +503,9 @@ ImageFileWriter<TInputImage>
e.SetDataObject(inputPtr);
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]<<"]");
}
......@@ -542,9 +547,6 @@ ImageFileWriter<TInputImage>
// Setup the ImageIO with information from inputPtr
//
m_ImageIO->SetNumberOfDimensions(TInputImage::ImageDimension);
const typename TInputImage::SpacingType& spacing = inputPtr->GetSpacing();
const typename TInputImage::PointType& origin = inputPtr->GetOrigin();
const typename TInputImage::DirectionType& direction = inputPtr->GetDirection();
int direction_sign(0);
for (unsigned int i = 0; i < TInputImage::ImageDimension; ++i)
{
......@@ -555,7 +557,7 @@ ImageFileWriter<TInputImage>
// Final image size
m_ImageIO->SetDimensions(i, inputRegion.GetSize(i));
m_ImageIO->SetSpacing(i, direction_sign * spacing[i]);
m_ImageIO->SetOrigin(i, origin[i] + static_cast<double>(inputRegion.GetIndex()[i]) * spacing[i]);
m_ImageIO->SetOrigin(i, origin[i]);
vnl_vector<double> axisDirection(TInputImage::ImageDimension);
// Please note: direction cosines are stored as columns of the
......
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