Page 195 - Computational Colour Science Using MATLAB
P. 195

182                   MULTISPECTRAL IMAGING
               where, the matrix XYZ is an n63 matrix of tristimulus values and obs is a string
               that defines the illuminant/observer combination (e.g. ‘d65_64’). A matrix P is
               returned with the reflectance values with size 316n.




                 Box 26: xyz2r.m


                 function [P] = xyz2r(XYZ, obs)

                 % function [P] = xyz2r(XYZ, obs)
                 % estimates reflectance P from XYZ trimulus values
                 % matrix XYZ must be n by 3
                 % illuminants A, C, D50, D55, D65, D75, F2, F7, F9
                 % set obs to ’d65___64 for D65 and 1964, for example
                 % matrix P is returned as an n by 31 matrix

                 % check dimensions of XYZ
                 dim = size(XYZ);
                 if (dim(2) *=3)
                   disp(’XYZ must be n by 3’);
                   return;
                 end


                 load evectors.mat
                 % loads the 31 by 3 matrix v containing three basis
                 functions

                 load weights % contains the tables of weights
                 if strcmp(’a___64’,obs)
                   cie = a___64;
                 elseif strcmp(’a___31’, obs)
                   cie = a___31;
                 elseif strcmp(’c___64’, obs)
                   cie = a___64;
                 elseif strcmp(’c___31’, obs)
                   cie = c___31;
                 elseif strcmp(’d50___64’, obs)
                   cie = d50___64;
                 elseif strcmp(’d___50’, obs)
                   cie = d___50;
                 elseif strcmp(’d55___64’, obs)
                   cie = d55___64;
   190   191   192   193   194   195   196   197   198   199   200