Page 135 - Computational Colour Science Using MATLAB
P. 135

122          CHARACTERIZATION OF COMPUTER DISPLAYS



                 Box 19: compgog.m

                 function [rgb] = compgog(gogs,dacs)

                 % function [rgb] = compgog(gogs,dacs)
                 % computes the linearized RGB values
                 % from the normalized RGB values
                 % for a given set of gog values
                 % gog is a 2 by 1 matrix that contains the gamma and gain
                 % dacs is an n by 1 matrix that contains the RGB values
                 % rgb is an n by 1 matrix of linearized RGB values

                 gamma = gogs(1);
                 gain = gogs(2);
                 for i = 1:length(dacs)
                   if (gain*dacs(i) + (1-gain)) 5=0
                      rgb(i) = 0;
                   else
                      rgb(i) = (gain*dacs(i) + (1-gain))^gamma;
                   end
                 end
                 % force output to be a column vector
                 rgb = rgb(:);








                 The characterization performance for the eight stimuli defined in Table 7.1 and
               the additional seven test samples (these were not used in the characterization
               procedure) is, on average, just under 1.7 CIELAB units.
                 An additional function, rgb2xyz, has been provided to convert RGB DAC
               values (in the range 0–255) to CIE XYZ values directly. The format of the
               rgb2xyz function is

                    [xyz] = rgb2xyz(dacs, gogvals, A),

               where dacs is a 361 matrix of RGB DAC values and the returned 361 matrix
               xyz contains the predicted CIE values. The 362 matrix gogvals must contain the
               gamma and gain terms of the GOG model for each of the three channels,
               whereas the matrix A must contain the 363 matrix that transforms linearized
               RGB values to XYZ values.
   130   131   132   133   134   135   136   137   138   139   140