内插法:
ratio=input('please input ratio:');
a=imread('1.jpg');
imshow(a);
[row,col,n]=size(a);
r1=round(row*ratio);
c1=round(col*ratio);
b=zeros(r1,c1,n);
for i=1:r1
for j=1:c1
i1=round(i/ratio);
j1=round(j/ratio);
if i1<1
i1=1;
end
if j1<1
j1=1;
end
b(i,j,1)=a(i1,j1,1);
b(i,j,2)=a(i1,j1,2);
b(i,j,3)=a(i1,j1,3);
end
end
b=uint8(b);
figure;
imshow(b);