Page 174 - Computational Colour Science Using MATLAB
P. 174
IMPLEMENTATIONS AND EXAMPLES 161
trainmat(i,19) = trainrgb(i,1)*trainrgb(i,2)*...
trainrgb(i,3);
trainmat(i,20) = 1;
end
% compute the coefficients using the pinv command
a = pinv(trainmat)*traintarget;
% now implement the model
ptraintarget = trainmat*a;
% convert the predicted densities back to XYZ values
for i = 1:729
ptraintarget(i,:) = exp(ptraintarget(i,:)).*white;
end
% compute CIELAB Delta E values
de = zeros(729,1);
for i = 1:729
lab1 = xyz2lab(trainxyz(i,:),’d65___31’);
lab2 = xyz2lab(ptraintarget(i,:),’d65___31’);
de(i,:) = cielabde(lab1, lab2);
end
% no semicoln on this line so that the results are displayed
perf = [min(de) mean(de) max(de)]
% compute the augmented matrix for the test set
testmat = zeros(729,20);
for i = 1:144
testmat(i,1) = testrgb(i,1);
testmat(i,2) = testrgb(i,2);
testmat(i,3) = testrgb(i,3);
testmat(i,4) = testrgb(i,1)*testrgb(i,2);
testmat(i,5) = testrgb(i,1)*testrgb(i,3);
testmat(i,6) = testrgb(i,2)*testrgb(i,3);
testmat(i,7) = testrgb(i,1)*testrgb(i,1);
testmat(i,8) = testrgb(i,2)*testrgb(i,2);
testmat(i,9) = testrgb(i,3)*testrgb(i,3);
testmat(i,10) = testrgb(i,1)*testrgb(i,1)*
testrgb(i,2);
testmat(i,11) = testrgb(i,1)*testrgb(i,1)*
testrgb(i,3);
testmat(i,12) = testrgb(i,2)*testrgb(i,2)*
testrgb(i,1);