title: fast Cartesian to Polar to Cartesian in Python
body: <p>I want to transform in Python 2d arrays/images to polar, process then, and subsequently transform them back to cartesian. The following is the result from ImajeJ <a href="http://rsbweb.nih.gov/ij/plugins/polar-transformer.html" rel="noreferrer">Polar Transformer</a> plugin (used on the concentric circles of the sample code):</p>
  
  <p><img src="https://i.stack.imgur.com/t38pW.jpg" alt="enter image description here"></p>
  
  <p>The number and dims of the images is quite large so I was checking whether openCV has a fast and simple way to do this.</p>
  
  <p>I read about cv. <code>CartToPolar</code> and <code>PolarToCart</code> but I failed to use it. I understand better the <code>LogPolar</code> where the input and output are arrays, and where you can set the center, interpolation,and inversion (i.e <code>CV_WARP_INVERSE_MAP</code>). Is there a way to use CartToPolar/PolarToCart in an similar fashion?</p>
  
  <pre><code>    import numpy as np
      import cv
  
      #sample 2D array that featues concentric circles
      circlesArr = np.ndarray((512,512),dtype=np.float32)
      for i in range(10,600,10): cv.Circle(circlesArr,(256,256),i-10,np.random.randint(60,500),thickness=4)
  
      #logpolar
      lp = np.ndarray((512,512),dtype=np.float32)
      cv.LogPolar(circlesArr,lp,(256,256),100,cv.CV_WARP_FILL_OUTLIERS)
  
      #logpolar Inverse
      lpinv = np.ndarray((512,512),dtype=np.float32)
      cv.LogPolar(lp,lpinv,(256,256),100, cv.CV_WARP_INVERSE_MAP + cv.CV_WARP_FILL_OUTLIERS)
  
      #display images
      from scipy.misc import toimage
      toimage(lp, mode="L").show()
      toimage(lpinv, mode="L").show()
  </code></pre>
  
  <p>This is for a tomography (CT) workflow where rings artifacts can be filtered out easier if they appear as lines.</p>