Page 56 - Computational Colour Science Using MATLAB
P. 56

IMPLEMENTATIONS AND EXAMPLES                       43

                  cie = f2___31;
                elseif strcmp(’f7___64’, obs)
                  cie = f7___64;
                elseif strcmp(’f7___31’, obs)
                  cie = f7___31;
                elseif strcmp(’f9___64’, obs)
                  cie = f9___64;
                elseif strcmp(’f9___31’, obs)
                  cie = f9___31;
                else
                  disp(’unknown option obs’);
                  disp(’use d65___64 for D65 and 1964 observer’); return;
                end

                % check dimensions of P
                dim = size(p);
                if (dim(1) == 1) | (dim(2) == 1)
                  p = p(:)’; % force to be a row matrix
                else
                  disp(’p must be a row matrix’);
                  return;
                end

                N = ((endlam-startlam)/10 + 1);
                if (length(p) *=N)
                  disp(’check dimensions of p’); return;
                end


                % deal with possible truncation of reflectance
                index1 = (startlam - 360)/10 + 1;
                if (index1 4 1)
                  cie(index1,:) = cie(index1,:) + sum(cie(1:index1-
                  1,:));
                end
                index2 = index1 + N - 1;
                if (index2 5 43)
                  cie(index2,:) = cie(index2,:) + sum(cie(index2+
                  1:43,:));
                end
                cie = cie(index1:index2,:);


                xyz = (p*cie)*100/sum(cie(:,2));
   51   52   53   54   55   56   57   58   59   60   61