%
% asymmetricMatchingPlot.m
%
% plot the results of asymmetric color matching for the images
%

load sonyInverseGammaColors;
load olympusInverseGammaColors;

colors = zeros(3,24);
colorsSonyControl = zeros(3,24); 
colorsOlympusControl = zeros(3,24); 

for j=1:3
 colorsSonyControl(j,:) = sonyInverseGammaColors(1,j,:);
 colorsOlympusControl(j,:) = olympusInverseGammaColors(1,j,:);
end

sonyErrors = zeros(1,18);
olympusErrors = zeros(1,18);

sonyOriginalErrors = zeros(1,18);
olympusOriginalErrors = zeros(1,18);

%compute the original error
for i=1:18
 %sony
 for j=1:3
  colors(j,:) = sonyInverseGammaColors(i,j,:);
 end
 sonyOriginalErrors(1,i) = sqrt(sum(sum(((colors - colorsSonyControl).^2)')')/72);
 
 %olympus
 for j=1:3
  colors(j,:) = olympusInverseGammaColors(i,j,:);
 end
 olympusOriginalErrors(1,i) = sqrt(sum(sum(((colors - colorsOlympusControl).^2)')')/72);
 
end

%compute the asymmetric error
for i=1:18
 %sony
 for j=1:3
  colors(j,:) = sonyInverseGammaColors(i,j,:);
 end
 
 [T, error] = asymmetricMatching(colorsSonyControl, colors);
 sonyErrors(1,i) = error;  
 
 %olympus
 for j=1:3
  colors(j,:) = olympusInverseGammaColors(i,j,:);
 end

 [T, error] = asymmetricMatching(colorsOlympusControl, colors);
 olympusErrors(1,i) = error;  
 
end

figure;
hold on;
plot(1:1, sonyErrors(1:1), 'k*');
plot(2:6, sonyErrors(2:6), 'b-');
plot(7:11, sonyErrors(7:11), 'r-');
plot(12:15, sonyErrors(12:15), 'g-');
plot(16:18, sonyErrors(16:18), 'm-');
legend('Control', 'Blue', 'Amber', 'Green', 'Magenta');
title('The average error for asymmetric color matching for Sony camera');
xlabel('Image Index');
ylabel('Average Error');
hold off;

figure;
hold on;
plot(1:1, olympusErrors(1:1), 'k*');
plot(2:6, olympusErrors(2:6), 'b-');
plot(7:11, olympusErrors(7:11), 'r-');
plot(12:15, olympusErrors(12:15), 'g-');
plot(16:18, olympusErrors(16:18), 'm-');
legend('Control', 'Blue', 'Amber', 'Green', 'Magenta');
title('The average error for asymmetric color matching for Olympus camera');
xlabel('Image Index');
ylabel('Average Error');
hold off;

figure;
hold on;
plot(1:1, sonyOriginalErrors(1:1), 'k*');
plot(2:6, sonyOriginalErrors(2:6), 'b-');
plot(7:11, sonyOriginalErrors(7:11), 'r-');
plot(12:15, sonyOriginalErrors(12:15), 'g-');
plot(16:18, sonyOriginalErrors(16:18), 'm-');
legend('Control', 'Blue', 'Amber', 'Green', 'Magenta');
title('The average error for Sony camera');
xlabel('Image Index');
ylabel('Average Error');
hold off;

figure;
hold on;
plot(1:1, olympusOriginalErrors(1:1), 'k*');
plot(2:6, olympusOriginalErrors(2:6), 'b-');
plot(7:11, olympusOriginalErrors(7:11), 'r-');
plot(12:15, olympusOriginalErrors(12:15), 'g-');
plot(16:18, olympusOriginalErrors(16:18), 'm-');
legend('Control', 'Blue', 'Amber', 'Green', 'Magenta');
title('The average error for Olympus camera');
xlabel('Image Index');
ylabel('Average Error');
hold off;

