CS180 Project 4: Image Mosaicing

Part 1: Shoot and Digitize Pictures

For this project, I took multiple photographs with projective transforms between them. I ensured that:

  • The camera's center of projection (COP) was fixed while rotating to capture photos.
  • Lenses with minimal distortion were used to ensure straight lines remained straight.
  • Photos were taken close together in time to minimize subject movement and lighting changes.
  • There was significant overlap (40-70%) between adjacent images.

Here are the original images I used for creating the mosaic:

Image 1 Image 1
Image 1 Image 1
Image 1 Image 1

Part 2: Recover Homographies

To recover the homographies between image pairs, I implemented the following function:

H = computeH(im1_pts, im2_pts)

This function takes two n-by-2 matrices of corresponding points from two images and returns the 3x3 homography matrix. I used more than 4 correspondences and solved the resulting overdetermined system using least-squares to improve stability.

Here's a visualization of the point correspondences I used:

Image 1 Image 1

Part 3: Warp the Images

I implemented the image warping function:

imwarped = warpImage(im, H)

This function takes an input image and a homography matrix, and returns the warped image. I used inverse warping with interpolation to avoid aliasing. An alpha channel was used to mark undefined pixels.

As a test, I performed image rectification on a photo containing a known rectangular object:

Image 1 Image 1

And for another one here are the points that we mapped to a rectangle:

Image 1
Image 1 Image 1

Part 4: Blend Images into a Mosaic

To create the final mosaic, I warped all images to a common projection and blended them using weighted averaging. The process involved:

  1. Determining the size of the final mosaic
  2. Warping all images to this size
  3. Creating an alpha channel for each image
  4. Blending the images using weighted averaging

Here is the image that I obtained by used simple averaging to blend the images:

Image 1

And here is the image that I obtained by using a weighted alpha average to blend the images:

Image 1

Here are the other two images:

Image 1 Image 1 Image 1
Image 1 Image 1 Image 1

Part B: Automatic Image Stitching

The second part focuses on automatically detecting and matching features between images to create mosaics without manual correspondence points.

Corner Detection

For detecting corners, I implemented the Harris corner detector with Adaptive Non-Maximal Suppression (ANMS) to:

  • Apply Harris corner detector for initial corner points
  • Use ANMS to select strong and well-distributed corners
  • Filter to keep top 1000 corners for feature matching
Harris Corners Image 1 Harris Corners Image 2
ANMS Image 1 ANMS Image 2

Feature Descriptors

For each detected corner, feature descriptors were extracted by:

  • Taking 40x40 pixel windows centered on each corner
  • Downsampling to 8x8 descriptors
  • Normalizing by subtracting mean and dividing by standard deviation
Features Image 1 Features Image 2

Feature Matching

Features were matched between images using Lowe's ratio test with a threshold of 0.8:

Feature Matching

Final Results

Comparison of manual vs automatic stitching results:

Manual Stitching Automatic Stitching
Manual Panorama 1 Auto Panorama 1
Manual Panorama 1 Auto Panorama 1
Manual Panorama 1 Auto Panorama 1