Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • otb otb
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 206
    • Issues 206
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 12
    • Merge requests 12
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Main Repositories
  • otbotb
  • Merge requests
  • !849

FIX: mosaic output image size fit best inputs extents

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Rémi Cresson requested to merge 2217-mosaic_out_size into develop Aug 26, 2021
  • Overview 2
  • Commits 2
  • Pipelines 3
  • Changes 7

Summary

Closes #2217 (closed)

Rationale

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[0] = vcl_floor((extentSup[0] - extentInf[0]) / vcl_abs(m_OutputSpacing[0])) + 1;
  m_OutputSize[1] = vcl_floor((extentSup[1] - extentInf[1]) / vcl_abs(m_OutputSpacing[1])) + 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[0] = std::round((extentSup[0] - extentInf[0]) / vcl_abs(m_OutputSpacing[0]));
  m_OutputSize[1] = std::round((extentSup[1] - extentInf[1]) / vcl_abs(m_OutputSpacing[1]));

Implementation Details

Classes and files

Only 2 lines of Modules/Filtering/Mosaic/include/otbStreamingMosaicFilterBase.hxx are changed (as described above).

Tests

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.

Documentation

No need

Copyright

The copyright owner is INRAe (ex-IRSTEA) and has signed the ORFEO ToolBox Contributor License Agreement.

Edited Aug 26, 2021 by Rémi Cresson
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: 2217-mosaic_out_size