[37] | 1 | function [toterr,totafferr,totstable] = comp_transmot(fo,nframes,npoints,frot,ftrans,sigma,n, real) |
---|
| 2 | % I will compare my methods to see how they work when there is translation. |
---|
| 3 | % The parameters to this function are just like compare_motions. I also allow |
---|
| 4 | % a translation to be added to the motions (I don't think this makes any difference. |
---|
| 5 | % what's important is whether translation is known or not. Whether there actually |
---|
| 6 | % is any translation or not, and what it's magnitude is, shouldn't matter). |
---|
| 7 | % ftrans indicates magnitude of translation (direction will be constant). Reasonable |
---|
| 8 | % ftrans is probably about .5. |
---|
| 9 | % |
---|
| 10 | % I will compare two possibilities. One, in which there is no translation |
---|
| 11 | % (this is like the old experiments). |
---|
| 12 | % Two, in which translation is added in to a motion that is otherwise the same, |
---|
| 13 | % and the new method is used to estimate the rank 4 matrix with one |
---|
| 14 | % vector constrained to be (1 1 1 ... 1). |
---|
| 15 | % |
---|
| 16 | % In the first case, I will run SHUM with five random starting points; I will run |
---|
| 17 | % my new method with and without iterative refinement, my old method with and |
---|
| 18 | % without refinement (if this is clearly inferior, I may eliminate it) |
---|
| 19 | % and I'll take ground truth with and without iterative refinement. |
---|
| 20 | % In the second case, I'll just run the new method. |
---|
| 21 | |
---|
| 22 | r = 3; |
---|
| 23 | num_data = 12; |
---|
| 24 | coltrips = 1000; |
---|
| 25 | |
---|
| 26 | for j = 1:n |
---|
| 27 | if ~ isempty(real) |
---|
| 28 | INC = motion_incidence(fo,nframes,npoints); |
---|
| 29 | Dtj = remove_translations(real, INC); |
---|
| 30 | [M, pts] = approx_full_matrix(Dtj,3); |
---|
| 31 | ERR = Dtj - M; |
---|
| 32 | Mt = real - ERR; |
---|
| 33 | end |
---|
| 34 | if isempty(real) [M,INC,pts] = occluded_motion(fo,nframes,npoints,frot,0); end |
---|
| 35 | if isempty(real) ERR = randn(size(M)).*sigma; end |
---|
| 36 | [M, INC, ERR, pts] = rem_inc_els_pts(M, INC, ERR, pts, 4); |
---|
| 37 | % occpercent = 1 - sum(sum(INC))/size(M,1)/size(M,2); |
---|
| 38 | INCsize = min(size(INC)); |
---|
| 39 | if INCsize < 4 |
---|
| 40 | err = repeat(-1,num_data); |
---|
| 41 | aff_err = repeat(-1,num_data); |
---|
| 42 | stable = repeat(-1,num_data); |
---|
| 43 | else |
---|
| 44 | Mt = add_translations(M,ftrans); |
---|
| 45 | Merr = M + ERR; |
---|
| 46 | [shum_err, shum_aff_err, shum_stab] = compshum(Merr, pts, INC, r, 5); |
---|
| 47 | [old_err, old_res, old_stable] = rankr(Merr,INC,3,coltrips,j); |
---|
| 48 | [old_aff_err, old_shum_err, old_shum_aff_err, old_shum_stab] ... |
---|
| 49 | = process_sol(old_err, old_res, Merr, pts, INC, r); |
---|
| 50 | [rankr_err, rankr_res, rankr_stable] = rankrsfm_tpose(Merr,INC,0); |
---|
| 51 | % 0 means no translations. |
---|
| 52 | [rankr_aff_err, rankr_shum_err, rankr_shum_aff_err, rankr_shum_stab] ... |
---|
| 53 | = process_sol(rankr_err, rankr_res, Merr, pts, INC, r); |
---|
| 54 | [rankr_trans_err, rankr_trans_aff_err, trans_stable] = rankrsfm_aff_err(Mt,INC,ERR,pts); |
---|
| 55 | ground_truth_aff_err = affine_error(M,pts,r); |
---|
| 56 | ground_truth_err = sum(sum((M.*INC - Merr.*INC).^2)); |
---|
| 57 | [gt_shum_err, gt_shum_res, gt_shum_stab] = shum(Merr,INC,r,M,100); |
---|
| 58 | if gt_shum_err ~= -2 |
---|
| 59 | gt_shum_aff_err = affine_error(gt_shum_res, pts, r); |
---|
| 60 | else |
---|
| 61 | gt_shum_aff_err = -2; |
---|
| 62 | end |
---|
| 63 | |
---|
| 64 | err=[shum_err,old_err,old_shum_err,rankr_err,rankr_shum_err,rankr_trans_err, ... |
---|
| 65 | ground_truth_err,gt_shum_err]; |
---|
| 66 | afferr=[shum_aff_err,old_aff_err,old_shum_aff_err,rankr_aff_err,rankr_shum_aff_err,... |
---|
| 67 | rankr_trans_aff_err,ground_truth_aff_err,gt_shum_aff_err]; |
---|
| 68 | stable = [shum_stab, old_stable, old_shum_stab, rankr_stable, rankr_shum_stab, ... |
---|
| 69 | trans_stable, gt_shum_stab]; |
---|
| 70 | end |
---|
| 71 | toterr = [toterr', err']'; |
---|
| 72 | totafferr = [totafferr', afferr']'; |
---|
| 73 | totstable = [totstable', stable']'; |
---|
| 74 | if j < 11 | j == 20 | j == 30 | rem(j,100) == 0 |
---|
| 75 | toterr |
---|
| 76 | totafferr |
---|
| 77 | totstable |
---|
| 78 | end |
---|
| 79 | end |
---|