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

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

Added original make3d

File size: 1.5 KB
Line 
1%       By Philip Torr 2002
2%       copyright Microsoft Corp.
3function [f,f_sq_errors, n_inliers,inlier_index] = torr_mapsac_F(x1,y1,x2,y2, no_matches, m3, no_samp, T)
4%disp('This just does calculation of perfect data,for test')
5%disp('Use estf otherwise')
6%f = rand(9);% estimate fundamental matrix from perfect points??
7
8function f = torr_mapsach(x1,y1,x2,y2, no_matches,m3, no_samp, T)
9%disp('This just does calculation of perfect data,for test')
10%disp('Use estf otherwise')
11f = rand(9);
12no_samp = 200;
13ptot = 0.0;
14
15   et = errh(f,x1,y1,x2,y2, no_matches, m3);
16   bestsse = norm(et) * norm(et);
17
18for(i = 1:no_samp)
19   
20   choice = randperm(no_matches);
21   
22   %set up local design matrix
23   for (j = 1:4)
24      tx1(j) = x1( choice(j));   
25      tx2(j) = x2( choice(j));   
26      ty1(j) = y1( choice(j));   
27      ty2(j) = y2( choice(j));   
28     
29   end
30   
31   ft = esth(tx1,ty1,tx2,ty2,4,m3);
32   et = errh(ft,x1,y1,x2,y2, no_matches, m3);
33   sse(i) = norm(et) * norm(et);
34   % use sse 0 to bring it to a reasonable value
35   
36   if i ==0
37      f = ft;
38      bestsse = sse(i);
39   elseif bestsse > sse(i)
40      f = ft;
41      bestsse = sse(i);
42   end
43   
44   
45   
46   p(i) = exp( -sse(i));
47   ptot = ptot + p(i);
48   
49end
50
51
52%bayes factor
53bf = 0.0;
54logptot = log(ptot);
55for(i = 1:no_samp)
56   sse2(i) = - sse(i) - logptot;
57   %integrate p(D|R)p(R)
58   p(i) =p(i)*  exp( sse2(i) );
59   bf = bf + p(i);
60end
61
62%ptot
63bf
64logbf = log(bf)
65%log(p)
66%maybe do  a better fit after
Note: See TracBrowser for help on using the repository browser.