lucem_hist::raster
Small raster helpers on the host, for images already reduced to an analysis resolution (tissue at a coarse level, density maps, class maps): smoothing, Otsu, connected components, small pieces and holes.
pub struct GridWhere a raster lies on the slide: its size, the level-0 position of its first pixel and how many level-0 pixels one of its pixels covers.
Fields
width: usizeheight: usizeorigin: Pointdownsample: f64
Methods
pub fn new(width: usize, height: usize, origin: Point, downsample: f64) -> Selfpub fn len(&self) -> usizepub fn is_empty(&self) -> boolImplements Clone, Copy, Debug, PartialEq.
Functions
Section titled “Functions”gaussian
Section titled “gaussian”pub fn gaussian(values: &[f32], w: usize, h: usize, sigma: f64) -> Vec<f32>A separable Gaussian blur (σ in pixels; edges repeat the border).
pub fn otsu(values: &[f32]) -> f32Otsu’s threshold of finite values (256 bins between their min and max).
components
Section titled “components”pub fn components(mask: &[u8], w: usize, h: usize) -> (Vec<u32>, u32)8-connected components of the non-zero pixels: labels 1..=n and n.
label_areas
Section titled “label_areas”pub fn label_areas(labels: &[u32], n: u32) -> Vec<usize>Pixels per label (index 0: background).
pub fn clean(mask: &mut [u8], w: usize, h: usize, min_area: f64, min_hole: f64)Drops pieces of mask smaller than min_area pixels and fills holes smaller than
min_hole pixels (background pieces not touching the border).