%
% PerfectReflectorTest1.m
%
% Use 100 image series to test PerfectReflector Algorithm
%
% Hui Li
% 3/7/2000
%

backgroundCol = ['430' '445' '460' '475' '490' '505' '520' '535' '550' '565' '580' '595' '610' '625' '640' '655' '670' '685' '700' '715' '730'];
primeCol = ['435' '460' '485' '510' '535' '560' '585' '610' '635' '660' '685' '710'];

for j = 1:12
	for i = 1:21
		bmin = (i-1)*3+1;
		bmax = i*3;
		pmin = (j-1)*3+1;
		pmax = j*3;
		inputfn = strcat('./image/input',backgroundCol(bmin:bmax),'-',primeCol(pmin:pmax),'.bmp');

		[X,map] = imread(inputfn,'bmp');
		
		% Read into RGB
		Y = double(X)+1;
		[r,g,b] = ind2rgb(Y,map);

		%rgb = [r,g,b];
		%imshow(rgb,map);
		
		[PRr,PRg,PRb] = PerfectReflectorFun(r,g,b);

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

		outputfn = strcat('./PRoutput/PRoutput',backgroundCol(bmin:bmax),'-',primeCol(pmin:pmax),'.bmp');
		
		if backgroundCol(bmin:bmax) == primeCol(pmin:pmax)
			imwrite(PRoutIm, outputfn, 'bmp');
		else
			[PRoutInd, mapOut] = rgb2ind(PRoutIm,256);
			imwrite(PRoutInd, mapOut, outputfn, 'bmp');
		end
		
	end
	
end


