source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/BlueCCal/RansacM/rEG.m @ 86

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

Added original make3d

File size: 1.5 KB
Line 
1function [F, inls] = rEG(u,th,th4,conf,ss)
2% REG  robust estimation of the epipolar geometry via RANSAC
3%
4% [H, inls] = rRG(u,th,{th4=th,conf=0.99,ss=8})
5% u ... 6xN pairs homogenous coordinates
6% th ... inlier tolerance in pixels
7% th4 ... currently not used
8% conf ... confidence, the higher -> more samples
9% ss ... sample size
10%
11% F ... 3x3 fundamental matrix
12% inls ... 1xN logical 1->inlier. 0->outlier
13%
14% $Id: rEG.m,v 1.1 2005/05/23 16:16:00 svoboda Exp $
15
16
17MAX_SAM = 100000;  % maimal number of random samples
18
19len = size(u,2);
20
21% parsing the inputs
22if nargin < 3
23  th4 = th;
24end
25
26if nargin < 4
27  conf = 0.99;
28end
29
30if nargin < 5
31  ss = 8;          % sample size
32end
33
34len = size(u,2);
35ptr = 1:len;
36max_i = 5;
37max_sam = MAX_SAM;
38 
39no_sam = 0;
40no_mod = 0;
41 
42th = 2*th^2;
43
44while no_sam < max_sam   
45  for pos = 1:ss
46      idx = pos + ceil(rand * (len-pos));
47      ptr([pos, idx]) = ptr([idx, pos]);
48  end;
49 
50  no_sam = no_sam +1;
51 
52  sF = u2Fdlt(u(:,ptr(1:ss)),0);
53  errs = Fsampson(sF,u);
54  v        = errs < th;
55  no_i = sum(v);
56 
57  if max_i < no_i
58        inls = v;
59        F        = sF;
60        max_i = no_i;
61        max_sam = min([max_sam,nsamples(max_i, len, ss, conf)]);
62  end
63end
64
65%%%
66% refine the F by using all detected outliers and with point normalization
67F = u2Fdlt(u(:,inls),1);
68
69if no_sam == MAX_SAM
70  warning(sprintf('RANSAC - termination forced after %d samples expected number of samples is %d',  no_sam, exp_sam));
71else
72  disp(sprintf('RANSAC: %d samples, %d inliers out of %d points',no_sam,sum(inls),len))
73end;
74
75return;
Note: See TracBrowser for help on using the repository browser.