%
% computeXYZ.m
%
% compute the XYZ of all the color patches
%

load xyz;
load spd/filtered_light_spd;
load macbethChart;

% there are 18 images, 3 for XYZ, and 24 patches
macbethXYZ_filters = zeros(3,24,18);

xyz = xyz';

for i=1:18
 % reflected is 361x24
 reflected = diag(filtered_light_spd(i,:))*macbethChart;
 macbethXYZ_filters(:,:,i) = xyz*reflected;
 whiteY = macbethXYZ_filters(2,19,i);
 macbethXYZ_filters(:,:,i) = macbethXYZ_filters(:,:,i)*100/whiteY;
end

save macbethXYZ_filters macbethXYZ_filters;
