Page 76 - Computational Colour Science Using MATLAB
P. 76
IMPLEMENTATIONS AND EXAMPLES 63
end
% compute fy for use later
fy = xyz(2)/white(2);
if (fy > 0.008856)
fy = fy^(1/3);
else
fy = 7.787*fy + 16/116;
end
% compute X
if ((lab(2)/500 + fy)^3 > 0.008856)
xyz(1) = white(1)*(lab(2)/500 + fy)^3;
else
xyz(1) = white(1)*((lab(2)/500 + fy) - 16/116)/7.787;
end
% compute Z
if ((fy - lab(3)/200)^3 > 0.008856)
xyz(3) = white(3)*(fy - lab(3)/200)^3;
else
xyz(3) = white(3)*((fy - lab(3)/200) - 16/116)/7.787;
end
The function xyz2luv computes CIELUV L*u*v* coordinates from tristimulus
values. A typical call would be
[luv] = xyz2luv(xyz,’d65___64’);
where xyz is a 361 column matrix of tristimulus values. The previous discussion
about the selection of the white point in xyz2lab is equally valid in the case of
xyz2luv. An alternative function call is also possible, however, so that the u and
0
v values of the CIE 1976 UCS can also be obtained:
0
[luv, uprime, vprime] = xyz2luv(xyz,’d65___64’);
In MATLAB whenever multiple outputs are returned from a function, typing the
function on its own
xyz2luv(xyz,’d65___64’)
will output only the first of these arguments (in this case the vector luv) and
assign it to the variable ans.