title: OpenCV/Python: Colorbar in fft magnitude
body: <p>I'm using opencv in python 2.7.</p>
  
  <ol>
  <li>The colormap is oversized. How to shrink it to has the same length as the image?</li>
  <li>How do I explain the value/range of magnitude?</li>
  </ol>
  
  <p>This is my code:</p>
  
  <pre><code>import numpy as np
  import cv2
  from matplotlib import pyplot as plt
  
  img = cv2.imread('messi.jpg',0)
  
  dft = cv2.dft(np.float32(img),flags = cv2.DFT_COMPLEX_OUTPUT)
  dft_shift = np.fft.fftshift(dft)
  
  magnitude_spectrum = np.log(cv2.magnitude(dft_shift[:,:,0],dft_shift[:,:,1]))
  
  plt.subplot(131),plt.imshow(img, cmap = 'gray')
  plt.title('Input Image'), plt.xticks([]), plt.yticks([])
  plt.subplot(132),plt.imshow(magnitude_spectrum, cmap = 'gray'), plt.colorbar(cmap = 'gray')
  plt.title('Magnitude Spectrum'), plt.xticks([]), plt.yticks([])
  plt.show() 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/iNEYT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iNEYT.png" alt="enter image description here"></a></p>