How to store a color and location in a matrix?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to locate the colors in this image and put them into a matrix. My thoughts were to somehow define the colors, then mark their location and put them into a 3x3 matrix. I also have a BW image of this. This is for a Rubiks cube, so all sides will have to be checked like this, then be compiled into a 3d model of the cube. From there I should be able to figure out a way to solve it.
0 comentarios
Respuestas (1)
KALYAN ACHARJYA
el 5 de Feb. de 2021
Editada: KALYAN ACHARJYA
el 5 de Feb. de 2021
"How to store a color and location in a matrix?"
Lets say image is "imRGB"
[r,c,ch]=size(imRGB);
R_data=double(imRGB(:,:,1));
G_data=double(imRGB(:,:,2));
B_data=double(imRGB(:,:,3));
R_data=repelem(1:r,c);
C_data=repmat(1:c,[1,r]);
Save the all Data in the Following Format
% [Row, Column, Red Comp,Green Comp, Blue Comp]
Image_data=[R_data',C_data',R_data,G_data,B_data]
Next Save the Image data in csv or excel, as per requirement
Use writematrix or write table or see the other Matlab functions.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!