source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/torr/torr_estimateF.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.7 KB
Line 
1%       By Philip Torr 2002
2%       copyright Microsoft Corp.
3
4%this is a set of functions for minimizing F
5
6function [f, f_sq_errors, n_inliers,inlier_index,F] = torr_estimateF( matches, m3, f_optim_parameters, method, set_rank2, f_init)
7
8no_matches = length(matches);
9x1 = matches(:,1);
10y1 = matches(:,2);
11x2 = matches(:,3);
12y2 = matches(:,4);
13
14
15if nargin <5
16    set_rank2 = 0;
17end
18
19switch lower(method)
20        %as in ransac and torr mlesac/mapsac papers
21case {'mlesac',0}
22    no_samp = f_optim_parameters(1);
23    T = f_optim_parameters(2);
24    f = torr_mlesac_F(x1,y1,x2,y2, no_matches, m3, no_samp, T);
25    %function f = mlesac_F(x1,y1,x2,y2, n_matches, m3, no_samp, f_threshold)
26    %as in ransac and torr mlesac/mapsac papers
27   
28   
29case {'mapsac',1}
30    if isempty(f_optim_parameters)
31        no_samp =1000;
32        T = 4;
33    else
34        no_samp = f_optim_parameters(1);
35        T = f_optim_parameters(2);
36    end       
37    [f,f_sq_errors, n_inliers,inlier_index] = torr_mapsac_F(x1,y1,x2,y2, no_matches, m3, no_samp, T);
38   
39   
40case {'linear',2}
41    f = torr_estf(x1,y1,x2,y2, no_matches,m3);
42   
43    %as in Torr & Fitzgibbon paper
44case {'bookstein',3}
45    f = torr_estf_bookstein(x1,y1,x2,y2, no_matches,m3);
46   
47 
48   
49case {'b+sampson','boosam',4}
50    f = torr_estf_bookstein_sampson(x1,y1,x2,y2, no_matches,m3);
51   
52case {'non_linear',5}
53    f = torr_nonlinf_mincon2x2(f_init, x1,y1,x2,y2, no_matches, m3);
54   
55case {'lin+non_lin',6}
56    set_rank2 = 1;
57    f = torr_estimateF(matches, m3, [], 'linear',set_rank2);
58    f = torr_estimateF(matches, m3, [], 'non_linear',set_rank2,f);
59   
60case {'hegel1',7}
61   f = torr_estimateF(matches, m3, [], 'linear');
62   f = ant_fnsf(x1,y1,x2,y2,m3,f);
63   
64otherwise
65    disp('Unknown method.')
66end
67
68
69
70F = reshape(f, 3, 3);
71%make it my way round
72F = F';
73
74
75
76%the F matrix is defined like:
77   % (nx2, ny2, m3) f(1 2 3) nx1
78   %                 (4 5 6) ny1 
79   %                 (7 8 9) m3
80
81% disp('before rank 2')
82% F
83if set_rank2
84    [U,S,V] = svd(F);
85    S(3,3) = 0;
86    F = U*S*V';
87    f = reshape(F',9,1);
88end
89% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90% disp('after rank 2')
91% F
92
93% % Unit fro-norm F:
94% fn = norm(F(:));
95% fn = 2^(-floor(log(fn) / log(2)));
96% F = F * fn;
97
98F = F/norm(F,'fro');
99f = f/norm(f);
100
101switch lower(method)
102case {'bookstein',3,'linear',2,'bookstein',3,'b+sampson','boosam',4,'non_linear',5,'lin+non_lin',6, ...
103        'hegel1',7}
104    %f = reshape(F',9,1);   %calculate squared errors (distance to manifold of F)
105    f_sq_errors = torr_errf2(f,x1,y1,x2,y2, no_matches, m3);
106    %next generate index set of inliers
107    T = 10;
108    inlier_index = find((f_sq_errors < T) == 1);
109    n_inliers = length(inlier_index);
110   
111
112end
113
Note: See TracBrowser for help on using the repository browser.