Misplaced Pages

Summed-area table

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
Type of data structure algorithm
Using a summed-area table (2.) of a 6×6 matrix (1.) to sum up a subrectangle of its values; each coloured spot highlights the sum inside the rectangle of that colour.

A summed-area table is a data structure and algorithm for quickly and efficiently generating the sum of values in a rectangular subset of a grid. In the image processing domain, it is also known as an integral image. It was introduced to computer graphics in 1984 by Frank Crow for use with mipmaps. In computer vision it was popularized by Lewis and then given the name "integral image" and prominently used within the Viola–Jones object detection framework in 2001. Historically, this principle is very well known in the study of multi-dimensional probability distribution functions, namely in computing 2D (or ND) probabilities (area under the probability distribution) from the respective cumulative distribution functions.

The algorithm

As the name suggests, the value at any point (xy) in the summed-area table is the sum of all the pixels above and to the left of (xy), inclusive: I ( x , y ) = x x y y i ( x , y ) {\displaystyle I(x,y)=\sum _{\begin{smallmatrix}x'\leq x\\y'\leq y\end{smallmatrix}}i(x',y')} where i ( x , y ) {\displaystyle i(x,y)} is the value of the pixel at (x,y).

The summed-area table can be computed efficiently in a single pass over the image, as the value in the summed-area table at (xy) is just: I ( x , y ) = i ( x , y ) + I ( x , y 1 ) + I ( x 1 , y ) I ( x 1 , y 1 ) {\displaystyle I(x,y)=i(x,y)+I(x,y-1)+I(x-1,y)-I(x-1,y-1)} (Noted that the summed matrix is calculated from top left corner)

A description of computing a sum in the summed-area table data structure/algorithm

Once the summed-area table has been computed, evaluating the sum of intensities over any rectangular area requires exactly four array references regardless of the area size. That is, the notation in the figure at right, having A = (x0, y0), B = (x1, y0), C = (x0, y1) and D = (x1, y1), the sum of i(x,y) over the rectangle spanned by A, B, C, and D is: x 0 < x x 1 y 0 < y y 1 i ( x , y ) = I ( D ) + I ( A ) I ( B ) I ( C ) {\displaystyle \sum _{\begin{smallmatrix}x_{0}<x\leq x_{1}\\y_{0}<y\leq y_{1}\end{smallmatrix}}i(x,y)=I(D)+I(A)-I(B)-I(C)}

Extensions

This method is naturally extended to continuous domains.

The method can be also extended to high-dimensional images. If the corners of the rectangle are x p {\displaystyle x^{p}} with p {\displaystyle p} in { 0 , 1 } d {\displaystyle \{0,1\}^{d}} , then the sum of image values contained in the rectangle are computed with the formula p { 0 , 1 } d ( 1 ) d p 1 I ( x p ) {\displaystyle \sum _{p\in \{0,1\}^{d}}(-1)^{d-\|p\|_{1}}I(x^{p})} where I ( x ) {\displaystyle I(x)} is the integral image at x {\displaystyle x} and d {\displaystyle d} the image dimension. The notation x p {\displaystyle x^{p}} correspond in the example to d = 2 {\displaystyle d=2} , A = x ( 0 , 0 ) {\displaystyle A=x^{(0,0)}} , B = x ( 1 , 0 ) {\displaystyle B=x^{(1,0)}} , C = x ( 1 , 1 ) {\displaystyle C=x^{(1,1)}} and D = x ( 0 , 1 ) {\displaystyle D=x^{(0,1)}} . In neuroimaging, for example, the images have dimension d = 3 {\displaystyle d=3} or d = 4 {\displaystyle d=4} , when using voxels or voxels with a time-stamp.

This method has been extended to high-order integral image as in the work of Phan et al. who provided two, three, or four integral images for quickly and efficiently calculating the standard deviation (variance), skewness, and kurtosis of local block in the image. This is detailed below:

