backgroundsubtractorcv

Applies a background subtractor and computes a foreground mask for image handle.

Syntax

R = backgroundsubtractorcv(handle...)

R = backgroundsubtractorcv(handle, type, rate)

Inputs

handle
Handle of an image or video frame.
Type: integer
type
Background subtractor type. Default value is 'MOG2'. Valid values are:
KNN
Uses K-nearest neighbors background subtraction algorithm.
MOG2
Uses Gaussian Mixture-based algorithm. This is the default option.
Type: integer
rate
Optional learning rate. Default value is -1, indicating that the algorithm will chose an automatic learning rate.
Type: scalar

Outputs

R
Handle of the 8-bit single channel output image.
Type: integer

Example

Apply the MOG2 background subtractor:

handle = imreadcv('image1.jpg');
mask = backgroundsubtractorcv(handle, 'MOG2', -1);