Python Forum

Full Version: Maximas in grayscale image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a grayscale image (2d matrix), and I want to extract N (defined integer) maximas (marked in red).

I don't want them to be clustered all together near each other (the result of directly looking for top N points).

I would like these points to be spread all over the image (like shown bellow), with higher density where the values are high, and lower density where the values are low. I am looking for an efficient python algorithm for the task.

Thanks.

[Image: VyBhJ43]
Take a look at scikit-image's peak_local_max function.
It has min_distance parameter which regulates density of max-points to be chosen.
(Aug-13-2020, 11:59 AM)scidam Wrote: [ -> ]Take a look at scikit-image's peak_local_max function.
It has min_distance parameter which regulates density of max-points to be chosen.

This worked very nicely! One problem I had was that min_distance was ignored for clusters of pixels that had equal values (all of them were chosen, even though min_distance should have prevented that). This problem was solved by adding noise to the image before using peak_local_max.

Thanks.