pub fn variance(
    integral_image: &Image<Luma<u32>>,
    integral_squared_image: &Image<Luma<u32>>,
    left: u32,
    top: u32,
    right: u32,
    bottom: u32
) -> f64
Expand description

Computes the variance of [left, right] * [top, bottom] in F, where integral_image is the integral image of F and integral_squared_image is the integral image of the squares of the pixels in F.

See the integral_image documentation for more information on integral images.

Examples

use std::f64;
use imageproc::integral_image::{integral_image, integral_squared_image, variance};

let image = gray_image!(
    1, 2, 3;
    4, 5, 6);

let integral = integral_image(&image);
let integral_squared = integral_squared_image(&image);

// Compute the variance of the pixels in the right two columns
let mean: f64 = (2.0 + 3.0 + 5.0 + 6.0) / 4.0;
let var = ((2.0 - mean).powi(2)
    + (3.0 - mean).powi(2)
    + (5.0 - mean).powi(2)
    + (6.0 - mean).powi(2)) / 4.0;

assert_eq!(variance(&integral, &integral_squared, 1, 0, 2, 1), var);