# A Background Subtraction Algorithm in Complex Environments Based on Category Entropy Analysis
## 3 Materials and Methods  
There are moving objects and background in the sequence of images captured by a fixed camera. Since most of the background does not move, the background color at the same position should be fixed. In practice, however, background colors are often obscured by moving objects that pass by,and therefore background extraction techniques are needed to obtain the background. As shown by previous research, background extraction techniques are based on the concept that the color with the highest occurrence frequency within an observation time window should be considered as the background. The main disadvantage of such methods is that in the presence of background masking, the background observation time is not dynamically changed. Therefore, when the observation time is too short, and the moving object obscures the background for a long time, the moving object will likely be mistaken for the background, causing misjudgment. On the other hand, if the observation time is set for too long, the system initial time will also be too long and the computation cost will increase. Conversely, background colors at the same position are sometimes not only composed of one color, such as the background colors of shaking trees, a flying flag, and other dynamic backgrounds or background shifts caused by camera shake. In order to make background extraction methods adapt to the dynamic background environment, some researchers have used multiple background models to identify real backgrounds [12; 13; 14]. However, determining the number of background models is also a problem. To address this problem, some researchers regarded all the colors with an occurrence frequency higher than a preset threshold as the background using the color change of input images [17; 18; 21]. However, this type of method tends to generate incorrect detection results because the established background colors contain the colors of moving objects that pass by. In order to solve these problems encountered in the initial background extraction process, this paper proposes an EBBE method, which--based on the analysis of the change in color category entropy--can automatically determine the background convergence time required for each pixel. Moreover, the method uses color category entropy to determine the number of background colors needed to obtain not only the correct background colors via the extension of convergence time in the scenario of moving objects frequently passing by, but also to automatically pick out a representative color category to detect moving objects. Figure 1 is a flowchart of the proposed method, with the implementation steps elaborated as follows. We first obtained the input image \(I\) by a camera and defined \(I_{R}^{x,y}\), \(I_{G}^{x,y}\), and \(I_{B}^{x,y}\) as the red, green, and blue color values, respectively, of \(I\) at the (\(x\),\(y\)) coordinate. In the beginning, when the background category was not yet acquired at position (\(x\),\(y\)), we used a color classifier to create the color category \(S\) as shown in Equation (1), where \(C_{(n)}^{x,y}\) represents the total number of samples in the \(n\)th color category located at the (\(x\),\(y\)) coordinate, while \(R_{(n)}^{x,y}\), \(G_{(n)}^{x,y}\), and \(B_{(n)}^{x,y}\) represent the red, green, and blue color values in the \(n\)th color category at the (\(x\),\(y\)) coordinate, respectively. \(N^{x,y}\) is the total number of color categories at the (\(x\),\(y\)) coordinate. \[\left\{ \begin{array}{l}S^{x,y}=\left\{S_{(n)}^{x,y}|n=1,2,\ldots,N^{x,y} \right\}\\ S_{(n)}^{x,y}=\left\{C_{(n)}^{x,y},R_{(n)}^{x,y},G_{(n)}^{x,y},B_{(n)}^{x,y} \right\}.\end{array} \right. \tag{1}\]  
When starting to process the first input image, we created the initial color category \(S_{(1)}^{x,y}\) at its corresponding position (\(x\),\(y\)), namely \(C_{(1)}^{x,y}=1\), \(R_{(1)}^{x,y}=I_{R}^{x,y}\), \(G_{(1)}^{x,y}=I_{G}^{x,y}\), and \(B_{(1)}^{x,y}=I_{B}^{x,y}\).