%
% PerfectReflectorTest2.m
%
% Test PerfectReflector algorithm for 2 real images
%
% Hui Li
% 3/7/2000
%

% First Image
im = imread('ST1GammaInv.jpg','jpg');
im = double(im)./256;
imshow(im);
		
% Read into RGB
r = im(:,:,1);
g = im(:,:,2);
b = im(:,:,3);

[PRr,PRg,PRb] = PerfectReflectorFun(r,g,b);

PRoutIm(:,:,1) = PRr;
PRoutIm(:,:,2) = PRg;
PRoutIm(:,:,3) = PRb;
imshow(PRoutIm);

imwrite(PRoutIm, './PRoutput/PRStanfordTower1.jpg', 'jpg');

avgIn1RGB = [mean(mean(r)) mean(mean(g)) mean(mean(b))];
avgPR1RGB = [mean(mean(PRr)) mean(mean(PRg)) mean(mean(PRb))];
avgIn1 = mean([mean(mean(r)) mean(mean(g)) mean(mean(b))]);
avgPR1 = mean([mean(mean(PRr)) mean(mean(PRg)) mean(mean(PRb))]);


% Second image
im = imread('ST2GammaInv.jpg','jpg');
im = double(im)./256;
imshow(im);
		
% Read into RGB
r = im(:,:,1);
g = im(:,:,2);
b = im(:,:,3);

[PRr,PRg,PRb] = PerfectReflectorFun(r,g,b);

PRoutIm(:,:,1) = PRr;
PRoutIm(:,:,2) = PRg;
PRoutIm(:,:,3) = PRb;
imshow(PRoutIm);

imwrite(PRoutIm, './PRoutput/PRStanfordTower2.jpg', 'jpg');

avgIn2RGB = [mean(mean(r)) mean(mean(g)) mean(mean(b))];
avgPR2RGB = [mean(mean(PRr)) mean(mean(PRg)) mean(mean(PRb))];
avgIn2 = mean([mean(mean(r)) mean(mean(g)) mean(mean(b))]);
avgPR2 = mean([mean(mean(PRr)) mean(mean(PRg)) mean(mean(PRb))]);
