Expand description
Histopathology color / stain algorithms (pure Rust, caller-buffered).
CIE LAB (D65), optical density, Reinhard normalize, Macenko deconvolution, background illumination correction, and lite non-negative unmixing.
No Python, no OpenCV ABI. Hot paths take caller-owned buffers.
Structs§
- LabStats
- Lab mean (L, a, b).
- Macenko
Result - Result of Macenko: two unit-ish stain vectors in OD space (rows: H, E; cols: R,G,B).
- RgbBg
- Per-channel background estimate (linear RGB8 mean of bright pixels).
- Stain
Basis - Stain basis in optical-density space: up to 3 vectors × RGB.
Enums§
- Histo
Error - Errors for histopathology kernels.
Constants§
- DEFAULT_
HE_ TARGET_ MEAN - Approximate H&E appearance targets in CIE Lab (D65).
- DEFAULT_
HE_ TARGET_ STD - Companion std for
DEFAULT_HE_TARGET_MEAN.
Functions§
- apply_
background_ correct - Correct RGB illumination:
out = clamp(rgb * 255 / bg, 0..255)per channel. - background_
intensity_ sample - Sample background as the mean RGB of pixels whose luminance is at or above
the given percentile (e.g.
percentile = 95.0→ top ~5% brightest). - lab_
to_ rgb - Convert interleaved Lab f32 to packed RGB8.
outlength ≥lab.len(). - macenko_
deconvolution - Macenko deconvolution.
- optical_
density_ rgb - Convert packed RGB8 intensities to optical density (f32, same layout).
- reinhard_
normalize - Reinhard-normalize packed RGB8 toward
targetLab stats (or H&E defaults ifNone). - rgb_
to_ lab - Convert packed RGB8 to interleaved Lab f32.
outlength ≥rgb.len(). - snmf_
unmix_ lite - Unmix packed RGB into non-negative concentrations via multiplicative updates.