To compute variance or standard deviation of a block, we need two integral images: I ( x , y ) = x x y y i ( x , y ) {\displaystyle I(x,y)=\sum _{\begin{smallmatrix}x'\leq x\\y'\leq y\end{smallmatrix}}i(x',y')} I 2 ( x , y ) = x x y y i 2 ( x , y ) {\displaystyle I^{2}(x,y)=\sum _{\begin{smallmatrix}x'\leq x\\y'\leq y\end{smallmatrix}}i^{2}(x',y')} The variance is given by: Var ( X ) = 1 n i = 1 n ( x i μ ) 2 . {\displaystyle \operatorname {Var} (X)={\frac {1}{n}}\sum _{i=1}^{n}(x_{i}-\mu )^{2}.} Let S 1 {\displaystyle S_{1}} and S 2 {\displaystyle S_{2}} denote the summations of block A B C D {\displaystyle ABCD} of I {\displaystyle I} and I 2 {\displaystyle I^{2}} , respectively. S 1 {\displaystyle S_{1}} and S 2 {\displaystyle S_{2}} are computed quickly by integral image. Now, we manipulate the variance equation as: Var ( X ) = 1 n i = 1 n ( x i 2 2 μ x i + μ 2 ) = 1 n [ i = 1 n x i 2 2 i = 1 n μ x i + i = 1 n μ 2 ] = 1 n [ i = 1 n x i 2 2 i = 1 n μ x i + n μ 2 ] = 1 n [ i = 1 n x i 2 2 μ i = 1 n x i + n μ 2 ] = 1 n [ S 2 2 S 1 n S 1 + n ( S 1 n ) 2 ] = 1 n [ S 2 S 1 2 n ] {\displaystyle {\begin{aligned}\operatorname {Var} (X)&={\frac {1}{n}}\sum _{i=1}^{n}\left(x_{i}^{2}-2\mu x_{i}+\mu ^{2}\right)\\&={\frac {1}{n}}\left\\&={\frac {1}{n}}\left\\&={\frac {1}{n}}\left\\&={\frac {1}{n}}\left\\&={\frac {1}{n}}\left\end{aligned}}} Where μ = S 1 / n {\displaystyle \mu =S_{1}/n} and S 2 = i = 1 n x i 2 {\textstyle S_{2}=\sum _{i=1}^{n}x_{i}^{2}} .

Similar to the estimation of the mean ( μ {\displaystyle \mu } ) and variance ( Var {\displaystyle \operatorname {Var} } ), which requires the integral images of the first and second power of the image respectively (i.e. I , I 2 {\displaystyle I,I^{2}} ); manipulations similar to the ones mentioned above can be made to the third and fourth powers of the images (i.e. I 3 ( x , y ) , I 4 ( x , y ) {\displaystyle I^{3}(x,y),I^{4}(x,y)} .) for obtaining the skewness and kurtosis. But one important implementation detail that must be kept in mind for the above methods, as mentioned by F Shafait et al. is that of integer overflow occurring for the higher order integral images in case 32-bit integers are used.

Implementation considerations

The data type for the sums may need to be different and larger than the data type used for the original values, in order to accommodate the largest expected sum without overflow. For floating-point data, error can be reduced using compensated summation.

See also

References

  1. Lewis, J.P. (1995). Fast template matching. Proc. Vision Interface. pp. 120–123.
  2. ^ Finkelstein, Amir; neeratsharma (2010). "Double Integrals By Summing Values Of Cumulative Distribution Function". Wolfram Demonstration Project.
  3. Crow, Franklin (1984). "Summed-area tables for texture mapping". SIGGRAPH '84: Proceedings of the 11th annual conference on Computer graphics and interactive techniques. pp. 207–212. doi:10.1145/800031.808600.
  4. Viola, Paul; Jones, Michael (2002). "Robust Real-time Object Detection" (PDF). International Journal of Computer Vision.
  5. BADGERATI (2010-09-03). "Computer Vision – The Integral Image". computersciencesource.wordpress.com. Retrieved 2017-02-13.
  6. Tapia, Ernesto (January 2011). "A note on the computation of high-dimensional integral images". Pattern Recognition Letters. 32 (2): 197–201. Bibcode:2011PaReL..32..197T. doi:10.1016/j.patrec.2010.10.007.
  7. ^ Phan, Thien; Sohoni, Sohum; Larson, Eric C.; Chandler, Damon M. (22 April 2012). "Performance-analysis-based acceleration of image quality assessment". 2012 IEEE Southwest Symposium on Image Analysis and Interpretation (PDF). pp. 81–84. CiteSeerX 10.1.1.666.4791. doi:10.1109/SSIAI.2012.6202458. hdl:11244/25701. ISBN 978-1-4673-1830-3. S2CID 12472935.
  8. Shafait, Faisal; Keysers, Daniel; M. Breuel, Thomas (January 2008). Yanikoglu, Berrin A.; Berkner, Kathrin (eds.). "Efficient implementation of local adaptive thresholding techniques using integral images" (PDF). Electronic Imaging. Document Recognition and Retrieval XV. 6815: 681510–681510–6. Bibcode:2008SPIE.6815E..10S. CiteSeerX 10.1.1.109.2748. doi:10.1117/12.767755. S2CID 9284084.

External links

Lecture videos

Categories: