title: numpy function .fft.fft2() giving an error: "cannot do a non-empty take from an empty axis" (opencv, matplotlib, numpy, python27)
body: <p>I am trying to fourier transform an image according to a <a href="http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_imgproc/py_transforms/py_fourier_transform/py_fourier_transform.htm" rel="nofollow noreferrer">tutorial</a> I found. </p>
  
  <p>When I try to run my code the following error appears: </p>
  
  <p><a href="https://i.stack.imgur.com/wRqij.jpg" rel="nofollow noreferrer">Error</a></p>
  
  <p>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. </p>
  
  <p>My code:</p>
  
  <pre><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()
  </code></pre>
  
  <p>I am using Python 2.7 on Windows 10. Any help is appreciated! </p>