According to my understanding you want to calculate mean of all pixels in the image and it's a greyscale image.
So if your image is given by img you can use the function mean in the manner given below:
meanIntensity = mean(img(:));
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!