Skip to main content

Module histopathology

Module histopathology 

Source
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).
MacenkoResult
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).
StainBasis
Stain basis in optical-density space: up to 3 vectors × RGB.

Enums§

HistoError
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. out length ≥ 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 target Lab stats (or H&E defaults if None).
rgb_to_lab
Convert packed RGB8 to interleaved Lab f32. out length ≥ rgb.len().
snmf_unmix_lite
Unmix packed RGB into non-negative concentrations via multiplicative updates.