Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Maximas in grayscale image
#1
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]
Reply
#2
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.
Reply
#3
(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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting an RGBA image to Grayscale and Binary Joni_Engr 3 4,616 Aug-23-2021, 11:54 AM
Last Post: Pedroski55
  Convert 400 grayscale pixels into RGB python420 1 2,443 Jan-02-2020, 04:19 PM
Last Post: Clunk_Head
  python opencv grayscale conversion error Spandora 1 9,558 May-26-2019, 10:43 AM
Last Post: heiner55
  show grayscale image using matplotlib zyb1003 1 16,505 Nov-01-2017, 11:45 AM
Last Post: heiner55
  Grayscale - plot python 1 3,164 Aug-10-2017, 11:56 AM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020