Oil seal surface defect detection using superpixel segmentation and circumferential difference

Surface defects affect the quality and safety of oil seals. It is a challenge to detect such defects in a vision system because of the unequal reflection property of oil seal surfaces and low contrast between the defect and the background. This article proposes a visual detection method (VDM) for oil seal surface defects and outlines two key issues of VDMs. First, we present a superpixel segmentation algorithm based on the significant gray level variation in the radial direction of an oil seal surface image. This image is then divided into several ring belts. Subsequently, considering the reflection inequality and low contrast, we propose a new circumferential background difference algorithm based on the small variation along the circumferential direction of the image. This algorithm eliminates the influence of the reflection inequality and improves the contrast distinction between the defects and the background. The experimental results verify the effectiveness of the proposed method with a recall and precision as high as 95.2% and 86.8%, respectively.


Introduction
An oil seal is a mechanical part used for sealing oils. It helps lubricate the output part of a component while keeping the transmission part isolated, as it prevents lubricating oil from seeping. Because an oil seal sealing station is made of rubber, defects, such as burrs, dents, crack, cut mark, and blemish, will occur given the restricted process conditions. Because of such defects, dust would enter the transmission parts and cause lubricating oil leakage. This will significantly reduce the sealing performance and reliability and affect the machinery performance and life expectancy. Therefore, the detection of oil seal surface defects is an important aspect of oil seal production. 1,2 Conventionally, oil seal defects are inspected by trained personnel who scour the production line for potential damages. However, manual inspection is slow, inefficient, and even dangerous. With the advancement in automation, the inspection meets serious challenges. Recently, many studies have been conducted on developing machine vision and image processing techniques to detect oil seal dimensions with some good results.
Jiang and Jiang 2 employed the control chart concept and pixel voting procedure to obtain a feature matrix for the inspected surface and analyzed the feature matrix for defects. However, the parameters were complicated and difficult to control, and the misinspection rate was 17.31%. Recently, Bharathi et al. 3 proposed a rubber oil seal defect detection method based on texture analysis. In this method, an oil seal image is divided into several subimages, and the textural features are extracted from the gray level co-occurrence matrix with different spatial relationships to detect defects in the oil seal. However, texturebased analysis alone is not sufficient to detect the defects. 3 Moreover, the gray level co-occurrence matrix is too complicated to ensure the detection speed and meet real-time requirements. Chen and Zhao 4 proposed a method for burrs detection for sealing rubber ring using window template. Hsieh et al. 5 developed a LabVIEW-based visual dimensional inspection system. Xu 6 applied machine vision to develop a measurement system for oil seals. Jiang and Zhang proposed an inspection algorithm for an oil seal spring based on Gaussian filtering to reduce human operations and ensure consistent product quality. 7 Zheng et al. studied machine vision for inner diameter of skeleton oil seal. 8 However, the methods mentioned above 5-8 mainly focus on dimensional inspection. Our group has done some research on the dimension 9,10 and detection of oil seal defects. 1,[11][12][13] Aiming at the geometric characteristics of lip edges and lip faces, we discussed the classification and recognition method using support vector machine and constructed a support vector machine classifier for detecting lip defects in oil seals. 1,12 Liu et al. used median filtering, image segmentation, and a canny operator to preprocess an image and employed mathematical morphology dilation 13 to highlight the defects in lip region. This method was effective in detecting bubble defects but is not known to detect crack, cut mark, and blemish in oil seals.
The surface defect is mainly induced in the inner and outer rings of an oil seal. The surface defects are due to degumming and material shortage as well as equipment failure in the production process. Although this type of defect is not observed in the sealing position and does not directly affect the sealing performance of an oil seal, the deformation or tear of the oil seal is due to this type of defect in the assembly process or during usage. Moreover, it significantly reduces the service life of oil seals. Hence, the detection of surface defects in oil seals is an important aspect of oil seal defect detection. Most studies have conducted visual inspection and processing for lip seals. However, there is little research on surface defects.
To overcome these problems, we propose a detection algorithm for oil seal surface defects based on superpixel segmentation and circumferential difference by analyzing the characteristics of an oil seal image. The simple linear iterative clustering (SLIC) algorithm is used to segment different detection regions. A distinct circumferential difference method is proposed to suppress the inhomogeneous illumination and variation in the surface reflection and enhance the desired defect regions. Thus, the defects can be easily detected with simple threshold binarization.
The novelties and contributions of our article are summarized as follows: The method to detect oil seal surface defects using superpixel segmentation and circumferential difference is proposed; The superpixel algorithm SLIC is used to segment different detection regions exactly on the base of priori dimensions; A circumferential difference method proposed to obtain differential image with two advantages of proportion to the light intensity and uniform background, a simple binary thresholding, can then easily segment the defects and then can remove the influence of light variation and uneven reflection; The proposed method has shown its effectiveness in the experimental setup and test data sets, as evident in the experimental results.
The remainder of this article is organized as follows. In the second section, a vision inspection system is presented, and the properties of an oil seal surface image are analyzed. The proposed algorithms are described in the third section. The experiment and evaluation results are given in the fourth section. Finally, the conclusions are drawn in the fifth section.

