{'fraction_non_alphanumeric': 0.02399559713813979, 'fraction_numerical': 0.008007705008255366, 'mean_word_length': 4.789549147682013, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Defect Detection of Aluminum Alloy Wheels in Radiography Images Using Adaptive Threshold and Morphological Reconstruction

In low-pressure casting, aluminum alloy wheels are prone to internal defects such as gas holes and shrinkage cavities, which call for X-ray inspection to ensure quality. Automatic defect segmentation of X-ray images is an important task in X-ray inspection of wheels. For this, a solution is proposed here that combines adaptive threshold segmentation algorithm and mathematical morphology reconstruction. First, the X-ray image of the wheel is smoothed, and then the smoothed image is subtracted from the original image, and the resulting difference image is binarized; the binary image resulting from the low threshold is taken as the marker image, and that from the high threshold is taken as mask image, and mathematical morphology reconstruction is performed on the two images, with the resulting image being the preliminary result of the wheel defect segmentation. Finally, with area and diameter parameters as the conditions, the preliminary segmentation result is analyzed, and the defect regions satisfying the conditions are taken as the ultimate result of the whole solution. Experiments proved the feasibility of the above solution, which is found capable of extracting different types of wheel defects satisfactorily.


Introduction
The aluminum alloy wheel is a main component and also a major load-bearing component of the car and its quality has an important effect on the overall performance of the car. At present, the mainstream production process of automobile hubs is low-pressure casting, in which the molten alloy liquid is poured into the ready mold. In the molding and cooling process, internal defects, like gas holes or shrinkage cavities or shrinkage porosity, occur if air does not escape in time or if the alloy liquid is not adequately replenished [1]. So, X-ray inspection equipment is required for flaw detection. A typical wheel X-ray inspection set includes a radiation source, a detector, a computer, a manipulator, and a protective lead-clad room. The radiation penetrates a certain part of the wheel and is picked up by the detector and then transmitted to the computer, where a corresponding X-ray image is generated. The manipulator moves the wheel so that every part of the wheel is exposed to the X-ray. The lead room is used to shield the X-ray radiation and protect the operators [2]. The X-ray image in the computer carries the internal defect information of the wheel. An important part of the X-ray inspection of the hub is to process and analyze the X-ray image.
Over the past two decades, a lot of literature appeared that dealt with defect segmentation and identification in wheel X-ray images. D. Merry and D. Filbert proposed a wheel defect detection technique based on video tracking [3]. It first used an edge detection operator to process the wheel image to get the preliminary detection result, and then, relying on area and mean gray, two quantities, to eliminate some pseudo-defects. Matching between and tracking of sequential images was performed on the remaining defects to produce the final detection result. In reference [4], X. Li et al. compared the second-order derivative and morphology operation, the row-by-row adaptive thresholding, and the two-dimensional (2-D) wavelet transform method. It was shown that only the 2-D wavelet transform was able to satisfactorily detect cracks, shrinkage cavities, and foreign inclusions, three defects mentioned in the paper [4]. Y. Tang et al. proposed a maximum fuzzy exponential entropy criterion based on bound histogram (MFEEC-BH) for extracting defects from wheel X-ray images, which made full use of the advantages of fuzzy set theory and bound histogram and was capable of fast and accurate separation of wheel defects from the background [5]. A. Osman et al., drawing on the Dempster-Shafer data fusion theory, used the measurement characteristics of the examined wheel as the information source to design an automatic defect-type recognition function by use of a manually classified database, which has improved the reliability of the wheel examination [6]. M. Carrasco, based on the fact that a physical hub defect is definable by geometries and is tracked in multiple images in an image sequence, designed a method that automatically detected the images of various parts of the hub from multiple viewpoints, which was able to detect true defects and pick out most pseudo-defects [7]. X. Zhao divided the detection of hub defects into two categories: direct detection and detection by model, and proposed to train the grayscale arranging pairs (GAP) feature on a series of images and then used the trained model to complete defect segmentation [8]. The Randomly Distributed Triangle (RDT) feature was extracted from the segmented defects, and a classifier called Sparse Representation-based Classification (SRC) was designed to classify the defects. This method enabled automatic recognition of weak and minor defects under low contrast and nonuniform illumination conditions [9]. Over recent years, with the advance of computer vision technology, some new methods have found their way into automatic detection of wheel hub defects. An example in point is the convolutional neural network technology used in deep learning [10].
Threshold segmentation, a classical image segmentation method, has the advantages of low computational cost and fast speed, and is widely used in the field of industrial X-ray examination [4,5,[11][12][13][14]. A wheel is complex in geometry, the gray scale of its X-ray image varies widely, and a defect only accounts for a small part of the whole image, therefore accurately extracting defects by the traditional threshold segmentation is quite difficult. Considering the fact that a hub defect has a brighter gray than the background in the neighborhood, this paper makes use of a technique called 'adaptive threshold segmentation' to carry out defect segmentation by specifying the margin by which the target object is brighter than the background. To avoid the interference of noise and hub geometry on defect extraction, the segmentation result is processed by reconstruction operation, a technique in mathematical morphology. After processing, the area and diameter in all regions are counted, and proper area and diameter value ranges are determined having regard to the physical facts of the defects. Thus, accurate defect segmentation can be achieved.

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: Equation (1) has an equivalent expression as follows: 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: 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 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 × 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 × 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 × 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 × 25 mean filter is shown in Figure 2c, in which the gray value of each pixel is the mean of a 25 × 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. It is clear that the adaptive threshold segmentation produces a much better result than the OTSU algorithm, because the defect in the image has been segmented with accuracy. The reason is that the adaptive threshold segmentation algorithm takes advantage of the fact that a target object is brighter among its local background. In regions without a target object, the gray scale changes in a graded manner, with the result that the original gray scale differs not much from the smoothed one (less than or equal to T), and is then regarded as the background. In contrast, a region with a target object changes drastically in gray value, with the result that the original gray differs significantly from the smoothed one (greater than T), and is then regarded as an object. The adaptive threshold segmentation algorithm focuses on local gray variation and is therefore more robust than fixed threshold segmentation algorithms when the target objects are smaller and the background gray is more complex, but undesirably, the noise points and the edges of light regions or dark regions in the image, which change drastically too in gray, are segmented out too. As shown in Figure 2d, some portions not related to defects are segmented out.  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 × 25 mean filter is shown in Figure 2c, in which the gray value of each pixel is the mean of a 25 × 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. It is clear that the adaptive threshold segmentation produces a much better result than the OTSU algorithm, because the defect in the image has been segmented with accuracy. The reason is that the adaptive threshold segmentation algorithm takes advantage of the fact that a target object is brighter among its local background. In regions without a target object, the gray scale changes in a graded manner, with the result that the original gray scale differs not much from the smoothed one (less than or equal to T), and is then regarded as the background. In contrast, a region with a target object changes drastically in gray value, with the result that the original gray differs significantly from the smoothed one (greater than T), and is then regarded as an object. The adaptive threshold segmentation algorithm focuses on local gray variation and is therefore more robust than fixed threshold segmentation algorithms when the target objects are smaller and the background gray is more complex, but undesirably, the noise points and the edges of light regions or dark regions in the image, which change drastically too in gray, are segmented out too. As shown in Figure 2d, some portions not related to defects are segmented out. The above analysis shows that the smoothing factor size and the threshold value are two determining factors in the adaptive threshold segmentation algorithm. Suitable operators for image smoothing are mean filtering, Gaussian filtering, or median filtering operators, the size of which is the size of the local area. This size determines the size of the objects that can be segmented. Too small a filter size is unable to give an accurate estimate of the local background brightness at the center of the object, resulting in segmentation failure. The larger the filter size, the better the filtered result will represent the local background, and the more likely the object is accurately segmented out. But too large a filter size will result in higher computational load, and adjacent objects, too, may have an undesirable effect on the filtering results. Experience suggests that when the filter is about the size of The above analysis shows that the smoothing factor size and the threshold value are two determining factors in the adaptive threshold segmentation algorithm. Suitable operators for image smoothing are mean filtering, Gaussian filtering, or median filtering operators, the size of which is the size of the local area. This size determines the size of the objects that can be segmented. Too small a filter size is unable to give an accurate estimate of the local background brightness at the center of the object, resulting in segmentation failure. The larger the filter size, the better the filtered result will represent the local background, and the more likely the object is accurately segmented out. But too large a filter size will result in higher computational load, and adjacent objects, too, may have an undesirable effect on the filtering results. Experience suggests that when the filter is about the size of the object to be recognized, an accurate estimation of the background gray level of the defect and an accurate segmentation of the defect can be obtained at once. The value of the threshold T varies with the object to be segmented. A larger threshold suppresses the noise better, but may lead to the loss of the edge pixels of the target object, resulting in incomplete segmentation. A smaller threshold ensures that the target object is completely segmented, but noise and light and dark edges may exert some influence. For Figure 2a, the segmentation results of a smaller and a larger filter size but with the T value maintained at 2 are shown in in Figure 3a,b, respectively, while the segmentation results of a smaller T value and a larger T value but with the filter size maintained unchanged are shown in in Figure 3c,d, respectively. Figure 3a shows the segmentation result when the filter for smoothing is set at 9 × 9, the smaller size. Too small a filter window leads to local background estimation inaccuracy, and compared with Figure 2d, the defect is not a whole one but consists of discrete pieces. Figure 3b shows the segmentation result when the filter size is increased to 51 × 51. Although the defect is segmented out as a whole compared with Figure 2d, too large a filtering window makes the hub geometry interfere with the defect area, such that the two come together, resulting in segmentation failure. Figure 3c shows the segmentation result when the threshold T is set to 0, and the noise interference and the effect of the light and dark edges are significantly stronger than in Figure 2d. Figure 3d shows the segmentation result when the threshold T becomes 20, and it can be seen that both noise and edge interference disappear, but the defect is just partially segmented out.
defect is segmented out as a whole compared with Figure 2d, too large a filtering window makes the hub geometry interfere with the defect area, such that the two come together, resulting in segmentation failure. Figure 3c shows the segmentation result when the threshold T is set to 0, and the noise interference and the effect of the light and dark edges are significantly stronger than in Figure 2d. Figure 3d shows the segmentation result when the threshold T becomes 20, and it can be seen that both noise and edge interference disappear, but the defect is just partially segmented out. It becomes clear now that too large or too small a smoothing window size or threshold value affects the final segmentation result. The two parameters, smoothing window size and threshold value, have to be determined intelligently to bring about perfect segmentation results. However, in practical applications, it is hard to achieve this goal, especially in defect detection of wheel X-ray images.

Morphological Reconstruction
Mathematical morphology originated from the geometric study of the permeability of porous media by French scholars in the 1960s. It was initially confined to the geometrical analysis of binary images, but slowly expanded to the field of grayscale and color images. Mathematically, it is based on set theory, integral geometry, and mesh algebra. It has gradually developed into a powerful image analysis technology, widely used in the field of industrial nondestructive testing [16,17]. Mathematical morphology detects images through a small set called structuring element, and its basic It becomes clear now that too large or too small a smoothing window size or threshold value affects the final segmentation result. The two parameters, smoothing window size and threshold value, have to be determined intelligently to bring about perfect segmentation results. However, in practical applications, it is hard to achieve this goal, especially in defect detection of wheel X-ray images.

Morphological Reconstruction
Mathematical morphology originated from the geometric study of the permeability of porous media by French scholars in the 1960s. It was initially confined to the geometrical analysis of binary images, but slowly expanded to the field of grayscale and color images. Mathematically, it is based on set theory, integral geometry, and mesh algebra. It has gradually developed into a powerful image analysis technology, widely used in the field of industrial nondestructive testing [16,17]. Mathematical morphology detects images through a small set called structuring element, and its basic operations include dilation and erosion. From this as the basis, other transformations are made through combinations. Reconstruction of mathematical morphology involves two images, one called a mask image and the other called a marker image, with the latter being smaller than or equal to its corresponding mask image. Reconstruction transformation is an iterative process in which the marker image is used to reconstruct the mask image. The operation process begins with dilating the marker image using 3 × 3 all one-square structuring elements, and the dilation result where f R (x,y) is the result of the reconstruction operation. Reconstruction operation attempts to restore the mask image f (x,y) using the marker image m(x,y), and the light regions on m(x,y) that have completely disappeared will not be restored in f R (x,y), but light regions partially shown in m(x,y) are fully recovered in f R (x,y). The result of reconstruction operation, with the image in Figure 3d as the marker image m(x,y) and the image in Figure 2d as the mask image f (x,y), is as shown in Figure 4. It can be seen that the defect region is completely recovered, and noise and edge interference is removed too, producing a perfect defect segmentation.
where fR(x,y) is the result of the reconstruction operation. Reconstruction operation attempts to restore the mask image f(x,y) using the marker image m(x,y), and the light regions on m(x,y) that have completely disappeared will not be restored in fR(x,y), but light regions partially shown in m(x,y) are fully recovered in fR(x,y). The result of reconstruction operation, with the image in Figure 3d as the marker image m(x,y) and the image in Figure 2d as the mask image f(x,y), is as shown in Figure 4. It can be seen that the defect region is completely recovered, and noise and edge interference is removed too, producing a perfect defect segmentation. If the high-threshold segmentation image is used to reconstruct the low-threshold segmentation image in the adaptive threshold segmentation algorithm, then the reconstruction result will completely recover the low-threshold segmentation regions tagged by the high-threshold segmentation, completely removing the low-threshold segmentation regions not tagged by the highthreshold segmentation. In other words, morphological reconstruction operation combines the advantages of high-threshold segmentation (low interference) and low-threshold segmentation (complete defects), and thus qualifies as a useful supplement to adaptive threshold segmentation algorithm and minimizes the difficulty of parameter setting for segmentation.

Procedures of the Proposed Method
Drawing on adaptive threshold segmentation algorithm and morphological reconstruction operation, the proposed hub defect segmentation solution consists of the following steps: 1. Choose a smoothing operator of a suitable size to smooth the wheel X-ray image to obtain a If the high-threshold segmentation image is used to reconstruct the low-threshold segmentation image in the adaptive threshold segmentation algorithm, then the reconstruction result will completely recover the low-threshold segmentation regions tagged by the high-threshold segmentation, completely removing the low-threshold segmentation regions not tagged by the high-threshold segmentation. In other words, morphological reconstruction operation combines the advantages of high-threshold segmentation (low interference) and low-threshold segmentation (complete defects), and thus qualifies as a useful supplement to adaptive threshold segmentation algorithm and minimizes the difficulty of parameter setting for segmentation.

Procedures of the Proposed Method
Drawing on adaptive threshold segmentation algorithm and morphological reconstruction operation, the proposed hub defect segmentation solution consists of the following steps: 1.
Choose a smoothing operator of a suitable size to smooth the wheel X-ray image to obtain a smoothed image.

2.
The smoothed image is subtracted from the original image to obtain a difference image.

3.
Choose a smaller threshold value for the difference image to perform binarization to obtain the first-time segmentation result, and the result is used as a mask image for morphological reconstruction.

4.
Choose a larger threshold value for the difference image to perform binarization to obtain the segmentation result, and the result is used as the marker image for morphological reconstruction.

5.
Perform morphological reconstruction using the marker image and the mask image to obtain the preliminary defect segmentation result. 6.
Perform preliminary analysis of the defect segmentation result having regard to the physical facts of the wheel defect, and this produces the final defect segmentation result.
Throughout the segmentation process, the parameters involved include the size of the smoothing operator and the threshold value for binarization, the determination of which has been discussed in Section 2.1. In step 3, the small threshold binarization produces whole defect regions, but pseudo-defects such as noise and structural interference are inevitable. In step 4, the large threshold binarization only produces partial region of defects, but most pseudo-defects are removed. The morphological reconstruction operation in step 5 restores complete defect regions obtained in step 3 but removes the pseudo-defects not tagged in step 4, to produce the preliminary segmentation result. For many wheel images, the geometry of the hub itself creates sharp edges in the X-ray image, and such edges cannot be removed by steps 3, 4, and 5, but their geometric features, such as area and diameter, are significantly larger than common defects. Step 6 includes further analysis of the preliminary result obtained in step 5 with a view to eliminating such pseudo-defects by studying the geometric features of the defect regions, and the product of this step is the final segmentation result.

Experiment Results
The data for this experiment came from a wheel defect on-line detection system which includes an X-ray detector as an image intensifier plus a CCD camera. The resolution of the camera is 768 × 576, and the power of the ray source is set to 170 kV and 2 mA. Figure 5a shows an X-ray image of a wheel acquired by this system, and Figure 2a shows a part of the image. Given the state-of-the-art wheel hub production, hub defects are generally small. A smoothing operator of size r about 5% of the long side of the acquired image will satisfy the detection purpose and, in this system, the size is about 39. The ray source by its voltage and current determines the gradation change of the X-ray image. For the combination of 170 kV and 2 mA, the small threshold T s in step 3 of the segmentation process should be set between 0 and 10, and the large threshold T b in step 4 should be between 10 and 20. The area s of the hub defect is defined as the number of pixels in the segmented region, and the diameter d is the maximum distance between any two points on the edge of the segmented region. According to the physical fact that a hub defect is typically small, the upper limit M s of the defect area is generally smaller than 10% of the total number of pixels in the image, and the upper limit M d of the diameter is generally less than 20% of the shorter side of the entire image. In the acquisition system in question, M s is 4424 and M d is 115. In step 6 of the division process, a region having an area smaller than M s and having a diameter smaller than M d is retained as the final defect region.
Appl. Sci. 2018, 8, x FOR PEER REVIEW 9 of 13 shown in Figure 5f, it can be seen that the defect is accurately segmented out while the interference is altogether removed.
(e) (f)  Figure 5a is smoothed using a mean smoothing operator with an r of 39. The segmentation result with the small threshold T s set to 1 is shown in Figure 5b, and the segmentation result with the large threshold T b set to 12 is shown in Figure 5c. The morphological reconstruction result is shown in Figure 5d. The reconstruction result includes the sought defect region along with pretty much interference. So, the result is to be analyzed having regard to the area and diameter, as described in step 6 of the segmentation process. Figure 5d is superimposed, in the format of a pseudo-color image, onto the original image Figure 5a, with its diameter displayed and each region numbered, and Figure 5e shows the result. Each defect region is studied for its area and diameter, and the data are shown in Table 1. As can be seen from Table 1, region 2, which meets the requirement that its area shall be smaller than M s and its diameter shall be smaller than M d , is the true defect region. Performing step 6 of the segmentation process to get the defect region, which is marked on the original image, as shown in Figure 5f, it can be seen that the defect is accurately segmented out while the interference is altogether removed. To verify the performance of the algorithm, testing was conducted on different hub images. Figure 6a is another hub X-ray image with defects, taken from the same acquisition system. Figure 6b shows the segmentation result obtained from the same parameters, that is, the size r of the mean smoothing operator is 39, the small threshold T s is 1, the large threshold T b is set to 12, the defect area is less than 4424, and its diameter is less than 115. It can be seen that the more obvious large defect is extracted with accuracy while the small one, which is less obvious and of a poor contrast, is also extracted.  To verify the performance of the algorithm, testing was conducted on different hub images. Figure 6a is another hub X-ray image with defects, taken from the same acquisition system. Figure  6b shows the segmentation result obtained from the same parameters, that is, the size r of the mean smoothing operator is 39, the small threshold Ts is 1, the large threshold Tb is set to 12, the defect area is less than 4424, and its diameter is less than 115. It can be seen that the more obvious large defect is extracted with accuracy while the small one, which is less obvious and of a poor contrast, is also extracted.  Figure 7a shows still another hub X-ray image with small defects. The defects were segmented using the same parameters as in Figure 6a. The initial segmentation result, produced by step 3, is shown in Figure 7b. As can be seen, the defect regions are not distinguishable from those created by the hub geometry, so subsequent steps are unable to extract the defects correctly. The smoothing operator was resized to have an r of 19, and the small threshold Ts was raised to 5, to have produced the initial segmentation result as shown in Figure 7c. As can be seen, the defects are extracted, distinguishable from interference. Continuing from Figure 7c, with the large threshold Tb, the area Ms, and the diameter Md unchanged, the remaining steps of the segmentation process were performed, to have produced the final defect segmentation result as shown in Figure 7d, in which the defects are marked on the original image. The defects are accurately segmented out.  Figure 7a shows still another hub X-ray image with small defects. The defects were segmented using the same parameters as in Figure 6a. The initial segmentation result, produced by step 3, is shown in Figure 7b. As can be seen, the defect regions are not distinguishable from those created by the hub geometry, so subsequent steps are unable to extract the defects correctly. The smoothing operator was resized to have an r of 19, and the small threshold T s was raised to 5, to have produced the initial segmentation result as shown in Figure 7c. As can be seen, the defects are extracted, distinguishable from interference. Continuing from Figure 7c, with the large threshold T b , the area M s , and the diameter M d unchanged, the remaining steps of the segmentation process were performed, to have produced the final defect segmentation result as shown in Figure 7d, in which the defects are marked on the original image. The defects are accurately segmented out.

Discussion
This paper proposes a technical solution that combines adaptive threshold segmentation algorithm and morphological reconstruction operation to extract the defects on wheel X-ray images. The innovation of the algorithm for dynamic threshold segmentation is that in case of defect segmentation, the algorithm focuses on the grayscale variation of the local area, and the size of local area and the grayscale variation can be directly determined by setting the parameters r and T, which is very suitable for the extraction of the hub defect. The morphological reconstruction operation restores the mask image by specifying the marking image. The operation feature is that the area existing in the marking image can be completely restored in the mask image, and the area not in the marking image will completely disappear in the mask image. Combining the algorithm for dynamic threshold segmentation with the morphological reconstruction operation is the max novelty in this paper. Taking the high-threshold segmentation result in the dynamic threshold segmentation algorithm as the marking image, and the low-threshold segmentation result as the mask image, the defect area marked by the high-threshold segmentation result after the reconstruction operation can be completely restored, and the interference area generated by the low-threshold segmentation result can be completely removed, and the accurate extraction of the hub defect is realized.
Parameters shall be set to match different types and sizes of defects. The choice of the smoothing operator size r and the small threshold Ts is critical, for it determines what defects will be finally segmented out. Parameters shall be such that the defects are all segmented out and separated from the interference at once. Improper parameters, examples of which are shown in Figures 3b and 7b, may lead to failure in defect extraction. Large threshold Tb, area Ms, and diameter Md are designed to

Discussion
This paper proposes a technical solution that combines adaptive threshold segmentation algorithm and morphological reconstruction operation to extract the defects on wheel X-ray images. The innovation of the algorithm for dynamic threshold segmentation is that in case of defect segmentation, the algorithm focuses on the grayscale variation of the local area, and the size of local area and the grayscale variation can be directly determined by setting the parameters r and T, which is very suitable for the extraction of the hub defect. The morphological reconstruction operation restores the mask image by specifying the marking image. The operation feature is that the area existing in the marking image can be completely restored in the mask image, and the area not in the marking image will completely disappear in the mask image. Combining the algorithm for dynamic threshold segmentation with the morphological reconstruction operation is the max novelty in this paper. Taking the high-threshold segmentation result in the dynamic threshold segmentation algorithm as the marking image, and the low-threshold segmentation result as the mask image, the defect area marked by the high-threshold segmentation result after the reconstruction operation can be completely restored, and the interference area generated by the low-threshold segmentation result can be completely removed, and the accurate extraction of the hub defect is realized.
Parameters shall be set to match different types and sizes of defects. The choice of the smoothing operator size r and the small threshold T s is critical, for it determines what defects will be finally segmented out. Parameters shall be such that the defects are all segmented out and separated from the interference at once. Improper parameters, examples of which are shown in Figures 3 and 7, may lead to failure in defect extraction. Large threshold T b , area M s , and diameter M d are designed to remove pseudo-defects. Parameter T b shall be such that maximum interference is discarded without ignoring the defects. Parameter M s and M d act to remove the interference that is generated by the hub geometry and is not removable by thresholding. The experiment results show that the proposed method is capable of accurate segmentation of wheel hub defects and in practical applications, it is important to make proper parameter settings.

Conflicts of Interest:
The authors declare no conflict of interest.