![](https://vgg.fiit.stuba.sk/wp-uploads/2011/06/input.jpg)
Michal Lohnicky
This example shows how to merge two photos using OpenCV. SURF features are used to find a homography to align the images and histogram matching with Bhattacharyya distance is used for merging them seamlessly.
Functions used: cv.CalcHist, cv.FindHomography, cv.CompareHist(…, CV_COMP_BHATTACHARYYA), cv.ExtractSURF
Inputs
![Sample input](http://vgg.fiit.stuba.sk/wp-uploads/2011/06/input-300x115.jpg)
The process
- Preprocessing
- Image registration
- Finding the correspondences between detected points
- Calculating the homography
- Histogram matching
- Creating the blurred stitching mask
The matching process is demonstrated on the following images:
![Keypoints](http://vgg.fiit.stuba.sk/wp-uploads/2011/06/keypoints-300x114.jpg)
![Matching](http://vgg.fiit.stuba.sk/wp-uploads/2011/06/matching-208x300.jpg)
![Histogram](http://vgg.fiit.stuba.sk/wp-uploads/2011/06/histogram1-300x230.jpg)
![Masks](http://vgg.fiit.stuba.sk/wp-uploads/2011/06/masks-300x112.jpg)
Results
Python source code is provided