## 2 Theoretical Background and Proposed Method  
### Adaptive Threshold Segmentation  
The adaptive threshold segmentation algorithm is different from its traditional counterparts (e.g., OTSU algorithm [15]) which apply the same threshold to the entire image for segmentation. In contrast, the proposed algorithm applies a smoothing operator to the image, and then finds the difference between the original image and the smoothed one. Later, a fixed threshold is applied to the difference image, that is, how much the target object is brighter than the background, to achieve binarization. Suppose that _f_(_x,y_) represents the original hub X-ray image to be segmented, _g_(_x,y_) represents the image resulting from smoothing, and _B_(_x,y_) represents the final segmentation result. Let \(T\) be the specified fixed threshold. Then, the adaptive threshold segmentation algorithm can be expressed as:  
\[B(x,y)=[f(x,y)-g(x,y)]>T \tag{1}\]  
Equation (1) has an equivalent expression as follows:  
\[B(x,y)=f(x,y)>[g(x,y)+T] \tag{2}\]  
For the original image \(f(x,y)\), the actual threshold of each pixel (\(x,y\)) is the sum of the background gray value \(g\), obtained by applying the smoothing operator to that point, and the specified threshold \(T\), and so it varies with the background gray value \(g\) at that point. The gray value \(g\) on each pixel of the smoothed image \(g(x,y)\) is jointly determined by the gray level of the corresponding pixels of the original image \(f(x,y)\) and the peripheral pixels. Assuming that the smoothing operator is \(h(x,y)\), then \(g(x,y)\) is obtained from the following formula:  
\[g(x,y)=f(x,y)*h(x,y) \tag{3}\]  
The symbol \"*\" indicates a convolution operation in the digital signal processing. The smoothing operator \(h(x,y)\) appears in the form of a matrix, usually being the mean smoothing operators and Gaussian smoothing operators. Taking the mean smoothing operator as an example, the \(h(x,y)\) expression when the size \(r\) is 3 shall be  
\[h(x,y)=\frac{1}{3\times 3}\left[ \begin{array}{ccc}1&1&1\\ 1&1&1\\ 1&1&1\end{array} \right] \tag{4}\]  
Using the operator in Formula (4), the original image \(f(x,y)\) is operated according to Formula (3), and the gray value g of each point in the image \(g(x,y)\) that has been obtained is the average gray scale of a total of 9 pixels in a 3 \(\times\) 3 square area that takes that point as the center. Figure 1a shows a part of the gray value of the X-ray image of the hub, and the image \(g(x,y)\) obtained through 3 \(\times\) 3 mean smoothing is shown in Figure 1b. Assuming that the fixed threshold \(T\) is set to 5, the actual threshold value of each point in Figure 1a when it is processed by binarization based on Formula (2) is the gray value corresponding to that point in Figure 1b plus 5, that is, Figure 1c. Finally, the binarization result of Figure 1a is equivalent to selecting a target object whose gray scale is larger than the average background by 5 in 3 \(\times\) 3 local area, as shown in Figure 1d. Figure 2a shows a part of a hub X-ray image. There is an obvious shrinkage cavity in this part, but it is of a small proportion of the image. It is also noted that the background gray of the image varies widely. The image is segmented with the OTSU algorithm and the threshold is found to be 162, so each pixel with a gray value greater than 162 is taken as a pixel from a target object. Those with a value below 162 are taken as one from the background. The segmentation result is shown in Figure 2b. As can be seen, the target object, or the shrinkage cavity, has not been accurately extracted. The image obtained by smoothing Figure 2a with a 25 \(\times\) 25 mean filter is shown in Figure 2c, in which the gray value of each pixel is the mean of a 25 \(\times\) 25 square centered on this pixel in Figure 2a. From Equations (1) or (2), with the threshold \(T\) taken as 2, the resulting segmentation is as shown in Figure 2d.