Analysis of oil seal defects and detection difficulties
In this study, the TC double-lip skeleton oil seal commonly used in transmission systems is taken as the research object. The typical defect characteristics and distribution position in the production are analyzed, and a visual inspection algorithm is designed to detect any defects on the surface of this oil seal. Figure 1 shows an actual image and the profile of the skeleton oil seal. Clearly, the oil seal surface contrast is low, and the gray value distribution is uneven.
Therefore, it is difficult to detect the defects. Oil seal defects can be classified as lip region defects and surface defects, as shown in Figure 2. The lip region defects, such as burrs and dents, mainly appear in the inner lip mouth, inner lip area, and outer lip edge area. Notably, the inner lip mouth is the sealing position of the oil seal. Burrs and dents in the lip region will cause oil seal leakage. The surface defects, such as crack, cut mark, and blemish in the outer and inner rim areas, will easily lead to tear and deformation in the process of oil package matching, resulting in sealing failure.
In a previous study, a method for detecting burrs and dents in the lip region of an oil seal was proposed with good results. 13 This article mainly discusses the extraction and detection methods for surface defects.
The main difficulties in detecting oil seal defects lie in the following aspects:

1) Inhomogeneous background and complex defects
Each region of the oil seal is a ring belt but is in different planes. As such, the different regions have different backgrounds. Moreover, the defect type is complex. This makes it impossible to extract all the defect features using just one method. Hence, it is necessary to detect the defects in each region separately. For this purpose, each region must be accurately divided to avoid mutual interference. Secondly, the gray value in each detection area is unevenly distributed because of reflection and surface oil pollution, which makes image segmentation difficult.

2) Low contrast between background and defect
Most oil seals are made of silica gel or fluorine glue. As the defect area and the defect-free area are black in color, the contrast is low. Because of the limited visual features, most object recognition methodologies that are based on sophisticated texture and shape features cannot be used in inspection systems.

Oil seal surface defect detection method
In this study, a superpixel region segmentation method based on SLIC is used to divide the oil seal into four regions: a lip region, an inner region, a groove region, and an outer region. Based on characteristics, such as the uneven distribution of the gray level along the radial direction and the uniform distribution of the same along the circumference, a background model of the oil seal ring belt is established. A differential image is then obtained by subtracting the background image from the original image. Finally, the differential image is binarized using an adaptive threshold value. Thus, any surface defect is detected. Figure 3 shows the flowchart of the detection method.

