-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patherror_plane.m
68 lines (56 loc) · 1.65 KB
/
error_plane.m
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function [E T_noise_squared d] = error_plane(Theta, X, sigma, P_inlier)
% [E T_noise_squared d] = error_plane(Theta, X, sigma, P_inlier)
%
% DESC:
% estimate the squared fitting error for a plane expresed in cartesian form
%
% a*x1+b*y1+c*z1+d = 0
% a*x2+b*y2+c*z2+d = 0
% a*x3+b*y3+c*z3+d = 0
%
% AUTHOR
% Marco Zuliani - marco.zuliani@gmail.com
%
% VERSION:
% 1.0.1
%
% INPUT:
% Theta = plane parameter vector
% X = samples on the manifold
% sigma = noise std
% P_inlier = Chi squared probability threshold for inliers
% If 0 then use directly sigma.
%
% OUTPUT:
% E = squared symmetric reprojection error
% T_noise_squared = squared noise threshold
% d = degrees of freedom of the error distribution
% HISTORY
%
% 1.0.0 - 07/05/08 initial version
% 1.0.1 - 02/22/09 updated error threshold
% compute the squared error
E = [];
if ~isempty(Theta) && ~isempty(X)
den = Theta(1)^2 + Theta(2)^2 + Theta(3)^2;
E = ( ...
Theta(1)*X(1,:) + ...
Theta(2)*X(2,:) + ...
Theta(3)*X(3,:) + ...
Theta(4)...
).^2 / den;
end;
% compute the error threshold
if (nargout > 1)
if (P_inlier == 0)
T_noise_squared = sigma;
else
% Assumes the errors are normally distributed. Hence the sum of
% their squares is Chi distributed (with 3 DOF since we are
% computing the distance of a 3D point to a plane)
d = 3;
% compute the inverse probability
T_noise_squared = sigma^2 * chi2inv_LUT(P_inlier, d);
end;
end;
return;