Background subtraction involves calculating a reference image,
subtracting each new frame from this image and thresholding the result which results is a binary segmentation of the image which highlights regions of non-stationary objects .
We then use erosion and dilation to enhance the changes to make it more prominant.