I am trying to implement, in Python, some functions that transform images to their Fourier domain and vice-versa, for image processing tasks.
I implemented the 2D-DFT using repeated 1D-DFT, and it worked fine, but when I tried to implement 2D inverse DFT using repeated inverse 1D-DFT, some weird problem occurred: when I transform an image to its Fourier domain and then back to the image domain, it looks like the image was reflected and merged with its reflection, as can be seen here:
This is the input:
and this is the output
This is the function that is responsible for the mess:
def IDFT2(fourier_image):
image = np.zeros(fourier_image.shape)
for col in range(image.shape[1]):
image[:, col] = IDFT1(fourier_image[:, col])
for row in range(image.shape[0]):
image[row, :] = IDFT1(image[row,:])
return image
What did I do wrong? I am pretty sure that IDFT1 works fine, and so is the regular 2D-DFT.