#image #integral #table

summed-area

Implementation of a summed-area table for fast sums or averages of subsections of a 2d array or an image

1 stable release

1.0.0 Sep 19, 2022

#1678 in Math

Download history 287/week @ 2025-11-08 296/week @ 2025-11-15 429/week @ 2025-11-22 525/week @ 2025-11-29 45/week @ 2025-12-06 10/week @ 2025-12-13 60/week @ 2025-12-20 103/week @ 2025-12-27 339/week @ 2026-01-03 540/week @ 2026-01-10 304/week @ 2026-01-17 443/week @ 2026-01-24 262/week @ 2026-01-31 311/week @ 2026-02-07 175/week @ 2026-02-14 266/week @ 2026-02-21

1,065 downloads per month
Used in mss_saliency

MIT/Apache

12KB
198 lines

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);

Dependencies

~67KB