program that reads the color value in the CIE xyz color space and represents it on 3d space coordinates
15 次查看(过去 30 天)
显示 更早的评论
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 个评论
DGM
2021-6-6
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.
回答(2 个)
DGM
2021-6-6
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 个评论
DGM
2021-6-7
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!