forked from iscilab2020/TERI-3DNLOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SupplementaryFigure12_single_snap_recons.m
139 lines (102 loc) · 4.56 KB
/
SupplementaryFigure12_single_snap_recons.m
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
%% Two-Edge-Resolved 3D NLOS Imaging (Supplementary Figure 12 Reconstructions)
% Manuscript:
% Czajkowski, R. and Murray-Bruce, J., 'Two-edge-resolved three-dimensional non-line-of-sight
% imaging with an ordinary camera', Nat. Commun., 2023.
%
% Notes:
% 1) Each newly computed forward model is saved, if it doesn't already
% exist. If you want to turn this off, set cacheForwardModels to false.
% Last Modified by John Murray-Bruce at the University of South Florida
% 03-Dec-2023 (Code clean-up and commented for dissemination)
%% Set configuration parameters and simulate forward model
clear; clc;
close all;
addpath('Functions')
cacheForwardModels = true;
% Function to convert from PESC to Cartesian coordinates for visualization
projsph2cartesian = @(rhoval, angles_tp) ([rhoval./sqrt(1 + tan(angles_tp(:,1)).^2 + tan(angles_tp(:,2)).^2), ...
tan(angles_tp(:,1)).* rhoval./sqrt(1 + tan(angles_tp(:,1)).^2 + tan(angles_tp(:,2)).^2), ...
tan(angles_tp(:,2)).* rhoval./sqrt(1 + tan(angles_tp(:,1)).^2 + tan(angles_tp(:,2)).^2)]);
% Height of doorway head
h = -(0.46*0.61);
% Number of measurement pixels (along each axis)
Mx = 125;
My = 125;
% Camera Field of View (small shift to avoid division by zero).
px = linspace(-0.46,0,Mx)-0.0000001;
py = linspace(-0.46,0,My)-0.0000001;
% Number of sub-discretizations used to simulate a each surface element.
Ntp_sub = [3 3];
N_theta = 120; % Number of angular bins along azimuth (N_theta).
N_psi = 120; % Number of angular bins along azimuth (N_theta).
rho_0 = 0.5; % Initial range used for estimating shape.
fprintf('Simulating forward model...\n')
fwdmodelName = ['M',num2str(Mx),'x', num2str(My),'_N', num2str(N_theta), 'x',num2str(N_psi)];
fwdmodelpathName = ['ForwardModels', filesep, fwdmodelName,filesep, fwdmodelName,'rho_',num2str(rho_0),'.mat'];
% Simulate the forward model (or load it if it already exists).
tic
if isfile(fwdmodelpathName)
load(fwdmodelpathName);
else
[Amat,angles_tp] = forwardmodelDoorwayCam1(px,py,h,[N_theta N_psi], Ntp_sub,rho_0);
if cacheForwardModels==true
if ~isfolder(['ForwardModels', filesep, fwdmodelName,filesep])
mkdir(['ForwardModels', filesep, fwdmodelName,filesep]);
end
save(fwdmodelpathName);
end
end
toc
bgsource_loc = [-0.4 -0.4 2];
bg_term = simbackground(px,py,h,bgsource_loc);
bg_cols = [mean(Amat(:))*ones(My*Mx, 1) mean(Amat(:))*bg_term];
Bmat = [bg_cols Amat];
% Point to dataset path
addpath((['Dataset' filesep 'SingleSnapshot']))
scene_names = {'play1', 'work', 'USF_man', 'twoman0bg'};
% Can set 'useTVrefinedRadiosity' to true to get cleaner/smoother recons.
useTVrefinedRadiosity = false;
% SingleSnapshot Dataset, a flag to set new l1-regularization paramater for
% the play scene case
singleSnapshotData = true;
%% Manuscript Figure 3(a): Play scene reconstruction
scene_id = 1; % Select 1 for play scene, 2 for work scene, and 3 for USF scene
fig_start = 0;
scriptRunReconstructionMethod
Ranges_play_scene = rho_est_t;
%% Manuscript Figure 3(b): Work scene reconstruction
scene_id = 2; % Select 2 for work scene
fig_start = 4;
scriptRunReconstructionMethod
Ranges_work_scene = rho_est_t;
%% Manuscript Figure 3(c): USF scene reconstruction
scene_id = 3; % Select 3 for USF scene
fig_start = 8;
scriptRunReconstructionMethod
Ranges_usf_scene = rho_est_t;
%% Supplementary Figure 12(d): Two Mannequins scene without visible side ambient light
scene_id = 4; % Select 1 for play scene, 2 for work scene, and 3 for USF scene
fig_start = 12;
scriptRunReconstructionMethod
Ranges_2man0bg_scene = rho_est_t;
%% Display Ranges
disp('======== RANGE ESTIMATES - PLAY ========')
disp(['Doughnut: ', num2str(Ranges_play_scene(1)), 'm'])
disp(['Mannequin: ' num2str(Ranges_play_scene(2)),' m'])
disp(['Volleyball: ' num2str(Ranges_play_scene(3)),' m'])
fprintf('\n')
disp('======== RANGE ESTIMATES - WORK ========')
disp(['Shelf: ', num2str(Ranges_work_scene(1)), 'm'])
disp(['Chair: ' num2str(Ranges_work_scene(2)),' m'])
disp(['Basketball: ' num2str(Ranges_work_scene(3)),' m'])
fprintf('\n')
disp('======== RANGE ESTIMATES - USF ========')
disp(['U: ', num2str(Ranges_usf_scene(1)), 'm'])
disp(['S: ' num2str(Ranges_usf_scene(2)),' m'])
disp(['F: ' num2str(Ranges_usf_scene(3)),' m'])
disp(['Celebrating Mannequin: ' num2str(Ranges_usf_scene(4)),' m'])
fprintf('\n')
disp('======== RANGE ESTIMATES - TWO MANNEQUINS LOW BG ========')
disp(['White marching mannequin: ', num2str(Ranges_2man0bg_scene(1)), 'm'])
disp(['Red-Green T-pose mannequin: ' num2str(Ranges_2man0bg_scene(2)),' m'])
fprintf('\n')