I moved the imgs 50 pixels towards the positive x-axis using torchvision.transforms.functional.affine.

The transformation is fine, however, since i would like to get the optical flow of the entire image, I went deeper into the source code and figure out that, it uses a grid to create the new image.

The deafault uses theta, which is the affine transformation matrix to compute the grid.

In my case, the theta would be:

[1 0 -50]

[0 1 0]

However, when i plot the grid [1,H,W,2] it is something like this:

clearly we can see the 50, but i was expecting a uniform vector field that points to the right, I have no idea why i am getting a vector field like this, could someone exlpain what the grid is? what is its relation with optical flow?

Both the source code of generating grid from theta, and using grid to transform the image is implemented in C, and the doc does not explain much.