An alternative implementation of the background model presented above is to use the mean image over N
frames as the background image. This mean image captures gradual variations in the scene and thus provides greater resilience to background variations.
Additional complexity can be added by modeling the variation in the value of each pixel as a Gaussian distribution with a mean and variance. This adds further robustness to background subtraction.
The choice of threshold will also impact the number of foreground pixels detected. A low threshold will allow smaller changes to be qualified as foreground pixels. A high threshold will remove too many pixels, causing holes and gaps in foreground blobs. The effect of these thresholds is illustrated in Figure 4.
View full size
Figure 4: A low threshold results in extraneous "clutter" pixels, while a high threshold causes gaps and holes in foreground blobs.
Clutter removal and morphological filtering are applied to the resulting thresholded image to mitigate the effects of thresholding. Clutter refers to foreground pixels that are not associated with real objects. These may occur due to sensor noise, environmental effects such as moving foliage, rain or snow, or illumination variations due to clouds or indoor lights. Additional clutter may result from shadows, glare and reflections. Simple motion detection does not adequately remove clutter and will cause false detections.
A morphological filter can be used to fill in holes and gaps and, if desired, remove small blobs. The final step in segmentation is the unique labeling of each connected blob.
Blob labeling can be done by recursively visiting all foreground neighbors of a foreground pixel and labeling them until no unvisited neighbors are available. The result of blob labeling is then available for further analysis. Figure 5 shows foreground blobs after morphological filtering and labeling.
The net outcome of these processing steps is the detection of blobs corresponding to foreground objects and a region of interest, which is a bounding box around each blob that localizes it within the frame. Further processing need only be performed on the pixels in the region of interest (ROI) corresponding to each foreground blob.
View full size
Figure 5: Foreground blobs are morphologically filtered to fill holes and remove clutter. This is followed by blob labeling.