program that reads the color value in the CIE xyz color space and represents it on 3d space coordinates

15 views (last 30 days)
i am new to matlab programming my first exercise is to read value in CIE xyz color space and represent it in 3d color space i tried but still not working can someone guide me how to do are not? Thanks very much
lab(:,1)=str2double(get(handles.hesoa,'String'));
lab(:,2)=str2double(get(handles.hesob,'String'));
lab(:,3)=str2double(get(handles.hesol,'String'));
axes(handles.axes1); xlabel('a');
ylabel ('b*');
zlabel ('L*');
axis([-100 100 -100 100 0 100]);
hold on;
x=-100:100;
y=x*0;
z=x*0;
plot3(x,y,z+50,'b','LineWidth',1);
plot3(y,x,z+50,'b','LineWidth',1);
plot3(y,z,x,'b','LineWidth',1);
plot3(lab(:,2),lab(:,3),lab(:,1),'.','Markersize',20);
title('khong gian mau CIExyz');
  1 Comment
DGM
DGM on 6 Jun 2021
You say you want to use a color point in CIEXYZ, but you're using CIELAB. These aren't the same thing. You'll need to specify which you actually want and what the input is. If you're starting with an RGB tuple and you want XYZ, there's no need to use LAB.

Sign in to comment.

Answers (2)

DGM
DGM on 6 Jun 2021
Maybe this is of use.
% generate two clusters of color points
lab1 = randn(100,3).*[40 10 20] + [40 -40 40];
lab2 = randn(100,3).*[40 10 20] + [40 40 -40];
lab = [lab1; lab2];
xlabel('a');
ylabel ('b*');
zlabel ('L*');
hold on;
% plot the points
plot3(lab(:,2),lab(:,3),lab(:,1),'.','Markersize',20);
view(3); grid on;
axis equal
axis([-100 100 -100 100 0 100]);
My comment about whether you want XYZ or LAB still holds. If you want XYZ, just use rgb2xyz() and xyz2rgb().
  2 Comments
thelong le
thelong le on 7 Jun 2021
thank you, I have determined my direction, my exercise now is to read the RGB color value and convert to XYZ , then represent that value in 3d space, after displaying pixels is there a way to colorize that pixel, thanks for your opinion
DGM
DGM on 7 Jun 2021
This is pretty easy with scatter.
% generate two clusters of color points
rgb = min(abs(randn(2000,3).*[0.5 0.3 0.1] + [0 0 0]),1);
rgb = [rgb; 1-rgb];
xyz = rgb2xyz(rgb);
xlabel('X');
ylabel('Z');
zlabel('Y');
hold on;
% plot the points
scatter3(xyz(:,1),xyz(:,3),xyz(:,2),100,rgb,'.');
view(3); grid on;
axis equal
axis([0 1 0 1.1 0 1]);
set(gca,'color','k','gridcolor','w','gridalpha',0.3)
set(gca,'projection','perspective');
I inverted the background so it's easier to see the color of the points. We can check to see if this distribution of points makes sense. MIMT (on the file exchange) has a crude viewing tool called csview().
csview('xyz','alpha',0.2,'invert',1); hold on; % do this before scatter3()
Since all the color points started within the confines of sRGB, their projection into XYZ lies within the projection of the parent space. We only have a few points, but that does appear to hold true.
You don't need to actually use csview(), but I figured I might as well disclose how I made the illustration.

Sign in to comment.


thelong le
thelong le on 8 Jun 2021
last question, i feel embarrassed to ask you a bit too much but if you can help me, that would be great, thank you very much(^^)
I want to read the color value of the input image and then represent the color value of that image in the 3d XYZ color space as shown below via the command.
plotChromaticity("ColorSpace","uv","View",3,"BrightnessThreshold",0).
The final result is a color space with the color points shown below.
You can refer to this link.(https://ch.mathworks.com/help/images/ref/plotchromaticity.html#d123e231937)
thanks bro again

Tags

Community Treasure Hunt

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

Start Hunting!