Skip to content

Undistort masks alongside images in COLMAP workspaces - #4905

Open
cola1917 wants to merge 1 commit into
colmap:mainfrom
cola1917:feat/undistort-image-masks
Open

cola1917 wants to merge 1 commit into
colmap:mainfrom
cola1917:feat/undistort-image-masks

Conversation

@cola1917

Copy link
Copy Markdown
Contributor

Closes #2361.

Add an optional mask_path to image_undistorter and pycolmap.undistort_images for COLMAP workspaces. Masks follow the exact output camera, crop, and resolution of their images, with nearest-neighbor sampling (including large downscales) and lossless grayscale PNG output under masks/<image_name>.png. Already-undistorted and spherical images are supported as well.

Accept the existing image-name-plus-.png convention and the extension-replacement fallback. Require readable, correctly sized masks for selected images; report errors through the controller/Python API and a failed CLI exit status. Other output formats explicitly reject mask_path. Existing calls without masks retain their behavior, and the new Python argument is keyword-only.

Validation on a CPU-only Release build (GUI/CUDA/MVS disabled):

  • 39 C++ tests passed across controllers/undistorters_test, exe/image_test, image/undistortion_test, and image/warp_test.
  • 11 Python tests passed in src/pycolmap/pipeline/images_test.py, including masked/unmasked calls and error propagation.
  • CLI smoke test verified matching image/mask/model dimensions after downscaling and preservation of binary values; missing masks return exit status 1.
  • clang-format 23.1.3, Ruff, and git diff --check passed.

Developed with assistance from OpenAI Codex.

@fringehush-gif

Copy link
Copy Markdown
Contributor

I managed to squeeze more performance out of this, so I made a follow-up: #4930.

  • Calculate pinhole target coordinates once per column and row instead of per pixel.
  • Add exact-output regression tests for the optimized path.

I would appreciate feedback.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undistort images together with masks

2 participants