[37] | 1 | %fill_mm_sub Proj. reconstruction of a normed sub-scene. |
---|
| 2 | % |
---|
| 3 | % When the central image concept is used, the information which image is |
---|
| 4 | % the central image is passed to this function as input. |
---|
| 5 | % |
---|
| 6 | % Parameters: |
---|
| 7 | % |
---|
| 8 | % Mfull .. complete known parts of the problem, used here for the best |
---|
| 9 | % estimate of the fundamental matrices |
---|
| 10 | |
---|
| 11 | function [P,X, lambda, u1,u2, info] = fill_mm_sub(Mfull, M, central,opt,info) |
---|
| 12 | |
---|
| 13 | I = ~isnan(M(1:3:end,:)); |
---|
| 14 | [m n] = size(I); |
---|
| 15 | if isempty(central), central = 0; end |
---|
| 16 | |
---|
| 17 | P=[]; X=[]; lambda=[]; u1=1:m; u2=1:n; |
---|
| 18 | |
---|
| 19 | %estimate the fundamental matrices and epipoles with the method of [Har95] |
---|
| 20 | [F,ep,rows,nonrows] = M2Fe(Mfull, central); |
---|
| 21 | |
---|
| 22 | if ~isempty(nonrows), |
---|
| 23 | disp(sprintf('Used local images:%s.', sprintf(' %d', rows))); end |
---|
| 24 | if length(rows) < 2, return; end |
---|
| 25 | |
---|
| 26 | %determine scale faktors lambda_i_p |
---|
| 27 | if ~central, rows_central = 0; else rows_central = find(rows == central); end |
---|
| 28 | [lambda, Ilamb] = depth_estimation(M(k2i(rows),:),F,ep,rows, ... |
---|
| 29 | rows_central); |
---|
| 30 | |
---|
| 31 | % prepare info.show_prmm - for show_prmm function |
---|
| 32 | info.show_prmm.I = I; |
---|
| 33 | info.show_prmm.Idepths = zeros(m,n); info.show_prmm.Idepths(rows,:)=Ilamb; |
---|
| 34 | |
---|
| 35 | %build the rescaled measurement matrix B |
---|
| 36 | for i = 1:length(rows), B(k2i(i),:) = M(k2i(i),:).*([1;1;1]*lambda(i,:)); end |
---|
| 37 | |
---|
| 38 | %balance W by column-wise and "triplet-of-rows"-wise scalar multiplications |
---|
| 39 | B = balance_triplets(B, opt); |
---|
| 40 | |
---|
| 41 | %fit holes in JIM by Jacobs' algorithm |
---|
| 42 | [P,X, u1,u2, lambda1, info] = fill_prmm(B, Ilamb, central,opt,info); |
---|
| 43 | |
---|
| 44 | r1 = setdiff(1:length(rows),u1); r2 = setdiff(1:n,u2); |
---|
| 45 | |
---|
| 46 | lambda = lambda(r1,r2); % to fit P*X |
---|
| 47 | if ~isempty(lambda1), |
---|
| 48 | new = find(~Ilamb(r1,r2) & I(r1,r2)); lambda(new) = lambda1(new); end |
---|
| 49 | |
---|
| 50 | error = eucl_dist_only(B(k2i(r1), r2), P*X, ~isnan(B(3*r1,r2)), 3); |
---|
| 51 | if opt.verbose, disp(sprintf('Error balanced: %f', error)); end |
---|
| 52 | |
---|
| 53 | u1 = union(nonrows, rows(u1)); |
---|