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

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by M@lik Ali on 4 Jun 2012

Hi all, Can any one tel me the command in matlab to calculate the intensity of image.

Answer by Image Analyst on 4 Jun 2012

Accepted answer

The mean of a particular pixel is just simply the pixel value, since there is only one sample - nothing really to take the mean of:

intensityValue = grayImage(100, 230); meanIntensityValue = mean(grayImage(100, 230));

Here, of course meanIntensityValue will equal intensityValue.

To get the mean of all the pixel values in the entire image, you can do any of these:

meanIntensityValue = mean2(grayImage); meanIntensityValue = mean(grayImage(:)); meanIntensityValue = mean(mean(grayImage));

Show 4 older comments

Image Analyst on 26 Jun 2013

Please mark the discussion as "Answered" if you're done with it. Unless you want to open a can of confusing worms about how the units of an image are not really intensity.

Answer by Adina Stoica on 4 Jun 2012

Well, the intensity of the image is the average of the intensities of all pixels in an image (unless you're doing anything more specific than that). So if you do

mean(imagefile(:))

you should get the intensity of the image.

M@lik Ali on 4 Jun 2012

Adina thanks for your response,

But actually i want to calculate the intensity value of all elements of the images.

someone told me like

intensityValue = grayImage(100, 230);

But in i have to calculate the intensity value of each pixel or total image, i think i can do it by calculating the intensity of each pixel and then add it but i am not sure.

Kindly help me about it..

Answer by Saranya on 30 Jan 2014

hi image analyst i want to measure the intensity profile for gray scale image.. can you help me..?

Show 7 older comments

Image Analyst on 3 Feb 2014

Yes. improfile() can take arguments that are the endpoints of the line.

Jensa on 11 Feb 2014

Hi Image Analyst...Can you help me to find the density profile for my chromosome image..Attaching the image along with this.. http://postimg.org/image/pe5ozahzb/e770bd0c/

## 2 Comments

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/40195#comment_158464

Does anyone further know how to do this for a specific area of pixels? For example, image(100:1:200,100:1:200) for a 100 by 100 pixel area, and get the intensity in this area as an average?

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/40195#comment_158494

Don't use "image" as the name of your variable since it's a function.