How to store a color and location in a matrix?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
KALYAN ACHARJYA
2021-2-5
编辑:KALYAN ACHARJYA
2021-2-5
"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 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!