[F, G] = u2FG( u1, u2 )
The function u2FG computes the 'fundamental matrix' G using the eight-point algorithm from 8 euclidean correspondences u1, u2, measured in two images. Then the true fundamental matrix F is found, which is close to G and rank(F) = 2.
Inside this function, prior to constructing a matrix for SVD, the points must be normalized. This can be done by subtracting a centroid of the 8 points and dividing by it's standard deviation; in each image separately. Express the normalization as homographies H1 and H2, the points are modified by these.
u1n = H1 * u1p; % u1p are homogeneous u2n = H2 * u2p; % u2p are homogeneous
Then the computed Gn and Fn relate the normalized correspondences u1n and u2n and must be back-normalized.
G = H2' * Gn * H1 F = H2' * Fn * H1
The matrix Gn computed by SVD has usually rank = 3 due to noise in data. Therefore modification to rank = 2 is needed. Compute SVD of the Gn, nullify the D(3,3) and compose the matrix back.
1. Correspondences between the images
2. Epipolar geometry
F relating the images above: generate all (495) 8-tuples from the set of 12 correspondences, estimate (the true) F for each of them and chose the one, that minimizes maximal epipolar error over all (i.e. the 12 + the mesh) matches.
F, compute epipolar lines l1_i = F'*x2_i and l2_i = F*x1_i (provided that points are homogeneous) for each point i. Then evaluate the Euclidean distances d1_i = d(x1_i,l1_i) and d2_i = d(x2_i,l2_i) in images. The epipolar error for the i-th match is defined as d1_i + d2_i.
F, compute the corresponding epipolar lines and draw them into the images in corresponding colours (a line segment given by the intersection of the image area and a line must me computed). Export as 08_eg.pdf.
d1_i and d2_i for all points (point index on horizontal axis, the error on vertical axis). Draw both graphs into single figure (different colours) and export as 08_errors.pdf.
08_data.mat: all correspondences as u1, u2, the indices of the 12 selected correspondences as point_sel, the 'best' matrices F and G.
Hand an archive consisting of:
08_eg.pdf
08_errors.pdf
08_data.mat
u2FG.m
hw08.m – your Matlab implementation entry point.
any other files required by hw08.m (including data and files from the repository).