Assignment 1
Roshan Roy (roshanr)
Late Days: 1
Q1. Affine Rectification
Implementation Explained
- Calculate lines from consecutive points
- For lines and , calculate the intersection point . For lines and , calculate the intersection point .
- Calculate the image of the line at infinity
- The homography such that becomes is
- Warp the entire image with the homography
Tiles 5
cosine before | cosine after |
0.9868327646462675 | 0.9999251970022867 |
0.9987191070813485 | 0.9999383464088628 |
Tiles 3
cosine before | cosine after |
0.9868327646462675 | 0.9999251970022867 |
0.9987191070813485 | 0.9999383464088628 |
Facade
cosine before | cosine after |
0.7842324298864691 | 0.9999781395179718 |
0.999997015205378 | 0.9999869448826935 |
Custom Image 1
cosine before | cosine after |
0.999153546664808 | 0.9992655574980497 |
0.9983015358150276 | 0.9992655574980497 |
Custom Image 2
cosine before | cosine after |
0.998043936665419 | 0.9991465474980309 |
0.9993104678150189 | 0.9993455575680324 |
Q2. Metric Rectification
Implementation Explained
- Calculate lines from consecutive points. There should be 8 lines.
- Perform affine rectification of the image.
- Find for perpendicular lines such that
Since affine rectification of lines has already occurred, the matrix is expressed as:
- Collect 2 additional pairs of points for metric rectification since there are 2 remaining DoF. For each pair,
Setup the A matrix where each row contains a constraint from a pair of points.
- Solve using SVD to find
- Use SVD on to split it into matrices . The rectification matrix is given by:
Tiles 5
cosine before | cosine after |
0.19963725801696636 | -0.10807147974411524 |
-0.008091866263126116 | -0.029306932732914914 |
Tiles 3
cosine before | cosine after |
0.5980143904042284 | 0.6325307814220813 |
-0.01932094401210063 | 0.0295500629526544 |
Facade
cosine before | cosine after |
-0.668424698615251 | 0.6895051536253906 |
0.0460718686164777 | 0.01074685806717125 |
Custom 1
cosine before | cosine after |
0.5515686219390936 | 0.0900216412583554 |
0.16547797944608014 | 0.024742420217575188 |
Q3. Planar Homography
Implementation Details
First, we normalize the points in both images to bring it to similar scales.
For a given pair of correspondences,
We introduce the constraint
After expanding and massaging this equation (where h is an unrolled vector of 9 elements):
Note that this only gives us two constraints, not 3.
Given 4 point correspondences (H has 8 DoF), we stack the system of linear equations into the form . We solve with the constraint to avoid the trivial solution. Solve for h using SVD (h is the right singular vector of V).
Book on Table
Custom Image
Q4. Metric Rectification with Perpendicular Lines
Implementation Steps
- Calculate lines from consecutive points. Calculate all 8 lines:
- Find for perpendicular lines such that
is of the form
- Collect 5 pairs of perpendicular points for metric rectification since there are 5 DoF, and since each pair gives one constraint. For each pair:
- Setup the A matrix where each row contains a constraint from a pair of points.
- Solve using SVD to find
- Use SVD on to split it into matrices . The rectification matrix is given by:
- Warp the image with this matrix.
Tiles 5
cosine before | cosine after |
-0.0042055141371639656 | -0.07386339052291979 |
-0.19065250691171096 | -0.12920370791376876 |
Custom Image
cosine before | cosine after |
0.15904267459261565 | 0.17378726431444147 |
0.06352236613650239 | 0.09511044114149836 |
Q5. Bonus
A picture of my old roommate’s dog Rosy on multiple Times Square billboards. Implementation is similar to that of Q3, just applied multiple times. Please refer to the code for more details.