title: Estimate Euclidean transformation with python
body: <p>I want to do something similar to what in image analysis would be a standard 'image registration' using features.</p>
  
  <p>I want to find the best transformation that transforms a set of 2D coordinates A in another one B.
  But I want to add an extra constraint being that the transformation is 'rigid/Euclidean transformation' Meaning that there is no scaling but only translation and rotation.
  Normally allowing scaling I would do:</p>
  
  <pre><code> from skimage import io, transform
   destination = array([[1.0,2.0],[1.0,4.0],[3.0,3.0],[3.0,7.0]])
   source = array([[1.2,1.7],[1.1,3.8],[3.1,3.4],[2.6,7.0]])
   T = transform.estimate_transform('similarity',source,destination)
  </code></pre>
  
  <p>I believe<code>estimate_transform</code> under the hood just solves a least squares problem.
  But I want to add the constraint of no scaling.</p>
  
  <p>Are there any function in skimage or other packages that solve this?
  Probably I need to write my own optimization problem with scipy, CVXOPT or cvxpy.
  Any help to phrase/implement this optimization problem?</p>
  
  <p><strong>EDIT</strong>:
  My implementation thanks to Stefan van der Walt Answer</p>
  
  <pre><code>from matplotlib.pylab import *
  from scipy.optimize import *
  
  def obj_fun(pars,x,src):
      theta, tx, ty = pars
      H = array([[cos(theta), -sin(theta), tx],\
           [sin(theta), cos(theta), ty],
           [0,0,1]])
      src1 = c_[src,ones(src.shape[0])]
      return sum( (x - src1.dot(H.T)[:,:2])**2 )
  
  def apply_transform(pars, src):
      theta, tx, ty = pars
      H = array([[cos(theta), -sin(theta), tx],\
           [sin(theta), cos(theta), ty],
           [0,0,1]])
      src1 = c_[src,ones(src.shape[0])]
      return src1.dot(H.T)[:,:2]
  
  res = minimize(obj_fun,[0,0,0],args=(dst,src), method='Nelder-Mead')
  </code></pre>