clc
clear all
img=imread('orignal.bmp');
A=double(img);
[m,n]=size(A);
m1=input('Enter X Value: ');
n1=input('Enter Y Value: ');
B=zeros(m1,n1);
%B=zeros(360,480); %change size to what ever you want
%[m1,n1]=size(B);
a=m1/m;
b=n1/n;
for i=1:m1
for j=1:n1
x0=i/a;
y0=j/b;
x=round(i/a);
y=round(j/b);
x1=x+1;
y1=y+1;
if x==0
x=1;
end
if y==0
y=1;
end
if x >= m
x1=m;
end
if y >= n
y1=n;
end
f1=A(x,y)+(x0-x)*[A(x1,y)-A(x,y)];
f2=A(x,y1)+(x0-x)*[A(x1,y1)-A(x,y1)];
B(i,j)=f1+(y0-y)*(f2-f1);
end
end
imshow(uint8(B));
title('Bilinear');
fprintf('New Size: %d*%d ',m1,n1);
%size(A)
%size(B)
imwrite(uint8(B),'zoom.jpg');
clear all
img=imread('orignal.bmp');
A=double(img);
[m,n]=size(A);
m1=input('Enter X Value: ');
n1=input('Enter Y Value: ');
B=zeros(m1,n1);
%B=zeros(360,480); %change size to what ever you want
%[m1,n1]=size(B);
a=m1/m;
b=n1/n;
for i=1:m1
for j=1:n1
x0=i/a;
y0=j/b;
x=round(i/a);
y=round(j/b);
x1=x+1;
y1=y+1;
if x==0
x=1;
end
if y==0
y=1;
end
if x >= m
x1=m;
end
if y >= n
y1=n;
end
f1=A(x,y)+(x0-x)*[A(x1,y)-A(x,y)];
f2=A(x,y1)+(x0-x)*[A(x1,y1)-A(x,y1)];
B(i,j)=f1+(y0-y)*(f2-f1);
end
end
imshow(uint8(B));
title('Bilinear');
fprintf('New Size: %d*%d ',m1,n1);
%size(A)
%size(B)
imwrite(uint8(B),'zoom.jpg');
No comments:
Post a Comment