Commit 8e770af9 authored by remi cresson's avatar remi cresson

Merge branch 'bugfix_writer_box' into develop

parents b0193e0e e30efff6
......@@ -468,22 +468,22 @@ ImageFileWriter<TInputImage>
*/
inputPtr->UpdateOutputInformation();
InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion();
typename TInputImage::PointType origin = inputPtr->GetOrigin();
/** Parse region size modes */
if(m_FilenameHelper->BoxIsSet())
{
std::vector<int> boxVector;
Utils::ConvertStringToVector(
m_FilenameHelper->GetBox(), boxVector, "ExtendedFileName:box", ":");
typename InputImageRegionType::IndexType start;
std::vector<int> boxVector;
Utils::ConvertStringToVector(
m_FilenameHelper->GetBox(), boxVector, "ExtendedFileName:box", ":");
typename InputImageRegionType::IndexType start;
typename InputImageRegionType::SizeType size;
start[0] = boxVector[0]; // first index on X
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 +501,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]<<"]");
}
......@@ -541,10 +544,9 @@ 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();
m_ImageIO->SetNumberOfDimensions(TInputImage::ImageDimension);
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
......@@ -618,7 +620,6 @@ ImageFileWriter<TInputImage>
for (unsigned int i = 0; i < TInputImage::ImageDimension; ++i)
{
ioRegion.SetSize(i, streamRegion.GetSize(i));
ioRegion.SetIndex(i, streamRegion.GetIndex(i));
//Set the ioRegion index using the shifted index ( (0,0 without box parameter))
ioRegion.SetIndex(i, streamRegion.GetIndex(i) - m_ShiftOutputIndex[i]);
}
......
......@@ -458,6 +458,7 @@ SimpleParallelTiffWriter<TInputImage>
*/
inputPtr->UpdateOutputInformation();
InputImageRegionType inputRegion = inputPtr->GetLargestPossibleRegion();
typename InputImageType::PointType origin = inputPtr->GetOrigin();
/** Parse region size modes */
if(m_FilenameHelper->BoxIsSet())
......@@ -497,6 +498,9 @@ SimpleParallelTiffWriter<TInputImage>
throw e;
}
otbMsgDevMacro(<< "inputRegion " << inputRegion);
// Update the origin
inputPtr->TransformIndexToPhysicalPoint(inputRegion.GetIndex(), origin);
}
// Get number of bands & pixel data type
......@@ -538,7 +542,7 @@ SimpleParallelTiffWriter<TInputImage>
else
{
// When mode is not tiled (i.e. striped)
block_size_x = inputPtr->GetLargestPossibleRegion().GetSize()[0];
block_size_x = inputRegion.GetSize()[0];
}
// Master process (Rank 0) is responsible for the creation of the output raster.
......@@ -546,10 +550,10 @@ SimpleParallelTiffWriter<TInputImage>
{
// Set geotransform
double geotransform[6];
geotransform[0] = inputPtr->GetOrigin()[0] - 0.5*inputPtr->GetSignedSpacing()[0];
geotransform[0] = origin[0] - 0.5*inputPtr->GetSignedSpacing()[0];
geotransform[1] = inputPtr->GetSignedSpacing()[0];
geotransform[2] = 0.0;
geotransform[3] = inputPtr->GetOrigin()[1] - 0.5*inputPtr->GetSignedSpacing()[1];
geotransform[3] = origin[1] - 0.5*inputPtr->GetSignedSpacing()[1];
geotransform[4] = 0.0;
geotransform[5] = inputPtr->GetSignedSpacing()[1];
......@@ -557,8 +561,8 @@ SimpleParallelTiffWriter<TInputImage>
if(!m_TiffTiledMode)
{
SPTW_ERROR sperr = sptw::create_raster(m_FileName,
inputPtr->GetLargestPossibleRegion().GetSize()[0],
inputPtr->GetLargestPossibleRegion().GetSize()[1],
inputRegion.GetSize()[0],
inputRegion.GetSize()[1],
nBands,
dataType,
geotransform,
......@@ -573,8 +577,8 @@ SimpleParallelTiffWriter<TInputImage>
else
{
SPTW_ERROR sperr = sptw::create_tiled_raster(m_FileName,
inputPtr->GetLargestPossibleRegion().GetSize()[0],
inputPtr->GetLargestPossibleRegion().GetSize()[1],
inputRegion.GetSize()[0],
inputRegion.GetSize()[1],
nBands,
dataType,
geotransform,
......
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