## 3 Design of RoiSeg
### ROI-Central-Point Generation  
We use an imbalance degree \(\eta\) proposed in [35] to demonstrate the imbalance between the foreground and background, as shown in Table 1.  
\[\eta=\frac{\text{sum}(F)}{\text{sum}(B)}, \tag{1}\]  
where sum(\(F\)) and sum(\(B\)) are the sums of foreground and background pixels. We compute \(\eta\) on several subsets of the BMC database plus two self-captured sequences (\"My_video1\", \"My_video2\"). The result reveals that the foreground and background are relatively imbalanced. \(\infty\) means the number of foreground is far greater than the number of background.  
As shown in Figure 2, the moving targets often include the foreground and the background [13]. The frame difference is intended to compute the difference between the current frame and the previous frame in the video sequence and then segment the moving targets. Suppose we have obtained the foreground frame shown in Figure 2c. There is a significant change in the pixel value between the current and previous frames at the position of the moving target. The moving target in the current frame is copied to the corresponding position in the previous frame, and a new previous frame is obtained. The moving target will not appear again if the new previous frame is subtracted from the current frame, as shown in Figure 3.  
\begin{table}
\begin{tabular}{c c c c c c c c c c c c} \hline \hline
**Dataset** & **112** & **122** & **212** & **222** & **312** & **322** & **412** & **422** & **512** & **522** & **My_video1** & **My_video2** \\ \hline \(\eta\) & \(\infty\) & \(\infty\) & \(\infty\) & \(\infty\) & \(\infty\) & \(\infty\) & \(\infty\) & \(\infty\) & \(\infty\) & 0.0489 & 0.144 & 0.342 & 0.314 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Imbalance Degree of BMC Database And Self-captured Sequences.  
Figure 1: The framework of RoiSeg.  
Following this principle, suppose we have classified the foreground and background. The background of the current frame is copied to the corresponding position in the previous frame, and a new previous frame is obtained. Foreground detection is then done if the new previous frame is subtracted from the current frame, as shown in Figure 3. When the moving target is detected by the frame difference (shown in Figure 3b), the Canny algorithm is used to detect the contours of the moving target and then the bounding boxes of the contours are obtained (as shown in Figure 3c). We call the region of the bounding boxes the Region of Interest (ROI). Therefore, the classification of foreground and background can be regarded as the classification of the bounding boxes. Furthermore, we use the center of the bounding box (the ROI central point) to represent the bounding box so that foreground detection is transformed into an ROI-central-point-based classification problem.  
Figure 3: Copy all ROI in current frame to previous frame. (**a**,**d**,**g**) are current frame; (**b**,**e**) are previous frame; (**c**,**f**,**h**,**i**) are binary frame. (**a**–**c**) show the Process that copy all ROI in current frame to previous frame. (**d**–**f**) show the Process that selectively copy ROI of current frame to previous frame. (**g**–**i**) The moving target detected by the frame difference.  
Figure 2: Frame difference. (**a**) Current frame. (**b**) Previous frame. (**c**) Binary frame.