summed-area

Crates.iosummed-area
lib.rssummed-area
version1.0.0
sourcesrc
created_at2022-09-19 20:09:20.427399
updated_at2022-09-19 20:09:20.427399
descriptionImplementation of a summed-area table for fast sums or averages of subsections of a 2d array or an image
homepagehttps://lib.rs/crates/summed-area
repositoryhttps://gitlab.com/kornelski/summed-area
max_upload_size
id669337
size11,303
maintainers (github:rust-bus:maintainers)

documentation

README

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);
Commit count: 0

cargo fmt