Skip to content

Warn when r/g/b channels have divergent ranges#682

Merged
timtreis merged 2 commits into
mainfrom
fix/issue-610-warn-divergent-rgb-ranges
May 21, 2026
Merged

Warn when r/g/b channels have divergent ranges#682
timtreis merged 2 commits into
mainfrom
fix/issue-610-warn-divergent-rgb-ranges

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented May 21, 2026

Summary

  • Closes Images with channel names ["r","g","b"] use global normalization, silently crushing low-range channels #610. In the RGB path of render_images, per-channel ranges that differ by more than 100x are flagged with a logger.warning before global normalization runs.
  • Naming channels r/g/b is treated as a deliberate intent signal, so the existing normalization behavior is preserved — we just stop being silent when low-range channels are about to be crushed.
  • Skipped when the user supplies an explicit norm (that branch already normalizes per channel).

Global normalization in the RGB path silently crushed low-range channels
when channels named r/g/b actually held fluorescence-like data with very
different native ranges. Emit a warning when per-channel ranges differ by
more than 100x so users know to rename channels or supply per-channel cmaps.
@timtreis timtreis changed the title Warn when r/g/b channels have divergent ranges (#610) Warn when r/g/b channels have divergent ranges May 21, 2026
- Compute per-channel min/max on original dtype with axis=(1,2) instead of
  copying to float64 and reshaping.
- Add tests confirming the warning also fires for RGBA, and stays quiet on
  the multichannel (non-r/g/b-named) and user-norm paths.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.83%. Comparing base (8a6a33f) to head (301209b).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #682      +/-   ##
==========================================
+ Coverage   77.79%   77.83%   +0.04%     
==========================================
  Files          11       11              
  Lines        3693     3709      +16     
  Branches      877      881       +4     
==========================================
+ Hits         2873     2887      +14     
- Misses        490      491       +1     
- Partials      330      331       +1     
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/render.py 87.11% <100.00%> (+<0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis timtreis merged commit 831d206 into main May 21, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Images with channel names ["r","g","b"] use global normalization, silently crushing low-range channels

2 participants