source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/missing-data/rankrsfm_tpose.m @ 37

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

Added original make3d

File size: 1.7 KB
Line 
1function [error, Mapprox, stable] = rankrsfm_tpose(M,INC,trans)
2% Compare to rankrsfm.  This will work on the transpose of the matrix.
3% trans is a switch that allows the same routine to either allow for
4% translation or not.
5
6if ~ trans
7  r = 3;
8else
9  r = 4;
10end
11M = M';
12INC = INC';
13MAXNULLSIZE = 10;
14[numrows,numcols] = size(M);
15NULLSPACE = [];
16frame_pairs = random_frame_pairs(numcols/2);
17% gives a 2 x (numframes choose 2) matrix with all pairs of frames, in random order.
18
19for pair = frame_pairs
20  if size(NULLSPACE,2) >= numcols*MAXNULLSIZE, break, end
21
22  [submatrix,subrows] = fp_submatrix(pair,M',INC');
23  submatrix = submatrix';
24  % I have to transpose everything, since this routine is written to work with
25  % untransposed matrix.
26  num_subpoints = size(submatrix,1);
27  if num_subpoints > r
28    if trans
29      submatrix = [ones(num_subpoints,1), submatrix];
30    end
31    subnull = nulleps(submatrix,.001,r);
32    if size(subnull,2) == num_subpoints - r
33       % Since submatrix has 5+ rows and 5 columns, if it has rank 4, subnull is
34       % number rows - 4.
35       % If subnull is bigger, submatrix is rank deficient, and results unstable.
36       nullTEMP = zeros(numrows, size(subnull,2));
37       nullTEMP(subrows,:) = subnull;
38       NULLSPACE = [NULLSPACE, nullTEMP];
39    end
40  end
41end
42
43if size(NULLSPACE) == [0 0]
44  error = -2;
45  Mapprox = [];
46else
47  [error, Mapprox, stable1, stable2] = approximate(M,INC,r,NULLSPACE);
48  % Now we should be sure that the nullspace of NULLSPACE contains a column with all ones.
49  if error ~= -2
50    error = sum(sum((M.*INC - Mapprox.*INC).^2));
51    Mapprox = Mapprox';
52  end
53  stable = stable1 & stable2;
54end
55
56if error == -2
57  stable = 0;
58end
59
60
61
62
63 
64
Note: See TracBrowser for help on using the repository browser.