Closed travisdriver closed 1 year ago
Hi Travis. This is not a bug, but an intentional choice of pixel grid like, e.g., colmap. That is, we say the center of the top left pixel is (0.5, 0.5).
Ah ok, I was getting out of bounds errors when using another library which was using a different convention. Sorry for the confusion, and thank you for the explanation!
No worries, I should probably make this more clear :) It's a super common cause of confusion.
Thank you for your great work and for open-sourcing your code!
I believe there is a small bug in the
to_pixel_coordinates
function. Specifically, consider a square image with side length 1024. Sincealign_corners=False
is used throughout the code, where pixels are treated as squares of side length 1, -1 and 1 in the normalized grid correspond to 0 and 1024, respectively.You correctly accounted for this in the code via
torch.linspace(-1 + 1 / h, 1 - 1 / h, h)
andtorch.linspace(-1 + 1 / w, 1 - 1 / w, w)
, i.e.,-1 + 1 / h
corresponds to 0.5 and1 - 1 / h
corresponds to 1023.5. However, when converting these normalized coordinates back to pixels, they must be shifted left by 0.5 pixels after rescaling.