16-822 | Assignment 1 | prabhdes

Projective Geometry and Homography

Q1: Affine Rectification

Affine rectification aims to transform an image such that parallel lines remain parallel, preserving the geometric structure up to an affine transformation. The process can be summarized as follows:

  1. Two sets of parallel lines are given, each line defined by two distinct points.
  2. The line equation is derived using the cross product of the two points:
  3. Vanishing points represent where parallel lines converge at infinity, for that we take the cross product of the corresponding lines:
  4. The line at infinity is computed as the cross product of the two points at infinity:
  5. Finally, we construct the homography matrix H that aligns the input image with the affine plane. This matrix incorporates the line at infinity, ensuring that parallel lines in the image remain parallel. Normalize the matrix such that:
    $H = I$
    $H[2] = l_{\infty}$
    $H[2] /= H[2][2]$

Given Examples:

Input Image Annotated parallel lines on input image Test lines on Input Image Affine-Rectified Image Test lines on Affine-Rectified Image Before Rectification After Rectification
-0.9878, 0.9846 -0.9998, 0.9999
0.7842, 0.9999 0.9999, 0.9999
0.9928, 0.9959 0.9999, 0.9996

Custom Examples:

Input Image Annotated parallel lines on input image Test lines on Input Image Affine-Rectified Image Test lines on Affine-Rectified Image Before Rectification After Rectification
0.9999, 0.9897 0.9999, 0.9997
0.9899, 0.9911 0.9999, 0.9999

Q2: Metric Rectification

In this approach, we aim to compute the conic at infinity from an affine-rectified image by leveraging pairs of perpendicular lines. The process is outlined as follows:

  1. We begin with 4 pairs of perpendicular lines.
  2. Using the coordinates of the perpendicular lines, we take the cross product of each pair of points to generate the corresponding line equations. These lines are then used to form a matrix system that represents the conic at infinity. $C_{\infty}^{'} = \begin{bmatrix} a & b/2 & c/2 \ b/2 & c & e/2 \ d/2& e/2 & f \end{bmatrix}$
  3. To obtain the conic at infinity, we solve this system of linear equations through SVD.
  4. Once the conic at infinity is computed, another SVD is performed on the resulting matrix to acquire the transformation matrix H.

Given Examples:

Input Image Annotated perpendicular lines on input image Test lines on Input Image Affine-Rectified Image Test lines on Affine-Rectified Image Before Rectification After Rectification
0.1187, -0.1602 -0.0288, 0.0162
0.2527, 0.0882 -0.0018, -0.0082
-0.6686, 0.0448 0.0212, -0.0096

Custom Examples:

Input Image Annotated parallel lines on input image Test lines on Input Image Affine-Rectified Image Test lines on Affine-Rectified Image Before Rectification After Rectification
0.2158, 0.3655 -0.4986, -0.4624
0.1567, 0.2873 -0.0179, 0.1096

Q3: Planar Homography from Point Correspondences

In this approach, we compute a homography matrix to map one image onto another using corresponding points. The procedure is outlined below:

  1. We start by selecting at lease 4 pairs of corresponding points between two images the source image and the reference image.

  2. For each correspondence pair in the source image and in the reference image, two linear equations are constructed. These equations are combined into a matrix A, which relates the point correspondences to the elements of the homography matrix H.

  3. By solving the system of equations Ah=0, where h is the flattened form of the homography matrix, we can compute H using SVD. The smallest singular value provides the solution for the homography matrix.

  4. Once the homography matrix is computed, we warp the source image so that it aligns with the reference image

Given Examples:

Normal Image Perspective Image Annotated corners in Perspective Image Warped and Overlaid Image

Q5: Bonus: More Planar Homography from Point Correspondences

The methodology in this section is same as Q3 we just do this multiple times and overlay the composite image with a new normal image multiple times

Normal Image1 Normal Image2 Normal Image3 Normal Image4 Perspective Image Final Warped and Overlaid Image