Can anyone explain why the empty or black holes (or squares) disappear as I add more products (of the weighting function-Wx and pixels values - Nx) in the Y(i,j) sum ?
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I do need your help! Here's the source code that does the bilinear interpolation:
_I = imread('LENNA128.bmp');
[originheight, originwidth] = size(I);
ratio = 2;
H = ratio * originheight;
W = ratio * originwidth;
Y = zeros(H,W);
hscale = originheight/H;
wscale = originwidth/W;
for i = 1:H;
y = hscale*i;
for j = 1:W;
x = wscale*j;
if(floor(x)==0||floor(y)==0||floor(x)==originwidth floor(y)==originheight)
Y(i,j) = I(ceil(y),ceil(x));
else
x1=floor(x);
x2=x1+1;
y2=floor(y);
y1=y2+1;
N1=I(y2,x1);
N2=I(y2,x2);
N3=I(y1,x2);
N4=I(y1,x1);
W4 = (y-y2)*(x2-x);
W3 = (y-y2)*(x-x1);
W1 = (y1-y)*(x2-x);
W2 = (y1-y)*(x-x1);
Y(i,j) = N1*W1 + N2*W2 + N3*W3 + N4*W4;
end
end
end
Y = uint8(Y);
imshow(Y)
My questions are: When I modify the (second) Y(i,j) sum to Y(i,j) = N1 * W1, I obtain an incompletely interpolated image with many empty holes as shown in Figure(W1), crossing each other. Again, when I change Y(i,j) again and make it like this Y(i,j) = N1 * W1 + N2 * W2, I obtain an incompletely interpolated image, this time, with only empty straight lines. The first situation seems to repeat when I add N3 * W3 to Y(i,j) = N1 * W1 + N2 * W2. Finally, I obtain a completely interpolated image when I add N4 * W4 to Y(i,j) = N1 * W1 + N2 * W2 + N3 * W3.
Can anyone explain (with a drawing or diagram, if possible) why? Also, why, Y(i,j) = N1, the output image looks like an image interpolated using the Nearest Neighbor Algorithm ?
Many thanks and I would appreciate very much your replies at your earliest convenience.
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!