clear,close all;

ir1 = imread('IR1.BMP');
ir2 = imread('IR2.BMP');
ir3 = imread('IR3.BMP');
ir4 = imread('IR4.BMP');
ir5 = imread('IR5.BMP');
ir6 = imread('IR6.BMP');
ir7 = imread('IR7.BMP');
ir8 = imread('IR8.BMP');

img = imread('Pic1.bmp');

profile = img(58:340,624:624,:);

vectorcol(:,1) = profile(:,1,1);
vectorcol(:,2) = profile(:,1,2);
vectorcol(:,3) = profile(:,1,3);

vectorcol(182,:) = [0,239,255];
vectorcol(214,:) = vectorcol(213,:);

blue = vectorcol(:,3);
green = vectorcol(:,2);
red = vectorcol(:,1);

% figure(1)
% hold on;
% plot(blue,'b');
% plot(green,'g');
% plot(red,'r');
% hold off;

figure(1)
imshow(ir1);

colormap = vectorcol;

tic;
irgray1 = convert2gray(ir1,colormap,' ir1');
irgray1i = irgray1;
irgray1 = im2double(irgray1/length(colormap(:,1)));
toc;
tic;
irgray2 = convert2gray(ir2,colormap,' ir2');
irgray2 = im2double(irgray2/length(colormap(:,1)));
toc;
tic;
irgray3 = convert2gray(ir3,colormap,' ir3');
irgray3 = im2double(irgray3/length(colormap(:,1)));
toc;
tic;
irgray4 = convert2gray(ir4,colormap,' ir4');
irgray4 = im2double(irgray4/length(colormap(:,1)));
toc;
tic;
irgray5 = convert2gray(ir5,colormap,' ir5');
irgray5 = im2double(irgray5/length(colormap(:,1)));
toc;
tic;
irgray6 = convert2gray(ir6,colormap,' ir6');
irgray6 = im2double(irgray6/length(colormap(:,1)));
toc;
tic;
irgray7 = convert2gray(ir7,colormap,' ir7');
irgray7 = im2double(irgray7/length(colormap(:,1)));
toc;
tic;
irgray8 = convert2gray(ir8,colormap,' ir8');
irgray8 = im2double(irgray8/length(colormap(:,1)));
toc;


wiener = wiener2(irgray1i,[2,2]);
wiener = wiener2(wiener,[2,2]);
wiener = wiener2(wiener,[2,2]);
wiener = wiener2(wiener,[2,2]);
wiener = wiener2(wiener,[2,2]);
wiener = wiener2(wiener,[2,2]);
moy = sum(irgray1(:,259:300),2)/(300-259+1);

figure(2)
hold on;
plot(moy,'red','LineWidth',2);
plot(irgray1(:,270));
hold off;

moy2 = sum(irgray1(259:300,:),1)/(300-259+1);

figure(3)
hold on;
plot(moy2,'red','LineWidth',2);
plot(irgray1(270,:));
hold off;

figure(4)
imshow(irgray1)

figure(5)
imshow(irgray2)

figure(6)
imshow(irgray3)

figure(7)
imshow(irgray4)

figure(8)
imshow(irgray5)

figure(9)
imshow(irgray6)

figure(10)
imshow(irgray7)

figure(11)
imshow(irgray8)

moyir3 = sum(irgray3(185:229,1:500),1)/(229-185+1);

figure(12)
hold on;
plot(moyir3,'red','LineWidth',2);
plot(irgray3(200,1:500)');
hold off;

moy2ir3 = sum(irgray3(:,245:290),2)/(290-245+1);

figure(13)
hold on;
plot(moy2ir3,'red','LineWidth',2);
plot(irgray3(:,265));
hold off;

map = jet(length(colormap(:,1)));

figure(14)
image(wiener)






