# Robust Background Subtraction via the Local Similarity Statistical Descriptor
## 3 Background Modeling
### Foreground Detection
In this paper, we set \(\#_{min}=2\) to get a reasonable trade-off between computational complexity and noise resistance. The pseudocode of foreground detection procedure is shown in Algorithm 1:  
```
1:current input pixel \(p^{t}(x,y)\)
2:the FG/BG label of \(p^{t}(x,y)\)
3:\(nMatches\) = 0, \(i\) = 0
4:while\(nMathes\)\(<\#_{min}\) && \(i<N\)
5:\(colorDist=dist(I^{t}(x,y),I_{i}(x,y))\)
6:if\(colorDist\geq R_{c}\)
7:goto failedMatch;
8:\(lssdDist=dist(LSSD^{t}(x,y),LSSD_{i}(x,y))\)
9:if\(lssdDist\geq R_{t}\)
10:goto failedMatch;
11:\(nMatches\)\(++\);
12:if\(nMatches\)\(<\#_{min}\)
13:\(p^{t}(x,y)\) is foreground;
14:else
15:\(p^{t}(x,y)\) is background;

### Background Model Update

Many background model update strategies have been summarized in [2]. Most of them use the first-in-first-out (FIFO) strategy to update their models. However, there is no evidence to show that this is optimal. In this paper, a conservative, stochastic update strategy is adopted. It contains two steps:

First, if the input pixel \(p^{t}(x,y)\) is classified as background, whether it will be used to update its background model \(\mathcal{B}(x,y)\) is determined by a random probability \(1/\phi\). We call \(\phi\) a time subsampling factor which controls the adaptation speed of the background model. A small value of \(\phi\) leads to high update probability and makes a rapid evolution background model, and vice-versa. If \(p^{t}(x,y)\) is determined to update its background model, a background sample feature \(F_{i}(x,y)\) randomly picked from its background model \(\mathcal{B}(x,y)\) will be replaced by \(F^{t}(x,y)\). Second, if the input pixel \(p^{t}(x,y)\) is classified as background, it also has the same probability \((1/\phi)\) of updating one of its neighborhood background models \(\mathcal{B}(\bar{x},\bar{y})\), where \((\bar{x},\bar{y})\) the position chosen randomly from its neighborhood \(\mathcal{N}(x,y)\). Then, a randomly selected background model sample in \(\mathcal{B}(\bar{x},\bar{y})\) will be replaced by \(F^{t}(x,y)\). The pseudocode of the update procedure is shown in Algorithm 2:
```
1:the FG/BG label of pixel \(p^{t}(x,y)\)
2:if\(p^{t}(x,y)\) is background
3:if\(rand()\) % \(\phi==0\)
4:update \(\mathcal{B}(x,y)\) with \(F^{t}(x,y)\);
5:if\(rand()\) % \(\phi==0\)
6:update \(\mathcal{B}(\bar{x},\bar{y})\) with \(F^{t}(x,y)\);
7:else
8:return;
```

**Algorithm 2**Background Model Update

In the first step, the background samples are replaced randomly instead of replacing the oldest one, guaranteeing a smooth, exponentially decaying lifespan for the background samples. This update strategy cancels the time window concept and new samples can be incorporated into the background model only if they are classified as background, thus prevent static foreground objects from being absorbed into the background model too fast. However, this conservative updating strategy may cause

Figure 7: Calculation of the number of matches between the input pixel and its background model. To find a match, both the color feature and LSSD texture feature must be successfully matched. a \"ghosting\" effect, which is the result of falsely classified pixel regions caused by the removal of scene objects, like static objects suddenly starting to move away. A popular method of dealing with this situation is through the \"detection support map [32]\" which saves the number of times that a pixel has been consecutively classified as foreground. If the value exceeds a given threshold, then the pixel is classified into the background model, however, this strategy will add parameters and increase the computational complexity. Fortunately, the second step in our model update procedure allows \"ghosting\" regions to be automatic absorbed into the background model as time goes by. As neighboring pixels share similar spatial distribution, according to the neighborhood diffusion update strategy, background models hidden by the removed object will be updated with neighboring pixel samples from time to time.