# How to calculate the mean of an image?

138 views (last 30 days)

Show older comments

bh dhouha
on 16 Feb 2015

Commented: Kweku Nkrumah
on 15 Jun 2018

How to calculate the mean of an image? Does the code mean2(img) give the right result?

##### 0 Comments

### Accepted Answer

Image Analyst
on 16 Feb 2015

To calculate the mean of all pixels in the image, without regard to what color channel they came from (if it's a color image), you do

meanIntensity = mean(img(:));

What you did will not do it, as I'm sure you found out.

##### 2 Comments

Image Analyst
on 16 Feb 2015

### More Answers (1)

Rashmi.D Jeya kumar
on 8 Jan 2018

meanval = mean2(I) you can get mean value of an image

##### 3 Comments

Image Analyst
on 13 Jun 2018

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!