Name | Input Image | Annotated parallel lines on input image | Affine-Rectified Image | Annotated Affine-Rectified Image |
---|---|---|---|---|
book1 | ![]() |
![]() |
![]() |
![]() |
chess1 | ![]() |
![]() |
![]() |
![]() |
facade | ![]() |
![]() |
![]() |
![]() |
custom1 | ![]() |
![]() |
![]() |
![]() |
custom2 | ![]() |
![]() |
![]() |
![]() |
Name | Before | After | Test Image | Test Image (after rectification) |
---|---|---|---|---|
book1 | 0.9503 0.9999 | 1.0000 0.9999 | ![]() |
![]() |
chess1 | 0.9997 0.9790 | 0.9999 1.0000 | ![]() |
![]() |
facade | 0.9999 0.8178 | 0.9999 0.9999 | ![]() |
![]() |
custom1 | 0.9689 0.9999 | 0.9999 0.9999 | ![]() |
![]() |
custom2 | 0.4788 0.9998 | 0.9999 0.9999 | ![]() |
![]() |
Algorithm:
Identify 2 pairs of parallel lines by manually annotating 2 points for each line in the image.
Store the pixel coordinates and add a column of ones to convert them to homogeneous space.
Find the lines corresponding to these points using the cross product.
Compute the intersection points of each pair of lines: $$ p1 = l{11} \times l_{12}, \quad p2 = l{21} \times l_{22} $$
Determine the line at infinity by finding the cross product of the intersection points:
$$ l_{\infty} = p_1 \times p_2 $$
Apply a transformation to map l_{\infty} to the ideal line. The homography matrix is: $$ \mathbf{H} = \begin{bmatrix} 1 & 0 & 0 \ 0 & 1 & 0 \ l_1 & l_2 & l_3 \end{bmatrix} $$
Warp the original image using H to perform affine rectification.
Name | Input Image | Annotated parallel lines on input image | Affine-Rectified Image | Annotated Affine-Rectified Image |
---|---|---|---|---|
book1 | ![]() |
![]() |
![]() |
![]() |
chess1 | ![]() |
![]() |
![]() |
![]() |
facade | ![]() |
![]() |
![]() |
![]() |
custom1 | ![]() |
![]() |
![]() |
![]() |
custom2 | ![]() |
![]() |
![]() |
![]() |
Name | Before | After | Test Image | Test Image (after rectification) |
---|---|---|---|---|
book1 | -0.4058 0.4449 | 0.0009 -0.0858 | ![]() |
![]() |
chess1 | -0.6685 0.0211 | -0.0448 -0.0096 | ![]() |
![]() |
facade | 0.1918 -0.1065 | -0.0461 0.0107 | ![]() |
![]() |
custom1 | 0.5437 -0.2881 | 0.0062 0.0212 | ![]() |
![]() |
custom2 | -0.0183 -0.0145 | 0.0082 -0.0124 | ![]() |
![]() |
Convert Points and Compute Lines: Convert each point to homogeneous coordinates and apply the affine transformation: pi^{\prime}=H{\mathrm{affine}} p_i. Compute the line equation for each pair of transformed points using the cross product: \ell^{\prime}=p_1^{\prime} \times p_2^{\prime}. This results in four lines representing two pairs of perpendicular lines in the affine-rectified image.
Compute the Transformed Circle Conic: For two perpendicular lines, the relation $l^TCm=0$ gives the matrix equation: $$ A=U \Sigma V^T $$
Compute the Rectification Matrix, the rectification matrix is: H_{\text {rect }}=\operatorname{diag}\left(1 / \sqrt{\sigma_1}, 1 / \sqrt{\sigma_2}, 1\right) V^T
Apply Metric Rectification to the affine-rectified image to obtain the metric rectified image:
$$ x^{\prime \prime}=H_{\text {rect }} x^{\prime} $$
original Image | Perspective Image | Overlaid Image |
---|---|---|
![]() |
![]() |
![]() |
Annotate Corner Points Annotate the four target corner points on the perspective image in pixel coordinates. The corresponding source corner points from the normal image are its four corners.
Compute Homography Matrix Convert the source and target points to homogeneous coordinates. The transformation satisfies the relation $$ $p^{\prime} \equiv H p$. $$ Each correspondence provides 2 independent equations, forming matrix A. Solve Ah = 0 using SVD to get the homography matrix H, reshaped from the null vector h.
Apply Homography Apply the homography matrix H to each point in the normal image to warp and overlay it onto the perspective image.