Averaging an image

2 次查看(过去 30 天)
Niranjan
Niranjan 2011-3-20
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?

采纳的回答

Walter Roberson
Walter Roberson 2011-3-20
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.)
  3 个评论
Walter Roberson
Walter Roberson 2011-3-21
Do you want the average R, the average G, and the average B? If so, that's what the second expression gives.
If you want a single value that averages the intensity of _everything_, then that is what the first expression gives.
If you want a simpler version of the second expression, it would be
mean(reshape(YourImage,[],size(YourImage,3)))
Jan
Jan 2011-3-21
Or even simpler for RGB images: mean(reshape(YourImage, [], 3))

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by