How to store a color and location in a matrix?

조회 수: 3 (최근 30일)
Conner Carriere
Conner Carriere 2021년 2월 5일
편집: KALYAN ACHARJYA 2021년 2월 5일
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.

답변 (1개)

KALYAN ACHARJYA
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.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by