Using maximum variance of foreground classes as an estimator of the background variance