我正在尝试实现双线性插值函数,但由于某种原因它不起作用。这是我的功能:
function [g] = imgscale(data)
a = data;
[row col d] = size(a); %3 dimentional array
zoom=3; %zooming factor
zr=zoom*row;
zc=zoom*col;
for i=1:zr
x=i/zoom;
x1=floor(x);
x2=ceil(x);
if x1==0
x1=1;
end
for j=1:zc
y=j/zoom;
y1=floor(y);
y2=ceil(y);
if y1==0
y1=1;
end
BL=a(x1,y1,:);
TL=a(x1,y2,:);
BR=a(x2,y1,:);
TR=a(x2,y2,:);
R1=((x2-x)/(x2-x1))*BR+((x-x1)/(x2-x1))*BL;
R2=((x2-x)/(x2-x1))*TR+((x-x1)/(x2-x1))*TL;
P=((y2-y)/(y2-y1))*R1+((y-y1)/(y2-y1))*R2;
im_zoom(i,j,:)=p;
end
end
g = im_zoom;
当它变大时,图像中有黑色的行和列。我该如何解决?