yinboc / liif

Learning Continuous Image Representation with Local Implicit Image Function, in CVPR 2021 (Oral)
https://yinboc.github.io/liif/
BSD 3-Clause "New" or "Revised" License
1.26k stars 145 forks source link

Regarding the code in liif.py #34

Open Swaraj-72 opened 3 years ago

Swaraj-72 commented 3 years ago

Hi, I have found it difficult to understand the purpose of rx, ry in the code below. Kindly let me know the same. Also why should we perform the flip operation (coord.flip(-1)) on the "coord" variable when we have received the actual coordinates.Thank you.

Issue
Surayuth commented 2 years ago

The coordinates of all centers are a constraint, by default, within [-1, 1]. This means the length of the side of each grid is [1 - (-1)]/N = 2/N where N is the number of grids in each direction. Thus, the shortest distance between the center of each grid to its border (radius, r) = (2/N)/2 = 2 / N / 2

codeslake commented 2 years ago

I believe flip is required for properly indexing x and y coordinates. The documentation for grid_sample() states that,

...the size-2 vector grid[n, h, w] specifies input pixel locations x and y... .

As the coord variable is basically a meshgride in (y, x) coordinate format (here), flip is required.

axhiao commented 2 years ago

For later readers, note that in grid_sample(), the x-axis is along the width of an image and the y-axis is along its height.

I believe flip is required for properly indexing x and y coordinates. The documentation for grid_sample() states that,

...the size-2 vector grid[n, h, w] specifies input pixel locations x and y... .

As the coord variable is basically a meshgride in (y, x) coordinate format (here), flip is required.