Project5A IMAGE WARPING and MOSAICING

Zhenkai Han

Overview

In this project, I learned how to image warping and mosaicing to create a panoramic photo.

Part 1: Shoot the Pictures

I got some photos good for mosaicing in the Internet. Their aperture & exposure settings are identical. All photos were taken in China somewhere.

Mountain photo 1 from Internet. A wide shot.
Mountain photo 2 from Internet. A wide shot.
Building photo a from Internet. A wide shot.
Building photo b from Internet. A wide shot.
Building photo c with park from Internet.
Building photo d with park from Internet.

Part 2: Recover Homographies

I wrote my own little tool (set_points.py) to define pairs of corresponding points on two images. I defined the points in same order and position.

I recovered the matrix H of homography transformation. We at least need 4 points to recover it since H is a 3x3 matrix with 8 degrees of freedom (lower right corner is a scaling factor and can be set to 1). However, to get more precise blending, I set more than 8 points for each image and used least-squares to get matrix H.

Homography transformation matrix H from Lecture slides.
One corresponding point in p matrix to fit least-squares.
One corresponding point in p' matrix to fit least-squares.
H matrix to fit least-squares.
Photo with corresponding points.
Photo with corresponding points.

Warp the Images and Image Rectification

I used inverse warping which is similar to project 3. This time I used inverse of matrix H to transform pixels in original image to pixels in warpped image. For warpped image, I calculated a bounding box for original image to determine the size of warpped image so that I can put another image on warpped image directly later. With method skimage.draw.polygon, I could get a mask which contains all coordinates of points in the warpped image.

Rectified frontal-parallel mountain photo 2
Rectified frontal-parallel building photo b
Rectified frontal-parallel building photo d

Blend the images into a mosaic

Here I blended only two images together, so I don't need to warp another image. Since I already have a rectified image which big enough to contain another image, I can just add another image to the rectified image. To reduce edge artifacts, I take two weighted pixels from rectified image and another image for one pixel in blended image.

Mountain photo 1 from Internet. A wide shot.
Mountain photo 2 from Internet. A wide shot.
Mountain mosaic with photo 1 and 2. If the brightness of two photos can be the same, the result will be better.
Building photo a from Internet. A wide shot.
Building photo b from Internet. A wide shot.
Building mosaic with photo a and b. If the brightness of two photos can be the same, the result will be better.
Building photo c with park from Internet.
Building photo d with park from Internet.
Building mosaic with photo c and d. The edge artifact is stronger. I think define corresponding points more precisely can help to reduce it.

What I've learned

The key is set corresponding points precisely. Zooming in and set points carefully is a good idea to do so. Setting more corresponding points is better, but if there is offset between a pair of corresponding points, the result will be bad. The coolest thing the two images can be blended very well with homography transformation!