Skip to content

Refactor fundamental matrix scaling#7767

Merged
mkcor merged 10 commits intoscikit-image:mainfrom
matthew-brett:refactor-fundamental
Jul 9, 2025
Merged

Refactor fundamental matrix scaling#7767
mkcor merged 10 commits intoscikit-image:mainfrom
matthew-brett:refactor-fundamental

Conversation

@matthew-brett
Copy link
Contributor

@matthew-brett matthew-brett commented Apr 4, 2025

Refactor scaling of FundamentalMatrixTransform calculation to make algorithm clearer, and allow original Hartley algorithm if preferred.

Add some tests of scaling algorithms, including cross-check against opencv2.

Also see https://github.com/matthew-brett/test-fundamental-matrices

Release note

For maintainers and optionally contributors, please refer to the instructions on how to document this PR for the release notes.

In `skimage.transform.FundamentalMatrixTransform`, refactor scaling calculation
to make algorithm clearer, and allow original Hartley algorithm if preferred.

@matthew-brett matthew-brett force-pushed the refactor-fundamental branch 3 times, most recently from 7ff66d8 to 5feab11 Compare April 4, 2025 10:48
@matthew-brett matthew-brett requested a review from mkcor April 4, 2025 11:08
Refactor scaling of FundamentalMatrixTransform calculation to make
algorithm clearer, and allow original Hartley algorithm if preferred.

Add some tests of scaling algorithms, including cross-check against
opencv2.

Also see <https://github.com/matthew-brett/test-fundamental-matrices>
@matthew-brett matthew-brett force-pushed the refactor-fundamental branch from 5feab11 to 211c7fd Compare April 4, 2025 15:01
@stefanv
Copy link
Member

stefanv commented Apr 22, 2025

Discussed on the community call:

  • The calculation involves using the SVD to examine the null-space of A.
  • Because of noise, we take the vector corresponding to the smallest singular value.
  • Hartley & Zisserman explain that scaling, so all elements of A are roughly of the same magnitude, is important for conditioning. The exact method of scaling is likely less important.
  • Matthew's tests confirm this, and that our current method works fine.
  • However, this is not the method described by H&Z exactly, so we will provide (somewhat concealed) access to the H+Z method, in case others want to compare for themselves.

@lagru lagru self-requested a review July 1, 2025 18:17
* origin/main:
  Deprecate estimate method in favor of class constructor (scikit-image#7771)
  Temporary fix for Visual Studio & Clang incompatibility in Windows image (scikit-image#7835)
  Address deprecations in Pillow 11.3 (scikit-image#7828)
  Remove unused & obsolete `legacy_datasets`, `legacy_registry` vars (scikit-image#7677)
  Draft migration guide for skimage2 (scikit-image#7785)
  Do not report failure in wheels sub-recipe (scikit-image#7806)
  Use consistent wording in property description. (scikit-image#7804)
  Add intensity_median to regionprops (scikit-image#7745)
  CI: Update pypa/gh-action-pypi-publish to v1.12.4 for attestations on PyPI (scikit-image#7793)
  Document output dtype for transform.resize. (scikit-image#7792)
  Use `cibuildwheel` to build WASM/Pyodide wheels for `scikit-image`, push nightlies to Anaconda.org (scikit-image#7440)
  DOC: Include missing gain parameter in adjust_gamma equation (scikit-image#7763)
  Temporarily pin to `pyodide-build==0.30.0`, and ensure that the correct xbuildenvs are used (scikit-image#7788)
  Deprecate old names & attributes in RegionProperties (scikit-image#7778)
  Pin JasonEtco/create-an-issue action to SHA for v2.9.2 (scikit-image#7787)
  Make doctest-plus work with spin (scikit-image#7786)
  Report failures on main via issue (scikit-image#7752)
  Use `workers` instead of alternate parameter names (scikit-image#7302)
  Fix f-string in otsu plot (scikit-image#7780)
  Further document use of regionprops function and fix terms. (scikit-image#7518)
Copy link
Member

@mkcor mkcor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

matthew-brett and others added 4 commits July 7, 2025 23:36
From @mkcor suggestion.
Add various suggestions from @mkcor's review.

Co-authored-by: Marianne Corvellec <[email protected]>
rather than the generic link to the paper.  From @mkcor's review.
Copy link
Contributor Author

@matthew-brett matthew-brett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Responses, with thanks.

Use `from_estimate` instead of `estimate`.
@matthew-brett
Copy link
Contributor Author

@mkcor - I've added nearly all your changes with thanks, left one trivial one unmerged - happy either way - let me know.

Copy link
Member

@mkcor mkcor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're most welcome, @matthew-brett. We're almost there!

matthew-brett and others added 2 commits July 9, 2025 16:32
Copy link
Member

@mkcor mkcor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthew-brett thanks for bearing with me! Mostly, thank you for undertaking this 'fix' -- I'm glad you folks were able to come up with this compromise. I'll just wait for CI to pass before merging.

@mkcor mkcor merged commit 61ac6dd into scikit-image:main Jul 9, 2025
24 of 25 checks passed
@stefanv stefanv added this to the 0.26 milestone Jul 9, 2025
matthew-brett added a commit to matthew-brett/scikit-image that referenced this pull request Jul 11, 2025
* origin/main:
  Update import convention in certain gallery examples (scikit-image#7764)
  Refactor fundamental matrix scaling (scikit-image#7767)
matthew-brett added a commit to matthew-brett/scikit-image that referenced this pull request Jul 14, 2025
* origin/main: (31 commits)
  Update import convention in certain gallery examples (scikit-image#7764)
  Refactor fundamental matrix scaling (scikit-image#7767)
  Add unit test for cval unequal to zero
  Forward  in _generic_edge_filter
  Remove superfluous mask argument from _generic_edge_filter
  Only report failure on main branch once
  Deprecate estimate method in favor of class constructor (scikit-image#7771)
  Temporary fix for Visual Studio & Clang incompatibility in Windows image (scikit-image#7835)
  Address deprecations in Pillow 11.3 (scikit-image#7828)
  Remove unused & obsolete `legacy_datasets`, `legacy_registry` vars (scikit-image#7677)
  Draft migration guide for skimage2 (scikit-image#7785)
  Do not report failure in wheels sub-recipe (scikit-image#7806)
  Use consistent wording in property description. (scikit-image#7804)
  Add intensity_median to regionprops (scikit-image#7745)
  CI: Update pypa/gh-action-pypi-publish to v1.12.4 for attestations on PyPI (scikit-image#7793)
  Document output dtype for transform.resize. (scikit-image#7792)
  Use `cibuildwheel` to build WASM/Pyodide wheels for `scikit-image`, push nightlies to Anaconda.org (scikit-image#7440)
  DOC: Include missing gain parameter in adjust_gamma equation (scikit-image#7763)
  Temporarily pin to `pyodide-build==0.30.0`, and ensure that the correct xbuildenvs are used (scikit-image#7788)
  Deprecate old names & attributes in RegionProperties (scikit-image#7778)
  ...
@lagru lagru added ⏩ type: Enhancement Improve existing features 🔧 type: Maintenance Refactoring and maintenance of internals and removed ⏩ type: Enhancement Improve existing features labels Nov 29, 2025
@lagru
Copy link
Member

lagru commented Nov 29, 2025

Note, I've relabeled this as "maintenance". The new scaling attribute added with this PR isn't really documented. I think it was discussed as a nice to have for people looking at the internal implementation? So let's not advertise a feature in the release notes that's not well documented.

Instead we should document it in a follow-up PR if we want it as public API?

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

Labels

🔧 type: Maintenance Refactoring and maintenance of internals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants