Page 110 - Computational Colour Science Using MATLAB
P. 110
IMPLEMENTATIONS AND EXAMPLES 97
Box 15: cmccat97.m
function [xyzc] = cmccat97(xyz,xyzt,xyzr,la,f)
% function [xyzc] = cmccat97(xyz,xyzt,xyzr,la,f)
% implements the CMCCAT97 chromatic adaptation transform
% operates on 1 by 3 matrix xyz containing tristimulus
% values of the stimulus under the test illuminant
% xyzt and xyzr are 1 by 3 matrices containing the
% white points for the test and reference conditions
% f has default value 1
% la is the luminance of the adapting test field
% and has default value of 100
% xyzc contains the tristimulus values of the
% stimulus under the reference illuminant
% see also cmccat00
% check the arguments
xyz = xyz(:); % force to be a column matrix
xyzt = xyzt(:); % force to be a column matrix
xyzr = xyzr(:); % force to be a column matrix
if (length(xyz) *=3)
disp(’first argument must be 3 by 1 or 1 by 3’); return;
end
if (length(xyzt) *=3)
disp(’second argument must be 3 by 1 or 1 by 3’); return;
end
if (length(xyzr) *=3)
disp(’third argument must be 3 by 1 or 1 by 3’); return;
end
if (nargin54)
disp(’using default values of LA and F’)
la = 100.0; f = 1.0;
end
% define the matrix for the transform to ’cone’ space
M(1,:) = [0.8951 0.2664 -0.1614];
M(2,:) = [-0.7502 1.7135 0.0367];
M(3,:) = [0.0389 -0.0685 1.0296];