Page 88 - Computational Colour Science Using MATLAB
P. 88
IMPLEMENTATIONS AND EXAMPLES 75
[c,h] = car2pol([lab1(2) lab1(3)]);
% require C*ab and H*ab of standard
Cweight = 1.0 + 0.045*c;
Hweight = 1.0 + 0.015*c;
dl = dl/Lweight;
dc = dc/Cweight;
dh = dh/Hweight;
de = sqrt(dl^2 + dc^2 + dh^2);
Finally, the function cie00de implements the CIEDE2000 colour-difference
metric:
[de, dl, dc, dh] = cie00de(lab1, lab2, paral, parac,
parah).
The CIEDE2000 formula allows for three parametric terms for lightness, chroma
and hue weightings, respectively. The default values for these parameters are all
set to unity. The implementation of the CIEDE2000 formula requires that the
hue values of the standard and trial be averaged. But the arithmetic mean cannot
simply be computed directly since this would give a mean hue of 1858 for the two
hues 208 and 3508, whereas the true average hue would be 58. The approach
taken here is to make use of the pol2car (Box 9) and car2pol (Box 8) functions.
Polar representations are converted to cartesian representations so that the
simple arithmetic means may be computed before returning to the polar
representation to recover the average hue (see Box 13).
In this code an alternative procedure has been implemented to compute the
hue difference:
1=2
DH ¼ 2ðC T C S Þ sinðDh=2Þ, ð5.17Þ
where Dh is the hue of the trial minus the hue of the standard. This method gives
a relatively simple way to compute DH but a correction is still required to ensure
the correct sign is always computed. The correction is to subtract 360 from Dh if
Dh4180.
Box 14: cie00de.m
function [de,dl,dc,dh] = cie00de(lab1,lab2,paral,
parac,parah)