Function imageproc::integralimage::integral_image [] [src]

pub fn integral_image(image: &GrayImage) -> Image<Luma<u32>>

Compute the 2d running sum of a grayscale image.

An integral image I has width and height one greater than its source image F, and is defined by I(x, y) = sum of F(x', y') for x' < x, y' < y, i.e. each pixel in the integral image contains the sum of the pixel intensities of all input pixels that are strictly above it and strictly to its left. In particular, the left column and top row of an integral image are all 0, and the value of the bottom right pixel of an integral image is equal to the sum of all pixels in the source image.

Integral images have the helpful property of allowing us to compute the sum of pixel intensities in a rectangular region of an image in constant time. Specifically, given a rectangle [l, r] * [t, b] in F, the sum of the pixels in this rectangle is I(r + 1, b + 1) - I(r + 1, t) - I(l, b + 1) + I(l, t).