How to obtain sum of RGB color values of a pixel?
조회 수: 2 (최근 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!