Borrar filtros
Borrar filtros

Image processing help. Regarding pixel values and not needing to click on diagram to select pixel.

2 visualizaciones (últimos 30 días)
From what I understand, matlab mostly requires us to click on an image and then it will display the resulting pixel RGB value. Is there a way to let the code run through, finding ALL pixel's individual values without having to click? I do not want to select because I want to iterate through the whole picture.
How do I use code to get just R,G and B respectively of a pixel? Like when a pixel is selected, what code will give only R portion of RGB. I wish to compile RGB together meaning adding R, G and B to get my resulting pixel value.
Please help. Thanks.

Respuesta aceptada

Image Analyst
Image Analyst el 26 de Dic. de 2014
You can read in an image file with imread(). That will get you ALL the image pixel values without having to click on anything.
rgbImage = imread(fullFileName);
To split apart an RGB image into the individual color channels, you can do this:
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
To recombine them into an RGB image again, do this:
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
  7 comentarios
Image Analyst
Image Analyst el 28 de Dic. de 2014
Editada: Image Analyst el 28 de Dic. de 2014
They must be uint8. What does this reveal if you put it right before the second disp():
whos I
whos RED
whos GREEN
whos BLUE
whos total_value
whos array
Try casting to uint16 before summing.
total_Value = uint16(RED) + uint16(GREEN) + uint16(BLUE);
lim -
lim - el 29 de Dic. de 2014
Oh it works now. The problem was that I did not cast it to uint16 before summing. Just adding the "total_Value = uint16(RED) + uint16(GREEN) + uint16(BLUE);" line and it works like I wanted. Thank you.

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by