16-822 Assignment1

Q1: Affine Rectification (30 points)

We can get the line by using the cross product of 2 points l=p1×p2, and two pairs of parallel lines can be denoted as l1 and l2, and l3 and l4. Then, we can get two infinite points using these lines p1=l1×l2 and p2=l3×l4. From the two infinite points we can get the infinite line l=p1×p2. Now we can construct the 3x3 homography matrix by setting the third row to l and the other diagnal values to 0.

We can show the results as follows. Each example will include the evaluate angles before and after affine rectification, and a row of visualizations: {input annotated parallel lines | affine-rectified image | input test lines | affined-rectified test lines},

Example1: consines of test lines before affine-rectification: 0.9868 and 0.9987; after affine-rectification: 0.9999 and 0.9999.

q1_1_1q1_1_2q1_1_3q1_1_4

Example2: consines of test lines before affine-rectification: 0.7842 and 0.9999; after affine-rectification: 0.9999 and 0.9999.

q1_2_1q1_2_2q1_2_3q1_2_4

Example3: consines of test lines before affine-rectification: 0.8964 and 0.9574; after affine-rectification: 0.9999 and 0.9999.

q1_3_1q1_3_2q1_3_3q1_3_4

Example4: consines of test lines before affine-rectification: 0.9997 and 0.9911; after affine-rectification: 0.9999 and 0.9999.

q1_4_1q1_4_2q1_4_3q1_4_4

Example5: consines of test lines before affine-rectification: and ; after affine-rectification: and .

q1_5_1q1_5_2q1_5_3q1_5_4

 

Q2: Metric Rectification (40 points)

Using the affine rectification matrix from Q1, we can get the affine rectified images. And from it, we can get the metric rectification simply by using two pairs of perpendicular lines. Suppose for these two pairs of lines, each line pair can be annotated as l=[x1,y1,1]T and m=[x2,y2,1]T, we want to solve C=[ab/20b/2c0000] which satisfies lTCm=0. Thus, for each pair we can get a condition that is x1x2a+x1y2+y1x22b+y1y2c=0, and with two such conditions, to solve for [a,b,c]T, which is orthogonal to two conditions of [x1x2,x1y2+y1x22,y1y2], we can take the cross products of these two conditions and solve for C. Then with C, we can conduct singular value decomposition on it getting U,S,VT. With the two non-zero values from S, which can be annotated as σ1 and σ2, we can get the metric rectification homography matrix Hs which can be calculated by [1/σ10001/σ20001] and UT.

We can show the results as follows. Each example will include the evaluate angles before and after metric rectification, and a row of visualizations: {input annotated perpendicular lines | affine-rectified image | metric-rectified image | input test lines | affined-rectified test lines | metric-rectified test lines},

Example1: consines of test lines before metric-rectification: -0.1677 and -0.0349; after metric-rectification: 0.0081 and 0.0293.

q2_1_1q2_1_2q2_1_3

q2_1_4q2_1_5q2_1_6

Example2: consines of test lines before metric-rectification: 0.1919 and -0.1065; after metric-rectification: -0.0461 and 0.0107.

q2_2_1q2_2_2q2_2_3

q2_2_4q2_2_5q2_2_6

Example3: consines of test lines before metric-rectification: 0.2527 and 0.0882; after metric-rectification: -0.0018 and 0.0082.

q2_3_1q2_3_2q2_3_3

q2_3_4q2_3_5q2_3_6

Example4: consines of test lines before metric-rectification: -0.3019 and -0.1722; after metric-rectification: -0.0347 and -0.0404.

q2_4_4q2_4_5q2_4_6

q2_4_1q2_4_2q2_3_6

Example5: consines of test lines before metric-rectification: 0.9184 and 0.9073; after metric-rectification: 0.0876 and 0.0213.

q2_5_1q2_5_2q2_5_3

q2_5_4q2_5_5q2_5_6

 

Q3: Planar Homography from Point Correspondences (30 points)

We want to find the H that can transform each point from [x1,y1,1] to [x1,y1,1]. So this 3x3 matrix, whose parameters can be annotated from h0 to h9, can be solved by 4 point correspondences, where each correspondance can be expressed in matrix A=[x1y11000x1x1y1x1x1000x1y11x1y1y1y1y1]. To solve for H, we can also apply SVD on A, and select the last row of VT.

We can show the results as follows. Each example will include a row of visualizations: {normal Image | perspecticve image | output image}.

Example1:

q3_1_1q3_1_2q3_1_3

Example2:

q5_1_4q3_1_2q3_1_2

 

Q4: Bonus: Metric Rectification from Perpendicular Lines (10 points)

Now we do not have the affine rectified images, but we have 5 pairs of perpendicular lines. Similar as Q2, each line pair can be annotated as l=[x1,y1,1]T and m=[x2,y2,1]T, but we want to solve C=[ab/2d/2b/2ce/2d/2e/2f] which satisfies lTCm=0. Thus, for each pair we can get a condition that is x1x2a+x1y2+y1x22b+y1y2c+x1+x22d+y1+y22e+f=0. With five such conditions, to solve for [a,b,c,d,e,f]T, we can perform SVD on the 5x6 condition matrix, and set the result as the last row of VT. After getting the a,b,c,d,e,f, we get the C, and the remaining operation is same as Q2.

We can show the results as follows. Each example will include the 3 evaluate angles before and after metric rectification, and a row of visualizations: {input annotated perpendicular lines | metric-rectified image}

Example1: consines of test lines before metric-rectification: -0.1476, -0.1761 and 0.1482; after metric-rectification: 0.0063, 0.0155, and 0.0515.

q4_1_1q4_1_2

Example2: consines of test lines before metric-rectification: -0.1579, -0.2694 and -0.3019; after metric-rectification: -0.0129, -0.0118, and -0.0221.

q4_2_1q4_2_2

 

Q5: Bonus: More Planar Homography from Point Correspondences (10 points)

Using the same approach from Q3, we can overlay 3 normal images on top of an image with perspective effect by applying Q3 three times. The result is as follows:

input images:

q5_1_1q5_1_2q5_1_3q5_1_4

Output image:

q5_1_5