Page 84 - Computational Colour Science Using MATLAB
P. 84

IMPLEMENTATIONS AND EXAMPLES                       71

                % lab1 and lab2 must be 3 by 1 or 1 by 3 matrices
                % and contain L*, a* and b* values
                % p is +1 if the hue of the trial (lab2) is anticlockwise
                % from the standard (lab1) and -1 otherwise

                [c1, h1] = car2pol([lab1(2) lab1(3)]);
                [c2, h2] = car2pol([lab2(2) lab2(3)]);
                p = (h2-h1);
                if (p==0)
                  p=1;
                else
                  if (p>180)
                    p = p - 360;
                  end
                  p = p/abs(p);
                end




               The function cmcde operates in a similar way to cielabde but computes the
             CMC(l:c) colour difference. A typical function call would be

                  [de, dl, dc, dh] = cmcde(lab1, lab2, paral, parac);

             where the variables paral and parac represent the parametric values l and c.
             Default values of 1 are used for both l and c if the number of arguments to the
             function is less than four. Note that the component delta values that are also
             returned are the CMC delta values rather than the CIELAB delta values. Note
             also that the MATLAB trigonometric functions expect input in radians and
             therefore the hue angle in degree must be multiplied by the factor p/180 when
             computing the parameter T in Equation (5.14). The dimensions of the CMC
             tolerance ellipsoids are computed based upon the CIELAB values of the first of
             the triplets lab1 which is assumed to be the standard.





                Box 12: cmcde.m


                function [de,dl,dc,dh] = cmcde(lab1,lab2,paral,parac)

                % function [de,dl,dc,dh] = cmcde(lab1,lab2,paral,parac)
                % computes colour difference from CIELAB values
   79   80   81   82   83   84   85   86   87   88   89