[37] | 1 | function [es, as, shum_err] = impute_compare(frot,sigma,n) |
---|
| 2 | % This will be a simple comparison between an imputation method of |
---|
| 3 | % Tomasi and Kanade, and my method. |
---|
| 4 | |
---|
| 5 | % matrix will have form: |
---|
| 6 | % x x x |
---|
| 7 | % x x x |
---|
| 8 | % . |
---|
| 9 | % . |
---|
| 10 | % . |
---|
| 11 | % x x x |
---|
| 12 | % x x x x x x |
---|
| 13 | % x x x x x x |
---|
| 14 | % x x x x x x |
---|
| 15 | % x x x x x x |
---|
| 16 | % x x x |
---|
| 17 | % x x x |
---|
| 18 | % . |
---|
| 19 | % . |
---|
| 20 | % . |
---|
| 21 | % x x x |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | left_start_rows = 1; |
---|
| 25 | left_end_rows = 18; |
---|
| 26 | full_start_rows = left_end_rows + 1; |
---|
| 27 | full_end_rows = full_start_rows + 3; |
---|
| 28 | right_start_rows = full_end_rows + 1; |
---|
| 29 | right_end_rows = full_end_rows + left_end_rows; |
---|
| 30 | |
---|
| 31 | left_start_col = 1; |
---|
| 32 | left_end_col = 4; |
---|
| 33 | right_start_col = left_end_col + 1; |
---|
| 34 | right_end_col = left_end_col + left_end_col; |
---|
| 35 | |
---|
| 36 | es = []; |
---|
| 37 | as = []; |
---|
| 38 | shum_err = []; |
---|
| 39 | |
---|
| 40 | for i=1:n |
---|
| 41 | [M, pts] = unoccluded_motion(right_end_rows/2, right_end_col, frot, 0); |
---|
| 42 | INC = [[ones(left_end_rows, left_end_col), ... |
---|
| 43 | zeros(left_end_rows, right_end_col - left_end_col)]; ... |
---|
| 44 | ones(full_end_rows - left_end_rows, right_end_col); ... |
---|
| 45 | [zeros(right_end_rows - full_end_rows, left_end_col), ... |
---|
| 46 | ones(right_end_rows - full_end_rows, right_end_col - left_end_col)]]; |
---|
| 47 | |
---|
| 48 | ERR = randn(size(M)).*sigma; |
---|
| 49 | Merr = M + ERR; |
---|
| 50 | [e1, Mapprox1, s1] = rankr(Merr, INC, 3, 1000, 0); |
---|
| 51 | a1 = affine_error(Mapprox1, pts, 3); |
---|
| 52 | |
---|
| 53 | M_left_top = Merr(left_start_rows:left_end_rows, left_start_col:left_end_col); |
---|
| 54 | M_right_top = Merr(left_start_rows:left_end_rows, right_start_col:right_end_col); |
---|
| 55 | M_left_full = Merr(full_start_rows:full_end_rows, left_start_col:left_end_col); |
---|
| 56 | M_right_full = Merr(full_start_rows:full_end_rows, right_start_col:right_end_col); |
---|
| 57 | M_left_bottom = Merr(right_start_rows:right_end_rows, left_start_col:left_end_col); |
---|
| 58 | M_right_bottom = Merr(right_start_rows:right_end_rows, right_start_col:right_end_col); |
---|
| 59 | |
---|
| 60 | IM_right_top = M_left_top*(M_left_full\M_right_full); |
---|
| 61 | IM_left_bottom = M_right_bottom*(M_right_full\M_left_full); |
---|
| 62 | |
---|
| 63 | IM = [[M_left_top, IM_right_top];[M_left_full, M_right_full];... |
---|
| 64 | [IM_left_bottom, M_right_bottom]]; |
---|
| 65 | Mapprox2 = approx_full_matrix(IM,3); |
---|
| 66 | e2 = sum(sum((M.*INC - Mapprox2.*INC).^2)); |
---|
| 67 | a2 = affine_error(Mapprox2, pts, 3); |
---|
| 68 | |
---|
| 69 | [shum_err1, shum_res1] = shum(Merr,INC,3,Mapprox1,100); |
---|
| 70 | [shum_err2, shum_res2] = shum(Merr,INC,3,Mapprox2,100); |
---|
| 71 | |
---|
| 72 | es = [es; [e1,e2]]; |
---|
| 73 | as = [as; [a1,a2]]; |
---|
| 74 | shum_err = [shum_err; [shum_err1,shum_err2]]; |
---|
| 75 | end |
---|