Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve stability of local_minima #7534

Merged

Conversation

michaelbratsch
Copy link
Contributor

@michaelbratsch michaelbratsch commented Sep 8, 2024

Description

As stated in issue #7530, local_minima is not numerically stable for extremely small floats due to the inversion of the image which subtracts the values from one. Just flipping the sign is sufficient to be able to dispatch to local_maxima and does not cause any rounding errors.

Checklist

Release note

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

Improve numerical stability of `skimage.morphology.local_minima`
for extremely small floats.

@lagru lagru added the ⏩ type: Enhancement Improve existing features label Sep 15, 2024
Copy link
Member

@lagru lagru left a comment

Choose a reason for hiding this comment

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

Looks perfect. Thanks @michaelbratsch for making these improvements! 😊

For other reviewers, it's useful to keep using invert because it also handles dtype bool for which a simple -image wouldn't work.

@lagru lagru added the 🚀 Quick win Trivial, small, easy to address or review label Sep 15, 2024
@lagru lagru changed the title Feature/improve stability local minima Improve stability of local_minima Sep 15, 2024
@lagru lagru added the 👍 1st approval Needs 2nd approval to merge label Sep 24, 2024
@mkcor mkcor merged commit d15a5f7 into scikit-image:main Sep 24, 2024
28 checks passed
@stefanv stefanv added this to the 0.25 milestone Sep 24, 2024
@lagru
Copy link
Member

lagru commented Sep 24, 2024

Thanks @michaelbratsch!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏩ type: Enhancement Improve existing features 🚀 Quick win Trivial, small, easy to address or review 👍 1st approval Needs 2nd approval to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants