I want to use Fast Fourier Transform but already trying a simple back and forth transformation doesn't work. The code is
import cv2
import numpy as np
img = cv2.imread('Picture.bmp',0)
f = np.fft.fft2(img)
fshift = np.fft.fftshift(f)
f_ishift = np.fft.ifftshift(fshift)
img_back = cv2.idft(f_ishift)
img_back = cv2.magnitude(img_back[:,:,0],img_back[:,:,1])
and the error is
Traceback (most recent call last):
File "test.py", line 8, in <module>
img_back = cv2.idft(f_ishift)
TypeError: src data type = 15 is not supported
How can this be fixed?
I think I figured it out. cv2.idft() wants the complex numbers in a different format. I had to extract the real and imaginary part separately and write them in the third dimension: