Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Finding local maxima in an image

178 views
Skip to first unread message

ma

unread,
Jun 30, 2006, 10:15:25 AM6/30/06
to
Hello,

How can I determine the place of local maxima (minima) on an intensive
image? Is there any function in Matlab that can do this for me? Any paper or
documentation that can help me on this?

Where can I read more about the theory behind 'imhmax'? I don't have access
to the book that comes as reference to this function.

Regards


Pinpress

unread,
Jun 30, 2006, 12:08:17 PM6/30/06
to
ma wrote:
>
>
> Hello,
>
> How can I determine the place of local maxima (minima) on an
> intensive
> image? Is there any function in Matlab that can do this for me? Any
> paper or
> documentation that can help me on this?
>
>

[I,J]=find(im==max(im(:))); should do the work

ma

unread,
Jul 1, 2006, 3:58:06 AM7/1/06
to
Thanks for reply, but I believe it is the maximum of the image and not the
local maxima. Am image have one maxima but may have several local maxima.

Regards

"Pinpress" <sb...@yahoo.com> wrote in message
news:ef3a...@webcrossing.raydaftYaTP...

Brian

unread,
Jul 3, 2006, 10:20:21 AM7/3/06
to
I don't think there's a single function. I think you have two
choices: either a couple of loops, whereby you compare each pixel to
its 8 (or 4) neighbors, or 2) Take the element-by-element product of
4 (or 8) convolutions.

If you decide to do the convolutions (conv2), the image is convolved
with a 3-3 matrix that has 0s everywhere except the center, which is
-1, and one of the neighbors, which is 1. You vary the neighbor
covering each of the 4 or 8 neighbors. Threshold each convolution to
find values > 0; these are pixels that have values less than a
neighbor in a specific position. By ORing (ie, multiplying) the
thresholded convolution results together, you'll be setting equal to
1 only those pixel that are local minima.

It's not pretty, but it gets around the pixel loop. I'd be surprised
if there weren't a better way, but I think you're not going to find a
one-line function.

Ver Versath

unread,
Jul 3, 2006, 10:43:29 AM7/3/06
to
Hallo,
the simplest way (not the fastest though) is to divide your image
into many small subimages and find the maximum of each of them. This
goes via nested loops in x and y. A sample code could look like this:

% image - your image
% seedImage - binary output image with all local maxima = 1
% x,y - size of the images
% wSize - size of the subimage(size of your local area)
% wStep - size of the step (should be <= wSize)

for cntX = 1:wStep:x
%Define x range of the subimage
begX = max((cntX-wSize), 1);
endX = min((cntX+wSize), x);
for cntY = 1:wStep:y
%Define y range of the subimage
begY = max((cntY-wSize), 1);
endY = min((cntY+wSize), y);
%Extract matrix in which to look for local max
tempMatrix = image(begX:endX,begY:endY);
%Find max value in the tempMatrix
[maxVal, maxInd] = maxn(tempMatrix);
%Convert linear indice to subscripts, get real coordinates
[maxSubX, maxSubY] = ind2sub(size(tempMatrix),maxInd);
maxSubX = maxSubX + begX-1; maxSubY = maxSubY + begY-1;
seedImage(maxSubX(1), maxSubY(1), maxSubZ(1)) = 1;
end
end

I use here the maxn function (from the File Exchange) which returns x
and y coordinates of the max value.
Hope this helps,
Versath

0 new messages