How to store a color and location in a matrix?

1 visualizzazione (ultimi 30 giorni)
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.

Risposte (1)

KALYAN ACHARJYA
KALYAN ACHARJYA il 5 Feb 2021
Modificato: KALYAN ACHARJYA il 5 Feb 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.

Community Treasure Hunt

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

Start Hunting!

Translated by