-
Notifications
You must be signed in to change notification settings - Fork 7
/
deltaLab.m
59 lines (53 loc) · 1.63 KB
/
deltaLab.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
function [d, lab1, lab2] = deltaLab(xyz1, xyz2, whitepoint, exp, k94)
% [d, lab1, lab2] = deltaLab(xyz1, xyz2, whitepoint, exp, k94)
%
% xyz should be in the form [x-plane y-plane z-plane].
% whitepoint is a 3-vector of the xyz values of the white point.
% If not given, use [95.5 100 108.9] as default (not recommended).
%
% exp is the exponent used in the formula. Default is the
% cube root used in standard CIELAB. If specified, use the number
% as exponent.
% k94 is a vector with 3 elements, specifying some viewing
% parameters. If k94 is provided, compute delta E94 instead of the standard
% delta E, using the numbers in k94 as the k parameter (see
% deltaE94). If k94 is only one number, use the default k=[1 1 1].
%
% Functions called: xyz2lab, deltaE94.
%
% Xuemei Zhang 10/26/95
% Last modified 4/15/98
if (nargin<4)
exp = 1/3;
end
if (nargin<3)
disp('Using XYZ values of normalized D65 (95.05, 100, 108.88) as white point.');
disp('You should really provide your own white point data to ensure reasonable results.');
whitepoint = [95.05 100 108.88];
end
m = size(xyz1);
if (m(2)~=3)
xyz1 = reshape(xyz1, prod(m)/3, 3);
xyz2 = reshape(xyz2, prod(m)/3, 3);
end
lab1 = xyz2lab(xyz1, whitepoint, exp);
lab2 = xyz2lab(xyz2, whitepoint, exp);
if (nargin>4)
if (length(k94)<3)
k94 = [1 1 1];
end
% disp('Computing CIE94 Delta E ...');
d = deltaE94(lab1, lab2, k94);
else
% disp('Computing standard Delta E ...');
d = (lab1-lab2)';
d = sqrt(sum(d.*d));
end
if (m(2)~=3)
if (nargout > 1)
lab1 = reshape(lab1, m);
lab2 = reshape(lab2, m);
end
m(length(m)) = m(length(m))/3;
d = reshape(d, m);
end