- Introduced by
- Stauffer and Grimson
- Year
- 1999
- Type
- Temporal image analysis
- Family
- Video segmentation
What does it do?
Background subtraction is a video processing technique that separates moving foreground objects from a static or slowly changing background by comparing each frame with a learned background model.
It is widely used in video surveillance and motion detection. It tolerates gradual illumination change, but it is not reliable under sudden global lighting changes or dynamic backgrounds such as waving trees or water.
The intuition behind the method
In a video sequence, pixels showing a static background tend to keep similar intensity values over time, while pixels covered by a moving object change suddenly. Background subtraction builds a statistical model of how each background pixel behaves, then labels each pixel in a new frame as foreground (clearly different from the model) or background. In the Gaussian Mixture Model (GMM) approach associated with Stauffer and Grimson, each pixel's intensity history is modelled as a mixture of Gaussians. Some components capture the stable background values, while others capture values that do not belong to the stable background, such as passing objects.
History
Stauffer and Grimson (1999) proposed modelling each pixel as a mixture of Gaussians, updated online, and classifying a pixel by whether the Gaussian that best represents it is judged to be background. Their paper reported a real-time outdoor tracker that dealt with lighting changes and repetitive motion from clutter. KaewTraKulPong and Bowden later extended the approach with shadow detection. Learning-based methods now exist, but the GMM formulation is still often used as a baseline.
When to use it
Choose background subtraction when the camera is fixed and the background is relatively stable or changes slowly and predictably, as with outdoor scenes whose appearance shifts with weather or time of day. It suits surveillance, motion detection, and as a first stage for object tracking, where the goal is to find all moving objects without a model of what they are. Avoid it when the background itself moves (water, waving trees, flickering lights), when the camera moves, when foreground and background look alike (camouflage), or when objects must be identified rather than merely detected. In these cases, optical flow or learning-based detection are more suitable alternatives.
Limitations and considerations
- Strongly dynamic backgrounds (waving trees, water, flickering light) can still produce recurring pixel values that the model labels as foreground, because a mixture represents only a limited number of background states
- Shadows and reflections change pixel intensity relative to the background, and the basic model often labels them as foreground; shadow detection, as in the extension by KaewTraKulPong and Bowden, is needed to address this
- Sudden global illumination changes, such as switching on a light, alter many pixels at once; the model needs frames to adapt, and false foreground occurs in the meantime
- Slow-moving or stationary objects can be absorbed into the background model over time
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Per-pixel updates are simple to compute, and the original GMM system was designed to run in real time on outdoor video; computational cost grows with the number of mixture components kept per pixel
- Adapts to gradual background changes such as lighting or weather without manual retraining
- Needs no object model or labelled training data; background statistics are learned from the video itself
- Detects any moving object without recognising its class, so it does not depend on target-specific appearance
- Modelling each pixel as a mixture lets it keep more than one background state, which reduces (but does not eliminate) false foreground from repetitive motion such as clutter, instead of forcing a single average intensity
Applications
- Video surveillance: detecting people or vehicles entering a monitored area
- Traffic monitoring: extracting vehicles from fixed-camera footage of roads or intersections for counting and tracking
- Wildlife monitoring: detecting animals in long fixed-camera recordings
How it works
How it works
Set up the per-pixel background model, typically from the first frame or from frames in which no moving objects are present, because the model is meant to describe the background only.
For each new frame, compare each pixel with its Gaussian components and update the parameters of the matching component. This incremental update lets the model follow gradual changes such as slow lighting shifts. The learning rate sets how fast this happens: a high rate adapts quickly to lighting changes but absorbs stationary objects sooner, while a low rate adapts slowly and keeps objects visible for longer. The number of components sets how many background states each pixel can represent; more components capture more variation but increase computation. A pixel that stays unchanged for a long time can still be absorbed into the background.
For each pixel, check whether the Gaussian component that best matches its current value is judged to belong to the background. The background decision threshold controls how much of the model's weight must be attributed to background components. A higher threshold admits more components as background, which reduces false foreground labels but raises the risk of hiding real objects. Pixels matching a background component are labelled background; all others are labelled foreground, which yields a binary foreground mask.
Post-process the foreground mask, for example with morphological operations, to remove isolated noise pixels and fill gaps within objects. Check the result against labelled ground-truth frames using standard binary-mask measures: precision (the share of detected foreground that is correct), recall (the share of true foreground that is detected), and their harmonic mean, the F-measure. Scores depend on the scene and the recording, so they should not be generalised to other videos without testing. Shadow handling is not part of the basic model and requires a dedicated extension.
Common pitfalls
- Initialising the model from frames that already contain moving objects, which then become part of the background
- Ignoring shadows: shadow pixels are usually better classified as background for accurate object boundaries
- Applying one global decision threshold to all pixels, although background variability differs between regions of the same image
- Turning off model updates; without adaptation, lighting changes quickly produce false positives
- Choosing the learning rate without considering how long objects stay still: a rate that is too high absorbs stationary objects into the background, while a rate that is too low cannot follow lighting changes
Frequently asked questions
Why use a Gaussian Mixture Model (GMM) instead of a single Gaussian for each pixel?
Pixel values from a static background are not constant: small changes in light direction, sensor noise, and slowly moving vegetation cause fluctuations. A single Gaussian can describe only one such mode. A mixture allows one component to capture a stable background state and others to capture recurring variations, and the model can judge which component best represents the background.
How does background subtraction adapt to illumination changes?
When a pixel matches one of its background components, that observation is used to update the component's mean and variance, so the model gradually follows slow lighting changes. Sudden changes behave differently: when many pixels shift at once, the model has not yet seen the new values, so they are labelled foreground until enough frames have updated the model.
What is shadow detection and why is it necessary?
A shadow darkens the background where a foreground object blocks light. Without special handling, these darkened pixels differ from the background model and are labelled foreground, which enlarges and distorts the object outline. Shadow detection methods, such as the extension by KaewTraKulPong and Bowden, try to recognise darkened regions that still correspond to the background and label them as background.
How does background subtraction handle temporary occlusions or re-lighting?
A person who stops moving is gradually absorbed into the background model, because their pixels begin to match a background component. The update rate controls how quickly this happens, and some systems keep track of persistent foreground regions separately so they are not forgotten. Shadow modelling and stationary-object handling are different problems and should not be confused.
Related methods
Sources
Stauffer, C., & Grimson, W. E. L. (1999). Adaptive background mixture models for real-time tracking. IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 246–252.
Open DOI referenceKaewTraKulPong, P., & Bowden, R. (2002). An improved adaptive background mixture model for real-time tracking with shadow detection. Proceedings of the European Conference on Computer Vision (ECCV), 135–144.
Open publication reference