I1 = imread('1.jpg');
I2 = imread('2.jpg');
I3 = imread('3.jpg');
I4 = imread('4.jpg');

I1 = imresize(I1,0.25,'nearest');
I2 = imresize(I2,0.25,'nearest');
I3 = imresize(I3,0.25,'nearest');
I4 = imresize(I4,0.25,'nearest');


H = [1 0 400; 0 1 100; 0 0 1];
tform = maketform('projective',H');
Base = imtransform(I2,tform,'nearest','xyscale',1,...
                'xdata', [1 2000], 'ydata', [1 1000],...
                'fillvalues', 0);

tform = auto(I1,Base);
Base_tmp = imtransform(I1,tform,'nearest','xyscale',1,...
                'xdata', [1 2000], 'ydata', [1 1000],...
                'fillvalues', 0);
            
Base = gra_proc(Base_tmp,Base);

figure;
imshow(Base);

tform = auto(I3,Base);
Base_tmp = imtransform(I3,tform,'nearest','xyscale',1,...
                'xdata', [1 2000], 'ydata', [1 1000],...
                'fillvalues', 0);
            
Base = gra_proc(Base_tmp,Base);

figure;
imshow(Base);

tform = auto(I4,Base);
Base_tmp = imtransform(I4,tform,'nearest','xyscale',1,...
                'xdata', [1 2000], 'ydata', [1 1000],...
                'fillvalues', 0);
            
Base = gra_proc(Base_tmp,Base);

figure;
imshow(Base);