Summed-area Table

A Summed-area table is a data structure and algorithm for quickly and efficiently generating the sum of values in a rectangular grid. In image processing it is also known as an integral image.

To generate a summed-area table, each cell is given a value which is the sum of all values in a rectangular subset where the top left corner is the first cell in the grid and where the bottom right cell is the cell you're calculating the value for (assumuing the array starts top left).

        
        
    

Now each cell has its own count value. This isn't much help on it's own, however we can use it to calculate the sum value of any subset of the grid by interrogating 4 cells and performing only 4 additions. NOTE: we have to add the 'top left' region as it as been subtracted twice.

        
        
    

Click a sqaure on the grid to turn it on or off.

Shift+Click two square to define a rectangle.

Press the show count button to display the sum value of each cell (in this example a cell's value can only be 0 or 1).

Press show rectangles to see the different regions simplified and see how it changes the sum below.

0 = 0 + 0 - 0 - 0