Multidetection region segmentation method based on superpixel segmentation
Because of the random gray-level distribution of the oil seal on the belt and the vibration due to the belt movement, the location of the oil seal and the extraction of the detection area are the main factors in the defect detection method. As shown in Figure 4, the oil seal is divided into a lip region with an inclined plane between r 1 and r 2 , an inner ring region in r 2 and r 3 , a groove region in r 3 and r 4 , and an outer ring region in r 4 and r 5 . Even under reasonable illumination, there is a certain gray level difference between   the detection areas. Fortunately, the oil seal of the same specification has nominal geometric parameters, and there is a nominal size relationship between the radii. Hence, the SLIC method can be used to segment each detection region, and the oil seal center location and detection area extraction can be completed by fitting the edge contour based on the geometric parameters of the oil seal.

Superpixel-based simple linear iterative clustering algorithm
Achanta et al. 14 proposed an SLIC algorithm based on color proximity and spatial distance relationship. Firstly, the color image is transformed into 5D vector [l, a, b, x, y] T in CIELAB color space and XY coordinate, the clustering procedure begins with an initialization step, where K initial cluster centers C K ¼ [l K , a K , b K , x K , y K ] T are sampled on a regular grid spaced S pixels apart. Then, the normalized distance based on color and spatial location features is as follows represents the color distance and d s ¼ ffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffiffi ffi ðx j À x i Þ 2 þ ðy j À y i Þ 2 q is space distance. N c and N s are normalization constants of color and space distance, respectively. N s is the maximum spatial distance within a cluster, defined as N s ¼ ffiffiffiffiffiffiffiffiffiffi N =K p . The maximum color distance N c varies with different pictures and clusters, so we take a fixed constant in the range [1,40].
After the initial clustering, the clustering center C Cj is updated iteratively according to the mean value of color and spatial features of all pixels in the corresponding clustering image block B Cj , that is where N j is the number of pixels in the image block B Cj . The algorithm iteratively clusters and updates until the termination conditions are met. Finally, the neighbor merging strategy is used to eliminate isolated small size superpixels, which ensures that the final results have good compactness.
The main advantages of SLIC are summarized as follows: (1) the generated superpixels are compact, and the neighborhood features are easy to express; (2) not only color image can be segmented but also gray image can be segmented; and (3) there are very few parameters to be set. By default, only one number of presegmented superpixels is needed. (4) Compared with other superpixel segmentation methods, SLIC is more ideal in terms of running speed, compactness of superpixel generation, and contour keeping.

Multidetection region extraction method based on superpixel segmentation and prior dimension information
In this study, the SLIC superpixel segmentation method is used to extract each detection region with the prior dimension information of the oil seal. Figure 5 shows the flowchart.
The superpixel number (k) is assumed 4. The oil seal image is divided into inner circle background region, inner circle and lip regions, outer and groove regions, and outer background region, as shown in Figure 6.
To reduce the computational complexity, the center and radius of a circle can be fitted based on the boundaries of one region obtained by cluster segmentation, and the radii of the other regions can be obtained from the prior geometric dimensions of the boundaries of each region.
The fitting contour is obtained by determining the roundness of each boundary contour. The roundness calculation method is as follows where perimeterðS i Þ is the circumference of the S i region point set and areaðS i Þ is the area of the region. The experimental results show that the outer boundary of the inner ring region has the highest roundness, and the boundary is the metal skeleton of the oil seal, which makes it difficult to deform. The contour of the boundary is complete, and it is not affected by surface defects. Therefore, the outer boundary of the inner ring belt is selected to fit the center and radius of the circle.
The commonly used methods for circle fitting include the centroid method, 15 Hough transform, 16 and least squares method. 17 In this study, the least squares method is used to fit the circle and find its center, as it is fast and accurate. 18 The fitted radius of the oil seal is R, that is, r 3 in Figure 4.
According to the preacquired image, the inner and outer diameters of each detection region are calibrated offline, and the ratio S i (¼ r i /r 3 ) of the radii of each region to the outer diameter of the inner ring band r 3 is obtained. The radii of each region in the actual image can be obtained by multiplying the ratio S i with the outer diameter of the inner region, that is, r i ¼ R*S i .

