# Selective Background Updating in Running Gaussian Average Method for Background Subtraction

I am studying the Running Gaussian Average Method for background subtraction. One alternative, as described in Wikipedia, also known as Selective Background Updating, is to only update the distribution of background pixels.

I have two questions on this topic:

(1) To determine whether a pixel is foreground or background, we need to calculate ${\mu}_t$ as follows: $${\mu}_t = M{\mu}_{t-1} + (1-M)(I_t{\rho}+(1-{\rho}){\mu}_{t-1})$$

But the $M$ in this formula depends on whether the pixel is foreground (in this case, $M=1$) or background (in this case, $M=0$). So it becomes a circular dependence. Currently I tried to solve this by calculating: $$(I_t{\rho}+(1-{\rho}){\mu}_{t-1})$$

Then after deciding the pixel is foreground or background, I determine $M$ and use the first formula to update the value of ${\mu}_t$. Is this correct?

(2) The Wikipedia page only suggests to update the mean of each background pixel using the first formula above. Shall we update the variance as well, like as follows? $${\sigma_t}^2 = M{\sigma^2_{t-1}} + (1-M)(d^2{\rho}+(1-{\rho}){\sigma^2_{t-1}})$$

1) You start with first frame of video. Gather several frames to calculate accumulators, denote everything like background - at first frame you do not know which is which. Yes, recalculate.

2) Yes we shall update variance.

Never used unmodifief version: remember to use illumination infependent color space. Think about taking running variance on your own.