# Nonuniform Background Correction for Wide-Field Surveillance Camera
## 3 Enhanced New Top-Hat Transform  
The nonuniform background of the wide-field surveillance camera has a certain particularity. Considering the performance and complexity of the algorithm, scholars generally adopt the improved algorithm based on morphological filtering. In these algorithms, the background suppression effect and weak target retention degree have great limitations and dependence on the selection of structural elements [29]. In order to solve this problem and achieve accurate nonuniform background correction and effective target segmentation, we propose an enhanced new top-hat transform (ENTHT) correction algorithm based on mathematical morphology operation. Mathematical morphology operation is based on two basic operations: dilation operation and erosion operation, as shown in Equations (1) and (2). From dilation and erosion, the opening operation, the closing operation, and the top-hat transform in mathematical morphology operation can be obtained, respectively. \[f\oplus S=\max\{f(i-m,j-n)+S(m,n)\left|(i-m),(j-n)\in D_{f},(m,n)\in D_{S}\right.\} \tag{1}\]  
\[f\Theta\ S=\min\{f(i+m,j+n)-S(m,n)\left|(i+m),(j+n)\in D_{f},(m,n)\in D_{S}\right.\} \tag{2}\]  
where \(\oplus\) and \(\Theta\) represents the dilation and erosion, respectively, and \(S\) represents the structuring element (SE). \(D_{f}\) and \(D_{S}\) represent the domain of \(f\) and \(S\), respectively. SE is a matrix with only 1 s and 0 s of any size and shape. Dilation makes the image's gray value larger than that of the original image, which will also increase the size of the bright region. Erosion makes the image's gray value smaller than that of the original image, which will also decrease the size of the bright region. The operation and principle of the proposed ENTHT correction algorithm are described as follows. Firstly, we select two morphological, structural elements: \(L\) and \(\Delta L\), as shown in Figure 4. Then we use the structural element \(\Delta L\) to perform a dilation operation on the surveillance image to obtain the image \(F_{1}\), as shown in Equation (3). \[F_{1}=F\oplus\Delta L=\max\{F(i-m,j-n)+\Delta L(m,n)\,|(i-m),(j-n)\in D_{F},(m,n) \in D_{\Delta L}\,\} \tag{3}\]  
First, we choose the size of the structural element \(\Delta L\). The larger \(\Delta L_{ab}\) is, the stronger the background suppression will be, and the weak targets in the image will be weakened or even eliminated. In order to have a better detection ability for the wide-field surveillance camera, \(\Delta L_{ab}\) should be as small as possible. In this paper, we choose the value of parameter \(\Delta L_{ab}\) to be one pixel. The purpose of this step is to replace the target pixels with the pixels around the target and transfer the target energy to the structural elements, so the size of the structural elements should be larger than the target. The larger \(L_{a}\) is, the stronger the background suppression will be, and the weak targets in the image will be weakened or even eliminated. If \(L_{a}\) is too small, more noise will remain in the background. The target of our interest ranges within 20 \(\times\) 20 pixels. Reasonable structural elements can achieve the best suppression of the nonuniform background of the surveillance image. At the same time, the energy distribution of the target is not destroyed, i.e., no loss of weak targets and no energy loss of large targets. Therefore, \(L_{a}\) should be larger than 20 pixels. The larger the \(L_{a}\), the stronger the background suppression, but it will also weaken space targets. So we take the weak target with the size of 3 \(\times\) 3 pixels as a reference and adjust \(L_{a}\) appropriately to further suppress the background noise while ensuring that this target is retained intact. Finally, \(L_{a}\) is 29 pixels and \(L_{b}\) is 31 pixels. Then, we use the structural element \(L\) to perform an erosion operation on the image \(F_{1}\), as shown in Equation (4). The purpose of this step is to remove the structural elements containing the target energy.