Page 83 - Computational Colour Science Using MATLAB
P. 83
70 COMPUTING COLOUR DIFFERENCE
disp(’lab2 must be a row matrix’);
return;
end
if (dim(2) *=3)
disp(’lab2 must be 3 by 1 or 1 by 3’);
return;
end
dl = lab2(1)-lab1(1);
dc = sqrt(lab2(2)^2 + lab2(3)^2) - sqrt(lab1(2)^2 + . . .
lab1(3)^2);
dh = sqrt((lab2(2)-lab1(2))^2 + (lab2(3)-lab1(3))^2 - . . .
dc^2);
% get the polarity of the dh term
dh = dh*dhpolarity(lab1,lab2);
de = sqrt(dl^2 + dc^2 + dh^2);
The function cielabde uses Equation (5.12) to compute the hue difference. As
previously mentioned this returns the magnitude of the hue difference but the
sign is indeterminate. A separate function has therefore been written called
dhpolarity which returns +1 if the trial is anti-clockwise from the standard and
1 if the trial is clockwise from the standard. The format for this function is
[p] = dhpolarity(lab1, lab2);
where lab1 and lab2 are the 361 column matrices containing the L*, a* and b*
values of the standard and trial, respectively.
Box 11: dhpolarity.m
function [p] = dhpolarity(lab1,lab2)
% function [p] = dhpolarity(lab1,lab2)
% computes polarity of hue difference