header image
 

BG Subtraction vs BG Subtraction+Frame differencing

Today I wanted to test if there might be some improvement in the detection / blob quality by adding the results of both algorithms: BG Subtraction AND Frame differencing.

The tests show that there is a significant improvement, specially in the cases where BG Subtraction is difficult due high similitude between the background and the foreground to be detected. In that cases, if the foreground shows some movement, the addition of the pixels detected byt the Frame Differencing algorithm allow a better blob detection.

This is the code of the BGS+FD algorithm in openFrameworks:


// Frame Differencing
grayDiff.absDiff(grayBackground, grayCurrentFrame);
// Background Subtraction
grayDiff2.absDiff(grayLastFrame, grayCurrentFrame);
// BGS + FD
grayDiff += grayDiff2;
// apply dilate to reduce pixel noise interference
grayDiff.dilate_3x3();
// apply the threshold
grayDiff.threshold(threshold);

Here are some screenshot videos comparing the results. On the left: BGS+FD, on the right: only BGS.

~ by David Sanz Kirbis on 18 January, 2011. Tagged: , , , ,

Comments are closed.