This project is designed to build on top of project 2 in terms of improving the feature matching process between two images. The project is broken down into 2 parts: calculating the camera projection matrix (extrinsic) and camera center, and using the RANSAC algorithm to estimate the optimal fundamental matrix
The projection matrix formula is (x,y,1) = K*[R T]*(u,v,w,1)^T whereby (u,v,w,1) are homogeneous coordinates.
0.0445
Algorithm for Fundamental Matrix Estimation
Obtaining optimal fundamental Matrix
The following results display 30 random inliers. All of the image pairs show only around 1 or 2 inliers that are incorrectly marked
Vis Arrows | Left Epipolar Image | Right Epipolar Image | Best Fundamental Matrix |
---|---|---|---|
I'm using Gaudi and Notre Dame to demonstrate the effectiveness of normalization. As shown here, the accuracy of 30 random inliers for Gaudi and Notre Dame without normalization is <= 76.67%
Vis Arrows | Left Epipolar Image | Right Epipolar Image | Best Fundamental Matrix |
---|---|---|---|
The two tables above demonstrate the effect of coordinate normalization and that the accuracy is boosted with its implementation.
Implementation of extra credit
n = length(Points_a);
A = zeros(n, 9);
mean_a_u = mean2(Points_a(:,1));
mean_a_v = mean2(Points_a(:,2));
mean_b_u = mean2(Points_b(:,1));
mean_b_v = mean2(Points_b(:,2));
scale_a = 1/(abs(mean_a_u - mean_a_v));
scale_b = 1/(abs(mean_b_u - mean_b_v));
scale_matrix_a = [scale_a 0 0;...
0 scale_a 0; ...
0 0 1];
scale_matrix_b = [scale_b 0 0;...
0 scale_b 0; ...
0 0 1];
offset_matrix_a = [1 0 -mean_a_u;...
0 1 -mean_a_v; ...
0 0 1];
offset_matrix_b = [1 0 -mean_b_u;...
0 1 -mean_b_v; ...
0 0 1];
T_a = scale_matrix_a*offset_matrix_a;
T_b = scale_matrix_b*offset_matrix_b;
for i=1:n
a = T_a*[Points_a(i,:) 1]';
b = T_b*[Points_b(i,:) 1]';
a1 = a(1,1);
a2 = a(2,1);
b1 = b(1,1);
b2 = b(2,1);
A(i, :) = [b1*a1 b1*a2 b1 b2*a1 b2*a2 b2 a1 a2 1];
end
[U, S, V] = svd(A);
F = V(:,end);
F = reshape(F, [3 3])';
[U, S, V] = svd(F);
S(3,3) = 0;
F_matrix = U*S*V';
F_matrix = T_b'*F_matrix*T_a;
end