Closes #2217 (closed)
The Mosaic application computes the output image origin, size, and spacing in the
GenerateOutputInformation method of the base mosaic filter.
First, the extent of the output image is retrieved. The pixel spacing is computed from the smallest pixel spacing values of the input images. Then, the origin is computed (from this pixel spacing, and the extent). After that, the output image size is finally computed.
In the current implementation, the output image size is rounded to the upper number of pixels (the idea was to avoid losing one col/row of pixels, and it was not a big deal if we add some extra row/col to the output image):
// Set final size m_OutputSize = vcl_floor((extentSup - extentInf) / vcl_abs(m_OutputSpacing)) + 1; m_OutputSize = vcl_floor((extentSup - extentInf) / vcl_abs(m_OutputSpacing)) + 1;
However this is very embarrassing when you need to mosaic several images of the same extent/size, because the output image size will have +1 row/col.
The proposed change intend to correct that using
std::round to compute the output image size from the extent and the pixel spacing.
This way, the output image size is more correctly adjusted and fits better the actual content: if the continuous size of the output image falls between the start corner of the pixel and its center, it will be rounded to the lower number. If it falls between its center and its end corner, it will be rounded to the upper number.
// Set final size (proposed changes) m_OutputSize = std::round((extentSup - extentInf) / vcl_abs(m_OutputSpacing)); m_OutputSize = std::round((extentSup - extentInf) / vcl_abs(m_OutputSpacing));
Classes and files
Only 2 lines of
Modules/Filtering/Mosaic/include/otbStreamingMosaicFilterBase.hxx are changed (as described above).
If we are lucky, tests could pass (depending on the rounding of the input images extents...)
If not, the baseline of all Mosaic tests must be updated.
The copyright owner is INRAe (ex-IRSTEA) and has signed the ORFEO ToolBox Contributor License Agreement.