MATLAB Answers

maximum pixel intensity of image

Asked by Lalit Patil on 2 Oct 2012
Latest activity Commented on by Nonu 007
on 1 Nov 2015 at 6:22

My current project is based on CCD and LASER. i want to calculate maximum intensity of laser strip on ccd.. so please give me a code to find maximum intensity pixel and location of that pixel as row and column..


4 Answers

Answer by Image Analyst
on 2 Oct 2012
 Accepted answer

Try this:

% Generate sample data
imageArray = [ 3 4 5 5 4 4 5 5 3; 5 4 5 5 3 3 3 3 4];
% Find the max value.
maxValue = max(imageArray(:))
% Find all locations where it exists.
[rowsOfMaxes colsOfMaxes] = find(imageArray == maxValue)

That said, this is probably not what you want to do to find the laser spot. You probably want to either do a spatial filter or a threshold, and then binarize and find the centroid of the binary blob. There are some laser tracking programs in the File Exchange:,,,, etc. etc.


Matt J
Answer by Matt J
on 2 Oct 2012
[row,col]=ind2sub(size(image), idx);


Answer by Lalit Patil on 2 Oct 2012

This gives one irritating figure and gives only value of one pixel... The response of this code is same for all figures.. ... and in my image there is more than one pixel that contains same maximum intensity... So, please give modification or anothe code...


Answer by Lalit Patil on 3 Oct 2012

Thank you Image Analyst... This thing works me... Now I want to generate Image array from image in terms of row and column as you have shown.. I tried imread but it gives M*N*3 array... and i require only M*N array.. So please give code or suggestion..


Nonu 007
on 29 Oct 2015 at 6:25

Hey I am doing same analysis. But now i want a cross-section line of beam at highest intensity. Can you suggest me what to do for that... Please reply asap. thanks in advance.

Image Analyst
on 29 Oct 2015 at 10:25

Try improfile().

Nonu 007
on 1 Nov 2015 at 6:22

Hello Image Analyst. I am trying that too but I am not getting a single line of cross section in 2D at highest Peak. Here i am attaching a fig. May be from that you can help me.

I want a cross section line like this from the image at max intensity.

Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!