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..

 Réponse acceptée

Image Analyst
Image Analyst le 2 Oct 2012

2 votes

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: http://www.mathworks.com/matlabcentral/fileexchange/32492-laser-dot-isolation, http://www.mathworks.com/matlabcentral/fileexchange/33666-simple-particle-filter-demo, http://www.mathworks.com/matlabcentral/fileexchange/17960-particle-filter-color-tracker, http://www.mathworks.com/matlabcentral/fileexchange/31463-simple-demo-program-for-color-based-tracking, etc. etc.

Plus de réponses (4)

Matt J
Matt J le 2 Oct 2012

0 votes

[maxval,idx]=max(image(:));
[row,col]=ind2sub(size(image), idx);
Lalit Patil
Lalit Patil le 2 Oct 2012

0 votes

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...
Lalit Patil
Lalit Patil le 3 Oct 2012

0 votes

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..

5 commentaires

Lalit Patil
Lalit Patil le 3 Oct 2012
Ok... Thank you image analyst... It has been solved... I = imread('Image'); i = I(:,:,3);
Image Analyst
Image Analyst le 3 Oct 2012
Yes, taking the blue channel will give you the best contrast for a red laser. Of course that doesn't solve the location (centroid) problem.
Nonu 007
Nonu 007 le 29 Oct 2015
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
Image Analyst le 29 Oct 2015
Try improfile().
Nonu 007
Nonu 007 le 1 Nov 2015
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.

Connectez-vous pour commenter.

Shel
Shel le 10 Oct 2018

0 votes

Hi, I am using max(I(:)) on my image but the error "Index exceeds matrix dimensions. " shows up ... do you know what the problem is?

1 commentaire

Matt J
Matt J le 10 Oct 2018
Modifié(e) : Matt J le 10 Oct 2018
You've probably created a variable named 'max' previously in your workspace, which Matlab is trying to index.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by