Page 87 - Computational Colour Science Using MATLAB
P. 87

74                COMPUTING COLOUR DIFFERENCE

                 % computes colour difference from CIELAB values
                 % using the CIE94 formula
                 % lab1 and lab2 must be 3 by 1 or 1 by 3 matrices
                 % and contain L*, a* and b* values
                 % The dl, dc and dh components are CIE94 deltas
                 % see also cielabde, cmcde, 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
                   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);

                 % need to compute the weights
                 Lweight = 1.0;
   82   83   84   85   86   87   88   89   90   91   92