GTag Logo

bsubtract

Contents:


Introduction

bsubtract is a program that performs background subtraction on a video image. It does this by averaging a large number of video frames to get a "background" for the current frame. This background frame is then subtracted from the current frame to get a difference frame. The difference frame is then output to resulting avi.

Return to top

Compiling

bsubtract is copiled by running gnu make.

Return to top

Running

To run bsubtract, go to the directory where the executable resides, and run ./bsubtract.
This will result in the following printed on the terminal:

./bsubtract Usage:
	./bsubtract <input_avi> [OPTIONS]
	where <input_avi> is a DV file to process

OPTIONS:
	-rl	// Performs a reverse linear Averaging method
	-c	// Performs a constant Averaging method
	-l	// Performs a linear Averaging method (default)
	-s <num>	// Output starts at frame <num>
	-e <num>	// Output ends at frame <num>
	-f <num>	// Average over <num> frames (default 50)
	-cb	// Absolute Difference is added from black
	-cw	// Absolute Difference is subtracted from white (default)
	-cg	// Difference is added to grey
	-y	// Use only Y values in the YUV color space for difference (default)
	-yuv	// Use the full YUV color space for difference
	-rgb	// Use the RGB color space for difference
	-diff <name>	// Name the diff output avi <name> (default diff.avi)
	-avg <name>	// Name the average output avi <name>
We can take a look at these options in more detail:

Required Arguments

Argument Name What it Means
<input_avi> AVI file to run processing on.

Note for required arguments: Any failure regarding the main arguments will cause the program to abort execution.

Return to top

Optional Arguments

Argument Name What it Means
-rl Averaging Method: Reverse Linear: This method averages the frames, with the most emphasis placed on the frames farthest from the current frame. Emphasis is distributed according to a linear function.
This method has the best chance of isolating a moving subject from the background, yet it also has an unfortionate side effect of creating ghost like objects at both ends of the foreground objects travel.
-c Averaging Method: Constant: This method places an equal weight on all the frames to average over.
-l Averaging Method: Linear: This method places an emphasis on the frames closest to the current frame. Emphasis is distributed linearly.
This is probably the most common used method for background subtraction.
-s <num> The first frame of the output movie will come from frame <num> of the input movie.
-e <num> The last frame of the output movie will come from frame <num> of the input movie.
-f <num> The background will be calculated using the averaging method above, over <num> framess specifed here. Half of these frames will be before the current frame, half of the frames will come from after the current frame.
-cb When calculating the difference, take the absolute value of the difference between the current frame and the average frame, and add this difference to black.
-cw When calculating the difference, take the absolute value of the difference between the current frame and the average frame, and subtract this difference from white.
-cg When calculating the difference, take value of the difference, either positive or negative, and add it to a grey background.
-y When calculating the averages and differences, only look at the Y values of the YUV color space.
-yuv When calculating the averages and differences, use the YUV color space.
-rgb When calculating the averages and differences, use the RGB color space.
-diff <name> The name of the avi that will be output that shows the difference between the current frame and the background average.
-avg <name> The name of the avi that will

Note for optional arguments: Any failure regarding optional arguments will result in that argument being ignored.
Also Note: Failure to specify a parameter for optional arguments that require one (like the <num> or <name>) will cause undefined results.

Return to top

Notes on Using

Right now, bsubtract does not handle boundry conditions very well. A boundy condition exists when during the following durations:
From frame (zero) to the frame (number_of_frames_to_avg / 2), and from frame (last_frame_of_movie - number_of_frames_to_avg / 2) to the frame (last_frame_of_movie)
For example, if you had a movie that was 1000 frames long, and used an averaging window of 200 frames, then frames 0-100 and frames 900-1000 will be considered boundry conditions.
It is not advised to use any frame inside a boundry condition for calculations by later programs.

Return to top

Downloading

The files have been consolidated in a single package. Get GTrack version 1.0 here MD5: 9b17ce83dda6851fe1528d20a2554583

Return to top

Examples

Reverse Linear averaging on a black background


Constant averaging on a black background


Linear averaging on a black background


Linear averaging on a grey background


Linear averaging on a white background


Sample average frame (linear averaging)

Return to top

All content Copyright 2003 Borg Lab.
Vim: The Right Way