# Matching two very similar images

I have two images for the same object from the almost same perspective (no more than 1-2 degrees or 1-2 mm is acceptable). I want to change the perspective of one of them to match exactly the other so I can make subtraction between them successfully to get a complete black result if there is no change of the content of the object. many thanks

• the difference between those two images described as "almost same perspective" seems a little inadequate for a quantitative answer if that is what you are looking for... – Fat32 Apr 13 '15 at 22:02

I think all these answers fail to provide a descent methodology.

You should consider "the closeness" of the images as the availability of the initial pose and cast this as a registration problem. The solution can typically be obtained through a least-squares adjustment, i.e., by minimizing the distances of the model points (from first image) to their corresponding image points. In case of a perspective distortion, you could optimize the 9 parameters of the homography matrix. Methods like Lukas Kanade, ESM or hyperplane tracking are some ways to do that. In essence, the procedure is similar to ICP, where an iterative procedure is applied.

Here is one work, extending ESM and comparing a few methods. If your camera is calibrated, you could benefit from some alternative methods.

Note that, to begin with, one could always resort to a simple approach, where you try different combinations of rigid motion $[-2,2]$ degrees for rotation and $[-5,5]$ pixels for translation. Then transform your template with all possible poses (in this case ~$40-50$). Then interpolate the sum of squared differences or normalized cross correlation scores in the pose space (6DOF freedom or 9DOF homography) to get a subpixel accurate refinement. This should give you a rough yet a better alignment. Keep in mind that you could also use this scheme iteratively.

If you have absolutely no clue on how to do any of these, check out this link.

• That is exactly the answer that I have implemented recently. I used KLT then RANSAC for the homography plus gamma correction which solves all the problem. Many thanks @Tbirdal – Humam Helfawi Jun 18 '15 at 6:50

What @creator means that it is not possible. You have two images say matrix A and B. You want to calculate say C=B-A so that A-B+C=0. If you do not have a model to go from A to C how can you find C? In other words you need B to get A-B if you do not know or do not have model to go from A to B, you cannot.

• Thanks , but is not possible to find similar feature then try to build that missing model? – Humam Helfawi Apr 20 '15 at 7:51
• No. We need a model otherwise not possible as no information is available. I would say model is the required information. – user15440 Apr 21 '15 at 18:57