1 | function [R, means, stds] = trans_best(a, stab, fname) |
---|
2 | % a contains the results of the new experiments, that contain the new algorithm |
---|
3 | % geared for sfm. |
---|
4 | |
---|
5 | % Each iteration had 12 results. All but one had no translation in the |
---|
6 | % motion, and did not allow for translation in the algorithm. There |
---|
7 | % were: five applications of Shum with random starting points, the old |
---|
8 | % method, old + shum, the new method (geared to motion, using all frame |
---|
9 | % pairs, but with no translation allowed), new method + shum, new method |
---|
10 | % allowing for translation, ground truth, ground truth + shum. |
---|
11 | |
---|
12 | % I'm going to ignore the old method here, since it seems clearly worse than the new |
---|
13 | % one, and I won't include it in the paper. |
---|
14 | |
---|
15 | R = []; |
---|
16 | for marg = [2, 1.1, 1.01]; |
---|
17 | % We'll look for all results within 10 percent of the best solution. |
---|
18 | |
---|
19 | numrows = size(a,1); |
---|
20 | |
---|
21 | its = abs(a(:,[1:5,9,12])); |
---|
22 | minits = (min(its'))'; |
---|
23 | minits_marg = marg*minits; |
---|
24 | itsbest = its < minits_marg*ones(1,7); |
---|
25 | |
---|
26 | ran1 = sum(sum(itsbest(:,1:5)))/(5*numrows); |
---|
27 | ran3 = sum(max((itsbest(:,1:3))'))'/numrows; |
---|
28 | ran5 = sum(max((itsbest(:,1:5))'))'/numrows; |
---|
29 | |
---|
30 | Rt = [ran1,ran3,ran5,sum(itsbest(:,6:7))/numrows]; |
---|
31 | R = [R;Rt]; |
---|
32 | end |
---|
33 | |
---|
34 | % Here I'm going to process results by producing mean and standard deviation. |
---|
35 | |
---|
36 | shum1 = abs(reshape(a(:,1:5),numrows*5,1)); |
---|
37 | m1 = mean(shum1); |
---|
38 | s1 = std(shum1)/sqrt(5*numrows); |
---|
39 | shum3 = (min(abs((a(:,1:3))')))'; |
---|
40 | shum5 = (min(abs((a(:,1:5))')))'; |
---|
41 | exps = [shum3, shum5, abs(a(:,6:12))]; |
---|
42 | |
---|
43 | stabs = [ones(numrows,2), stab(:,6), stab(:,6), stab(:,8), stab(:,8), ... |
---|
44 | stab(:,10), ones(numrows,2)]; |
---|
45 | % My methods, and iterative refinements of them may be unstable. |
---|
46 | stabexps = exps.*stabs |
---|
47 | numstab = sum(stabs) |
---|
48 | means = [m1, sum(stabexps)./numstab]; |
---|
49 | stds = [s1, sqrt( sum(stabexps.^2)./numstab - (sum(stabexps)./numstab).^2)./sqrt(numstab)]; |
---|
50 | |
---|
51 | %means = [m1,mean(exps)]; |
---|
52 | %stds = [s1,std(exps)./sqrt(numrows)]; |
---|
53 |
|
---|
54 | if fname
|
---|
55 | fid = fopen(fname, 'a'); |
---|
56 | fprintf(fid, '%% Data written from trans_best.\n\n'); |
---|
57 | |
---|
58 | fprintf(fid, 'Mean/(standard deviation) of: 1it, 3it, 5it, old, oldit, new, newit, newtrans, gt, gtit\n\n'); |
---|
59 | for i = 1:10 |
---|
60 | m = means(i); |
---|
61 | s = stds(i); |
---|
62 | fprintf(fid, '%4.8f/(%4.8f)\n', m, s); |
---|
63 | end |
---|
64 | |
---|
65 | fprintf(fid, '\n\nFraction times each iterative method converged to right answer.'); |
---|
66 | fprintf(fid, '\nMethods are 1it, 3it, 5it, newit, gtit'); |
---|
67 | fprintf(fid, '\nRows show convergence within 100, 10 and 1 percent of best answer.'); |
---|
68 | |
---|
69 | fprintf(fid, '\n\n %1.4f %1.4f %1.4f %1.4f %1.4f', R(1,1), R(1,2), R(1,3), R(1,4), R(1,5)); |
---|
70 | fprintf(fid, '\n %1.4f %1.4f %1.4f %1.4f %1.4f', R(2,1), R(2,2), R(2,3), R(2,4), R(2,5)); |
---|
71 | fprintf(fid, '\n %1.4f %1.4f %1.4f %1.4f %1.4f', R(3,1), R(3,2), R(3,3), R(3,4), R(3,5)); |
---|
72 | |
---|
73 | fclose(fid); |
---|
74 | end |
---|