Lab 4: 2D projective geometry and homography estimation

428/615, Martin Jagersand

Submit code and report electronically through the upload link on the e-Class course webpage.
Marks may be given for any of the questions in the assignment, so please answer them all
(many only require a one sentence answer).
Demo: In your lab session.


Exercise 1: Affine and homogeneous transforms (1.5)

Consider the 3D point (10,10,10). Perform the following operations first using the affine formulation of the transforms (3 coordinates) and then rewrite them in homogeneous form (4 coordinates) . Draw a sketch with the initial and the transformed point (one figure).

What is the corresponding transformation if you perform the same operations to transform the coordinate frame? Write the homogeneous and affine representation of the transformation. Draw a sketch of the initial and transformed coordinate system (one figure).
Write a matlab function that takes a 3-D point, a translation vector and a rotation vector as input, and returns the new coordinate of the point and the composite transformation matrix T. Use this function to repeat the exercise above.
Note: Consider the rotations like in the following figure. Your rotation vector will be a vector of the rotation angles around each coordinate axis. Apply the rotations in the appropriate order to get the same results from your MATLAB function as the results you derived by hand.

Refer to Lecture 4

Exercise 2: 2D projective Geometry: Points, lines and their incidence. (3)

References: lec06ProjG2D.pdf slides 3-5 and lec01bCRV16-2018.pdf slides 46 - 47

a. Construct the mid-point and mid-lines of the football field in the image below. (1)

b. Constructing mid line in video sequence (1)

Some real-world applications of this: To think about: Can you solve the midpoint problem if the helicopter landing pad is circular and has no other markings ?

c. Parallel lines and line-to-line (1)

Some real-world applications of this:
Exercise 3: Homography estimation in static images (4.5)

Reference: lec06ProjG2D.pdf, slides 40-44

Given two images of a planar scene and a set of four or more 2D point correspondences between the images ( xi <--> x'i ), compute the homography, H, which relates one image to the other, and then apply H to the first image to see if you get similar image as the second one.

Some useful commands in matlab to select files and points: imgetfile, cpselect, uigetfile, getpts and possibly many others. Use doc in matlab command window or google the relevant commands.

(a). (1.5) Write a matlab program that displays two images. Allow the user to select four or more points in each image. Use these correspondences to estimate the homography by the direct linear transform algorithm (DLT). Apply the homography to the first image, such as using imwarp. For imwarp, you may need to use the transpose of your homography matrix, and may want to set the 'OutputView' argument to preserve the size of the image.

(b). (1) Recall that in DLT we need to constrain the magnitude of the homography H to be strictly positive, which is usually done by constraining the Euclidean norm of H to be 1 (as in (a)). We also need a loss function on the residual Ah, which is again usually done by the Euclidean norm (as in (a)). Replace the loss function by the L1 norm (sum of absolute values) and do (a) again.

A numerical procedure to solve the L1 norm based DLT is outlined here. Graduate students are welcome (but not compulsory) to come up with their own numerical procedures.

(c). (1) Add the normalization procedure into the DLT algorithm (in both (a) and (b)): For undergraduate students, translate the points such that they center around the origin, then scale the points such that their sum of distances to the origin is fixed to root 2; For graduate students, use principal component analysis to center the points and normalize the variances in different principal axes to unity. Please do NOT forget to apply the inverse normalization after estimating the homography.

(d). Discussion (1)

Compare (a) and (b) by deliberately picking some pair(s) of points that do not correspond to each other (i.e., outliers). Here is what I will do for the comparison: Choose perfect correspondences first and estimate the homography H by (a) and (b), then ruin some correspondence(s) and run (a) and (b) again, how significantly will the estimated homography change? (You can apply the homography to the image and see how the recovery changes). Repeat what you have done with (c) turned on.

Use the sample images below or capture your own.



Provide comments for each step of your implementation. I expect your implementation to have flags that can switch between (a) and (b), and can turn normalization (c) on and off.

Exercise 4: Homography on live video for Augmented Reality. (Bonus - 3)