## 2 Materials and Methods
### Improved Optical Flow Estimation Method  
#### 2.2.1 Improved Optical Flow Estimation Energy Equation  
The optical flow field estimation results directly affect the accuracy of moving object detection and extraction. To enhance the algorithm's anti-interference of illumination variation and the robustness in the case of the rotation and warping of moving objects or background regions, the energy equation of optical flow estimation in this paper is  
Figure 1: The framework of the algorithm for detecting moving objects with advanced estimated optical flow robust feature threshold segmentation. (**a**) is the optical flow estimation patch, (**b**) is the moving object detection patch.  
designed to include two parts: data term \(E_{Data}\) and smoothing term \(E_{Smooth}\). The energy equation is expressed as follows: \(E=E_{Data}+\alpha E_{Smooth}\).  
The data term is designed to fuse image brightness conservation and first derivative gradient conservation:  
\[E_{Data}=\iint\limits_{\Omega}\Psi[\gamma_{1}(I(x+u,y+v,t+1)-I(x,y,t))^{2}+ \gamma_{2}(\
abla I(x+u,y+v,t+1)-\
abla I(x,y,t))^{2}]dxdy \tag{1}\]  
where \(\gamma_{1}\) and \(\gamma_{2}\) are the coefficients of the grey and gradient term [27], respectively, \(\Psi(\mathrm{X})=\sqrt{X^{2}+\xi^{2}}\), and \(\xi\) is the non-square penalty function [28]. \(\xi\) is just for the numerical reason and can be set to a fixed value to ensure the \(\Psi\) can always be a convex function in the minimization process. Due to the small positive constant \(\xi\), we set \(\xi=0.001\).  
The spatial gradient was defined as \(\
abla_{3}I=[I_{x}I_{y}I_{t}]^{T}\). The partial derivatives of the spatial gradient in the \(x\) and \(y\) directions are \(\
abla_{3}I_{x}=[I_{xx}I_{yy}I_{xt}]^{T}\) and \(\
abla_{3}I_{y}=[I_{xy}I_{yy}I_{yt}]^{T}\). \(\omega=[u\gamma]^{T}\) represents the optical flow vector based on the assumption of brightness constancy: \([(\
abla_{3}I_{x})^{T}+(\
abla_{3}I_{y})^{T}]\omega=0\). The data term can be expressed as follows:  
\[E_{Data}=\iint\limits_{\Omega}\Psi\{\omega^{T}[\gamma_{1}\
abla_{3}I(\
abla_{ 3}I)^{T}+\gamma_{2}(\
abla_{3}I_{x}(\
abla_{3}I_{x})^{T}+\
abla_{3}I_{y}( \
abla_{3}I_{y})^{T})]\omega\}dxdy \tag{2}\]  
The HS global optical flow method can determine the dense image optical flow field. However, because the data term of its energy equation is constructed based on the changes in brightness and gradient, the HS method has low robustness to image noise and dynamic texture such as shaking leaves, water, and fog. In contrast, the LK local optical flow estimation method exhibits higher anti-interference of those elements. Therefore, the local convolution kernel function \(K_{\rho}\) of the LK method data term was introduced [29]. \(K_{\rho}\) represents the Gaussian kernel function with a variance of \(\rho\) for improving the robustness of noise and dynamic texture. Therefore, the data term fuses the HS and LK optical flow energy equations as follows:  
\[E_{Data}=\iint\limits_{\Omega}\Psi\{\omega^{T}K_{\rho}*[\gamma_{1}\
abla_{3}I (\
abla_{3}I)^{T}+\gamma_{2}(\
abla_{3}I_{x}(\
abla_{3}I_{x})^{T}+\
abla_{3}I _{y}(\
abla_{3}I_{y})^{T})]\omega\}dxdy \tag{3}\]  
The smoothing term is designed as the edge-preserving strategy \(\mathrm{DF}-\beta\)(decreasing scalar function) [30]. The smoothing term is defined as follows:  
\[E_{Smooth}=\iint\limits_{\Omega}\Psi[(e^{-\lambda|\
abla I_{t}|}+\beta)(| \
abla u|^{2}+|\
abla v|^{2})]dxdy \tag{4}\]