title: Matching two different images of the same object
body: <p>I am looking at an application where I have two images from a single object (a smartphone) acquired using x-ray. The two images have been acquired at different instant. The intensity content of the two images is thus different and I would like to be able to fuse the two images in order to extract some information about the phones. </p>
  
  <p><a href="https://i.stack.imgur.com/tVTiq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tVTiq.jpg" alt="enter image description here"></a></p>
  
  <p>In between the two images, the set up have been slightly changed such that the phone is not placed at the same pixel value in the two images. To be able to correctly compare the two images, I would need to translate and rotate the images of the phones such that they overlap as much as possible.  </p>
  
  <p>For this I am using python and open cv (cv2). I was thinking to use a thresholding and then find the coordinate of the two thresholded images and use the coordinate to map the yellow image on the red one (or the opposite). The attached image shows what I have obtained so far. </p>
  
  <p><a href="https://i.stack.imgur.com/1a95W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1a95W.png" alt="enter image description here"></a></p>
  
  <p>The pseudo code is given in the following: </p>
  
  <pre><code>ret1, thresh1 = cv2.threshold(img1.astype(np.uint8),200,255,cv2.THRESH_BINARY_INV)
  ret2, thresh2 = cv2.threshold(template.astype(np.uint8),200,255,cv2.THRESH_BINARY_INV)
  
  plt.figure(1)
  plt.subplot(121)
  plt.imshow(thresh1)
  plt.subplot(122)
  plt.imshow(thresh2)
  plt.show()
  </code></pre>
  
  <p>where img1 is one image acquired with the first filter and template is the image acquired with the second filter. One can see that the phones are at different position in the yellow and green images respectivelly. </p>
  
  <p>My question is how to perform the next step. How can I find the coordinate of this thresholded images and then superpose the images of the two phones? Is it the right strategy at all or are there better solutions? </p>
  
  <p>I have been looking at <a href="http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_imgproc/py_template_matching/py_template_matching.html" rel="nofollow noreferrer">this link</a> on template matching, but for the moment I have had no success. </p>