Double The Size of an Image using Bi-linear Interpolation
%================== Program to double the size of an Image ===================%
A=imread('pic1.tif');
[M N]=size(A);
B=uint8(zeros(2*M,2*N));
for i=1:M
for j=1:N
B(2*i-1,2*j-1)=A(i,j);
B(2*i,2*j-1)=A(i,j);
B(2*i-1,2*j)=A(i,j);
B(2*i,2*j)=A(i,j);
end
end
C=B;
[M N]=size(B);
mask=[0, 1, 0;1, 0, 1;0, 1, 0;];
const_mat=zeros(1,4);
for i=1:M
for j=1:N
mat=zeros(1,4);
S=zeros(4,4);
m=1;
for x=1:3
for y=1:3
if(((i+x-2)<M &&(j+y-2)<N)&&((i+x-2)>0 && (j+y-2)>0))
if(mask(x,y))
S(m,:)=[(i+x-2),(j+y-2),(i+x-2)*(j+y-2),1];
mat(1,m)=B(i+x-2,j+y-2);
m=m+1;
end
end
end
end
const_mat=mat*pinv(S');
C(i,j)=const_mat(1,1)*i+const_mat(1,2)*j+const_mat(1,3)*i*j+const_mat(1,4);
end
end
figure;imshow(A); % displaying input image
figure;imshow(C); % displaying output image
%==================================================================%
Input Image
output Image