Detecting similar points between two pictures and then overlaying them (Python)
This kind of question comes up quite often in computer vision. To do it automatically is the exact same problem as panorama stitching. What you basically need to do is what you've nearly finished:
- Extract feature points (you are using ORB features - SIFT might give you better results, it's just a nonfree algorithm if that matters) and their descriptors
- Match them
- Use RANSAC to filter them
- Compute a homography between the two sets of points
- Do the stitching
I have never used skimage for feature extraction / processing, but your pipeline looks good. I also found this lovely (written-by-the-authors-of-skimage) guide for image stitching that you will find very useful! https://github.com/scikit-image/scikit-image-paper/blob/master/skimage/pano.txt
It basically does half of what you did, and walks through the next steps!
Does it has to be done automatically? Actually it took some time for me to correlate these two images visually, so I think it would be really tough to write a script that alignes them. If you are going to overlay several images (not several hundreds), I would suggest to do this manually with hugin panorama stitcher. It will save your efforts.
I tried to solve your problem and it took me less than 10 minutes to find similarities, manually place control points, and export the images.
Control points in hugin
It this what you want?
- first image
- second image
I used Masking feature of hugin to specify which image should be visible in the final remapped image, and exported panorama twice with different masks.
Update
Hugin project file .pto
is a plain text file that contains image names and transformations applied to them, like this:
# image lines
#-hugin cropFactor=1
i w3400 h4000 f0 v1.99999941916805 Ra0 Rb0 Rc0 Rd0 Re0 Eev0 Er1 Eb1 r0.00641705670350258 p0.588362807000514 y-0.252729475162748 TrX0 TrY0 TrZ0 j0 a0 b0 c0 d0 e0 g0 t0 Va1 Vb0 Vc0 Vd0 Vx0 Vy0 Vm5 n"SQNrnTw.png"
You can parse this with Python using re and apply image transformations yourself, if you would like to.