## 3 Design of RoiSeg
### Automatic Training-Sample Generation
#### 3.3.2 ROI Central Point Based Sample Clustering  
We noticed that the background noise is often bound to a specific area. In adjacent frames, however, a moving target's coordinates are also similar. Regardless of the foreground or background, the same type of target has more similar color features R, G, and B. In this section, we cluster ROI central points with similar characteristics. A GMM is a function to estimate the probability density of the exact polymorphism. It has excellent performance in clustering and its general form is as follows:  
\[P(x_{i})=\sum_{j=1}^{k}\alpha_{j}G\left(x_{i},\mu_{j};\sum_{j}\right). \tag{2}\]  
\begin{table}
\begin{tabular}{c c c c c c c c c c c c c c c c c c c c c c} \hline \hline \multirow{2}{*}{**BMC**} & \multicolumn{3}{c}{**DPWine GABCS**} & \multicolumn{3}{c}{**Mixture Of Gaussian V1 BCS**} & \multicolumn{3}{c}{**MultiLayer BCS**} & \multicolumn{3}{c}{**Fixel Based Adaptive Segmenter**} & \multicolumn{3}{c}{**LBAdaptive SOM**} & \multicolumn{3}{c}{**Proposed RoiSeg**} \\ \cline{2-19}  & **P** &  
The weighted coefficient \(\alpha_{j}\) is satisfied as follows:  
\[\sum_{j=1}^{k}\alpha_{j}=1,0\leq\alpha_{j}\leq 1. \tag{3}\]  
The \(j\)-th component \((j=1,\ldots,k)\) is shown below:  
\[G\Bigg{(}x_{i};\mu_{j};\sum_{j}\Bigg{)}=\frac{\left|\sum_{j}\right|^{-\frac{1}{ 2}}}{(2\pi)^{\frac{4}{2}}}e^{-\frac{1}{2}\left(x_{j}-\mu_{j}\right)^{\prime} \sum_{j}^{-1}\left(x_{j}-\mu_{j}\right)}, \tag{4}\]  
where \(\mu_{j}\) and \(\sum_{j}\) represent the \(i^{-t_{1}}\) mean vector and covariance matrices, respectively. We choose \(z_{i}^{t}=\left(t_{i}^{t},g_{i}^{t},b_{i}^{t},x_{i}^{t},y_{i}^{t}\right)\) as \(x_{i}\), which is the input of the GMM. All ROI central points in the first 1 frames (here we set 1 = 5) are used as input samples for the GMM. For example, we use the 3-Component GMM, so the ROI central points are clustered into 3 similar clusters, red, blue and yellow sets, as shown in Figure 5. However, the number of components determines the clustering accuracy of GMM. We choose precision (\(P\)), recall (\(R\)), and F-Measure (\(F\)) for performance evaluation:  
\[\text{precision} =\frac{TP}{TP+FN},\text{ recall }=\frac{TP}{TP+FP}, \tag{5}\] \[F =\frac{2\times\text{precision}\times\text{recall}}{\text{precision }+\text{ recall}}. \tag{6}\]  
\(TP,FN\) and \(FP\) are the number of true positive, false negative, and false positive pixels, respectively. Figure 6 shows that \(F\) increases with the number of components increases. However, when this number reaches 6, the growth of F tends to be slow. Figure 7 shows that FPS drops with the increase of the number of components. The reasons are as follows: with the number of GMM components increasing, the data-fitting ability of the GMM is gradually enhanced, so the \(F\) value increases; meanwhile, the computation load is also increasing, which leads to the reduction of FPS; finally, the number of components increasing makes it easy for the GMM to over-fit the data. As such, we set the number of components to 6. Figure 6 demonstrated that F is between 0.87 and 0.91, which means that we can use the pooled ROI center point as the input of the GMM.  
Figure 5: The clustering result with the 3-Component GMM of the 7-th, 8-th, 9-th, 10-th frames in My_video1.