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

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

Added original make3d

File size: 979 bytes
Line 
1function [E, stable] = extend_matrix(M,INC,subM, rows, nonrows, r)
2% rows indicates which rows of M and INC were used to find a solution.
3%   subM is a fit to just these rows.  nonrows indicate rows of M
4%   that still need to be fit.
5E(rows,:) = subM;
6stable = 1;
7
8if ~isempty(nonrows)
9
10  [u,s,v] = svd(subM);
11  vp = v';
12  basis = vp(1:r,:);
13  for i = nonrows
14     INCrow = INC(i,:);
15     Mrow = M(i,:).*INCrow;
16     INCmat = repeat(INCrow',r)';
17     basisrows = basis.*INCmat;
18     if rank(basisrows) ~= r
19       stable = 0
20
21% putting zeros in for the elements that cannot be determined.
22% to avoid dividing by a matrix that is not full rank.
23       E(i,:) = Mrow;
24
25%instead of zeros, choose a random value between -1 and 1 for each
26%unfindable missing point.
27       missingpoints = find(INCrow == 0);
28       E(i,missingpoints) = rand(1,length(missingpoints)).*2 - 1;
29     else
30       E(i,:) = (Mrow/basisrows)*basis;
31     end
32  end
33
34end   
Note: See TracBrowser for help on using the repository browser.