create_bg_esti ( InitializeImage : : Syspar1, Syspar2, GainMode, Gain1, Gain2, AdaptMode, MinDiff, StatNum, ConfidenceC, TimeC : )

Generate and initialize a data set for the background estimation

create_bg_esti creates a new data set for the background estimation and initializes it with the appropriate parameters. The estimated background image is part of this data set. The newly created set automatically becomes the current set.

InitializeImage is used as an initial prediction for the background image. For a good prediction an image of the ovserved scene without moving objects should be passed in InitializeImage. That way the foreground adaptation rate can be held low. If there is no empty scene image available, a homogenous grey image can be used instead. In that case the adaptation rate for the foreground image must be raised, because initially most of the image will be detected as foreground. The intialization image has to be of type byte or real. When processing multi-channel images, data sets must be created for every channel. Size and region of InitializeImage determines size and region for all background estimations (run_bg_esti) that are performed with this data set.

Syspar1 and Syspar2 are the parameters of the kalman system matrix. The system matrix describes the system of the grey value changes according to kalman filter theory. The background estimator implements a different system for each pixel.

GainMode defines whether a fixed kalman gain should be used for the estimation or whether the gain should adapt itself depending on the difference between estimation and actual value. If GainMode is set to 'fixed', then Gain1 is used as kalman gain for pixels predicted as foreground and Gain2 as gain for pixels predicted as background. Gain1 should be smaller than Gain2, because adaptation of the foreground should be slower than adaptaion of the background. Both Gain1 and Gain2 should be smaller than 1.0.

If GainMode is set to 'frame', then tables for foreground and background estimation are computed containing kalman gains for all the 256 possible greyvalue changes. Gain1 and Gain2 then denote the number of frames necessary to adapt the difference between estimated value and actual value. So with a fixed time for adaptation (i.e. number of frames) the needed kalman gain grows with the greyvalue difference. Gain1 should therefore be larger than Gain2. Different gains for different greyvalue differences are useful if the background estimator is used for generating an 'empty' scene assuming that there are always moving objects in the observea area. In that case the adaptation time for foreground adaptaion (Gain1) must not be too big. Gain1 and Gain2 should be bigger than 1.0.

AdaptMode denotes, whether the foreground/background decision threshold applied to the greyvalue difference between estimation and actual value is fixed or whether it adapts itself depending on the greyvalue deviation of the background pixels.

If AdaptMode is set to 'off', the parameter MinDiff denotes a fixed threshold. The paramters StatNum, ConfidenceC and TimeC are meaningless in this case.

If AdaptMode is set to 'on', then MinDiff is interpreted as a base threshold. For each pixel an offset is added to this threshold depending on the statistical evaluation of the pixel value over time. StatNum holds the number of data sets (past frames) that are used for computing the greyvalue variance (FIR-Filter). ConfidenceC is used to determine the confidence interval.

The confidence interval determines the values of the background statistics if background pixels are hidden by a foreground object and thus are detected as foreground. According to the stutent t-distribution the confidence constant is 4.30 (3.25, 2.82, 2.26) for a confidence interval of 99,8\% (99,0\%, 98,0\%, 95,0\%). TimeC holds a time constant for the exp-function that raises the threshold in case of a foreground estimation of the pixel. That means, the threshold is raised in regions where movement is detected in the foreground. That way larger changes in illumination are tolerated if the background becomes visible again. The main reason for increasing this tolerance is the impossibility for a prediction of illumintaion changes while the background is hidden. Therefore no adaptation of the estimated background image is possible.


Attention

If GainMode was set to 'frame', the run-time can be extremly long for large values of Gain1 or Gain2, because the values for the table fo gains are determined by a simple binary search.


Parameters

InitializeImage (input_object)
image -> object : byte / real
initialization image

Syspar1 (input_control)
real -> real
1. system matrix parameter
Default value: 0.7
Suggested values: 0.65, 0.7, 0.75
Range of values: 0.05 <= Syspar1 <= 1.0
Recommended increment: 0.05

Syspar2 (input_control)
real -> real
2. system matrix parameter
Default value: 0.7
Suggested values: 0.65, 0.7, 0.75
Range of values: 0.05 <= Syspar2 <= 1.0
Recommended increment: 0.05

GainMode (input_control)
string -> string
gain type
Default value: 'fixed'
List of values: 'fixed', 'frame'

Gain1 (input_control)
real -> real
kalman gain / foreground adaptation time
Default value: 0.002
Suggested values: 10.0, 20.0, 50.0, 0.1, 0.05, 0.01, 0.005, 0.001
Restriction: 0.0 <= Gain1

Gain2 (input_control)
real -> real
kalman gain / background adaptation time
Default value: 0.02
Suggested values: 2.0, 4.0, 8.0, 0.5, 0.1, 0.05, 0.01
Restriction: 0.0 <= Gain2

AdaptMode (input_control)
string -> string
threshold adaptation
Default value: 'on'
List of values: 'on', 'off'

MinDiff (input_control)
real -> real
foreground/background threshold
Default value: 7.0
Suggested values: 3.0, 5.0, 7.0, 9.0, 11.0
Recommended increment: 0.2

StatNum (input_control)
integer -> integer
number of statistic data sets
Default value: 10
Suggested values: 5, 10, 20, 30
Range of values: 1 <= StatNum
Recommended increment: 5

ConfidenceC (input_control)
real -> real
confidence constant
Default value: 3.25
Suggested values: 4.30, 3.25, 2.82, 2.62
Recommended increment: 0.01
Restriction: 0.0 < ConfidenceC

TimeC (input_control)
real -> real
constant for decay time
Default value: 15.0
Suggested values: 10.0, 15.0, 20.0
Recommended increment: 5.0
Restriction: 0.0 < TimeC


Example
/* read Init-Image: */
read_image(:InitImage:'Init_Image':) >
/* initialize 1. BgEsti-Dataset with fixed gains and threshold adaption: */
create_bg_esti(InitImage::0.7,0.7,'fixed',0.002,0.02,'on',7.0,10,3.25,15.0:) >
/* initialize 2. BgEsti-Dataset with frame orientated gains and fixed threshold */
create_bg_esti(InitImage::0.7,0.7,'frame',30.0,4.0,'off',9.0,10,3.25,15.0:).

Result

create_bg_esti returns TRUE if all parameters are correct.


Possible Successors

run_bg_esti


See also

change_bg_esti_params, set_bg_esti, get_bg_esti, close_bg_esti



Copyright © 1996-1997 MVTec Software GmbH