Page 85 - Computational Colour Science Using MATLAB
P. 85

72                COMPUTING COLOUR DIFFERENCE

                 % using CMC(l:c) 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 CMC deltas
                 % The defaults for paral and parac are 1
                 % see also cielabde, 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
                   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

                 if (nargin<4)
                   disp(’using default values of l:c’)
                   paral=1; parac=1;
                 end

                 % first compute the CIELAB deltas
                 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 - . . .
   80   81   82   83   84   85   86   87   88   89   90