Image analysis of oil seal
Because of the structural characteristics of the oil seal, the image of the surface of the oil seal shows a uniform gray level in the circumferential direction and a significant variation in the gray level along the radial direction.
Uneven radial gray level: As shown in Figure 7(a), there are two lines across the oil seal in the horizontal and vertical directions. Figure 7(b) and (c) shows the gray-level profiles of the two lines. For a clearer observation, the corresponding curves of the outer circle region are magnified, as shown in Figure 7(d). Notably, the gray level variations along the radial direction are significant, because the lines cross four different regions with different reflection properties. Therefore, it is impossible to segment the defect and the background with one or more fixed gray thresholds.
Circumferential gray uniformity: The three circles R, G, and B cross three different regions, as shown in Figure 7(a). Figure 7(e) shows the gray profiles of the three circles. The gray level along circle B in the inner circle  region is uniform, and the same is true for circle R, except in the defect region. The gray level along circle G slightly fluctuates because of the groove texture inside the oil seal. Overall, the gray level of the oil seal image along the circumferential direction is uniform.
Next, an effective oil seal surface defect detection method is proposed based on the properties of the oil seal image.

1) Background modeling
Based on the fact that the gray level of the oil seal image varies in a narrow range along the circumference, the mean gray level along each circumference is calculated and a background model is established where I m (r,q) is the image background model on the circumference of the radius r, I(r,q) is the pixel value with the radius r and mean (Á) is the mean function. The background image is modeled, as shown in Figure 8(b), by selecting the outer loop detection region, as shown in Figure 8(a).

2) Background differencing
The differential image is obtained by subtracting the background image from the original image of the oil seal as follows DI r; q ð Þ ¼ I 0 r; q ð ÞÀI m r; q ð Þ ð5Þ Figure 9(b) shows the differential image. The difference image has the following properties Property 1: the difference image has a linear relationship with light intensity.
According to Phong illumination model 19 and camera photoelectric conversion model, image pixel value can be expressed as follows 20 F r; q ð Þ ¼ a Á k r; q ð ÞI l r; q ð Þþa Á I m r; q ð Þþb ð6Þ where a and b are constants, which are determined by camera parameters. I l is the light source intensity and I m is the ambient light reflection intensity. k is the reflection coefficient of oil seal surface. It can be seen from equation (6) that the pixel value is determined by the light source intensity, ambient light, and oil seal surface reflection coefficient. For any image, I l and I m are fixed values. Therefore, equation (6) can be simplified as follows Then, the background image can be expressed as where r k is the mean value of reflection coefficient of circular image with radius r.
By introducing equations (7) and (8) into equation (5), it is concluded that It can be seen from equation (9) that the difference image has a linear relationship with the light intensity.
Property 2: the difference image has the property of zero mean EðDIðr; qÞÞ ¼ Eðbðkðr; qÞ À r k ÞÞ ¼ bðEðkðr; qÞÞ À r k Þ ¼ 0 Property 3: the difference image has uniform background Under the compensation of an annular light source, the reflectivity of the image on the same annular band is the same. When there is no defect, the variance of each ring in the differential image approaches zero. Therefore, the differential image has a uniform background, making it easy to separate the defect from the background. Figure 9(a) and (b) shows the original image and the corresponding differential image, respectively. Clearly, the original image is heterogeneous; in contrast, the differential image has a single background. Hence, the influence of reflection inequality is eliminated.
Moreover, Figure 9(c) shows the gray-level profiles (I a and I b ) of the two circles that cross a certain defect in the original image, and the corresponding profiles (I diffa and I diffb ) are of the two circles in the differential image at the same location. The same conclusions can be drawn from Figure 9(c) as well.

