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

subpixel_crop_2d not returning square shape #6

Open
McHaillet opened this issue Nov 6, 2024 · 2 comments
Open

subpixel_crop_2d not returning square shape #6

McHaillet opened this issue Nov 6, 2024 · 2 comments

Comments

@McHaillet
Copy link
Member

Hi Alister,

I ran into the following issue with subpixel cropping.

Versions

  • torch-fourier-rescale version: 0.0.2
  • Python version: 3.11.7
  • Operating System: Ubuntu 22.04

Description

The output shape of subpixel_crop_2d is not square. This should highlight and reproduce the issue:

import torch
import einops
from torch_subpixel_crop import subpixel_crop_2d

x = torch.zeros((35, 465, 480))
center = torch.tensor([232,240])
center = einops.repeat(center, "yx -> b yx", b=len(x))
print(subpixel_crop_2d(x, positions=center, sidelength=465).shape)

>>> torch.Size([35, 465, 464])

while the expected shape is (35, 465, 465).

Perhaps a problem with uneven dimensions?

@alisterburt
Copy link
Member

Huh, thanks for the report! Yes I would assume this is the odd box size...

I'm actually not sure there is a good way to be consistent with FFTs of odd dimensions, do you think it's worth trying to support?

At a minimum we should explicitly disallow odd dims it if we don't support it

@McHaillet
Copy link
Member Author

The way it can be done is to use the s (shape) argument of irfftn. That way you can ask it to return the original shape.

So you think this issue originates from the fourier_shift_image_2d() function?

At a minimum we should explicitly disallow odd dims it if we don't support it

For sure!

BTW, the shape I started with (35, 465, 480) was output from fourier_rescale.

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