-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask5.m
More file actions
40 lines (28 loc) · 1.12 KB
/
task5.m
File metadata and controls
40 lines (28 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
load 'Task3_pixel_coords.mat';
% run('task4.m') % To load necessary variables
% run('task1.m')
% Fundamental Matrix already computed in Task 4
% Compute the symmetric epipolar distance
num_points = size(Im1_film_matrix, 2);
distances = zeros(num_points, 1);
for i = 1:num_points
% Point from image 1
x1 = Im1_film_matrix(1, i);
y1 = Im1_film_matrix(2, i);
% Corresponding point from image 2
x2 = Im2_film_matrix(1, i);
y2 = Im2_film_matrix(2, i);
% Epipolar line in image 2 for point from image 1
l2 = F * [x1; y1; 1];
% Squared distance from point in image 2 to epipolar line
d2_1 = (l2(1)*x2 + l2(2)*y2 + l2(3))^2 / (l2(1)^2 + l2(2)^2);
% Epipolar line in image 1 for point from image 2
l1 = F' * [x2; y2; 1];
% Squared distance from point in image 1 to epipolar line
d2_2 = (l1(1)*x1 + l1(2)*y1 + l1(3))^2 / (l1(1)^2 + l1(2)^2);
% Sum of squared distances
distances(i) = d2_1 + d2_2;
end
% Compute the mean of the squared distances
mean_distance = mean(distances);
disp([newline,'Mean Symmetric Epipolar Distance: ', num2str(mean_distance)]);