Getting RGB values out of an image into a matrix where I can retrieve specific elements

66 visualizaciones (últimos 30 días)
Hello, I have tried many ways to find the RGB values from an image and put them into a matrix to retrieve it.
============
I = imread('yellowdot.jpg');
imshow(I)
A = imread('yellowdot.jpg');
Red = A(:,:,1);
Red(250,190)
===========
This code grabs the image and displays the picture and then saves the red values into the matrix "Red". When I retrieve the value no matter the x,y values i put into that last line it outputs "120". When I look into the saved matrix at (250,190) from accessing it from that right hand menu of MatLab it read "254" for that same value which is what it should be.
It's saved as "288 X 384 uint"
I dont really know what uint means but that might be why its having a hard time reading it.
Any help is much appreciated, I'm new to matLab so keeping it simple would be great :)
Zach

Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 24 de Feb. de 2021
Editada: KALYAN ACHARJYA el 24 de Feb. de 2021
I = imread('yellowdot.jpg');
imshow(I)
A = imread('yellowdot.jpg');
Red = A(:,:,1);
Till here you are doing it correctly.
Here "Red" is a red plane of the A rgb Image, its a 2D array with datatype uint8 (Unsigned interger 8 Bits). When the data type with uint8, its have maximum value 2^8=256, if Pixels considertion satrt from 0, hence maximum pixel value is 255 in any plane for uint8 data type.
If you check the details of A, it may be shown as
A>> "288 X 384X3 uint8" for 3 channels (3D Array), once the extraction of first planes from the 3rd dimentions, it represents the red plane. Hence it may shows
Red>>"288 X 384 uint8"
2nd Section:
"When I retrieve the value no matter the x,y values i put into that last line it outputs "120"
Red(250,190) represent the pixel value/Matrix value at the incices rows 250 and column 190. May be the given image have same color irrespective of any indices location, please do confirm?
More: If you wish to check the pixel value in differrent positions of the image, you can use the following code (by moving the Mouse cursor)
A = imread('yellowdot.jpg');
Red = A(:,:,1);
imshow(Red)
impixelinfo;
:)
  4 comentarios
Zachary Steinwachs
Zachary Steinwachs el 25 de Feb. de 2021
So I've been checking my outputs with both the matrix and using the "data cursor" feature when the image comes up. Both the reading the table and "data cursor" feature give me the same output of RGB 254 253 2, for the (250,190) cords but when I output it with that command it gives me RBG values seemingly from a different location. However when I have it retrieve cords (190,250) it outputs what it is suppose to output for (250,190). I guess the x and y cords get mixed up when using that command but idk. Below is the image
Zachary Steinwachs
Zachary Steinwachs el 25 de Feb. de 2021
OHHHH is it returning values in (row, column) instead of (X,Y) how would I change that

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Geometric Transformation and Image Registration 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