Skip to content

Feature/local background subtraction#131

Open
ManuelOsburg wants to merge 3 commits into
FireDynamics:masterfrom
ManuelOsburg:feature/local-background-subtraction
Open

Feature/local background subtraction#131
ManuelOsburg wants to merge 3 commits into
FireDynamics:masterfrom
ManuelOsburg:feature/local-background-subtraction

Conversation

@ManuelOsburg

Copy link
Copy Markdown

No description provided.

The LED intensity sum_col_value is a plain sum over the search box and
therefore contains scene-dependent background (stray light, smoke path
radiance). Under smoke the LED dims while the background remains, biasing
the transmission high and the reconstructed extinction coefficient low.

Add a new quantity bgsub_sum_col_value computed alongside the existing
sums: the local background is estimated as the median of the positive
pixels in a 2 px border ring of the search area (zeros are excluded
because raw Bayer arrays mask foreign-channel pixels with 0) and
subtracted pixel-wise with clipping at 0 before summing.

The value is written as an additional CSV column and picked up by the
HDF aggregation, so it can be selected in the analysis via
reference_property = bgsub_sum_col_val. Defaults are unchanged:
sum_col_value is not modified and old CSV files still parse correctly.
Test with a synthetic Gaussian LED spot plus constant background that
bgsub_sum_col_value is independent of the background level and matches
the pure LED integral (also with a Bayer-like zero mask), while
sum_col_value scales with the background. Also cover the background
estimator edge cases and the HDF column name detection for old
(5-column) and new (6-column) CSV files.
…default results

- new suite 07: bgsub reference property reproduces ground truth on clean
  images; default analysis results are bit-identical with and without the
  bgsub column (old data format); constant background biases sum_col_val
  but not bgsub_sum_col_val
- test library: optional constant background for generated test images,
  reference_property parameter for analysis config and result checks,
  keywords to strip the bgsub column and compare result files
@kriboe90

Copy link
Copy Markdown
Contributor

Hi Manuel,

thanks for adding the feature. For traceability can you maybe elaborate the feature and model behind that here?

Thank you!

@ManuelOsburg

Copy link
Copy Markdown
Author

Hi Kristian,

sure — here is the feature and the model behind it.

What the feature adds. Step 3 computes one additional quantity per LED and image, bgsub_sum_col_value: the local background $\hat B$ is estimated as the median of the positive pixels in the outer 2-px border ring of the LED search area, and then subtracted from every pixel before summing:

$$\hat B = \mathrm{median}\lbrace p_i \in \mathrm{ring} \mid p_i > 0 \rbrace, \qquad S_{\mathrm{bgsub}} = \sum_{\mathrm{box}} \max(p_i - \hat B,\ 0)$$

Median → robust against LED tails and hot pixels; positive-only → raw Bayer arrays mask foreign-channel pixels with exactly 0, which would otherwise pull the median to ~0; clip at 0 → masked pixels stay untouched. The analysis uses it only when reference_property = bgsub_sum_col_val is set in config_analysis.ini — the default pipeline is unchanged (verified bit-identical by the new acceptance suite 07, which also covers reading pre-existing 5-column step-3 files).

The model behind it. The search-area sum contains, besides the LED, an additive background (ambient/stray light plus a small estimator noise floor) that does not dim with smoke. Because this floor $F$ is present in the reference image and the measurement image, the measured transmission becomes (exactly, for a constant floor):

$$T_{\mathrm{meas}} = \frac{S_0,T + F}{S_0 + F} = T + f,(1-T), \qquad f = \frac{F}{S_0+F}$$

which propagates to the extinction coefficient as $\Delta k/k \approx -f,(e^{\tau}-1)/\tau$: the bias is always negative (extinction underestimated) and grows with optical depth. The ring measures $\hat B$ locally and per image, so the correction itself does not rely on the floor being constant in time or on any assumption about its origin.

Empirical basis (Hasenheide data, camera F1L). The LED-free border ring falls only to 0.86 of its reference value while the LED signal falls to 0.51 — direct evidence of light in the box that the smoke does not dim. The floor fraction measured independently from the ring time series ($f = 9.4\ %$ for a dim probe channel) predicts a $-11\ %$ bias via the formula above; $-12.6\ %$ was observed. For the bright production channels $f \approx 1.4\ %$, i.e. a $-2$ to $-4\ %$ effect. In a synthetic-twin test with a constant floor injected into the acceptance-test images, sum_col_val follows the formula prediction within 1 pp across $f = 0\ldots 32\ %$ while bgsub_sum_col_val stays within $+0.2\ %$ of the known ground truth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants