# How the reference image is updated in Dynamic subtraction

A video stream is composed of a number of video images (frames). During data acquisition, EthoVision XT analyzes one every x images according to the sample rate specified (see Video file and image quality). When analyzing the sample (image) n, the reference image is obtained by summing up the gray scale values of each pixel from two images:

▪The reference image made of pixels which have an average value of previous images.

▪The current image, where a square area around the subject detected in the previous sample has been removed. This provides a rough estimate of the current background.

The gray scale values are summed up according to the formula:

Referencei,n = (1-a) * Referencei,n-1 + a * Currenti,n

for each pixel I, where:

▪Referencei,n = Gray scale value of pixel I in the reference image of sample n.

▪Referencei,n-1 = Gray scale value of pixel I in the reference image of sample n–1.

▪Currenti,n = Gray scale value of pixel I in sample n where a square area around the subject previously detected has been removed.

▪a = Current Frame weight.

The Current Frame weight determines the relative weight of the two components of the new reference image.

Because the above formula is recursive, that is, each value of Referencei,n is also a function of the previous sample, the value of a determines the number of past images that contribute to the reference image for the sample n. The lower a, the more past images contribute at least partially to the current reference image.

The extent to which each past image contributes to the current reference image is a power function of 1-a. The older an image relative to the current one, the smaller its contribution to the reference image.

example If a=20%, then 1-a =80%. The first video image contributes by 80% to the second sample, by 80%2 =64% to the third sample, then by 80%3 =51% to the fourth sample, etc. At the 21th sample, the contribution by the first image gets below 1%.

Below: In the Dynamic subtraction detection method, the reference image is updated at each sample. The starting reference image is the one you specify by clicking one of the buttons in the Reference Image window, otherwise it is the first frame analyzed (not shown in the picture). For the general sample n, the reference image is obtained by summing the reference image of the previous sample n–1 and the current image n where the area around the subject estimated from the previous sample has been removed. The current image with subject removed is given the weight a that you specify (see the procedure), while the previous reference image is given the weight (1-a). Because of the way it is determined, each reference contains information on a number of past images, depending on the value of a.