Optimized Image Stitching in Python


Rohan Gangakhedkar1,

1New York Univeristy   

Abstract


TL;DR: This image stitching algorithm utilizes feature matches between images to compute an homography matrix. Using this homography the second image is warped, and then the two images are layed on top of one another. Then, dynamic weighted fusion is used to remove the seam line caused by the pasting of the images onto one another. The result is a stitched image with little to no seam line present.

Left Image Right Image

Above is the two original images taken side by side. And below is the stitched result. As you can see there is little to no seam line present from the image and the alignment is as it should be.


Right Image

Pipeline overview


The pipeline of the image stitching consists of main parts. The first is converting the images to grayscale so that SIFT can extract matches.

Left (Grayscale)   Right (Grayscale)



After extracting matches OpenCV's FlannBasedMatcher is used and then Lowe's ratio test is performed to ensure good matches. These matches are displayed in the iamge below

Matches



Based on the extracted matches an homography is retrieved and this is applied to the right image to warp it in line with the left image.

Homography



The left image is then added to the warped right image. This will create a very sharp vertical seam line at the right hand edge of the left image. Although in this scenario the seam line is very minimal, it is very evident in the areas pointed out by the arrows.

Image Addition



After applying the weighted fusion on the image the seam line in removed and the result is a blending of the left image and right image.

Seam Correction



The final step is to fix the corners as a result of the image warped. Applying a simple warp of the image and moving the corners to the edges fixes this and gives the final image.

Output