Skip to main content

adaptive_threshold_mean

Function adaptive_threshold_mean 

Source
pub fn adaptive_threshold_mean(
    src: &[u8],
    width: usize,
    height: usize,
    block_size: usize,
    c: f64,
) -> Vec<u8> ⓘ
Expand description

Port of OpenCV adaptiveThreshold with ADAPTIVE_THRESH_MEAN_C and THRESH_BINARY.

For each pixel the local mean over a block_size x block_size neighborhood is computed with a normalized box filter and BORDER_REPLICATE (so the kernel area is always block_size^2). A pixel becomes 255 when src > mean - ceil(c), else 0.

Panics if block_size is even or less than 3, matching OpenCV’s requirement of an odd window.