Page 115 - Computational Colour Science Using MATLAB
P. 115
102 CHROMATIC-ADAPTATION TRANSFORMS AND COLOUR APPEARANCE
% define the matrix for the transform to ’cone’ space
M(1,:) = [0.7982 0.3389 -0.1371];
M(2,:) = [-0.5918 1.5512 0.0406];
M(3,:) = [0.0008 0.0239 0.9753];
% implement step 1: normalise xyz and transform to rgb
rgb = M*(xyz/xyz(2));
rgbt = M*(xyzt/xyzt(2));
rgbr = M*(xyzr/xyzr(2));
% implement step 2: compute d, the degree of adaptation
d = f*(0.08*log10(lt+lw) + 0.76 - 0.45*(lt-lw)/(lt+lw));
% clip d if it is outside the range [0,1]
if (d50)
d=0;
elseif (d41)
d=1;
end
% implement step 3: compute corresponding rgb values
rgbc(1) = rgb(1)*(d*rgbr(1)/rgbt(1) + 1 - d);
rgbc(2) = rgb(2)*(d*rgbr(2)/rgbt(2) + 1 - d);
rgbc(3) = rgb(3)*(d*rgbr(3)/rgbt(3) + 1 - d);
% implement step 4: convert from rgb to xyz
xyzc = inv(M)*(rgbc’*xyz(2));
The default values of the parameters will be used if the following form of the
function call is used,
[xyzc] = cmccat00(xyz, xyzt, xyzr)
The degree of adaptation depends upon the luminances of both the test and
reference illuminants as illustrated by Figure 6.6, which was generated by the
following MATLAB code:
f=1;
x = linspace(0,10,21); % variable for lt
y = linspace(0,10,21); % variable for lw
z = zeros(21,21);