You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
` # 2D FFT
x_freq = torch.fft.fft2(image)
# shift low frequency to the center
x_freq = torch.fft.fftshift(x_freq, dim=(-2, -1))
# mask a portion of frequencies
x_freq_masked = x_freq
# restore the original frequency order
x_freq_masked = torch.fft.ifftshift(x_freq_masked, dim=(-2, -1))
# 2D iFFT (only keep the real part)
x_corrupted = torch.fft.ifft2(x_freq_masked).real
x_corrupted = torch.clamp(x_corrupted, min=0., max=1.)
x_np = x_corrupted.numpy()
im = Image.fromarray((x_np * 255).astype(np.uint8))
im.save(os.path.join(output_folder, filename))`
The image I save with the above code is far from the image of the cat example, can you provide a demo of this please?
The text was updated successfully, but these errors were encountered:
` # 2D FFT x_freq = torch.fft.fft2(image) # shift low frequency to the center x_freq = torch.fft.fftshift(x_freq, dim=(-2, -1)) # mask a portion of frequencies x_freq_masked = x_freq # restore the original frequency order x_freq_masked = torch.fft.ifftshift(x_freq_masked, dim=(-2, -1)) # 2D iFFT (only keep the real part) x_corrupted = torch.fft.ifft2(x_freq_masked).real x_corrupted = torch.clamp(x_corrupted, min=0., max=1.) x_np = x_corrupted.numpy()
im = Image.fromarray((x_np * 255).astype(np.uint8))
im.save(os.path.join(output_folder, filename))`
The image I save with the above code is far from the image of the cat example, can you provide a demo of this please?
` # 2D FFT
x_freq = torch.fft.fft2(image)
# shift low frequency to the center
x_freq = torch.fft.fftshift(x_freq, dim=(-2, -1))
# mask a portion of frequencies
x_freq_masked = x_freq
# restore the original frequency order
x_freq_masked = torch.fft.ifftshift(x_freq_masked, dim=(-2, -1))
# 2D iFFT (only keep the real part)
x_corrupted = torch.fft.ifft2(x_freq_masked).real
x_corrupted = torch.clamp(x_corrupted, min=0., max=1.)
x_np = x_corrupted.numpy()
The image I save with the above code is far from the image of the cat example, can you provide a demo of this please?
The text was updated successfully, but these errors were encountered: