Note: This example has been significantly expanded and enhanced. The new, recommended version is located here. We retain this version intact as it was the exact example used in the scikit-image paper.
Panorama stitching
The ImageCollection
class provides an easy way of loading and representing multiple images. Images are not read from disk until accessed.
Credit: Photographs taken in Petra, Jordan by François Malan
License: CC-BY
For this demo, we estimate a projective transformation that relates the two images. Since the outer parts of these photographs do not comform well to such a model, we select only the central parts. To further speed up the demonstration, images are downscaled to 25% of their original size.
1. Feature detection and matching
"Oriented FAST and rotated BRIEF" features are detected in both images:
Each feature yields a binary descriptor; those are used to find the putative matches shown. Many false matches are observed.
2. Transform estimation
To filter matches, we apply RANdom SAMple Consensus (RANSAC), a common method of rejecting outliers. This iterative process estimates transformation models based on randomly chosen subsets of matches, finally selecting the model which corresponds best with the majority of matches.
Note how most of the false matches have now been rejected.
3. Warping
Next, we want to produce the panorama itself. The first step is to find the shape of the output image, by taking considering the extents of all warped images.
Warp the images according to the estimated transformation model. Values outside the input images are set to -1 to distinguish the "background".
A shift is added to make sure that both images are visible in their entirety. Note that warp
takes the inverse mapping as an input.
An alpha channel is now added to the warped images before they are merged together:
Note that, while the columns are well aligned, the color intensity is not well matched between images.
4. Blending
To blend images smoothly we make use of the open source package Enblend, which in turn employs multi-resolution splines and Laplacian pyramids [1, 2].
[1] P. Burt and E. Adelson. "A Multiresolution Spline With Application to Image Mosaics". ACM Transactions on Graphics, Vol. 2, No. 4, October 1983. Pg. 217-236. [2] P. Burt and E. Adelson. "The Laplacian Pyramid as a Compact Image Code". IEEE Transactions on Communications, April 1983.