I am trying to fourier transform an image according to a tutorial I found.
When I try to run my code the following error appears:
I didn't change anything in the tutorial I copied. So I thought there was something wrong with my libraries. I uninstalled Python and all libraries and installed it again. But the error still shows.
My code:
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('C:\Documents\data128.jpg',0)
f = np.fft.fft2(img)
fshift = np.fft.fftshift(f)
magnitude_spectrum = 20*np.log(np.abs(fshift))
plt.subplot(121),plt.imshow(img, cmap = 'gray')
plt.title('Input Image'), plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(magnitude_spectrum, cmap = 'gray')
plt.title('Magnitude Spectrum'), plt.xticks([]), plt.yticks([])
plt.show()
I am using Python 2.7 on Windows 10. Any help is appreciated!