[f949a5]: / bilinear.m

Download this file

47 lines (38 with data), 1.1 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function [im_zoom] = bilinear( array_recon )
%bilinear interpolation of an image is done here
a=array_recon;
factor=1; %zooming factor
[m n d] = size(a); %2 dimentional array values
rows=factor*m;
columns=factor*n;
for i=1:rows
x=i/factor;
x1=floor(x); %bilinear in X direction
x2=ceil(x);
if x1==0
x1=1;
end
xrem=rem(x,1);
for j=1:columns
y=j/factor;
y1=floor(y); %bilinear in Y direction
y2=ceil(y);
if y1==0
y1=1;
end
yrem=rem(y,1);
BottomLeft=a(x1,y1,:);
TopLeft=a(x1,y2,:);
BottomRight=a(x2,y1,:);
TopRight=a(x2,y2,:);
R1=BottomRight*yrem+BottomLeft*(1-yrem);
R2=TopRight*yrem+TopLeft*(1-yrem);
im_zoom(i,j)=R1*xrem+R2*(1-xrem);
end
end
%size(im_zoom)
%size(imagebig)
%ssd=sum(sum(sum((imagebig-im_zoom).*(imagebig-im_zoom))))
%imwrite(im_zoom,'bilinear zoom.png');
%imshow(im_zoom);
end