How to find the boundaries of the local maxima

6 次查看(过去 30 天)
I have a 2D image (matrix). I have found the local maxima of this image. Now I want to define the boundaries around each local maxima in such a way that I want all the pixels around the local maxima that has the value above 85% of the maximum. Any help would be appreciated.

回答(2 个)

Image Analyst
Image Analyst 2018-2-26
I think you're going to have to use imreconstruct(). Use the maxima binary image as the marker for a mask that is thresholded at 85% of it. If you don't use imreconstruct then you risk getting values selected by the threshold that aren't local maxima. Attach your original image, and local max image if you need more help. How did you get the local maxima? Did you use imregionalmax() or imdilate()?
  1 个评论
MINA
MINA 2018-2-26
I am not sure how I should use imreconstruct(). Could you please help me in that?

请先登录,再进行评论。


MINA
MINA 2018-2-26
编辑:MINA 2018-2-26
This is the function I wrote to find the local maxima. Once I find those maxima I have to draw a boundary around them and take only those pixels which are at least 85% of the peak. And then As you see some peaks are very close to each other so I have to merge them and make only one peak (if they have some shared pixels within their boundaries).
function [location]= Mfind_peak_2D( Image,varargin )
%This function finds the Peak in 2D
p = inputParser;
addParamValue(p,'max_n_loc_max',5);
addParamValue(p,'nb_size',3);
addParamValue(p,'thre',0);
addParamValue(p,'drop',0.15);
parse(p,varargin{:});
p=p.Results;
if sum(isnan(Image(:)))>0
Image(isnan(Image))=0;
end
hLocalMax = vision.LocalMaximaFinder;
hLocalMax.MaximumNumLocalMaxima = p.max_n_loc_max;
hLocalMax.NeighborhoodSize = [p.nb_size p.nb_size];
hLocalMax.Threshold = p.thre;
location = step(hLocalMax, Image);
imagesc(Image); hold on
plot(location(:,1),location(:,2),'rX')
colorbar;
end
%
  1 个评论
Image Analyst
Image Analyst 2018-2-27
You want a boundary around a single pixel? OK, so I'm guessing that the 5 red x's are the local maxima pixels. So you have up to 5 maxima values. When you say 85% of the maxima, which of the 5 maxima are you talking about?
And why didn't you simply use imregionalmax() instead of all that?

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by