program that reads the color value in the CIE xyz color space and represents it on 3d space coordinates
8 views (last 30 days)
Show older comments
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
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.
Answers (2)
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]);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/643565/image.png)
My comment about whether you want XYZ or LAB still holds. If you want XYZ, just use rgb2xyz() and xyz2rgb().
2 Comments
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');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/644500/image.png)
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()
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/644505/image.png)
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!