## 4 ES-MBD Binarization Method  
### Optimization of Sobel Operator with Local Gradient Enhancement  
The traditional Sobel operator binarization method uses horizontal and vertical directions for gradient operation [28; 29; 30]. As shown in Figure 11, due to the diverse angle of the X-ray image, the Sobel operator using only two directions tends to lose part of the gradient information of the image.  
The Sobel operator is added to four directions of a \(\pm 45^{\circ}\) diagonal line, as shown in Figure 12. The gradient features are calculated and fused, respectively. Compared with traditional methods, the gradient features of the image can be extracted more completely.  
Since the threshold is fixed in the binarization process, the parts with a weak local gradient in the image are filtered out by binarization, resulting in information loss. In order to solve this problem, the method of local gradient enhancement is adopted in this paper,  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Method** & **Advantage** & **Disadvantage** \\ \hline Gray binarization method & The implementation is simple and requires no additional hyperparameters & Object whose gray is smaller than background and larger than background cannot be detected simultaneously \\  & & The color parameter of the background needs to be known, and it is insensitive to areas similar to the background color \\  & & It is not sensitive to a large area of the same color, and information is often lost when the operator is used alone \\ \hline \hline \end{tabular}
\end{table}
Table 1: Advantages and disadvantages of different binarization methods.  
Figure 11: Vertical and transverse Sobel operator.  
Figure 12: The Sobel operator for 4 directions.  
and the gradient features are locally enhanced before binarization, as shown in Formula (8). For pixel point \(P\) in the local region, the gradient \(G_{P}\) after enhancement is  
\[G_{p}\ =\ \left\{\begin{aligned} & T+1,&& G_{p}^{0}> mean_{C}\\ & 0,&& G_{p}^{0}<mean_{C}\end{aligned}\right. \tag{8}\]  
where  
\(T\)--The binarized threshold, generally using the average value of the global gradient;  
\(G_{p}^{0}\)--The gradient of the pixels before the enhancement;  
\(mean_{C}\)--The average gradient of a local area.  
That is, if the gradient of a point is greater than the average gradient of the area, its gradient is enhanced to above the threshold. In this way, the loss of local information can be reduced, and a better detection effect can be obtained.  
Since the result obtained by the edge detection operator is smaller, smaller open operation structure elements need to be used to prevent the object from disappearing completely during the corrosion operation.  
For some items (such as cartons, backpacks), the imaging color under the X-ray security detector may be close to the background color, the use of background difference binarization method cannot better extract the complete target area. On the contrary, binarization method based on edge detection operator is more sensitive to the gradient changes in the image and can accurately detect the intersection of the edge and the background. For a large area of the image with the same color and less texture (such as a book, a knife, etc.), the edge detection operator cannot obtain better results.