You are on page 1of 2

clc

clear all
close all
img=imread('images.jpg');
figure(1),imshow(uint8(img));
s=.5;
gama=2;
[r c]=size(img(:,:,1));
if(mod(r,2)~=0)
r3=mod(r,2);
r=r-r3;
end
if(mod(c,2)~=0)
c3=mod(c,2);
c=c-c3;
end
r2=(r/2)-1;
c2=(c/2)-1;
imgexp=zeros((r+r2),(c+c2),3);

for z=1:3
x2=0;
y2=0;
for x=1:r+r2
if(mod(x,3)~=0)
x2=x2+1;
y2=1;
end
for y=1:c+c2
if(mod(y,3)==0)
imgexp(x,y,z)=0;
elseif(mod(x,3)==0)
imgexp(x,y,z)=0;
else
imgexp(x,y,z)=img(x2,y2,z);
y2=y2+1;
end
end
end
%% row wise interpolation
for x=1:r+r2
for y=1:3:c+c2-4
Er=imgexp(x,y+3,z)-((imgexp(x,y+1,z)+imgexp(x,y+4,z))/2);
El=imgexp(x,y+1,z)-((imgexp(x,y,z)+imgexp(x,y+3,z))/2);
imgexp(x,y+2,z)=((1-s)*imgexp(x,y+1,z))+(s*imgexp(x,y+3,z))+gama*(((1-s)
*El)+(s*Er))*s*(1-s);

end
end
%% column wise interpolation
for x=1:c+c2
for y=1:3:r+r2-4
Er=imgexp(y+3,x,z)-((imgexp(y+1,x,z)+imgexp(y+4,x,z))/2);
El=imgexp(y+1,x,z)-((imgexp(y,x,z)+imgexp(y+3,x,z))/2);
imgexp(y+2,x,z)=((1-s)*imgexp(y+1,x,z))+(s*imgexp(y+3,x,z))+gama*(((1-s)
*El)+(s*Er))*s*(1-s);
end
end
end
figure(2),imshow(uint8(imgexp));

You might also like