bgsubstractor optimisation