File talk:CIE 1960 UCS, FL4.svg
Jump to navigation
Jump to search
Source code
[edit]N=1000; % size of the image
a = 0.2526 ; b = 0.2534 ; c = 0.3475 ; d = 0.349; % CIE FL4
x=linspace(a,b,N*min(1,(b-a)/(d-c))); % right number of pixels
y=linspace(c,d,N*min(1,(d-c)/(b-a))); % right number of pixels
[u,v,Y]=meshgrid(x,y,50);
xyz=applycform(cat(3,u,v,Y),makecform('uvl2xyz'));
M=max(xyz,[],3);
norm_XYZ=xyz./cat(3,M,M,M);
mean_XYZ=norm_XYZ*0.5./repmat(mean(norm_XYZ,3), [1 1 3]);
srgb=applycform(mean_XYZ,makecform('xyz2srgb'));
image(x,y,srgb);
axis image;
set(gca,'YDir','normal'); % right way up
hold;
[LAMBDA, XFCN, YFCN, ZFCN]=colorMatchFcn('1931_full');
sl=applycform(cat(3,XFCN,YFCN,ZFCN),makecform('xyz2uvl'));
sl_loopx=[sl(:,:,1) sl(:,1,1)]; % make a closed polygon
sl_loopy=[sl(:,:,2) sl(:,1,2)]; % make a closed polygon
set(patch([b a a b sl_loopx b],[d d c c sl_loopy c],[0.5 0.5 0.5]),'EdgeColor','none');
plot(sl_loopx,sl_loopy,'k-'); % k- means solid (-) black (k) line
axis([a b c d]); xlabel('u'); ylabel('v'); shg; grid;
TEMP = 2900:3000; % FL4
[lambda,T]=meshgrid(LAMBDA,TEMP);
c2=1.4387752e+7; % 1.438 at the time the D series was announced
spd=lambda.^(-5)./(exp(c2./(lambda.*T))-1);
XYZbb=spd*[XFCN' YFCN' ZFCN'];
uvbb=applycform(XYZbb./repmat(XYZbb(:,2),[1 3]),makecform('xyz2uvl'));
plot(uvbb(:,1),uvbb(:,2),'Color',[0.5 0.5 0.5],'LineWidth',1.5);
% calculation of white point omitted for brevity
plot(0.2531,0.3477,'xr');
i=[1:10:find(TEMP==2935) find(TEMP==2935):find(TEMP==2945) find(TEMP==2945):10:length(TEMP)]; % for close up on FL4
xi=uvbb(i,1);
yi=uvbb(i,2);
slope=diff(uvbb(:,[1 2]));
a=-slope(i,1)./slope(i,2);
l=5.4e-3./sqrt(1+a.^2); % maximum permissible deviation
line([xi-l xi+l]',[yi-a.*l yi+a.*l]','Color','k','LineWidth',0.25,'LineStyle',':');