Page 90 - Computational Colour Science Using MATLAB
P. 90

IMPLEMENTATIONS AND EXAMPLES                       77

                [c1,h1] = car2pol([lab1(2) lab1(3)]);
                [c2,h2] = car2pol([lab2(2) lab2(3)]);
                meanC = (c2+c1)/2;


                % compute the G factor using the arithmetic mean chroma
                G = 0.5 - 0.5*sqrt((meanC^7)/(meanC^7 + 25^7));


                % transform the a* values
                lab1(2) = (1 + G)*lab1(2);
                lab2(2) = (1 + G)*lab2(2);
                % recompute the polar coordinates using the new a*
                [c1,h1] = car2pol([lab1(2) lab1(3)]);
                [c2,h2] = car2pol([lab2(2) lab2(3)]);

                % compute the mean values for use later
                meanC = (c2+c1)/2;
                meanL = (lab2(1)+lab1(1))/2;
                [a1,b1] = pol2car([1,h1]);
                [a2,b2] = pol2car([1,h2]);
                a = (a1+a2)/2;
                b = (b1+b2)/2;
                [c,meanH] = car2pol([a b]);

                % compute the basic delta values
                dh = (h2-h1);
                if (dh>180)
                  dh = dh - 360;
                end

                dl = lab2(1)-lab1(1);
                dc = c2-c1;
                dh = 2*sqrt(c1*c2)*sin((dh/2)*pi/180);

                T = 1 - 0.17*cos((meanH-30)*pi/180) + 0.24*cos((2*-...
                meanH)*pi/180);
                T = T + 0.32*cos((3*meanH + 6)*pi/180) - ...
                0.20*cos((4*meanH - 63)*pi/180);

                dthe = 30*exp(-((meanH-275)/25)^2);
                rc = 2*sqrt((meanC^7)/(meanC^7 + 25^7));
                rt = -sin(2*dthe*pi/180)*rc;
   85   86   87   88   89   90   91   92   93   94   95