% Correlation Interpolator Simulation
% Gary Embler, 05/09/01

%bmpname = input('Enter name of bitmap to interpolate > ','s');
%Pix = double(imread(bmpname, 'bmp'));

Pix_cor = double(imread('lighthouseraw.bmp', 'bmp'));

%Pix_uncor = double(imread('lighthousebilin.bmp', 'bmp'));

%outname = input('Enter the name you want for the final BMP file ','s');

%Pix = zeros;

%threshold_scale = .75;
%Pix = correlation0(Pix);
%Pix = correlation1(Pix, fix(threshold_scale * 1275));
%Pix = correlation2(Pix, fix(threshold_scale * 1275), fix(threshold_scale * 1785));
%Pix = correlation3(Pix, fix(threshold_scale * 765),  fix(threshold_scale * 1020));

%threshold_scale = 1;
%Pix_uncor = correlation0(Pix);
%Pix_uncor = correlation1(Pix_uncor, fix(threshold_scale * 1275));
%Pix_uncor = correlation2(Pix_uncor, fix(threshold_scale * 1275), fix(threshold_scale * 1785));
%Pix_uncor = correlation3(Pix_uncor, fix(threshold_scale * 765),  fix(threshold_scale * 1020));

threshold_adj = 255;

Pix_cor = correlation0(Pix);

%Pix_cor = correlation1(Pix_cor, (1275 - threshold_adj));
%Pix_cor = correlation1_1(Pix_cor, (1275 - threshold_adj));
Pix_cor = correlation1_2(Pix_cor, (1275));
%Pix_cor = correlation1_3(Pix_cor, (1275 - threshold_adj));

%Pix_cor = correlation2(Pix_cor, (1275 - threshold_adj), (2295 - threshold_adj));
%Pix_cor = correlation2_1(Pix_cor, (1275 - threshold_adj));
Pix_cor = correlation2_2(Pix_cor, (765));
%Pix_cor = correlation2_3(Pix_cor, (765 - threshold_adj));

Pix_cor = correlation3(Pix_cor, (765), (1020));

%Pix_cor = correlation4(Pix_cor);
%Pix_cor = correlation4_1(Pix_cor);

%Pix_cor = scalarmedian3x3(Pix_cor);
%Pix_cor = scalarmedian3x3_1(Pix_cor);

%Pix_diff = abs(Pix_cor - Pix_uncor);

%Pix_diff1 = clip((Pix_cor - Pix_uncor), 0, 255);

%Pix_diff2 = clip((Pix_uncor - Pix_cor), 0, 255);

%imwrite(uint8(Pix_uncor), 'lighthouseuncor.bmp', 'bmp');

imwrite(uint8(Pix_cor), 'lighthouseuncor_2.bmp', 'bmp');

%imwrite(uint8(Pix_diff1), 'lighthousediff1.bmp', 'bmp');

%imwrite(uint8(Pix_diff2), 'lighthousediff2.bmp', 'bmp');
