Skip to main content

otsu_threshold

Function otsu_threshold 

Source
pub fn otsu_threshold(data: &[f64], num_bins: usize) -> f64
Expand description

Otsu’s method for automatic threshold selection

Finds the threshold that maximizes inter-class variance. Matches MATLAB’s graythresh: operates on all values including zeros, normalizes to [0,1] range, and returns threshold at bin edge.

§Arguments

  • data - Input data (e.g. flattened 3D image)
  • num_bins - Number of histogram bins (typically 256)

§Returns

The optimal threshold value