How to obtain sum of RGB color values of a pixel?

4 visualizaciones (últimos 30 días)
Anushka
Anushka el 27 de Mayo de 2015
Comentada: John D'Errico el 27 de Mayo de 2015
How to obtain sum of RGB color values of a pixel?
Without using I(:,:,1) ,I(:,:,2),I(:,:,3).
  1 comentario
Stephen23
Stephen23 el 27 de Mayo de 2015
Editada: Stephen23 el 27 de Mayo de 2015
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.

Iniciar sesión para comentar.

Respuesta aceptada

Titus Edelhofer
Titus Edelhofer el 27 de Mayo de 2015
Hi,
something like
sum(I, 3)
?
Titus
  3 comentarios
Titus Edelhofer
Titus Edelhofer el 27 de Mayo de 2015
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
John D'Errico el 27 de Mayo de 2015
Probably the image is uint8, so summing the pixels will overflow. Better might be
sum(double(I),3)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Modify Image Colors en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by