Page 197 - Computational Colour Science Using MATLAB
P. 197
184 MULTISPECTRAL IMAGING
introduced in Chapter 8 (Cheung and Westland, 2004) were used for this
analysis. Thus RGB values were available from the Agfa StudioCam camera for
192 samples from the Macbeth DC Colorchecker (the training samples) and the
24 samples of the Macbeth Colorchecker (the test samples). The RGB values
were linearized and corrected for spatial non-uniformity of the device and
illumination (see Chapter 8) and were saved along with the reflectance spectra for
each of the samples in a file called agfa.mat.
clear
load agfa.mat
% refldc is a 192 by 31 matrix of reflectance
% reflck is a 24 by 31 matrix of reflectance
% rgbdc is a 192 by 3 matrix of RGB values
% rgbck is a 24 by 3 matrix of RGB values
% compute the basis functions from the Macbeth DC samples
[u,s,v] = svds(refldc,3);
% compute the matrix of weights for the Macbeth DC samples
adc = pinv(v)*refldc’;
% assume that T=Ma and solve for M
M = rgbdc’*pinv(adc);
% use the linear transform M to predict the weights
% from the camera values
padc = inv(M)*rgbdc’;
pack = inv(M)*rgbck’;
% now reconstruct the spectra
prefldc = v*padc;
prefldc = prefldc’;
preflck = v*pack;
preflck = preflck’;
% compute the colour differences for the reconstructions
deck = zeros(24,1);
dedc = zeros(192,1);
for i=1:192
xyzt = r2xyz(refldc(i,:),400,700,’d65___64’);
xyzp = r2xyz(prefldc(i,:),400,700,’d65___64’);
labt = xyz2lab(xyzt,’d65___64’);
labp = xyz2lab(xyzp,’d65___64’);