User:Mdockrey/Summed Area Table

A Summed Area Table (also known as an Integral Image) is an algorithm for quickly and efficiently generating the sum of values in a rectangular subset of a grid. It was first introduced to the computer graphics world in 1984 for use in mipmaps but wasn't widely used in the computer vision community until its prominent use in the Viola and Jones robust real-time object detection framework twenty years later.

The Algorithm
As the name suggests, the value at any point $$(x,y)$$ in the summed area table is just the sum of all the pixels above and to the left of $$(x,y)$$, inclusive: $$sat(x,y) = \sum_{x' \le x,y' \le y} i(x',y')$$

Moreover, the summed area table can be computed efficiently in a single pass over the image, using the fact that the value in the summed area table at $$(x,y)$$ is just:

$$sat(x,y) = sat(x-1,y) + \sum_{x' \le x} i(x',y)$$

Once the summed area table has been computed, the task of evaluating any rectangle can be accomplished in constant time with just four array references. Specifically, using the notation in the figure at right, the value is just:

$$\sum_{A(x) \le x' \le B(x), A(y) \le y' \le D(y)} i(x',y') = sat(A) + sat(C) - sat(B) - sat(D)$$