background subtraction
**Background subtraction** is the **classical motion detection technique that models static scene appearance and flags pixels that deviate from that model as foreground activity** - it is a foundational method for surveillance, traffic analytics, and lightweight video understanding pipelines.
**What Is Background Subtraction?**
- **Definition**: Compute difference between current frame and estimated background model to isolate moving objects.
- **Core Equation**: Pixels with absolute difference above threshold are marked as foreground.
- **Model Update**: Background is updated gradually to adapt to illumination and long-term scene changes.
- **Output**: Binary or probabilistic foreground mask per frame.
**Why Background Subtraction Matters**
- **Computational Simplicity**: Runs efficiently on edge hardware with low latency.
- **Event Triggering**: Effective for motion alarms and region-of-interest activation.
- **Preprocessing Utility**: Provides candidate object regions for heavier detectors.
- **Interpretability**: Foreground masks are straightforward to inspect and debug.
- **Legacy Importance**: Still useful in constrained systems and low-compute deployments.
**Common Background Models**
**Running Average**:
- Smoothly updates background over time with exponential averaging.
- Good for slowly changing scenes.
**Adaptive Median**:
- Uses temporal median statistics per pixel.
- More robust to transient motion.
**Probabilistic Models**:
- Estimate per-pixel distributions for dynamic backgrounds.
- Better for challenging outdoor conditions.
**How It Works**
**Step 1**:
- Initialize background model and compute per-pixel difference from current frame.
**Step 2**:
- Threshold differences to create foreground mask, then refine with morphology and update background model.
Background subtraction is **a practical first-line motion isolation tool that transforms raw video into actionable activity masks with minimal compute** - it remains valuable whenever speed and interpretability are critical.