%
% InputPlot.m
%
% Use 100 image series to compute and plot mean [R G B] value for input images
%
% 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'];

bg = 430:15:730;
pc = 435:25:710;

avgInR = zeros(12,21);
avgInG = zeros(12,21);
avgInB = zeros(12,21);

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 and compute mean
		Y = double(X)+1;
		[r,g,b] = ind2rgb(Y,map);

		avgInR(j,i) = mean(mean(r));
		avgInG(j,i) = mean(mean(g));
		avgInB(j,i) = mean(mean(b));

	end
end

avgIn = (avgInR + avgInG + avgInB)./3;
save('avg252Input.mat','avgInR','avgInG','avgInB','avgIn');


% Plot results

load avg252Input.mat;

figure
mesh(bg,pc,avgInR);
title('Input Mean Red Value');
xlabel('Background Wavelength');
ylabel('Target Wavelength');
zlabel('R Values');

figure
mesh(bg,pc,avgInG);
title('Input Mean Green Value');
xlabel('Background Wavelength');
ylabel('Target Wavelength');
zlabel('G Values');

figure
mesh(bg,pc,avgInB);
title('Input Mean Blue Value');
xlabel('Background Wavelength');
ylabel('Target Wavelength');
zlabel('B Values');

figure
mesh(bg,pc,avgIn);
title('Input Mean Overall RGB Value');
xlabel('Background Wavelength');
ylabel('Target Wavelength');
zlabel('Gray Values');

