Crate summed_area

Crate summed_area 

Source
Expand description

§Summed Area Table AKA Integral Image

It precomputes sums of all rows and columns in a 2d array for fast O(1) querying of sums of areas within it.

It does this:

let mut sum = 0;
for row in y1..y2 {
    for col in x1..x2 {
        sum += input[col + row * width];
    }
}

but faster:

// precompute
let s = SummedArea::new(input, width);

// now it's fast:
let sum = s.sum_range(x1..x2, y1..y2);

Structs§

SummedArea
AKA Integral Image. Precomputed sums of subsections of a 2d array.

Type Aliases§

ImgRef
Reference to pixels inside another image. Pass this structure by value (i.e. ImgRef, not &ImgRef).