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

How to translate flow to coordinate? #26

Open
Devlee247 opened this issue Jun 1, 2024 · 1 comment
Open

How to translate flow to coordinate? #26

Devlee247 opened this issue Jun 1, 2024 · 1 comment

Comments

@Devlee247
Copy link

Devlee247 commented Jun 1, 2024

Thanks for your nice work!

I'm curious about how to translate flow to coordinate. (u,v -> x, y)

@ksimmo
Copy link

ksimmo commented Sep 12, 2024

If you mean target coordinates (x,y) then it is quite simple. Just take the starting position of that pixel and add the flow vector of that pixel to get the target coordinates:

#assuming flow has the shape BxCxHxW

yy,xx = torch.meshgrid(torch.arange(flow.size(-2)), torch.arange(flow.size(-1)), indexing="ij") 
spatial_pos = torch.stack([xx,yy], dim=0)
target_pos = spatial_pos.unsqueeze(0)+flow

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

2 participants