Getting RGB values out of an image into a matrix where I can retrieve specific elements
66 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Zachary Steinwachs
el 24 de Feb. de 2021
Comentada: Zachary Steinwachs
el 25 de Feb. de 2021
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
0 comentarios
Respuesta aceptada
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
Más respuestas (0)
Ver también
Categorías
Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!