Open LucasFidon opened 2 years ago
Hi, if I want to extend to 3D image, how do I do that? Use torch.fft.rfftn instead?
I think it should be calculated for all four corners because the rfft in the older version of pytorch used by the author and the argument states that oneside does not apply.
Hi, thank you for sharing your code!
I have noticed two errors in your implementation of FDA in https://github.com/YanchaoYang/FDA/blob/b9a0cdf0bcc9b787c00e39df73eda5673706f219/utils/__init__.py#L11-L18
Only the the top left and bottom left part of the image in the Fourier space needs to be changed. This is because you use rfft (and not fft) and, as a result, only half of the image in the Fourier domain is returned (due to the symmetry). Otherwise, you are replacing high frequency which is not what is described in the paper.
The indices of the region mutated should be symmetrical around 0. Otherwise the output after inverse FFT will have a non-zero imaginary part (
-b
should be-b+1
above).Also you may want to multiply
b
by 0.5 to get the max transform for L=1 instead of L=0.5 (see https://github.com/YanchaoYang/FDA/issues/36#issue-1031310669)I propose to tackle those issues with this modified version fo your pytorch implementation:
I have tested it with PyTorch v1.11.0.
Best wishes, Lucas