MATLAB: Averaging an image

averagingimageimage processingImage Processing Toolboximage segmentation

A basic Image Processing question . How can I average the values or RGB for an input color image? If the input is a color image, the output I need is just the average value of RGB in the entire image. How can I do it?

Best Answer

One possible interpretation:
mean(YourImage(:))
Another possible interpretation:
mean(reshape(YourImage, size(YourImage,1) * size(YourImage,2), size(YourImage,3)))
Which you choose depends on whether you need the average R separate from the average G and average B (second expression) or if you are looking for the single over-all average value (first expression.)
Related Question