3) Threshold segmentation
As shown in Figure 9(c), the gray level is largely the same, except in the defect and fluctuating regions of the differential image. Therefore, the defects can be segmented using a single adaptive threshold, which is defined as follows where DI and d DI are the mean and standard deviation of the entire differential image, respectively, and C is a control constant. According to Chebyshev inequality, 21 in any data set, the proportion of the data with the average exceeding C times standard deviation is at most 1/C 2 . Therefore, C can be determined according to the proportion of defects in the image. Because the differential image has zero mean value property, that is, DI ¼ 0, the threshold is simplified as Substituting formula (9) into equation (11), we can get the following results It can be seen from equation (12) that there is a linear relationship between the threshold and the light intensity. Therefore, when the difference image is compared with the threshold size, B can be eliminated, that is, the defect threshold segmentation is independent of illumination. In the differential image, if DI(r, q) > th, it is considered that (r, q) is a nondefect point, and it is recorded as 0; otherwise, it is a defect point, marked as 1. The binary image can be represented as Figure 10 shows the binary image. It can be seen from the figure that the defect can be well segmented, but there is noise in the image.

4) Attribute-based filtering
From the result of the binary image, we can see that the defects can be detected using the adaptive threshold. However, the original regular texture of the outer ring of the oil seal is also detected with the gray level approximation of the defect. Fortunately, the texture features have invariance in terms of the length and area. Therefore, the defect area can be detected by open and close operation, connected region extraction, statistical pixel number of each region, and fitting length, if there are abnormal length and area, which is the defect area, as shown in Figure 11.

Experiment
In this study, the black skeleton oil seal with an inner diameter of 20 mm, an outer diameter of 30 mm, and a groove width of 7 mm was selected as the testing object to detect and analyze the surface defects in the outer ring belt. The visual inspection system for oil seal defect comprises a 1.4-megapixel CCD industrial camera (DH-SV411FC), a Computar telecentric lens (TEC-M55), and a circular surface light source, which are used to compensate for the illumination of the system. Figure 12 shows the experimental platform.
The real data of 100 oil seals with 120 surface defects from our own developed inspection system were used to evaluate the performance of the algorithms. Figure 13 Figure 11. Defect image.
shows the region segmentation and defect detection of the oil seal image collected by the platform. As shown in the second column of Figure 13, the zonal region is exactly segmented by the superpixel segmentation SLIC algorithm on the base of priori dimensions. The third column in the figure illustrates the zonal background differential image is evenly distributed, except in the defect parts, and the defect can be segmented using a single adaptive threshold, as shown in column 4 of Figure 13. Meanwhile, it also shows that it is not affected by illumination variation and uneven reflection. The experimental results verify the effectiveness of the algorithm. A quantitative analysis of the proposed algorithm is carried out with real images. Two indices, recall (R c ) and precision (P r ), are introduced as the most basic indicators in information retrieval, classification, and identification 22 Figure 13. Result images. Note: From left to right: (1) original images, (2) background images of the ring belt, (3) differential images of the ring belt, (4) binary images, and (5) defect images. R c ¼ TP=ðTP þ TNÞ where TP denotes the number of correct detection, FP is the number of false detection, and TN is the number of correct and undetected. The obtained average values of recall and precision are presented in Table 1.

Conclusions
In this article, an oil seal defect detection algorithm based on superpixel segmentation and circumferential difference is proposed by analyzing the characteristics of an oil seal surface image. Considering the significant variation in the radial direction of the oil seal surface image, an oil seal region segmentation algorithm based on SLIC was designed for detection region segmentation. Based on the fact that the variation in the oil seal surface image along the circumferential direction is small, a circumferential difference method based on the mean value was designed to detect the defects in the separated outer region. This method helped reduce the influence of reflection inequality due to the oil seal structure. Furthermore, to eliminate the unwanted noises, an attributebased filter was employed in the postprocessing stage.
The experimental results show that the proposed method could effectively complete the segmentation of each detection area of the oil seal and detect surface defects. The recall of the defects reached 95.2%, and the precision was approximately 86.8%.

Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.

Funding
The author(s) disclosed the receipt of following financial support for the research, authorship, and/or publication of this article: This work was supported by the National Natural Science