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
Refactor and fix peak_local_max #4760
Conversation
This reverts commit db38358.
…into Fix_peack_local_max
Co-authored-by: Marianne Corvellec <marianne.corvellec@ens-lyon.org>
…into Fix_peack_local_max
Thank you @mkcor for your review ;) |
…into Fix_peack_local_max
Can we plan this PR for 0.18 or is the schedule too short? |
@jni, here is the error reported by @emmanuelle: in >>> from skimage.feature import peak_local_max
>>> response = np.zeros((5, 5))
>>> response[2:4, 2:4] = 1
>>> response
array([[0., 0., 0., 0., 0.],
[0., 0., 0., 0., 0.],
[0., 0., 1., 1., 0.],
[0., 0., 1., 1., 0.],
[0., 0., 0., 0., 0.]])
>>> peak_local_max(response)
array([[2, 2]]) but with the last fix >>> peak_local_max(response)
array([[2, 2],
[2, 3],
[3, 2],
[3, 3]]) that's the result with I think that in this case, |
This is again a pixel centred VS grid centred point of view problem I think! |
I don't think so? In either case the distance to the adjacent pixels is exactly 1 or sqrt(2)? |
I think the new result is what I would expect. It's unclear to me why it wasn't that before. OR, if you want, change it to use |
I say that in the sens that pixel (0, 1) is adjacent to pixel (0, 2) (the distance between them is 0 because they join at (0, 0.5)). But the points (0, 1) is separated from the point (0, 2) by a distance of 1. |
In other words, do we consider that a pixel is a point or "a little square"? I know, pixels are not squares, but it can be seen as such 😄 (grid centred VS cell centred) |
BTW, |
Well, I think this is a can of worms that we do not want to open, since this definition no longer satisfies the definition of a metric between pixels. What do you think of my proposal to add |
I'd be into that, I was always confused by that function. But probably for 0.19 as that is a major API change. |
OK, let's keep the old behavior considering that consecutive pixels are separated by a distance of 1 for now 😉.
Let's go for that too, but we will then need to decide which behavior to keep ( |
Ok, as far as I can tell, the failures have nothing to do with this PR. @scikit-image/core anyone else ready to push the green button? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will approve now, but possibly add something about these changes as in the criteria:
- Check that new features, API changes, and deprecations are mentioned in
doc/release/release_dev.rst.
Co-authored-by: Gregory R. Lee <grlee77@gmail.com>
… if min_distance < 1
…e into Fix_peack_local_max
Thank you @grlee77, I added the changes to the release note as you advised 😉. |
🎉 thank you all for your reviews! I am happy to see this in 0.18 😄 |
@rfezzani Just wanted to give you a personal shout-out: the peak finder was performing poorly, and when I looked into what should be done to fixed it I discovered you had already done the work. Thank you very much! |
Description
In my attempt to fix #2592, I made a review of the code and found many issues (see #4756, #4749, #4752 and #3990 (comment)). It appeared to me that a global refactoring of
peak_local_max
is necessary.Multiple changes are applied in this PR:
min_distance
is enforced in the same way as in Add Minkowski distance metric support to corner_peak #4218 forcorner_peak
(see here)_get_threshold
and_get_excluded_border_width
are introduced for readabilitylabels
renumbering is avoidedIf accepted, this PR allows to deprecate
corner_peak
that becomes a duplicate ofpeak_local_max
.Fixes #2592. Fixes #4756. Fixes #4756. Closes #3990. Fixes #5047 .
Checklist
./doc/examples
(new features only)./benchmarks
, if your changes aren't covered by anexisting benchmark
For reviewers
later.
__init__.py
.doc/release/release_dev.rst
.