Is there a method to use ‘findpeaks’ to detect bright spots in an otherwise darkimage?

22 views (last 30 days)
I am currently having the problem that if I run findpeaks along the columns of said image, the same spot is being detected multiple times, as it appears as peak in every column.
I am aware that there are ad-on options for 2D peak detection, but I was hoping for a solution using findpeaks.

Accepted Answer

Walter Roberson
Walter Roberson on 14 Jun 2021
Edited: Walter Roberson on 15 Jun 2021
you can post process the findpeaks output but it really does not seem to be worth the effort.
islocalmax(img,1) & islocalmax(img,2)
will find 2d peaks.
You might need to do some processing for the case where a peak is the same height for several adjacent spots. You could do a imclose or dilation, and perhaps a bwmorph()
Or you could start with a dilation and then check for local max and then a bwmorph shrink... something like that.
  1 Comment
ヨナ エマヤ
ヨナ エマヤ on 15 Jun 2021
Thank you for your response.
Using islocalmax like described worked in the desired way.
The first results are very promising. Currently there are still some spots that are not detected (I will try to figure out under which conditions) and others that are detected twice. I will try to do some processing as you described and see if the result improves.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 15 Jun 2021
Show/attach/post your original gray scale image. My guess is that you can threshold to find the bright blobs, then find the centroid and/or weighted centroid with regionprops(). You can also get the mean intensity and the max intensity for each spot using regionprops.. You would not use findpeaks which is used for 1-D signals. Also, using imregionalmax() might not be what you want since this might pinpoint several small regional maxes inside a large spot when you want only one - the weighted centroid. I can give better advice if you attach the actual gray level image you forgot to attach.
See my Image Segmentation Tutorial for a general tutorial about finding bright blobs on dark backgrounds.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!