source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/BlueCCal/MultiCamSelfCal/MartinecPajdla/utils/normalize.m @ 37

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

Added original make3d

File size: 954 bytes
Line 
1%
2%       Function Mnorm=normalize(M,I)
3%
4% normalizes M by dividing each point by its homogenous coordinate
5% (these coordinates equal to ones afterwards).
6%
7% Parameter I can be omitted for complete scenes.
8
9function Mnorm=normalize(M,I)
10
11m=size(M,1)/3;
12n=size(M,2);
13
14if nargin < 2
15  I=ones(m,n);
16end
17
18Mnorm(1:3*m, 1:n) = M; % There are two reasons for this. (i) Make NaN the
19                       % unknown data thus the whole matrix has to be filled
20                       % by NaNs. (ii) Sometimes it happens that when there
21                       % is a missing data in the last column(s), the
22                       % column(s) disapppears.
23
24known      = find(I);
25big_enough = known(find( abs(M(known*3)) > eps ));
26if m == 1, big_enough = big_enough'; end
27 
28if ~isempty(big_enough)
29  div_by                      = repmat(M(big_enough*3)',3,1);
30  Mnorm(k2i(big_enough)) = M(k2i(big_enough)) ./ div_by(:);
31end
32
33Mnorm(setdiff(known, big_enough)*3) = 1;
Note: See TracBrowser for help on using the repository browser.