Skip to main content

compute_histogram

Function compute_histogram 

Source
pub fn compute_histogram(
    data: &NDDataBuffer,
    hist_size: usize,
    hist_min: f64,
    hist_max: f64,
) -> (Vec<f64>, f64, f64, f64)
Expand description

Compute histogram of pixel values.

Returns (histogram, below_count, above_count, entropy).

  • hist_size: number of bins
  • hist_min / hist_max: value range for binning
  • bin index = ((val - hist_min) * (hist_size - 1) / (hist_max - hist_min) + 0.5) as usize
  • Values below hist_min increment below_count; above hist_max increment above_count
  • Entropy = -sum(p * ln(p)) for non-zero bins where p = count / total_count