Intel® Integrated Performance Primitives (Intel® IPP) Developer Guide and Reference

ID 790148
Date 3/22/2024
Public
Document Table of Contents

Using ippiAdd for Background Differencing

This section describes functions that help build a statistical model of a background. This model can be used to subtract the background from an image.

Here, the term “background” stands for a set of motionless image pixels - that is, pixels that do not belong to any object, moving in front of the camera. The definition of background can vary if considered in other techniques of object extraction. For example, if the depth map of the scene can be obtained, for example, with the help of stereo, background can be determined as static parts of the scene that are located far enough from the camera.

The simplest background model assumes that every background pixel brightness varies independently, according to normal distribution. To calculate the characteristics of the background, several dozens of frames, as well as their squares, can be accumulated. That is, for every pixel location we find the sum of pixel values in this location S(x, y), using the function ippiAdd, and the sum of squares of the values Sq(x, y), using the function ippiAddSquare. Then mean is calculated as



where N is the number of collected frames, and standard deviation as



After that, the pixel in a certain pixel location within a certain frame is considered as belonging to a moving object, if the condition abs(p(x, y) - m(x, . y)) < C * stddev(x, y), where C is a constant, is met. If C is equal to 3, it satisfies the “three sigmas” rule. To obtain such background model, objects should be put away from the camera for a few seconds, so that the whole image from the camera represents the subsequent background observation.

Adapting the background differencing model to changes in lighting conditions and background scenes, for example, when the camera moves or an object passes behind the front object, can improve the described technique.

The mean brightness can be calculated through replacing the simple average with the running average found by using the function ippiAddWeighted. Also, several techniques can be used to identify moving scene parts and exclude them while accumulating background information. These techniques include change detection (see the functions ippiAbsDiff and ippiThreshold), optical flow, and some other operations.

Relevant addition functions used for background differencing include:

Add_8u32f_C1IR, Add_8s32f_C1IR, Add_32f_C1IR,

Add_8u32f_C1IMR, Add_8s32f_C1IMR, Add_32f_C1IMR (see Add),

and also all flavors of AddSquare, AddProduct, and AddWeighted.