forked from balcilar/DenseDepthMap
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdense_depth_map.m
More file actions
39 lines (30 loc) · 787 Bytes
/
Copy pathdense_depth_map.m
File metadata and controls
39 lines (30 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function [out mD]=dense_depth_map(Pts,n, m,grid)
% Writtenby Muhammet Balcilar, France
% All rights reserved.
ng=2*grid+1;
linearindex = sub2ind([n m], round(Pts(:,2)), round(Pts(:,1)));
mX=inf([n m]);
mX(linearindex)=Pts(:,1)-round(Pts(:,1));
mY=inf([n m]);
mY(linearindex)=Pts(:,2)-round(Pts(:,2));
mD=zeros([n m]);
mD(linearindex)=Pts(:,3);
for i=1:ng
for j=1:ng
KmX{i,j}=mX(i:n-ng+i,j:m-ng+j)-grid-1+i;
KmY{i,j}=mY(i:n-ng+i,j:m-ng+j)-grid-1+j;
KmD{i,j}=mD(i:n-ng+i,j:m-ng+j);
end
end
S=zeros(size(KmD{1,1}));
Y=zeros(size(KmD{1,1}));
for i=1:ng
for j=1:ng
s=1./sqrt(KmX{i,j}.*KmX{i,j}+KmY{i,j}.*KmY{i,j});
Y=Y+s.*KmD{i,j};
S=S+s;
end
end
S(S==0)=1;
out=zeros(n,m);
out(grid+1:end-grid,grid+1:end-grid)=Y./S;