Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ positional arguments:
{config,render,plot} Command
config Edit the TAL configuration file
render Create, edit or execute renders of simulated NLOS scene data captures
noise_simulation Simulate noise for already generated capture data
plot Plot capture data using one of the configured methods

optional arguments:
Expand Down Expand Up @@ -251,6 +252,34 @@ V = np.moveaxis(np.mgrid[-1:1.1:0.1, -1:1.1:0.1, 0.5:2.6:0.1], 0, -1).reshape(-1
reconstruction = tal.reconstruct.pf.solve(data, 6, 4, V, verbose=3, n_threads=1)
```

## `tal noise_simulation`: Command line tool to simulate SPAD noise

`tal noise_simulation` modifies a transient capture previously generated with `tal render`, simulating the noise
caused by a capture with a Single Photon Avalanche Diode (SPAD) sensor. Following [Hernandez2017] the noise simulation
takes random photon samples from the ground truth transient signal, with an added temporal jitter randomly sampled from
the time jitter function of the SPAD, as well as the gaussian pulse of the laser.

The simulation also models other sources of noise, namely dark counts and external noise caused by ambient lighting, as
well as afterpulsing. You can find examples on how to use the noise simulation in the
[`examples`](https://github.com/diegoroyo/tal/tree/master/examples) folder of this repository.
Note that to test the noise simulation you will need to have a HDF5 capture file.
If you don't, please check the `tal render` section or [convert your data to a format usable by `tal`](https://github.com/diegoroyo/tal/blob/master/tal/io/format.py).


```
❯ tal noise_simulation -h
usage: tal noise_simulation [-h] -c CAPTURE_FILE -n NOISE_CONFIG_FILE -o OUTPUT_PATH

options:
-h, --help show this help message and exit
-c CAPTURE_FILE, --capture_file CAPTURE_FILE
Path to the .hdf5 capture file to add noise to
-n NOISE_CONFIG_FILE, --noise_config_file NOISE_CONFIG_FILE
Path to the .yaml configuration file for the noise simulation
-o OUTPUT_PATH, --output_path OUTPUT_PATH
Path to save the capture data with the simulated noise
```

### Logging

The verbosity of the output can be controlled through `tal.set_log_level(level)`.
Expand Down Expand Up @@ -290,6 +319,8 @@ tal.set_resources(4) # use 4 CPUs

> [Liu2019] Liu, X., Guillén, I., La Manna, M., Nam, J. H., Reza, S. A., Huu Le, T., ... & Velten, A. (2019). Non-line-of-sight imaging using phasor-field virtual wave optics. Nature, 572(7771), 620-623.

> [Hernandez2017] Hernández, Q., Gutiérrez, D., Jarabo, A. (2017) A Computational Model of a Single-Photon Avalanche Diode Sensor for Transient Imaging. Technical report (arXiv:1703.02635).

### License and citation

`tal` is licensed under the GPL-3.0 license. If you use `tal` in an academic work, we would appreciate if you cited our work:
Expand Down
180 changes: 180 additions & 0 deletions examples/noise-simulation/Z.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# Blender 4.0.2
# www.blender.org
o hidden_geometry_Z
v 0.364878 0.296774 0.004000
v -0.400000 0.400000 0.004000
v 0.364878 0.400000 0.004000
v 0.364878 0.296774 0.004000
v -0.164553 0.296774 0.004000
v -0.400000 0.400000 0.004000
v -0.164553 0.296774 0.004000
v 0.164553 -0.296774 0.004000
v -0.400000 0.400000 0.004000
v 0.400000 -0.400000 0.004000
v 0.164553 -0.296774 0.004000
v -0.164553 0.296774 0.004000
v 0.400000 -0.400000 0.004000
v -0.400000 -0.296774 0.004000
v 0.164553 -0.296774 0.004000
v 0.400000 -0.400000 0.004000
v -0.400000 -0.400000 0.004000
v -0.400000 -0.296774 0.004000
v 0.364878 0.296774 -0.004000
v 0.364878 0.400000 -0.004000
v -0.400000 0.400000 -0.004000
v 0.364878 0.296774 -0.004000
v -0.400000 0.400000 -0.004000
v -0.164553 0.296774 -0.003999
v -0.164553 0.296774 -0.003999
v -0.400000 0.400000 -0.004000
v 0.164553 -0.296774 -0.004000
v 0.400000 -0.400000 -0.003999
v -0.164553 0.296774 -0.003999
v 0.164553 -0.296774 -0.004000
v 0.400000 -0.400000 -0.003999
v 0.164553 -0.296774 -0.004000
v -0.400000 -0.296774 -0.004000
v 0.400000 -0.400000 -0.003999
v -0.400000 -0.296774 -0.004000
v -0.400000 -0.400000 -0.004000
v -0.400000 0.400000 0.004000
v 0.164553 -0.296774 0.004000
v 0.164553 -0.296774 -0.004000
v -0.400000 0.400000 -0.004000
v 0.164553 -0.296774 0.004000
v -0.400000 -0.296774 0.004000
v -0.400000 -0.296774 -0.004000
v 0.164553 -0.296774 -0.004000
v 0.400000 -0.400000 0.004000
v -0.164553 0.296774 0.004000
v -0.164553 0.296774 -0.003999
v 0.400000 -0.400000 -0.003999
v 0.364878 0.400000 0.004000
v -0.400000 0.400000 0.004000
v -0.400000 0.400000 -0.004000
v 0.364878 0.400000 -0.004000
v 0.364878 0.296774 0.004000
v 0.364878 0.400000 0.004000
v 0.364878 0.400000 -0.004000
v 0.364878 0.296774 -0.004000
v -0.400000 -0.400000 0.004000
v 0.400000 -0.400000 0.004000
v 0.400000 -0.400000 -0.003999
v -0.400000 -0.400000 -0.004000
v -0.164553 0.296774 0.004000
v 0.364878 0.296774 0.004000
v 0.364878 0.296774 -0.004000
v -0.164553 0.296774 -0.003999
v -0.400000 -0.296774 0.004000
v -0.400000 -0.400000 0.004000
v -0.400000 -0.400000 -0.004000
v -0.400000 -0.296774 -0.004000
v 0.357368 0.303546 -0.000619
v 0.357368 0.393227 -0.000619
v -0.390323 0.395568 -0.000410
v 0.357368 0.303546 -0.000619
v -0.390323 0.395568 -0.000410
v -0.167537 0.298140 -0.003730
v -0.167537 0.298140 -0.003730
v -0.390323 0.395568 -0.000410
v 0.167536 -0.298140 -0.003731
v 0.390322 -0.395569 -0.000410
v -0.167537 0.298140 -0.003730
v 0.167536 -0.298140 -0.003731
v 0.390322 -0.395569 -0.000410
v 0.167536 -0.298140 -0.003731
v -0.392490 -0.303546 -0.000619
v 0.390322 -0.395569 -0.000410
v -0.392490 -0.303546 -0.000619
v -0.392490 -0.393228 -0.000619
v 0.357368 0.303546 0.000618
v -0.390323 0.395568 0.000410
v 0.357368 0.393227 0.000618
v 0.357368 0.303546 0.000618
v -0.167537 0.298141 0.003731
v -0.390323 0.395568 0.000410
v -0.167537 0.298141 0.003731
v 0.167536 -0.298140 0.003730
v -0.390323 0.395568 0.000410
v 0.390322 -0.395569 0.000410
v 0.167536 -0.298140 0.003730
v -0.167537 0.298141 0.003731
v 0.390322 -0.395569 0.000410
v -0.392490 -0.303546 0.000618
v 0.167536 -0.298140 0.003730
v 0.390322 -0.395569 0.000410
v -0.392490 -0.393228 0.000618
v -0.392490 -0.303546 0.000618
v -0.390323 0.395568 -0.000410
v -0.390323 0.395568 0.000410
v 0.167536 -0.298140 0.003730
v 0.167536 -0.298140 -0.003731
v 0.167536 -0.298140 -0.003731
v 0.167536 -0.298140 0.003730
v -0.392490 -0.303546 0.000618
v -0.392490 -0.303546 -0.000619
v 0.390322 -0.395569 -0.000410
v 0.390322 -0.395569 0.000410
v -0.167537 0.298141 0.003731
v -0.167537 0.298140 -0.003730
v 0.357368 0.393227 -0.000619
v 0.357368 0.393227 0.000618
v -0.390323 0.395568 0.000410
v -0.390323 0.395568 -0.000410
v 0.357368 0.303546 -0.000619
v 0.357368 0.303546 0.000618
v 0.357368 0.393227 0.000618
v 0.357368 0.393227 -0.000619
v -0.392490 -0.393228 -0.000619
v -0.392490 -0.393228 0.000618
v 0.390322 -0.395569 0.000410
v 0.390322 -0.395569 -0.000410
v -0.167537 0.298140 -0.003730
v -0.167537 0.298141 0.003731
v 0.357368 0.303546 0.000618
v 0.357368 0.303546 -0.000619
v -0.392490 -0.303546 -0.000619
v -0.392490 -0.303546 0.000618
v -0.392490 -0.393228 0.000618
v -0.392490 -0.393228 -0.000619
s 1
f 1 3 2
f 4 6 5
f 7 9 8
f 10 12 11
f 13 15 14
f 16 18 17
f 19 21 20
f 22 24 23
f 25 27 26
f 28 30 29
f 31 33 32
f 34 36 35
f 37 40 39 38
f 41 44 43 42
f 45 48 47 46
f 49 52 51 50
f 53 56 55 54
f 57 60 59 58
f 61 64 63 62
f 65 68 67 66
f 69 71 70
f 72 74 73
f 75 77 76
f 78 80 79
f 81 83 82
f 84 86 85
f 87 89 88
f 90 92 91
f 93 95 94
f 96 98 97
f 99 101 100
f 102 104 103
f 105 108 107 106
f 109 112 111 110
f 113 116 115 114
f 117 120 119 118
f 121 124 123 122
f 125 128 127 126
f 129 132 131 130
f 133 136 135 134
42 changes: 42 additions & 0 deletions examples/noise-simulation/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##
# SPAD parameters
##
time_jitter_FWHM: 20 # FWHM of the gaussian component of the SPAD's time-jitter, in picoseconds
time_jitter_tail: 50 # Tail (exponential decay parameter) of the exponential component of the SPAD's time-jitter, in picoseconds
time_jitter_tail_scale: 0.8 # Relative scale of the peak of the exponential decay in the time-jitter with respect to the gaussian component
time_jitter_n_timebins: 640 # Number of timebins of the jitter function
time_jitter_timebin_width: 0.75 # Timebin width of the jitter function in picoseconds. Should be as precise as possible, to avoid aliasing

# Load experimental time-jitter capture from hdf5 file. If defined, the previous parameters are ignored
# time_jitter_path: './spad_data_1.hdf5'
time_jitter_path: '' # Leave the path empty (or not set) to use the parametric jitter

photon_detection_ratio: 0.3 # Ratio of photons that are actually detected, in range [0, 1]
dead_time: 1000 # Hold-off time of the SPAD after each detected photon, in picoseconds
simulate_afterpulses: False # If True, simulates SPAD afterpulsing (increases execution time). If False, afterpulsing is ignored.
afterpulse_probability : 0.10 # Probability of each detected photon of generating an afterpulse, in range [0, 1]
exposure_time: 0.001 # Exposure time for each captured point, in seconds
number_of_samples: 0 # Number of captured photons per measurements. If 0 or non-defined, it will be computed
# from exposure time, laser frequency and the photon detection ratio
sensor_type: 'event' # Either frame (for frame-based SPADs) or event (for event-based SPADs)

##
# Frame based SPAD parameters, used if camera_type == 'frame'
##
frame_exposure_time: 100 # Exposure time of each SPAD frame in microseconds
# n_frames: 500_000 # Number of measured frames in the capture. During each frame, only one photon can be captured
# If not set, this number is obtained from the total exposure time and the exposure time of each frame

##
# External noise
##
dark_count_rate: 0 # Number of dark counts per second
external_noise_rate: 0 # Number of counts caused by external noise (ambient light) per second
number_of_false_counts: 0 # Number of false positive photons (either dark counts or external noise).
# If 0 or non-defined, this value is computed from exposure time and noise rates

##
# Laser
##
laser_jitter_FWHM: 30 # FWHM of the gaussian laser pulse, in picoseconds
frequency: 20 # Pulse frequency (nº of pulses per second) in MHz
Loading