Repository navigation
Add the side band pedestal and the ring mean as background-corrected sums - #145
Merged
kriboe90 merged 5 commits intoOct 27, 2026
Merged
Conversation
…rrected sums of step 3
…ns NaN, test the channel mask and the LED arrays used for the side bands
This was referenced Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The search area of an LED contains an additive pedestal besides the LED itself: stray light, light emitted or scattered by the smoke, and, for raw images, noise clipped at 0 after the black level subtraction. Under dense smoke the LED dims while the pedestal stays, so
sum_col_valoverestimates the transmission.bgsub_sum_col_val(#131) takes the background from the 2 px border ring of the search area. For small search areas that ring lies in the halo of the LED itself, so it measures part of the LED as background.Change
Step 3 writes three more columns after
bgsub_sum_col_value. Likebgsub_sum_col_val, they are opt-in throughreference_property:sidebg_sum_col_valsidebg_pedestalbgsub2_sum_col_valN is the number of channel pixels in the search area.
Side bands:
search_area_radius.merge_led_array_indicesthe arrays of step 2 are used, because a merged array may contain several strips.Means include zeros, subtraction is linear: clipped zeros are part of the box sum, so they are part of the mean as well. Subtracting N·b instead of clipping pixel by pixel keeps the correction linear in the pixel values.
Channel mask: for raw images the channel pixels are taken from the Bayer pattern (
raw_colors_visible), not from the pixel values, since channel pixels can be 0. For this,read_channel_data_and_mask_from_imgis added next toread_channel_data_from_img. It goes through_get_readerand_read_or_raise, so unreadable images are skipped as in Develop skip corrupted images #137.Lower limit: both corrected sums are kept at least at
sideband_floor, a fraction ofsum_col_val(default 0.05). Without it the optical depth would be unbounded where the LED vanishes in the pedestal. Values at this limit carry no information on the extinction.Options:
config.inigetssideband_distances(25 60),sideband_floor(0.05) andsideband_exclusion_margin(None= R) in[analyse_photo]. Config files without the options use the defaults.Reading the results:
_get_column_namesknows the new layouts with 9 (-s3_fast) and 23 (-s3) columns. The earlier layouts with 5, 6 and 20 columns are still read.NaN:
sidebg_sum_col_valis NaN for an LED whose strip direction cannot be estimated (an LED array with a single LED) or whose side bands contain no pixel, for example because the image ends closer to the strip.bgsub2_sum_col_valis NaN only if the search area is too small for a border ring (at most 4 px). The solvers do not handle NaN:ValueError: array must not contain infs or NaNsfromnnls;ExtinctionCoefficients.load_img_datatherefore stops with an error if the selected reference property contains NaN, and names the LEDs.sum_col_valandbgsub_sum_col_valcontain no NaN, so this check does not affect them.Docs: README section "Background correction (optional)", the
-s3_fastentry of the CLI docs and the API docs of the new module.Default results are unchanged
-s3_fastfollowed by--analysis(linear and nonlinear,sum_col_valandbgsub_sum_col_val) gives bit-identical extinction coefficients onmasterand on this branch. The step 3 files are identical in their first 6 columns.sidebg_sum_col_valalso runs through.Tests
test_sideband_background.pycovers:read_channel_data_and_mask_from_img;test_ring_background_mean.pycovers the ring mean andbgsub2_sum_col_val.test_background_subtraction.pyadditionally checks the new column layouts.10_test_sideband_background.robot:sum_col_valandbgsub_sum_col_valare bit-identical with and without the three new columns.sidebg_sum_col_valreproduces the ground truth: rmse 0.014 / 0.016 / 0.022 < 0.05.sum_col_valis biased (rmse 0.13 / 0.18 / 0.13 > 0.05), whilesidebg_sum_col_valstays close (0.022 / 0.025 / 0.027 < 0.06), also below half the rmse of the sum.sideband_distances = 12 20.-s3_fastnow reads through it.cp1252): the whole Robot suite passes 23/23 and the unit tests pass 71/71. The encoding check of the CI is clean.git diff --checkis clean.