Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Finding peak value in 2d array (image)

Subject: Finding peak value in 2d array (image)

From: Gregory

Date: 23 Nov, 2009 15:30:20

Message: 1 of 8

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

Subject: Finding peak value in 2d array (image)

From: Carlos Adrian Vargas Aguilera

Date: 23 Nov, 2009 15:55:19

Message: 2 of 8

Check out extrema2.m

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

Carlos

Subject: Finding peak value in 2d array (image)

From: Bruno Luong

Date: 23 Nov, 2009 16:48:05

Message: 3 of 8

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

Subject: Finding peak value in 2d array (image)

From: ImageAnalyst

Date: 23 Nov, 2009 19:53:49

Message: 4 of 8

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)));

Subject: Finding peak value in 2d array (image)

From: Bruno Luong

Date: 23 Nov, 2009 19:59:19

Message: 5 of 8

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <dafe86c7-8e9f-4dc4-9cf4-024694d94012@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

Subject: Finding peak value in 2d array (image)

From: shlomitz@gmail.com

Date: 24 Jul, 2012 04:39:22

Message: 6 of 8

On Monday, November 23, 2009 7:30:20 AM UTC-8, Gregory wrote:
> 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

you can also try this one:
http://www.mathworks.com/matlabcentral/fileexchange/37388-fast-2d-peak-finder

Subject: Finding peak value in 2d array (image)

From: nate2718281828@gmail.com

Date: 24 Jul, 2012 04:41:43

Message: 7 of 8

On Monday, November 23, 2009 7:30:20 AM UTC-8, Gregory wrote:
> 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
try this one,
http://www.mathworks.com/matlabcentral/fileexchange/37388-fast-2d-peak-finder

Subject: Finding peak value in 2d array (image)

From: nate2718281828@gmail.com

Date: 24 Jul, 2012 04:40:50

Message: 8 of 8

On Monday, November 23, 2009 7:30:20 AM UTC-8, Gregory wrote:
> 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

you can try this peak finder:
http://www.mathworks.com/matlabcentral/fileexchange/37388-fast-2d-peak-finder

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us