Image Stitching algorithm in Python from scratch with gain compensation and blending

CorentinBrtx CorentinBrtx Last update: Mar 21, 2024

Image Stitching

Image Stitching algorithm with multi-panoramas, gain compensation, simple blending, and multi-band blending. Part of a project for the Computer Vision course of CentraleSupélec.

The implementation is strongly based on the 2007 paper Automatic Panoramic Image Stitching using Invariant Features by Matthew Brown and David G. Lowe : http://matthewalunbrown.com/papers/ijcv2007.pdf

Install

Python 3.11 or higher is required. Clone the repository, and run the following command:

pip install -r requirements.txt

Usage

Simply put all your images in a single folder (possibly images of different panoramas), and run the following command:

python main.py /path/to/folder

For more options, see the command line help:

python main.py --help

You will find sample images in the folder samples/mountain for you to try the algorithm.

Examples

The below panoramas have been obtained with the default parameters.

car panorama

mountain panorama

centralesupelec panorama

Detailed description

The process contains multiple steps to obtain the best-looking panorama as possible. Namely, the following steps are performed:

  • Feature detection: the algorithm uses the SIFT algorithm to detect features in the images.
  • Feature matching: the algorithm matches the features between the images.
  • Connected components: the algorithm groups the images into connected components, each corresponding to a different panorama.
  • Panorama stitching: the algorithm stitches the images together.
  • Gain compensation: the algorithm compensates the gain of the images.
  • Blending: the algorithm blends the images together. Two different blending methods are available: simple blending and multi-band blending. The simple blending is the one used by default, as the multi-band blending is slower and gives more blurred results.

mountain panorama after panorama stitching Mountain panorama after panorama stitching without any compensation

mountain panorama after gain compensation Mountain panorama after gain compensation

mountain panorama with multi-band blending Mountain panorama with multi-band blending

mountain panorama after panorama stitching Mountain panorama with simple blending

Subscribe to our newsletter