Skip to content

A project for creating a panorama image from two images using Python (OpenCV), SIFT, kNN, RANSAC, Homography and weighted filters

Notifications You must be signed in to change notification settings

aserman01/Panorama-Image-Stitching

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Stitching OpenCV

A project for creating a panorama image from two images using SIFT, kNN, RANSAC, Homography and weighted filters.

I implemented a feature matching automatic image stitching algorithm. User inputs two images which have overlapped fields and program creates a wide panorama of both images.

Algorithm

  • Firstly, we turn both images into gray scale and use SIFT (Scale-invariant Feature Transform) Method to detect their keypoints.
  • Using kNN and brute force, we find the most similar keypoints and match them.
  • We compute the homography matrix needed for matched points' transformation.
  • Then we use RANSAC (Random Sample Consensus) we find the subset with most inliers and by doing so eliminate outliers.
  • With homography matrix, we warp the images.
  • Lastly, we use a weighted filter to make transition between both images seamless.

Optimization

For a better optimization, I tried two different methods.

Rectangle Masking with Percentage

As we know which image is left and which image is right, we can only scan the right and left part of images by scaning %75 part of an image, program can work in a more optimized manner.

My test results showed that scanning only %75 of the images helps us save 2-3 seconds for each stitching and this value still can increase as we reduce the scan area without losing any details in panorama.

Screen Shot 2022-08-18 at 11 00 38

Bucketing

We can seperate our image into little rectangles and can only take some of those rectangles to save computing time. As these rectangles are homogenously disturbed through our image, precision of the stitching doesn't change.

My test results showed that using 50x50 mask of the images helps us save 4-5 seconds (which is very drastic) for each stitching and this value still can increase as we reduce the scan area without losing any details in panorama.

Screen Shot 2022-08-18 at 11 34 24

Sample

Input Images

imageLeft imageRight

SIFT and kNN Matches

Screen Shot 2022-08-11 at 14 50 16

Weighted Filter

Screen Shot 2022-08-11 at 11 20 57

Output

Panorama_Final

About

A project for creating a panorama image from two images using Python (OpenCV), SIFT, kNN, RANSAC, Homography and weighted filters

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages