Page 82 - Computational Colour Science Using MATLAB
P. 82
IMPLEMENTATIONS AND EXAMPLES 69
DL*, DC* , and DH* , in addition to the overall colour difference. A typical call
ab
ab
would be
[de, dl, dc, dh] = cielabde(lab1, lab2);
where lab1 and lab2 are 361 column matrices containing the L*, a* and b*
values of the standard and trial, respectively. A shorter function call is of course
also valid; thus
[de] = cielabde(lab1, lab2);
can be used if the individual component differences are not required.
Box 10: cielabde.m
function [de,dl,dc,dh] = cielabde(lab1,lab2)
% function [de,dl,dc,dh] = cielabde(lab1,lab2)
% computes colour difference from CIELAB values
% using CIELAB formula
% lab1 and lab2 must be 3 by 1 or 1 by 3 matrices
% and contain L*, a* and b* values
% see also cmcde, cie94de, and cie00de
dim = size(lab1);
if (dim(1) == 1) | (dim(2) == 1)
lab1 = lab1(:)’; % force to be a row matrix
else
disp(’lab1 must be a row matrix’);
return;
end
if (dim(2) *=3)
disp(’lab1 must be 3 by 1 or 1 by 3’);
return;
end
dim = size(lab2);
if (dim(1) == 1) | (dim(2) == 1)
lab2 = lab2(:)’; % force to be a row matrix
else