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

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

Added original make3d

File size: 3.2 KB
Line 
1%       By Philip Torr 2002
2%       copyright Microsoft Corp.
3%
4% %designed for the good of the world by Philip Torr
5% copyright Philip Torr and Microsoft Corp 2002
6% linear estimation of H
7%
8% @article{Torr99c,
9%         author = "Torr, P. H. S.   and Zisserman, A",
10%         title ="MLESAC: A New Robust Estimator with Application to Estimating Image Geometry ",
11%         journal = "CVIU",
12%         Volume = {78},
13%         number = 1,
14%         pages = {138-156},
15%         year = 2000}
16%
17% %MAPSAC is the Bayesian version of MLESAC, and it is easier to pronounce!
18% it is described in:
19%
20% @article{Torr02d,
21%         author = "Torr, P. H. S.",
22%         title ="Bayesian Model Estimation and  Selection for Epipolar Geometry and
23% Generic Manifold Fitting",
24%         journal = "IJCV",
25%         Volume = {?},
26%         number = ?,
27%         pages = {?},
28%         url = "http://research.microsoft.com/~philtorr/",
29%         year = 2002}
30%
31
32function [h,h_sq_errors, n_inliers,inlier_index]  = torr_mapsac_H(x1,y1,x2,y2, no_matches,m3, no_samp, T)
33
34%disp('mapsac-ing H')
35%bestsse = T * no_matches + 1;
36
37%%%%%%%%%%debug
38%used for debugging:
39no_trials = 1;
40max_inliers = 0;
41%%%%%%%%%%end debug
42
43
44
45for(i = 1:no_samp)
46   
47    choice = randperm(no_matches);
48   
49    %set up local design matrix
50    for (j = 1:4)
51        tx1(j) = x1( choice(j));   
52        tx2(j) = x2( choice(j));   
53        ty1(j) = y1( choice(j));   
54        ty2(j) = y2( choice(j));   
55       
56    end
57   
58     %generate trial h
59    ht = torr_esth(tx1,ty1,tx2,ty2,4,m3);
60   
61    %get squared errors
62    et = torr_errh(ht,x1,y1,x2,y2, no_matches, m3);
63   
64    %capped residuals
65    cet = min(et,T);
66    sse = cet' * cet;
67   
68   
69    if i ==1
70        h = ht;
71      bestsse = sse;
72   elseif bestsse > sse
73      h = ht;
74      bestsse = sse;
75   end
76   
77       %monitor progress %debug
78    inlier_index = find((et < T) == 1);
79    mapsac_inliers(no_trials) = length(inlier_index);
80    if mapsac_inliers(no_trials) > max_inliers
81        max_inliers = mapsac_inliers(no_trials);
82    else
83        mapsac_inliers(no_trials) = max_inliers;
84    end
85    no_trials = no_trials + 1;
86    %%%%%%%%end debug
87   
88   
89end
90%calculate squared errors (distance to manifold of F)
91h_sq_errors = torr_errh(h,x1,y1,x2,y2, no_matches, m3);
92%next generate index set of inliers
93inlier_index = find((h_sq_errors < T) == 1);
94n_inliers = length(inlier_index);
95
96
97
98
99
100%%%%%%%%%%debug
101%for NAPSAC paper
102no_matches
103n_inliers
104no_trials
105
106mapsac_inliers(1:30)
107%find out how many it took to get to n_inliers
108perc = n_inliers;
109map_index = find((mapsac_inliers < perc) == 1);
110perc100 = length(map_index)+1
111%find out how many it took to get to n_inliers
112
113perc = n_inliers * 0.9;
114map_index = find((mapsac_inliers < perc) == 1);
115perc90 = length(map_index)+1
116
117perc = n_inliers * 0.8;
118map_index = find((mapsac_inliers < perc) == 1);
119perc80 = length(map_index)+1
120
121
122
123perc = n_inliers * 0.7;
124map_index = find((mapsac_inliers < perc) == 1);
125perc70 = length(map_index)+1
126
127
128
129perc = n_inliers * 0.6;
130map_index = find((mapsac_inliers < perc) == 1);
131perc60 = length(map_index)+1
132
133n_inliers
134
135disp('Mapsac');
Note: See TracBrowser for help on using the repository browser.