How to obtain sum of RGB color values of a pixel?
4 次查看(过去 30 天)
显示 更早的评论
How to obtain sum of RGB color values of a pixel?
Without using I(:,:,1) ,I(:,:,2),I(:,:,3).
1 个评论
Stephen23
2015-5-27
编辑:Stephen23
2015-5-27
It is important to note that the sum of the R, G, and B values is not the same as the grayscale! This is because each of the R, G, and B values contribute unequally to the luminance, so they cannot be simply summed to get the grayscale equivalent of a color pixel. If you want the grayscale value, then the easiest way is to use rgb2gray.
采纳的回答
Titus Edelhofer
2015-5-27
Hi,
something like
sum(I, 3)
?
Titus
3 个评论
Titus Edelhofer
2015-5-27
Hi,
what do you mean b "not properly". Was there an error? Result not as expected (see comment by Stephen on grayscale)?
Titus
John D'Errico
2015-5-27
Probably the image is uint8, so summing the pixels will overflow. Better might be
sum(double(I),3)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modify Image Colors 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!