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:
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:
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:
And for another one here are the points that we mapped to a rectangle:
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:
- Determining the size of the final mosaic
- Warping all images to this size
- Creating an alpha channel for each image
- Blending the images using weighted averaging
Here is the image that I obtained by used simple averaging to blend the images:
And here is the image that I obtained by using a weighted alpha average to blend the images:
Here are the other two images:
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
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
Feature Matching
Features were matched between images using Lowe's ratio test with a threshold of 0.8:
Final Results
Comparison of manual vs automatic stitching results:
Manual Stitching | Automatic Stitching |
---|---|