-
Notifications
You must be signed in to change notification settings - Fork 140
Description
As I see in code, both src and dst sizes reduced by 1.
https://github.com/torch/image/blob/master/generic/image.c#L84
It could be due to Lua's 1-based sizes, but actually it means that image scaled by (dst-1)/(src-1)
It results in loosing half a pixel on each side
im=torch.Tensor(3,3):zero()
im[2][2]=1
print(im)
0 0 0
0 1 0
0 0 0
[torch.DoubleTensor of size 3x3]
im4=image.scale(im,6,6,'bilinear')
print(im4)
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.1600 0.3200 0.3200 0.1600 0.0000
0.0000 0.3200 0.6400 0.6400 0.3200 0.0000
0.0000 0.3200 0.6400 0.6400 0.3200 0.0000
0.0000 0.1600 0.3200 0.3200 0.1600 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
[torch.DoubleTensor of size 6x6]
print(im4:sum())
5.7599997425079
s seen sum = 5.76, instead of expected 4
real scale ratio = 2.4 instead of 2