title: Unable to unwrap image in OpenCV
body: <p>I am trying to convert an image from cartesian to polar so that I can unravel the image, but I am getting a runtime error. If you are curious how this looks visually, see <a href="http://www.codeproject.com/KB/graphics/PolarView/PolarMap2.png" rel="nofollow">this example.</a></p>
  
  <p>Code:</p>
  
  <pre><code>import scipy
  import scipy.ndimage
  import numpy as np
  from math import *
  import cv2
  
  def logpolar(input):
      # This takes a numpy array and returns it in Log-Polar coordinates.
  
      coordinates = np.mgrid[0:max(input.shape[:])*2,0:360] # We create a cartesian array which will be used to compute log-polar coordinates.
      log_r = 10**(coordinates[0,:]/(input.shape[0]*2.)*log10(input.shape[1])) # This contains a normalized logarithmic gradient
      angle = 2.*pi*(coordinates[1,:]/360.) # This is a linear gradient going from 0 to 2*Pi
  
      # Using scipy's map_coordinates(), we map the input array on the log-polar coordinate. Do not forget to center the coordinates!
      lpinput = scipy.ndimage.interpolation.map_coordinates(input,(log_r*np.cos(angle)+input.shape[0]/2.,log_r*np.sin(angle)+input.shape[1]/2.),order=3,mode='constant')
  
      # Returning log-normal...
      return lpinput
  
  
  # Load image
  image = cv2.imread("test.jpg")
  result = logpolar(image)
  </code></pre>
  
  <p><br>
  Error message in console:</p>
  
  <pre>
  Traceback (most recent call last):
    File "test.py", line 23, in &lt;module&gt;
      result = logpolar(image)
    File "test.py", line 15, in logpolar
      lpinput = scipy.ndimage.interpolation.map_coordinates(input,(log_r*np.cos(angle)+input.shape[0]/2.,log_r*np.sin(angle)+input.shape[1]/2.),order=3,mode='constant')
    File "/Library/Python/2.7/site-packages/scipy-0.13.0.dev_c31f167_20130415-py2.7-macosx-10.8-intel.egg/scipy/ndimage/interpolation.py", line 295, in map_coordinates
      raise RuntimeError('invalid shape for coordinate array')
  RuntimeError: invalid shape for coordinate array
  </pre>