MATLAB: How to calculate the mean of an image

image processingmean

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

Best Answer

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.