euler-preprocess 3.10.0__tar.gz → 3.12.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. euler_preprocess-3.12.0/LICENSE +21 -0
  2. euler_preprocess-3.12.0/PKG-INFO +672 -0
  3. euler_preprocess-3.12.0/README.md +654 -0
  4. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/cli.py +0 -16
  5. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/io.py +0 -11
  6. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/atmospheric_light.py +0 -6
  7. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/capture.py +64 -7
  8. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/dcp_airlight_torch.py +0 -2
  9. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/dcp_heuristic_airlight.py +0 -4
  10. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/dcp_heuristic_airlight_torch.py +0 -2
  11. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/models.py +1 -1
  12. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/transform.py +1 -46
  13. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/radial/transform.py +0 -2
  14. euler_preprocess-3.12.0/euler_preprocess.egg-info/PKG-INFO +672 -0
  15. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess.egg-info/SOURCES.txt +2 -3
  16. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/pyproject.toml +10 -1
  17. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_airlight_fallback.py +21 -61
  18. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_dcp_heuristic_airlight.py +8 -8
  19. euler_preprocess-3.12.0/tests/test_fog_integration.py +82 -0
  20. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_radial.py +0 -1
  21. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_sky_depth.py +0 -1
  22. euler_preprocess-3.12.0/tests/test_tone_map_lut.py +139 -0
  23. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_zip_output.py +0 -1
  24. euler_preprocess-3.10.0/PKG-INFO +0 -858
  25. euler_preprocess-3.10.0/README.md +0 -844
  26. euler_preprocess-3.10.0/euler_preprocess/fog/foggify.py +0 -28
  27. euler_preprocess-3.10.0/euler_preprocess/fog/foggify_logging.py +0 -10
  28. euler_preprocess-3.10.0/euler_preprocess.egg-info/PKG-INFO +0 -858
  29. euler_preprocess-3.10.0/tests/test_foggify_integration.py +0 -119
  30. euler_preprocess-3.10.0/tests/test_tone_map_lut.py +0 -37
  31. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/MANIFEST.in +0 -0
  32. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/__init__.py +0 -0
  33. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/__init__.py +0 -0
  34. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/color.py +0 -0
  35. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/dataset.py +0 -0
  36. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/device.py +0 -0
  37. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/intrinsics.py +0 -0
  38. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/logging.py +0 -0
  39. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/noise.py +0 -0
  40. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/normalize.py +0 -0
  41. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/output.py +0 -0
  42. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/sampling.py +0 -0
  43. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/common/transform.py +0 -0
  44. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/__init__.py +0 -0
  45. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/airlight_from_sky.py +0 -0
  46. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/augmentations.py +0 -0
  47. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/dcp_airlight.py +0 -0
  48. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/inference.py +0 -0
  49. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/logging.py +0 -0
  50. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/fog/pipeline.py +0 -0
  51. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/radial/__init__.py +0 -0
  52. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/sky_depth/__init__.py +0 -0
  53. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess/sky_depth/transform.py +0 -0
  54. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess.egg-info/dependency_links.txt +0 -0
  55. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess.egg-info/entry_points.txt +0 -0
  56. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess.egg-info/requires.txt +0 -0
  57. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/euler_preprocess.egg-info/top_level.txt +0 -0
  58. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/setup.cfg +0 -0
  59. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_cli_sample_selection.py +0 -0
  60. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_dense_gloomy_daylight_config.py +0 -0
  61. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_fog_aux_outputs.py +0 -0
  62. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_fog_aware_auto_exposure.py +0 -0
  63. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_fog_cpu_gpu_parity.py +0 -0
  64. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_real_drive_sim_scenario_profiles.py +0 -0
  65. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_scene_illumination.py +0 -0
  66. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_sensor_identity.py +0 -0
  67. {euler_preprocess-3.10.0 → euler_preprocess-3.12.0}/tests/test_source_backed_output.py +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Daniel Rothenpieler
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,672 @@
1
+ Metadata-Version: 2.4
2
+ Name: euler-preprocess
3
+ Version: 3.12.0
4
+ Summary: Physics-based preprocessing (fog, etc.) for RGB+depth datasets
5
+ Author-email: Daniel Rothenpieler <rothenpielerdaniel@gmail.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: numpy
11
+ Requires-Dist: Pillow
12
+ Requires-Dist: euler-loading
13
+ Provides-Extra: gpu
14
+ Requires-Dist: torch; extra == "gpu"
15
+ Provides-Extra: progress
16
+ Requires-Dist: tqdm; extra == "progress"
17
+ Dynamic: license-file
18
+
19
+ # euler-preprocess
20
+
21
+ Physics-based preprocessing transforms for multi-modal RGB+depth datasets — synthetic
22
+ fog, sky-depth normalisation, and planar-to-radial depth conversion. Built on
23
+ [euler-loading](https://github.com/d-rothen/euler-loading) and
24
+ [ds-crawler](https://github.com/d-rothen/ds-crawler).
25
+
26
+ ![Source frame rendered at five meteorological visibility distances](docs/images/fog-visibility-ladder.jpg)
27
+
28
+ *One input frame rendered at 100 m, 70 m, 40 m, 20 m and 10 m meteorological visibility
29
+ (`configs/fog_stepped_config.json`). Fog density follows the depth map, so the
30
+ attenuation is scene-consistent rather than a flat overlay.*
31
+
32
+ ![Six correlated scene and camera condition profiles](docs/images/camera-scenarios.jpg)
33
+
34
+ *The same frame through all six `scenario_profiles` in
35
+ `configs/dense_gloomy_daylight_fog_camera.json`. Each profile samples fog density,
36
+ airlight, exposure, sensor noise and compression together, so weather and camera
37
+ response stay correlated. The last two are deliberately extreme low-light stress
38
+ cases — their auto-exposure targets a mean luminance of ~0.1.*
39
+
40
+ Both sets were rendered with `tools/run_fog_qualitative_samples.py`, which runs a
41
+ folder of RGB/depth/segmentation samples through the transform and writes images for
42
+ qualitative review.
43
+
44
+ | Command | Description |
45
+ |---|---|
46
+ | `euler-preprocess fog` | Synthetic fog via the Koschmieder atmospheric scattering model |
47
+ | `euler-preprocess sky-depth` | Override depth values in sky regions with a constant |
48
+ | `euler-preprocess radial` | Convert planar (z-buffer) depth to radial (Euclidean) depth |
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ uv pip install "euler-preprocess[gpu,progress]"
54
+ ```
55
+
56
+ ## Usage
57
+
58
+ ```bash
59
+ euler-preprocess fog -c configs/example_dataset_config.json
60
+ euler-preprocess sky-depth -c configs/sky_depth_dataset_config.json
61
+ euler-preprocess radial -c configs/radial_dataset_config.json
62
+ ```
63
+
64
+ ## Dataset Config
65
+
66
+ Every subcommand takes a **dataset config** that points to the input data and to a
67
+ **transform config**. Each modality path must be a directory indexed by
68
+ [ds-crawler](https://github.com/d-rothen/ds-crawler) with an `euler_loading` property
69
+ naming the loader and function, so euler-loading can auto-select the dataset-specific
70
+ loader.
71
+
72
+ ```json
73
+ {
74
+ "transform_config_path": "fog_config.json",
75
+ "output_path": "/path/to/output",
76
+ "modalities": {
77
+ "rgb": {"path": "/path/to/rgb", "split": "train"},
78
+ "depth": "/path/to/depth",
79
+ "semantic_segmentation": "/path/to/classSegmentation"
80
+ },
81
+ "hierarchical_modalities": {
82
+ "intrinsics": {"path": "/path/to/intrinsics"}
83
+ }
84
+ }
85
+ ```
86
+
87
+ | Field | Description |
88
+ |---|---|
89
+ | `transform_config_path` | Path to the transform-specific config, relative to this file. `fog_config_path` is also accepted. |
90
+ | `output_path` | Output root used when no pipeline target overrides it. Optional if `pipeline.output_root` or `pipeline.output_targets[].path` supplies the destination. |
91
+ | `output_slot` | Optional slot selector when `pipeline.output_targets` has several entries. Defaults to `rgb` for `fog` and `depth` for `sky-depth` / `radial`. |
92
+ | `sample` | Optional 0-based dataset index. Only `dataset[sample]` is transformed — useful for small benchmark slices of large datasets. |
93
+ | `samples` | Optional multi-sample selector: a list of indices (`[0, 10, 20]`) or a slice object (`{"start": 0, "stop": 1000, "step": 2, "count": 100}`). `stop` is exclusive, `count` caps the result. Mutually exclusive with `sample`. |
94
+ | `modalities` | Modalities that participate in sample-ID intersection. Each value is a path string or an object with `path` and optional `split`. |
95
+ | `hierarchical_modalities` | Per-scene data (e.g. intrinsics), same format. Loaded once per scene and cached. |
96
+ | `pipeline` | Optional runtime routing block compatible with `euler-inference`. |
97
+
98
+ **Required modalities per transform:**
99
+
100
+ | Transform | `modalities` | `hierarchical_modalities` |
101
+ |---|---|---|
102
+ | `fog` | `rgb`, `depth`, `semantic_segmentation` | `intrinsics` when available; used for radial depth conversion and camera-profile optics |
103
+ | `sky-depth` | `depth`, `semantic_segmentation` | — |
104
+ | `radial` | `depth` | `intrinsics` |
105
+
106
+ When a modality directory contains ds-crawler split files
107
+ (`.ds_crawler/split_<name>.json`), set `split` on that modality to select a subset.
108
+ Sample IDs are intersected across modalities, so a split on one modality restricts the
109
+ whole dataset.
110
+
111
+ ### Pipeline Runtime Block
112
+
113
+ `pipeline` follows the same shape as `euler-inference`:
114
+
115
+ ```json
116
+ {
117
+ "pipeline": {
118
+ "output_root": "/pipeline/output",
119
+ "outputs_manifest_path": "/pipeline/output/.euler_pipeline/pipeline_outputs.json",
120
+ "output_targets": [
121
+ {
122
+ "slot": "depth",
123
+ "datasetType": "depth",
124
+ "relativePath": "radial_depth.zip",
125
+ "path": "/pipeline/output/radial_depth.zip",
126
+ "storage": "zip"
127
+ }
128
+ ]
129
+ }
130
+ }
131
+ ```
132
+
133
+ - `output_root` is only a fallback when `output_path` is omitted.
134
+ - A matching `output_targets[].slot` overrides the write root for that run.
135
+ - `output_targets[].modelModalityId` is optional and passed through when present.
136
+ - `storage` is `"directory"` or `"zip"`; `"file"` parses but is rejected at runtime.
137
+ - When `outputs_manifest_path` is set and a target matches, finalization writes
138
+ `.euler_pipeline/pipeline_outputs.json` in the `euler-inference` manifest shape.
139
+
140
+ ---
141
+
142
+ ## Fog Transform
143
+
144
+ ### Fog Config
145
+
146
+ ```json
147
+ {
148
+ "airlight": "from_sky",
149
+ "seed": 1337,
150
+ "depth_scale": 1.0,
151
+ "resize_depth": true,
152
+ "contrast_threshold": 0.05,
153
+ "render_input_space": "srgb",
154
+ "mode": "sample",
155
+ "device": "cpu",
156
+ "gpu_batch_size": 4,
157
+ "capture": { "preset": "camera" },
158
+ "camera_profile": "dashcam",
159
+ "selection": { },
160
+ "models": { }
161
+ }
162
+ ```
163
+
164
+ | Field | Description |
165
+ |---|---|
166
+ | `airlight` | **Required.** `"from_sky"` (mean sky colour), `"dcp"` (dark channel prior), or `"dcp_heuristic"` (robust DCP with sky-guided colouring). |
167
+ | `seed` | Random seed for reproducibility; `null` for non-deterministic. |
168
+ | `depth_scale` | Multiplier applied to depth values after loading. |
169
+ | `resize_depth` | Bilinearly resize the depth map to the RGB resolution. |
170
+ | `contrast_threshold` | Threshold *C_t* in the visibility-to-attenuation conversion (default `0.05`). |
171
+ | `render_input_space` | Colour space of the input RGB. `"srgb"` for display-encoded images (fog is mixed in scene-linear RGB); `"linear"` for already-linear radiance. |
172
+ | `mode` | `"sample"` (default) renders one sampled scenario per image; `"progressive"` renders every scenario step for every image. |
173
+ | `device` | `"cpu"`, `"cuda"`, `"mps"`, or `"gpu"` (alias for cuda). |
174
+ | `gpu_batch_size` | Batch size on GPU. Uniform-model samples are batched; heterogeneous ones run individually. |
175
+ | `capture` | Post-fog camera artifact pipeline. Omit or use `{"stages": []}` for a no-op; `true` or `{"preset": "camera"}` enables the recommended stack. |
176
+ | `camera_profile` | Named or inline camera profile merged into the capture stack before per-stage overrides. Built-ins: `"default"`, `"generic"`, `"dashcam"`, `"low_light_fog"`. |
177
+ | `camera_profiles` | Map of project-specific named profiles for calibrated lens/sensor/ISP/transport settings. |
178
+ | `scenario_profiles` | Top-level correlated condition sampler (see below). |
179
+ | `selection` | Per-image fog model selection (see below). |
180
+ | `augmentations` | Stepped augmentation set. Every input produces every configured variant. |
181
+
182
+ ### Fog Model
183
+
184
+ The core equation is the **Koschmieder model**:
185
+
186
+ ```
187
+ I_fog(x) = I(x) * t(x) + L_s * (1 - t(x))
188
+ ```
189
+
190
+ - **I(x)** — original RGB colour at pixel *x*
191
+ - **t(x) = exp(-k * d(x))** — transmittance, falling exponentially with depth *d*
192
+ - **L_s** — atmospheric light (airlight): the colour of light scattered toward the camera
193
+ - **k** — attenuation, derived from meteorological visibility *V* as `k = -ln(C_t) / V`
194
+
195
+ Distant objects are attenuated more (`t` approaches 0) and replaced by airlight, just
196
+ as in real fog.
197
+
198
+ Rendering happens in two phases. First the *ideal scene* is rendered: physics-based fog
199
+ plus auxiliary `scattering_coefficient` and `atmospheric_light` maps. Then *capture
200
+ artifacts* are applied to the rendered RGB only. Physical fog maps therefore stay
201
+ stable while the RGB output can receive exposure shifts, lens blur, sensor noise, ISP
202
+ processing, and compression.
203
+
204
+ ### How Each Modality Is Used
205
+
206
+ **RGB** — the clean scene image, normalised to float32 in [0, 1]. This is *I(x)*.
207
+
208
+ **Depth** — a per-pixel depth map in **metres**, providing *d(x)*. Invalid values (NaN,
209
+ inf, negative) are clamped to zero, i.e. treated as infinitely close and receiving no
210
+ fog. Depth stays authoritative even where the semantic map says sky, unless
211
+ `sky_fog_path` is configured.
212
+
213
+ **Semantic Segmentation** — a per-pixel semantic map from which a boolean sky mask is
214
+ derived. Used for airlight estimation when `airlight` is `"from_sky"`: the mean RGB of
215
+ all sky pixels becomes *L_s*.
216
+
217
+ **Intrinsics** *(optional)* — when present, planar (z-buffer) depth is converted to
218
+ radial (Euclidean) depth before fog is applied.
219
+
220
+ For a bounded valley-fog treatment of sky, add `sky_fog_path` inside a model config:
221
+
222
+ ```json
223
+ "sky_fog_path": {
224
+ "mode": "layer",
225
+ "camera_height_m": 1.6,
226
+ "fog_valley_peak_m": 80.0,
227
+ "camera_pitch_deg": 0.0,
228
+ "camera_roll_deg": 0.0,
229
+ "density_profile": "linear_fade",
230
+ "transition_height_m": 10.0,
231
+ "max_path_m": 1000.0
232
+ }
233
+ ```
234
+
235
+ Pixel rays are reconstructed from the intrinsics: near-horizon rays accumulate long
236
+ paths through the fog layer while upward rays exit it sooner. `linear_fade` keeps full
237
+ density below `transition_height_m` and decreases linearly to zero at
238
+ `fog_valley_peak_m`; `uniform` keeps full density up to the top. Positive
239
+ `camera_pitch_deg` points the optical axis upward, and `max_path_m` bounds horizon
240
+ rays. The original depth is retained for non-sky pixels and capture effects. Enabling
241
+ this without intrinsics raises an error rather than silently falling back.
242
+
243
+ ### Airlight Estimation
244
+
245
+ | Method | Description |
246
+ |---|---|
247
+ | `from_sky` | Mean RGB of sky pixels. Falls back to white `[1, 1, 1]` when no sky pixels exist. |
248
+ | `dcp` | Dark Channel Prior — brightest pixel (by channel sum) among the top 0.1% darkest-channel pixels. |
249
+ | `dcp_heuristic` | Robust DCP — pools the brighter half of the top 0.1% darkest-channel pixels; when sky pixels exist their brightest colours act as a chromaticity prior while DCP-derived luminance is preserved. |
250
+
251
+ GPU-native implementations are selected automatically when running on GPU. With
252
+ `dcp_heuristic` you can add:
253
+
254
+ ```json
255
+ "dcp_heuristic": {
256
+ "patch_size": 15,
257
+ "top_percent": 0.001,
258
+ "white_bias": 0.1,
259
+ "cool_bias": 0.15,
260
+ "cool_target": [0.93, 0.97, 1.0]
261
+ }
262
+ ```
263
+
264
+ `white_bias` mixes the result toward neutral white and `cool_bias` toward a
265
+ sky-relative cool target derived from `cool_target`; their sum must be `<= 1`. The tint
266
+ bias preserves luminance, so it shifts colour without changing fog density.
267
+
268
+ #### Intensity dampening
269
+
270
+ Estimated airlight is dampened by default as fog density increases, keeping strong fog
271
+ closer to the low grey lighting seen in real in-car footage instead of washing toward
272
+ white. Each model can override the curve:
273
+
274
+ ```json
275
+ "airlight_dampening": {
276
+ "enabled": true,
277
+ "apply_to": "estimated",
278
+ "reference_visibility_m": 80.0,
279
+ "min_factor": 0.45,
280
+ "max_factor": 1.0,
281
+ "strength": 1.0
282
+ }
283
+ ```
284
+
285
+ The factor is
286
+ `min_factor + (max_factor - min_factor) / (1 + strength * beta / reference_beta)`, where
287
+ `reference_beta` comes from `reference_scattering_coefficient` / `reference_beta` or is
288
+ derived from `reference_visibility_m`. Values above `1.0` are allowed when you want to
289
+ brighten estimated airlight; the final RGB is still clamped. The default applies only
290
+ to estimated airlight methods — literal RGB `atmospheric_light` values stay exact
291
+ unless `apply_to` is `"all"`. Set `"enabled": false` or `apply_to: "none"` to disable.
292
+
293
+ For `heterogeneous_ls` and `heterogeneous_k_ls`, the Perlin atmospheric-light field is
294
+ sampled around the dampened base airlight.
295
+
296
+ ### Model Selection
297
+
298
+ ```json
299
+ "selection": {
300
+ "mode": "weighted",
301
+ "weights": {
302
+ "uniform": 0.25,
303
+ "heterogeneous_k": 0.35,
304
+ "heterogeneous_ls": 0.25,
305
+ "heterogeneous_k_ls": 0.15
306
+ }
307
+ }
308
+ ```
309
+
310
+ `fixed` mode always uses a single named model; `weighted` picks one per image according
311
+ to normalised weights.
312
+
313
+ | Model | Description |
314
+ |---|---|
315
+ | `uniform` | Constant *k* and *L_s*. Standard homogeneous fog. |
316
+ | `heterogeneous_k` | Spatially-varying *k*, constant *L_s*. Patchy fog / fog banks. |
317
+ | `heterogeneous_ls` | Constant *k*, spatially-varying *L_s*. Scattered-light colour variation. |
318
+ | `heterogeneous_k_ls` | Both vary spatially. Most expressive model. |
319
+
320
+ Each model samples a `visibility_m` distribution per image:
321
+
322
+ | `dist` | Parameters |
323
+ |---|---|
324
+ | `constant` | `value` |
325
+ | `uniform` | `min`, `max` |
326
+ | `normal` | `mean`, `std`, optional `min`/`max` |
327
+ | `lognormal` | `mean`, `sigma`, optional `min`/`max` |
328
+ | `choice` | `values`, optional `weights` |
329
+
330
+ The sampled visibility *V* becomes `k = -ln(C_t) / V`, once per output image. For the
331
+ heterogeneous-*k* models that value is the base coefficient, which the noise field then
332
+ modulates spatially.
333
+
334
+ ### Heterogeneous Noise Fields
335
+
336
+ `k_hetero` and `ls_hetero` use Perlin FBM to generate spatially-varying factor fields.
337
+ For realistic fog, prefer the smooth mode: Perlin wavelengths stay tied to the image
338
+ size, noise contrast is reduced, and an optional blur is applied before mapping noise
339
+ to physical factors.
340
+
341
+ ```json
342
+ "k_hetero": {
343
+ "scales": "smooth_auto",
344
+ "correlation_length_fraction": 0.25,
345
+ "octaves": 3,
346
+ "max_scale": null,
347
+ "min_factor": 0.65,
348
+ "max_factor": 1.45,
349
+ "contrast": 0.65,
350
+ "smooth_sigma_fraction": 0.0,
351
+ "normalize_to_mean": true
352
+ }
353
+ ```
354
+
355
+ | Parameter | Effect |
356
+ |---|---|
357
+ | `min_factor` / `max_factor` | Range of the multiplicative factor. |
358
+ | `normalize_to_mean` | Rescale factors so the image-wide mean equals the base value. Recommended for `k_hetero`. |
359
+ | `scales: "smooth_auto"` | Build low-frequency Perlin scales from the image size. |
360
+ | `correlation_length_fraction` | Smallest fog feature size as a fraction of the shorter image side. Larger is smoother. |
361
+ | `octaves` / `lacunarity` / `max_scale` | How many increasingly broad Perlin components are mixed. |
362
+ | `contrast` | Compress or expand the Perlin range before mapping to factors. Below 1 recommended. |
363
+ | `smooth_sigma` / `smooth_sigma_fraction` | Optional final Gaussian blur, in pixels or as a fraction of the shorter side. |
364
+ | `ls_gradient` | Optional `L_s` top-to-bottom or left-to-right factor field. Keep it weak and probabilistic so it does not become an image-position shortcut. |
365
+
366
+ The noise field (in [0, 1]) maps to
367
+ `factor(x) = min_factor + (max_factor - min_factor) * noise(x)`, and with heterogeneous
368
+ *k* the result is `k(x) = k_sampled * factor(x)`. With `normalize_to_mean: true` the
369
+ arithmetic mean of the per-pixel *k* map equals `k_sampled` (the median is not forced to
370
+ match); with `false`, the map mean shifts by the mean of the factor field.
371
+
372
+ `ls_hetero` can add a weak view-direction illumination prior that modulates the
373
+ atmospheric-light field itself, so the rendered effect is still gated by transmittance:
374
+
375
+ ```json
376
+ "ls_hetero": {
377
+ "ls_gradient": {
378
+ "enabled": true,
379
+ "probability": 0.65,
380
+ "axis": "vertical",
381
+ "top_factor": {"dist": "uniform", "min": 1.03, "max": 1.14},
382
+ "bottom_factor": {"dist": "uniform", "min": 0.88, "max": 0.99},
383
+ "gamma": {"dist": "uniform", "min": 0.85, "max": 1.6},
384
+ "normalize_to_mean": true,
385
+ "fog_opacity_weight": 0.65
386
+ }
387
+ }
388
+ ```
389
+
390
+ ### Scene Illumination
391
+
392
+ For gloomy conditions, add `scene_illumination` inside a fog model config. It darkens
393
+ pre-fog scene radiance *I(x)* before the scattering equation, so near objects become
394
+ plausibly overcast or storm-lit instead of passing through unchanged. `global_ev`
395
+ applies to the whole non-sky scene, `near_ev` adds near-field darkening with
396
+ `near_decay_depth_m`, `fog_coupled_ev` adds a term proportional to local fog opacity,
397
+ and `sky_weight: 0.0` preserves sky pixels when a sky mask is available.
398
+
399
+ ### Capture Artifact Stack
400
+
401
+ Enable the recommended camera stack with `"capture": {"preset": "camera"}` (or
402
+ `"capture": true`). For tighter control, list explicit stages in camera order:
403
+
404
+ ```json
405
+ "capture": {
406
+ "stages": [
407
+ {
408
+ "type": "optics",
409
+ "blur_sigma": {"dist": "uniform", "min": 0.2, "max": 0.8},
410
+ "vignetting_strength": 0.15,
411
+ "windshield_haze": {"enabled": true, "probability": 0.4}
412
+ },
413
+ {
414
+ "type": "sensor",
415
+ "input_space": "srgb",
416
+ "exposure_gain": {"dist": "uniform", "min": 0.85, "max": 1.2},
417
+ "row_noise_sigma": 0.003
418
+ },
419
+ {"type": "isp", "tone_map": "reinhard", "gamma": "srgb", "sharpen_amount": 0.2},
420
+ {
421
+ "type": "transport",
422
+ "jpeg": {"enabled": true, "quality": {"dist": "uniform", "min": 65, "max": 92}},
423
+ "bit_depth": 8
424
+ }
425
+ ]
426
+ }
427
+ ```
428
+
429
+ | Stage | Main effects |
430
+ |---|---|
431
+ | `optics` | Defocus/MTF blur, motion blur, bloom, veiling glare, vignetting, chromatic aberration, lens distortion, windshield haze, optional droplets. |
432
+ | `sensor` | Image-driven or sampled exposure, white balance, camera matrix, Bayer mosaic, shot/read noise, fixed-pattern noise, row/column banding, shadow-local recovery noise, hot/dead pixels, bilinear demosaic. |
433
+ | `isp` | Denoising, colour correction, tone mapping, sRGB/gamma, local contrast, sharpening halos, saturation shifts. |
434
+ | `transport` | Crop/resize, bit-depth quantization, JPEG round-trip compression. |
435
+ | `exposure` | Lightweight standalone exposure and white-balance stage for simple custom chains. |
436
+
437
+ `camera_profiles` holds reusable named versions of the same settings; see
438
+ `configs/dense_gloomy_daylight_fog_camera.json` for a fully specified dashcam profile.
439
+
440
+ Four opt-in `sensor` blocks cover most of the realism tuning:
441
+
442
+ | Block | Purpose | Key settings |
443
+ |---|---|---|
444
+ | `auto_exposure` | Meters the rendered image before raw sensor sampling. `exposure_gain` still applies on top as scenario compensation. | `target_luminance`, `metering`, `highlight_*`, gain bounds, `resolve_iso` (raises ISO from metering pressure, dark pixel fraction, and fog opacity) |
445
+ | `sensor_identity` | Persistent sensor structure across frames, deterministic per `sensor_id` / `seed` / shape / Bayer pattern. | `prnu_sigma` (pixel-response non-uniformity before shot noise), `dsnu_sigma`, `persistent_row_sigma`, `persistent_column_sigma`, persistent hot/dead pixel probabilities |
446
+ | `shadow_recovery_noise` | Corrupts luma and chroma only where pre-exposure luminance was low — less global grain, visibly noisy lifted shadows. | `luma_sigma`, `chroma_sigma`, `chroma_mode`, `red_chroma_gain`, `blue_chroma_gain`, `chroma_axis_correlation`, `black_noise_floor`, `black_suppression_*` |
447
+ | `noise_adjustment` | Scales the selected profile's noise relatively. | `level` (`1.0` = unchanged), `static_chroma_bias` from `-1.0` (fixed-pattern, banding, bad pixels) to `1.0` (chromatic high-ISO shadow noise) |
448
+
449
+ The fog-aware metering modes (`"fog_aware_center_weighted"`,
450
+ `"sky_aware_center_weighted"`) additionally read `CaptureContext.depth_m`, `k_map`, fog
451
+ opacity, and `attributes.sky_mask`. Tune `sky_suppression`, `fog_meter_suppression`,
452
+ `depth_meter_decay_m`, and `min_meter_weight` to keep bright sky or dense far-field
453
+ airlight from dominating the meter; legacy metering modes are unchanged unless these
454
+ keys are present.
455
+
456
+ For dark high-ISO scenes, keep `shadow_recovery_noise.luma_sigma` well below
457
+ `chroma_sigma`, use `chroma_mode: "balanced"`, and leave
458
+ `chroma_luminance_preservation` near `1.0` so the corruption reads as colour noise
459
+ rather than black speckle. Keep `chroma_spatial_sigma` near `0` for fine-grained rather
460
+ than blocky noise.
461
+
462
+ **Condition profiles.** Any stage can define `condition_profiles` to sample coherent
463
+ per-image settings before it runs — useful when ISO, exposure gain, read noise, banding,
464
+ and dark/fog modulation should move together:
465
+
466
+ ```json
467
+ {
468
+ "type": "sensor",
469
+ "condition_profiles": [
470
+ {"name": "clean_daylight", "weight": 0.25, "exposure_gain": 1.0, "iso": 100},
471
+ {"name": "underexposed_noisy", "weight": 0.25, "exposure_gain": 0.65, "iso": 1600}
472
+ ]
473
+ }
474
+ ```
475
+
476
+ **Tone mapping.** `isp.tone_map` supports `"reinhard"`, `"aces"`, `"clip"`, and
477
+ `"lut"`. The LUT mode interpolates a cheap 1D camera-response curve given by
478
+ `tone_map_lut` and interpreted in `tone_map_lut_domain`.
479
+
480
+ For `"lut"` and `"aces"`, `tone_map_strength` is an **exponent on the curve's
481
+ response**, not a linear blend: `0` leaves the image unchanged, `1` applies the
482
+ curve exactly, and values above `1` apply it more strongly. Because the blend is
483
+ geometric, output radiance stays strictly non-negative at any strength. For
484
+ `"reinhard"` the strength is a curve parameter (`x / (1 + strength * x)`) as
485
+ before.
486
+
487
+ ### Scenario Profiles
488
+
489
+ Top-level `scenario_profiles` sample one latent scene/camera condition before rendering.
490
+ The selected scenario is merged over the root config, so it can drive fog density,
491
+ atmospheric light, camera profile, capture overrides, ISP, and compression together:
492
+
493
+ ```json
494
+ "scenario_profiles": [
495
+ {
496
+ "name": "underexposed_dense_gloom",
497
+ "weight": 0.25,
498
+ "model": "heterogeneous_k_ls",
499
+ "airlight_method": "dcp_heuristic",
500
+ "models": {
501
+ "heterogeneous_k_ls": {
502
+ "visibility_m": {"dist": "uniform", "min": 18.0, "max": 55.0},
503
+ "scene_illumination": {
504
+ "enabled": true,
505
+ "global_ev": {"dist": "uniform", "min": 0.25, "max": 0.85},
506
+ "near_ev": {"dist": "uniform", "min": 0.35, "max": 1.20},
507
+ "near_decay_depth_m": {"dist": "uniform", "min": 10.0, "max": 22.0},
508
+ "fog_coupled_ev": {"dist": "uniform", "min": 0.10, "max": 0.45},
509
+ "sky_weight": 0.0
510
+ }
511
+ }
512
+ },
513
+ "capture_overrides": {
514
+ "sensor": {
515
+ "condition_profile": "underexposed_noisy",
516
+ "auto_exposure": {
517
+ "enabled": true,
518
+ "metering": "fog_aware_center_weighted",
519
+ "target_luminance": {"dist": "uniform", "min": 0.13, "max": 0.20},
520
+ "sky_suppression": 0.85,
521
+ "fog_meter_suppression": 0.65
522
+ }
523
+ },
524
+ "transport": {"jpeg": {"quality": {"dist": "uniform", "min": 54, "max": 78}}}
525
+ }
526
+ }
527
+ ]
528
+ ```
529
+
530
+ `capture_overrides` is merged after camera-profile and stage settings. Use
531
+ `condition_profile` to force one named profile from a stage's `condition_profiles`; if
532
+ omitted, the stage keeps sampling its own weights locally.
533
+ `configs/dense_gloomy_daylight_fog_camera.json` contains a complete six-profile set
534
+ covering clear weather through severe sensor stress — the profiles shown in the header
535
+ images.
536
+
537
+ ### Progressive Mode
538
+
539
+ Set `"mode": "progressive"` to emit every configured scenario for every input image
540
+ instead of sampling one. Each scenario accepts `"steps"` and `"progressive_weight"`
541
+ (aliases: `"max_weight"`, `"weight"`); the transform writes steps from weight `0`
542
+ through the scenario's configured weight, where weight `1` matches the original
543
+ scenario. Fog density progresses in scattering-coefficient space while numeric
544
+ camera/config values blend from the base config toward the scenario config. Blends
545
+ clamp probability-like values and non-negative physical factors back into valid domains,
546
+ so extrapolated weights above `1` cannot produce invalid render parameters.
547
+ Source-backed outputs are written as `fog_progression` variants under each source file
548
+ id.
549
+
550
+ ### Stepped Augmentations
551
+
552
+ For benchmark generation, set `augmentations`. The fog transform then produces one
553
+ output per configured variant instead of one sampled output per input:
554
+
555
+ ```json
556
+ {
557
+ "airlight": "from_sky",
558
+ "seed": 1337,
559
+ "contrast_threshold": 0.05,
560
+ "augmentations": {
561
+ "file_id_hierarchy_name": "file_id",
562
+ "attribute_key": "fog_augmentation",
563
+ "models": ["uniform"],
564
+ "visibility_m": [10, 20, 40, 70, 100],
565
+ "airlight_methods": ["from_sky"]
566
+ }
567
+ }
568
+ ```
569
+
570
+ The matrix form expands as the Cartesian product of `models`, `visibility_m` (MOR in
571
+ metres), optional `scattering_coefficients` / `beta`, and airlight choices.
572
+ `file_id_hierarchy_name` names the inserted hierarchy level when the ds-crawler writer
573
+ has a hierarchy separator; the directory name is the source file id either way. For
574
+ tighter control, use explicit `variants` instead:
575
+
576
+ ```json
577
+ "augmentations": {
578
+ "variants": [
579
+ {
580
+ "id": "mor_010m_sky",
581
+ "model": "uniform",
582
+ "visibility_m": 10,
583
+ "airlight_method": "from_sky"
584
+ },
585
+ {
586
+ "id": "beta_0.15_white",
587
+ "model": "heterogeneous_k",
588
+ "scattering_coefficient": 0.15,
589
+ "atmospheric_light": [1.0, 1.0, 1.0],
590
+ "k_hetero": {"scales": "smooth_auto", "min_factor": 0.65, "max_factor": 1.45}
591
+ }
592
+ ]
593
+ }
594
+ ```
595
+
596
+ Each output receives per-file ds-crawler attributes under `fog_augmentation` — the
597
+ augmentation id, source id and full id, model, actual scattering coefficient, actual
598
+ atmospheric light, and configured MOR/beta descriptors. euler-loading exposes these as
599
+ `sample["attributes"]["rgb"]["fog_augmentation"]`.
600
+
601
+ ### Output
602
+
603
+ CLI runs write a source-backed RGB dataset that keeps the source dataset's relative
604
+ paths, basenames, extensions, and ds-crawler metadata, so the result stays loadable by
605
+ euler-loading:
606
+
607
+ ```
608
+ <output_path>/
609
+ .ds_crawler/dataset-head.json
610
+ .ds_crawler/ds-crawler.json
611
+ .ds_crawler/index.json
612
+ Scene01/Camera_0/00000.png
613
+ ```
614
+
615
+ With `augmentations` enabled, outputs are written one level below the source file id:
616
+
617
+ ```
618
+ <output_path>/
619
+ Scene01/Camera_0/00000/
620
+ mor_10m_airlight_from_sky.png
621
+ mor_20m_airlight_from_sky.png
622
+ ```
623
+
624
+ Auxiliary `scattering_coefficient` and `atmospheric_light` pipeline targets use the same
625
+ file-id hierarchy and write matching `.npy` files.
626
+
627
+ When a pipeline target is present, `pipeline.output_targets[].path` replaces
628
+ `output_path` entirely. Standalone `FogTransform(...)` usage without the CLI keeps the
629
+ legacy per-model layout with `config.json` sidecars.
630
+
631
+ ---
632
+
633
+ ## Sky-Depth Transform
634
+
635
+ Overrides depth values in sky regions with a configurable constant. Useful for datasets
636
+ where sky depth is encoded as zero or infinity and needs a large finite value.
637
+
638
+ ```json
639
+ {
640
+ "sky_depth_value": 1000.0
641
+ }
642
+ ```
643
+
644
+ `sky_depth_value` defaults to `1000.0`.
645
+
646
+ CLI runs write a source-backed depth dataset mirroring the input depth modality's paths,
647
+ filenames, extensions, and metadata. Standalone `SkyDepthTransform(...)` usage keeps the
648
+ legacy `.npy` output behaviour.
649
+
650
+ ---
651
+
652
+ ## Radial Transform
653
+
654
+ Converts planar (z-buffer) depth to radial (Euclidean) depth using camera intrinsics.
655
+ For each pixel *(u, v)*:
656
+
657
+ ```
658
+ d_radial(u, v) = d_planar(u, v) * sqrt(((u - cx)/fx)^2 + ((v - cy)/fy)^2 + 1)
659
+ ```
660
+
661
+ The transform config takes no parameters (`{}`); intrinsics are read from the
662
+ `intrinsics` hierarchical modality.
663
+
664
+ CLI runs write a source-backed depth dataset mirroring the input depth modality's layout
665
+ and writer metadata, with `meta.radial_depth` set to `true` in the emitted `index.json`.
666
+ Standalone `RadialTransform(...)` usage keeps the legacy `.npy` output behaviour.
667
+
668
+ ---
669
+
670
+ ## License
671
+
672
+ [MIT](LICENSE) © Daniel Rothenpieler