Skip to content

Fix image matching and mask helper correctness - #60

Draft
georgeoshardo wants to merge 2 commits into
mainfrom
fix/image-helper-correctness
Draft

Fix image matching and mask helper correctness#60
georgeoshardo wants to merge 2 commits into
mainfrom
fix/image-helper-correctness

Conversation

@georgeoshardo

Copy link
Copy Markdown
Owner

What changed

  • keep explicit lumMatch mean and standard deviation values independent of the number of input images
  • infer masked luminance spread from the masked standard deviation rather than the masked mean
  • make sfMatch finite for zero-energy radial bins and replace repeated full-image bin scans with one vectorized bin map plus bincount reductions
  • preserve touching integer labels during nearest-neighbor mask resizing
  • allocate floating U-Net weight maps so fractional class weights are retained
  • add focused numerical regressions for each failure

Why

The helpers were losing caller-supplied luminance values, calculating one masked statistic from the wrong quantity, producing NaN/inf for constant images, merging touching instance labels, and truncating fractional weights. The Fourier implementation also repeatedly scanned every pixel once per radial bin.

Validation

  • pixi run pytest -q tests/test_image_helpers.py tests/test_renderer_mask_export.py — 8 passed, 1 existing CPU-fallback warning
  • pixi run pytest -q — 69 passed, 1 existing CPU-fallback warning
  • old/new sfMatch comparison on 4×4, 5×7, and 32×48 inputs — maximum absolute difference at most 1.421e-13
  • local full-function timing on two 256×256 images, 3 runs — median 29.7 ms before and 15.1 ms after (about 2× faster)

No benchmark test was added.

Deliberately unchanged

SyMBac/metrics.py is only imported by SyMBac/auto_optimise.py in this repository. Neither file was changed because auto_optimise.py is scheduled for removal.

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.

1 participant