clear all;
close all;

% Get original image, color-casted image and forced Specular
% Reflection Assumption image
OriginalMacbethGreen

CameraGamma = 1.8004;
DisplayGamma = 2.7;

newImage = flipud(rot90(reshape(1:24,6,4)));

% Get camera image
J=imread('IMAGES/1_5green.bmp','bmp');
K=reindexImage(J);
K=scale(K,0,1);
Klinear = K.^CameraGamma;
K=K.^(CameraGamma/DisplayGamma);
figure
colormap(K); image(newImage);
title('Camera Image');

% Plot Y-component of camera image,original image,Specular
% Reflection color-balanced image and color-casted image

KXYZ = inv(xyz2rgb)*Klinear';                  % Camera luminance
macXYZ = inv(xyz2rgb)*macbethLinearRGB1;       % Original luminance 
macbethXYZ1 = inv(xyz2rgb)*macbethRGBCast;     % Cast luminance
macbethXYZ2 = inv(xyz2rgb)*SRbalanced;         % SR balanced luminance


figure
plot(macXYZ(2,:),'r+-')
hold on
plot(KXYZ(2,:),'b*-')
hold on
plot(macbethXYZ1(2,:),'go-')
hold on
plot(macbethXYZ2(2,:),'ks-')
legend('original', 'camera','cast','SR output');
title('Luminance Comparison');


figure;
subplot(2,2,1)
plot(macbethLinearRGB1(1,:),'r+-');
hold on
plot(macbethLinearRGB1(2,:),'g+-');
hold on
plot(macbethLinearRGB1(3,:),'b+-');
hold off
title('RGB values for Original Image');
  
subplot(2,2,2)  
plot(macbethRGBCast(1,:),'r+-');
hold on
plot(macbethRGBCast(2,:),'g+-');
hold on
plot(macbethRGBCast(3,:),'b+-');
hold off  
title('RGB values for cast Image');
    
subplot(2,2,3)
plot(SRbalanced(1,:),'r+-');
hold on
plot(SRbalanced(2,:),'g+-');
hold on
plot(SRbalanced(3,:),'b+-');
hold off
title('RGB values for SRA balanced Image');

subplot(2,2,4)
plot(K(:,1),'r+-')
hold on
plot(K(:,2),'g+-')
hold on
plot(K(:,3),'b+-')
hold off
legend('R','G','B');
title('RGB Plot for Camera Image');
  
