Project4: Stitching Photo Mosaics

A. IMAGE WARPING and MOSAICING

Goal:

  1. Shoot and digitize pictures

  2. Recover homographies

  3. Warp the images

  4. Blend images into a mosaic

1. Shoot the Pictures

I shot pictures from my iPhone using a wide angle lenses.

1.2

1.1

2. Compute Homography matrix

In order to do the Homographies, we computer p' = Hp as following,

H=[h11h12h13h21h22h23h31h32h33]
{xi=h11xi+h12yi+h13h31xi+h32yi+h33yi=h21xi+h22yi+h23h31xi+h32yi+h33
xi(h31xi+h32yi+1)=h11xi+h12yi+h13yi(h31xi+h32yi+1)=h21xi+h22yi+h23
h11xi+h12yi+h13h31xixih32xiyixi=0h21xi+h22yi+h23h31yixih32yiyiyi=0,

Which could be represent to,

hAib=0

Where

h=[h11,h12,h13,h21,h22,h23,h31,h32]T
Ai=[xiyi1000xixixiyi000xiyi1yixiyiyi]

For n point correspondences, A will be a 2n * 8 matrix, and b will be a 2n * 1 vector. When n > 4 , the system is overdetermined which should be solved using least-squares (np.linalg.svd(A)).

3. Warp image

To avoid May result in gaps (“holes”) in the destination image because not every pixel in the destination image receives a value, use Inverse Warping.

  1. For each pixel p' in the destination image, compute its corresponding location p in the source image using the inverse homography H1.

  2. Apply H to the four corners of the source image to see where they map in the destination image.

  3. For each point p=[x,y,1]T in the destination image grid, compute: p=H1p. Then Normalize. Since x and y may not be integers, use interpolation to estimate the pixel values.

  4. Computer alpha mask which determines the effective value‘s range.

Warp the left image and we get:

2.1

4. Image Rectification

Then, use some photoes to test if warping function is right.

3.1

3.2

3.3

3.4

 

 

5. Blend the images into a mosaic

  1. Image Registration: Aligning images so that corresponding points match. This involves finding the transformation (homography) that maps points from one image to another.

  2. Image Warping: Applying the computed homography to warp images into a common coordinate frame.

  3. Blending: Combining the warped images into a single image, minimizing visible seams and artifacts.

The original photoes show as follow:

1.2

1.1

The warped left photo show as follow:

2.1

Mosaic image:

78a31fac-4bd3-477e-95b7-3b2cc6d834af

B. FEATURE MATCHING for AUTOSTITCHING

1. Detecting Corner Features

Using the provided Harris corner detector, I identified the corner features. To reduce the number of detected corners, I set the minimum distance between corners to 5 pixels and discarded 20 pixels along the edges. The result is displayed below:

B1

Next, Implemented the Adaptive Non-Maximal Suppression (ANMS) algorithm to select a fixed number of the best corners that are well-distributed spatially.

• For each corner x_i , find the distance r_i to the closest corner that has a stronger response.

(1)ri=minxj{S|f(xj)>f(xi)}xixj,wherec=0.9

Here, S is the set of all corners with a stronger response than corner x_i , and c is a robustness parameter as described in the paper.

• Sort these distances r_i in descending order and select the top N corners.

B2

2. Extracting Descriptors

  1. Based on Corner Strength : In interest point detection, the corner strength is the metric that determines the “importance” of each interest point. The ANMS strategy suppresses points based on the corner strength of each interest point.

  1. Suppression Strategy: We use a “suppression radius” to define the neighborhood size. Within this neighborhood, only the interest point that is the maximum within radius will be retained.

  1. Gradually Expanding Radius: Conceptually, we begin with and then incrementally increase until we reach the desired number of interest points .

  1. Global Maximum: The first element in the list is the global maximum, which is never suppressed regardless of the radius. As the suppression radius decreases from infinity, new interest points are added to the list. Once an interest point is added, it remains in the list because a point that is the maximum at a certain radius will continue to be the maximum at any smaller radius.

3. Matching Descriptors

  1. Identifying Feature Points of the Same Object or Position in Images: Feature descriptors are used to represent the pixels around a specific location in an image.

  1. Lowering Sampling Frequency: For each interest point, we sample an 8 × 8 pixel block around its sub-pixel location with a sampling interval of 5 pixels. In the illustration, sampling around each feature point at 5-pixel intervals minimizes the effect of positional error on the descriptor.

  1. Avoiding Aliasing: Sampling is done at a higher pyramid level than the detection scale to ensure a sampling rate of approximately once per pixel. Let s=5.

  1. Normalization of the Descriptor Vector: After sampling, the descriptor vector is normalized to have a mean of 0 and a standard deviation of 1, ensuring invariance of features to affine changes in intensity (offset and gain).

  1. Haar Wavelet Transformation: Finally, an 8 × 8 descriptor block undergoes a Haar wavelet transform, forming a 64-dimensional descriptor vector of wavelet coefficients . Due to the orthogonality of the Haar wavelet, Euclidean distances between features are preserved under this transformation.

    The result is displayed below:

B3

4. Compute Homography Using RANSAC

To compute homography using RANSAC, we iteratively select a minimal subset of point correspondences (typically 4) to estimate the homography matrix. For each subset, we calculate the homography and evaluate how well it aligns all points by counting inliers—points that fall within a specified distance threshold when transformed. This process is repeated over many iterations to maximize inliers, thus refining the homography estimation by prioritizing matches that align most accurately while excluding outliers. The final homography is derived from the subset with the most inliers, providing a robust transformation despite the presence of mismatches.

The result is displayed below:

B4

5. Produce a mosaic

Last, we mosaic the two images. The result with Hand-Annotated H and Automatically H is displayed below:

78a31fac-4bd3-477e-95b7-3b2cc6d834af

B5

Learned

In Project 4, I learned how to create seamless photo mosaics using homography-based transformations.

Capturing images with sufficient overlap was key to aligning them effectively. Calculating homographies taught me to map points between images, especially using least-squares for overdetermined systems. Inverse warping minimized gaps by mapping destination pixels back to the source, and interpolation ensured smooth transitions. Using the Harris corner detector with ANMS helped identify well-distributed, strong feature points, while extracting descriptors with reduced sampling frequency and normalization enhanced robustness to intensity variations. Implementing RANSAC allowed me to refine homographies by excluding outliers, yielding stable transformations.

Finally, blending techniques were crucial to produce a seamless mosaic by aligning images with minimized visible seams. This project deepened my understanding of image processing, feature matching, and transformation techniques fundamental to computer vision.