AI Glossary / Computer vision and multimodal AI / Advanced
Integral image
Definition
An integral image, also called a summed-area table, stores cumulative sums of image values so that sums over axis-aligned rectangular regions can be computed efficiently. After the table is built, a rectangle's sum requires a fixed number of table lookups and arithmetic operations, regardless of how many pixels the rectangle contains.
What it means
The representation performs useful work in advance. Instead of adding every pixel each time a region is queried, it records totals for rectangles anchored at a common origin. Overlapping totals can then be combined to isolate another rectangle. This is a data structure for computation, not an enhanced photograph or a learned interpretation of image content. Its benefit is greatest when many suitable region queries reuse the same input. Building the table still requires processing the original image and storing additional values.
How it works
Using a padded convention, define S(X,Y) as the sum of pixels with x<X and y<Y. The first row and column are zero. The sum over the half-open rectangle [x1,x2)×[y1,y2) is S(x2,y2)−S(x1,y2)−S(x2,y1)+S(x1,y1). The final addition restores the overlap subtracted twice. Tables of squared values can support related statistics when combined with counts and ordinary sums. Numeric range and precision matter because cumulative totals can be much larger than individual pixels. Rotated rectangles require a suitable extension rather than blindly applying the ordinary formula.
Three practical examples
- A vision pipeline evaluates many rectangular intensity features from one image without repeatedly summing every pixel in each region.
- An inspection tool computes local means over different window sizes using rectangular sums and the corresponding pixel counts.
- A developer compares direct summation with a summed-area table on representative workloads to determine whether preprocessing and memory costs are worthwhile.
Think of it this way
Imagine a financial ledger that records cumulative spending from the start of a period. Subtracting two cumulative totals reveals spending between two dates. An integral image extends that idea across two spatial directions, which requires correcting for the area subtracted twice. The analogy explains reuse of accumulated totals. It does not imply that the image values are financial quantities or that cumulative sums can answer every kind of region query equally efficiently.
Worked example
In an original 3×3 image, the rows are [1,2,3], [4,5,6] and [7,8,9]. Consider the bottom-right 2×2 region containing 5,6,8 and 9. Under the padded convention, S(3,3)=45, S(1,3)=12, S(3,1)=6 and S(1,1)=1. The rectangle sum is 45−12−6+1=28, matching direct addition. Its mean is 28/4=7. The table lookups do not depend on the rectangle's area, although building the table did require reading the image. Explicitly stating the indexing convention prevents a one-pixel shift in the selected region.
Illustrative case study
A fictional warehouse-imaging team computes brightness summaries for thousands of rectangular candidate regions. Repeated direct summation becomes expensive, so it introduces a summed-area table for each frame. Initial results disagree near the top border because the query code mixes inclusive endpoints with a padded half-open convention. The team fixes the coordinate interpretation and compares a selection of region sums against direct calculations. This scenario illustrates both the efficiency opportunity and a common implementation error. It does not claim that the same structure accelerates arbitrary shapes, weighted kernels or frequently changing images without additional work.
Common misconceptions and mistakes
Constant-time rectangle queries do not mean the entire processing pipeline has constant cost. Table construction, storage and the number of queries still matter. Another mistake is using an accumulator type that overflows on large images. Endpoint conventions are a frequent source of errors, especially when one implementation includes the corner pixel and another excludes it. A standard integral image also does not directly provide a median. Finally, changing the source image invalidates affected cumulative totals, so a table must not silently be reused after the underlying values change.
Business use
The structure can reduce repeated regional computation in classical vision and image-analysis systems. Teams should benchmark the actual workload, including preprocessing and memory use, rather than assuming every use of a rectangle benefits. Verify edge cases, accumulator range and coordinate conventions. If sums feed an automated decision, test a few known regions independently to catch indexing errors that might otherwise appear as model behavior. Keep the distinction between computational acceleration and analytical accuracy clear: a faster exact sum does not make the selected feature more informative about the business question.
People also ask
Is an integral image a neural network?
No. It is a cumulative-sum representation that can support many kinds of algorithms.
Can it provide a rectangle's mean?
Yes. Divide the region sum by its pixel count under the chosen region definition.
Does it directly compute any arbitrary shape's sum in constant time?
No. The ordinary four-corner rule applies to axis-aligned rectangles.
Check your understanding
Why was 1 added back in the example?
Answer: The top-left overlap had been subtracted twice.
What was the region mean?
Answer: Seven.
Why should the accumulator type be checked?
Answer: A cumulative total can exceed the range of an individual pixel value even when every input value is valid.
Related terms
- Box filter
- Summed-area table
- prefix sum
- Haar-like feature
- local mean
- accumulator precision
Learn next
Construct a small table by hand and compare several rectangle queries with direct addition. Include a region touching the image boundary. Then examine when a squared-value table supports variance calculations and where finite-precision subtraction can become important.
More in Computer vision and multimodal AI
- Implicit curve - An implicit curve in the plane is described by a relation such as F(x,y)=0, rather than by explicitly expressing one coordinate as a function of the other.
- Implicit surface - An implicit surface represents a three-dimensional boundary as the set of points satisfying an equation such as F(x,y,z)=0.
- Impulse (delta) - An impulse, or delta, is an idealized localized input used in signal and image processing.
- Intelligent scissors (live-wire) - Intelligent scissors, also called live-wire in related interactive boundary-selection workflows, helps a user trace an image boundary by finding low-cost...
- Interleaved (HWC) layout - An interleaved HWC image layout organizes data by height, width and channel, with channel values grouped for each pixel in a conventional contiguous...
- Intermediate representation - An intermediate representation, or IR, is a structured form of a program or computation used between stages of translation, analysis or optimization.
Sources
OpenCV, Miscellaneous Image Transformations, integral-image reference: https://docs.opencv.org/3.4.4/d7/d1b/group__imgproc__misc.html The 3×3 calculation, ledger analogy and warehouse-imaging case are original educational illustrations. The worked example explicitly uses a zero-padded table and half-open rectangle coordinates.
Previous: Instrumental variables Next: Integrated test facility