From: Gregory on
I'm new to Matlab...
I need to find the peak value stored in a 2d array which is actually an image (640x480). I need to know the row,column, and pixel value of the peak. Ideally I'd like something along the lines of [r,c,p] = findPeak(I).
I've been stumbling around trying to find a solution to what I know is probably a trivial problem. I thought max might do the trick, but I've not been successful.
Thanks
From: Carlos Adrian Vargas Aguilera on
Check out extrema2.m

http://www.mathworks.com/matlabcentral/fileexchange/12275-extrema-m-extrema2-m

Carlos
From: Bruno Luong on
If you need faster code, you might be interested in using a min/max filter on FEX (mex installation required).

z = peaks(500);
% on FEX http://www.mathworks.com/matlabcentral/fileexchange/24705
maxz = minmaxfilt(z,[],'max','same');
[i j] = find(maxz==z);

% Check
surf(z);
hold on;
zmax = z(sub2ind(size(z),i,j));
plot3(j,i,zmax,'vr','MarkerSize',20);

Bruno
From: ImageAnalyst on
For multiple local 2D max of different values, you can use
imregionalmax() if you have the Image Processing Toolbox. For a
global max, you can use the find() function like Bruno showed you. Or
do something like
[rows cols] = find(imageArray == max(max(imageArray)));
From: Bruno Luong on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <dafe86c7-8e9f-4dc4-9cf4-024694d94012(a)e20g2000vbb.googlegroups.com>...
> For a
> global max, you can use the find() function like Bruno showed you.

Accept that my code looks for all *local* maxima (including a global one).

Bruno