Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resizing scale different from expected #225

Open
AleximusOrloff opened this issue Sep 24, 2017 · 0 comments
Open

Resizing scale different from expected #225

AleximusOrloff opened this issue Sep 24, 2017 · 0 comments

Comments

@AleximusOrloff
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant