Research on Double Edge Detection Method of Midsole Based on Improved Otsu Method

The midsole is an important part of the shoe, but in its industrial production, the surface quality of the midsole currently relies on manual testing. It cost high and cannot meet the needs of industrial online real-time detection. To realize online surface defect detection, extracting the double edges of the midsole resulting from its special structure becomes an indispensable pre-work. This paper proposes a two-step Otsu method (TT-Otsu) to extract double edges of products. This method adopts the improved Otsu method to process the midsole image in two steps. It respectively combines with the Weighted Object Variance method (WOV) and the Neighborhood Valley-Emphasis method (NVE) to calculate the optimal threshold. Then the image is segmented to extract the edges and the misclassification error (ME) is 0.0007. To ensure the accuracy of the edge detection, the neighborhood gradient extreme value discrimination method is used to realize the local self-checking and make appropriate adjustments to the deviated edge. The false positive rate (FPR) and the false negative rate (FNR) of TT-Otsu are approximately equal to 5%. This method can effectively and clearly extract the double edges of the midsole. The precision rate is 95.61%, the average running time is 1.8s. The experiment demonstrates that the proposed method in this paper has good detection performance and good applicability.


I. INTRODUCTION
The midsole is an important part of the shoe. Its material has undergone a dramatic change in the past 70 years. Expanded thermoplastic polyurethane (E-TPU) is a new type of environmentally friendly material, and its various products are emerging in the international market. The shoe midsole is one of the popular product operations. However, under the background of the current industrial society, there is no outstanding industrial detection method to realize automated production. At present, defect detection still relies on manual detection, which is not only costly but also inaccurate. It is difficult to control production quality depending on the competency of employees. To achieve the purpose of edge defect detection and surface defect detection, the accurate edge of the midsole must be extracted first. It not only plays The associate editor coordinating the review of this manuscript and approving it for publication was Essam A. Rashed . an important role in edge defect detection but also needs to divide front-surface, back-surface, and flank to avoid interference when the defect is detecting. The edge of the image contains important structural information and is considered as the first step of image analysis and pattern recognition. Because by edge detection, the size of image data can be reduced to a size more suitable for image analysis [1]- [3]. The execution of tasks after edge detection, such as image segmentation [4], [5], boundary detection [6], [7], defect classification [8]- [10], and image registration [11], [12], all depend on the edge information.
Edge detection is a basic problem in image processing and machine vision, and it plays a vital role in a preprocessing step [13]. Edges are defined as sudden changes in image pixels. They appear at the boundary between two different gray levels in the image. The edge defines the boundary of the object in the image, and the edge appears when there is a discontinuity in the pixel value. The realization of the VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ edge detection algorithm is a challenging task due to different lighting conditions, noise interference, and slow processing speed [14]. Since Marr and Hildreth proposed the edge detection theory in the 1970s, many scholars have proposed a variety of image edge methods. Those methods can be roughly divided into classical differential edge detection operators [15]- [19], multiscale edge detection methods [20]- [23], fuzzy enhanced edge detection methods [24]- [26]. Among them, the differential edge detection operator is a trade-off between the fine edge detected by the second-order operator with high noise sensitivity and the noise robustness of the first-order operator, at the cost of lacking fine details in the edge detection [27]. The Canny operator [19] of the second-order operator is an operator with optimization ideas. It can locate the sharp intensity changes in the image and detect the boundary of the object. Meanwhile, it has a large signal-to-noise ratio and high detection accuracy. Therefore, the Canny operator and its various improvements [28]- [30] are widely used in various scenarios.
In this paper, the image is segmented first then the edge is extracted. The reasons are that the midsole has a special shape, and the grayscale difference of each area are relatively obviousand the follow-up work needs to obtain the two edges clearly and accurately. However, the two edges are close to each other, so most operators can only detect one edge or several discontinuous edges.
After reviewing various methods for gray level image segmentation, Pal [31] state that image thresholding is a popular segmentation method because of its simplicity and ease of implementation. There are two types of thresholding methods, global thresholding and local thresholding. Generally, a local thresholding method better suits poor and unevenly illuminated images. However, a global thresholding approach is a more appropriate choice for images in which the object and background can be separated with an optimal threshold. Although there are many algorithms to select the segmentation threshold of global thresholding, automatic selection of a robust, optimum threshold remains an interesting and challenging task.
Otsu method is one of the most basic image segmentation algorithms and has been widely used in various image processing algorithm. To accurately segment the image, many scholars have proposed the improved based on Otsu method [32]- [38]. Hu et al. [32] limited the range of the image background ratio within the region of interest, thereby limiting the range of threshold selection, and achieved reliable results in the segmentation of human brain magnetic resonance and computer tomography images. Qiao et al. [33] used a weighted sum of the sum of variance within the class to discriminate the intensity contrast of the intensity contrast knowledge of exploring the segmentation of small objects. Ng [34] proposed an improved Otsu method, called the valley-emphasis method (VE), which uses the valley point information in the objective function. This method can successfully detect defects in some images but fails to detect images with very small defects. Fan and Bo [35] proposed an improved Neighborhood valley-emphasis method (NVE), which uses the neighborhood information of neighborhood valley to improve segmentation quality. After that, Yuan et al. [36] proposed a method called the weighted object variance (WOV). According to the low probability of the existence of defects in the image, the weight coefficient is used to adjust the desired threshold. In [37], similar methods are applied to crop detection, and the operation time is optimized by controlling the threshold retrieval range.
Zhao et al. [38] proposed a new evaluation index, named Gaussian Separate Degree (GSD), to evaluate the clustering results of spore images. Based on the index, they propose a simple and effective thresholding method, called G-Otsu, to automatically segment image, which can provide an optimal threshold for the data with unbalanced and diverse distributions.
Many researchers mentioned the processing of multilevel thresholds but did not do further research and analysis. However, although these studies have proposed valuable improvements, most of these methods are task-specific, so it is difficult to convert them into similar detection schemes for the midsole.
According to the special structure of the midsole, this paper proposes a two-step tri-level threshold Otsu method (TT-Otsu) to detect the midsole double edge. This method bases on the improved Otsu method which is used to conduct tri-level threshold processing on the image. It divides the midsole image into three parts and extracts double edges of the midsole. In order to prove the effectiveness of our method, we compare the segmentation accuracy of Otsu, VE, NVE, WOV, and TT-Otsu with the misclassification error (ME) index. Then, the edge accuracy is judged by the neighborhood gradient extreme value, and the deviated edge is finetuned. So, two accurate edges curve is obtained. To verify the detection effect by TT-Otsu, we use the false positive rate (FPR) and the false negative rate (FNR) indexes to compare the accuracy of edges which by Canny, CV model, Frei-Chen, and TT-Otsu respectively.
The rest of the paper is organized as follows. Section II describes the details of materials and methods. Experimental results and analysis are presented in Section III. The conclusions are shown in Section IV.

II. MATERIALS AND METHODS
In this section, we introduce the particularity of the E-TPU midsole shape in the first subsection and the inference process of the TT-Otsu in the second subsection.
A. E-TPU MIDSOLE E-TPU is a new type of thermoplastic polyurethane (TPU) foam material made by the physical foaming of thermoplastic polyurethane particles. The polymer material is formed by changing and compounding high resilience foam particles through the structure of TPU particles, and is composed of numerous elastics and light TPU foam particles. It is a nontoxic, biodegradable, and recyclable new environmentally friendly material. It has the advantages of low density, high resilience, wear resistance, corrosion resistance, and good low-temperature performance. It can be widely used in insoles, cushions, pads, solid tires, marine floats, packaging, and shipping.
In this paper, 11 sets of molds are selected from the molds of different shapes, and 57 white midsoles are used as samples. Among them, 34 samples are substandard products. Picture of the samples is captured and a total of 114 front and back pictures are useful in this research. By analysis, there are four characteristics compared with conventional products.
1) During frontal imaging, since the back-surface area of the midsole is larger than the front-surface, there will be two edges in the captured image. When imaging on the back, there will be double edges due to the flank shape, as shown in Fig. 1 (a) and (b).
2) In frontal imaging, the contour shape is higher than the surface whereas shadows are formed inside the surface under the influence of light. Its gray value is similar to that of the flank area, as shown in Fig. 1(c).
3) The height variation between the heel and the front end of the midsole is uneven, and the image has uneven illumination, as shown in Fig. 1(c). 4) There is a protruding shape on the midsole flank. The gray values of the flank are changed by the shooting position.
These characteristics have caused great troubles and caused great errors for subsequent surface defect detection and edge defect detection. It also causes the existing powerful detection operator to detect multiple edges that are disorderly or discontinuous. So, it is not suitable for the midsole.
In this research, the hardware environment is Intel(R) Core (TM) i5-6600K @ 3.50GHz * 4 CPU, 8GB of memory, and the development environment is MATLAB 2018b. The image acquisition equipment is two strip light sources and an industrial camera with a resolution of 1200 * 1600 (Fig. 2).
Although our test conditions are not those of an industrial environment, they are sufficiently similar to real-life scenarios as to provide the required evidence in favor of the TT-Otsu.

B. ALGORITHM
In this section, we first derive Otsu as the tri-level threshold, and then we combine NVE and WOV methods based on the tri-level threshold to put forward TT-Otsu.

1) EXPAND OTSU METHOD
A mathematical model is established according to the tri-level threshold of the Otsu method: The image can be described as f (x, y), the grayscale ranges from 0 to L−1, where L is the number of different gray levels. The probability of gray level k is defined as follows: The image is divided into D 0 , D 1 , and D 2 by thresholds T 1 and T 2 . D 0 is composed of grayscale values at [0, t 1 ], D 1 is composed of grayscale values at [t 1 + 1, t 2 ], and D 2 is composed of grayscale values at [t 2 + 1, L − 1]. Let ω 0 (t), ω 1 (t), and ω 2 (t) denote cumulative probability: µ 0 (t), µ 1 (t), and µ 2 (t) represent the average levels of D 0 , D 1 , and D 2 , respectively. The average gray values of these three classes can be calculated as: The global mean µ T of the image is: The between-class variance of D 0 , D 1 , and D 2 is as follows: Substituting (5) and (9) into Formula (10), we can get: The value of µ T is independent of the value of t 1 and t 2 , so (11) can be reduced to: Then the optimal threshold T 1 , T 2 can be determined as: It is segmented into binary images according to the optimal threshold: 2

) OPTIMIZE THE SELECTION OF THE OPTIMAL THRESHOLD
In [35], Fan and Bo simply put forward the formula of their method at multilevel threshold, but did not do further research, which is expressed as follows: In the experiment, it is found that when the NVE method is used to calculate two threshold values at the same time, the two threshold values will interfere with each other, so that neither of them can reach the optimal solution.
WOV [36] has a significant effect in image processing with large differences in the size of histogram crest, but Yuan et al. are not applied to multilevel threshold. According to their theory, we deduce the WOV applied to tri-level threshold. The formula is as follows: The WOV method is not suitable for calculating multiple thresholds simultaneously at the same time, because it has too many parameters, the selection of each parameter will affect the image segmentation effect, and there is no better method to automatically calculate the weight coefficient. This inspires that we can divide OTUS into two steps and thus propose our method, TT-Otsu.
For the E-TPU midsole, the background area is clear. The background and the entire midsole can be divided first. In the tri-level threshold calculation, t 1 and t 2 are unknown quantities. Firstly, the threshold t 2 is fixed, the optimal threshold T 1 is calculated according to (17). In (17), we combine with the WOV method, that the background item is weighted by a parameter θ from 0 to 1. It is used to segment the background and flank of the midsole image. Then the optimal threshold value T 1 is introduced into equations (2-6) and (9). Combination with the NVE method, the accurate optimal threshold value T 2 can be obtained by using (18). It is used to segment the flank and front-surface of the midsole image.
Step 1: Fix t 2 , let t 2 = T. Where T is the optimal threshold by the traditional Otsu method. Then the optimal threshold T 1 can be determined as: where θ = ω 0 , it uses the parameter selection of [36].
Step 2: Bring T 1 into (2)-(6) and (9), then the optimal threshold t 2 can be determined as follows: The neighborhood range is selected as 5 gray values, which are the optimal values obtained from experiments.
According to the characteristics of the global threshold, the T 1 and T 2 must be distributed on both sides of T, and locate at between the two peaks. Therefore, it is possible to limit the selection range of t 1 and t 2 . t 1 ∈ [peak 1 , T ], t 2 ∈ [T , peak 2 ], where peak1 and peak2 are two peaks of the histogram curve, as shown in Fig.3.

3) EDGE ACCURACY SELF-CHECK AND DEVIATED EDGE ADJUSTMENT
The Otsu method, which uses a bi-level threshold to segment the entire image, is a global threshold method, which may cause deviations in the local area. So this step is to check and adjust the deviated edge in the local area.
The gray values of the detected edge and its longitudinally adjacent 20 pixels are performed gradient calculation. When the inner edge and the outer edge have the same abscissa, if the ordinate interval is less than 20, we select the smaller value (as shown in Figure 4, the inner edge accuracy selfcheck). The outer edge verification is performed first because the gray value between the background and the target changes significantly, and it is not easy to produce secondary errors. Step 1: If the maximum gradient is less than or equal to 10, this edge point can be confirmed as the correct edge. That is Max(|Grad R |) ≤ 10, where R ∈ [−10, 10] is the calculation interval of the defined gradient.
Step 2: If the previous step is not satisfied, the maximum gradient point is located within 3 pixels adjacent to the edge point, this edge point can be confirmed as the correct edge. 3] is the fault tolerance range.
Step 3: If the previous step is not satisfied, there are more than 2/3 accurate edge points in 5 adjacent edge points, this edge point can be confirmed as the correct edge. That is num J ≥ 7, where J ∈ [−5, 5] is the judgment range of adjacent edge.
Step 4: If the previous step is not satisfied, we adjust the ordinate of this edge point to 2/3 of the deviation distance in the direction of the gradient extreme point.
Step 5: Return to the first step and recheck whether the adjustment meets the judgment conditions.
The above adjacent areas are all based on midsole size, camera resolution, and experience values.

4) TEST METHOD AND PROCESS
Thresholding is a segmentation technique widely used in industrial applications. It is used when there is a clear difference between the objects and the scene background. Therefore, the scene should be characterized by a uniform background, similarity between the objects to be segmented and homogeneous appearance of these. Otherwise, all the pixels that compose the scene could be assigned to a single class. In industrial applications usually the illumination and other scene properties can be easily controlled [39].
When processing the image, the TT-Otsu is used to calculate the optimal thresholds T 1 and T 2 , and the image is binarized to facilitate subsequent morphological operations. The holes in the binary image will be filled, and the burrs will be filtered out. Finally, all the edges of the binary image are extracted. The edge accuracy is tested according to the proposed method, and the deviation edge is adjusted and checked again. If the judgment condition is met, the output is the final edge (Fig. 5).
The algorithm in this paper uses automatic calculation as much as possible to reduce manual intervention. In the actual industrial production environment, the background will change with the replacement of the product when it is placed on the conveyor belt.

III. RESULTS AND ANALYSIS
In this section, we show the segmentation effect of Otsu, VE, NVE, and WOV of bi-level threshold on the midsole in subsection A. These images demonstrate the effectiveness of the threshold segmentation method on the midsole and support for our further research. In subsection B, the segmentation effect of Otsu, VE, NVE, and WOV methods of tri-level threshold are analyzed in detail, which indicates that these methods still need further improvement. In subsection C, the experiments result and analysis of TT-Otsu are described.
In section D, we compare the effect of TT-Otsu with other edge detection methods in double edge extraction.
A. BI-LEVEL THRESHOLD SEGMENTATION EFFECT Figure 6 shows the segmentation effect of Otsu, VE, NVE, and WOV of bi-level threshold on midsole. We select different values of parameters for NVE and WOA. VOLUME 8, 2020 Fig. 6(a) shows the original image of the midsole. Fig. 6(b) shows the segmentation effect of the traditional Otsu method. From the histogram (Fig. 3), it can be seen that the optimal threshold T by the Otsu method lies in the gray value distribution range of the midsole flank. When the image is binarized, the flank area will divide the mess. Fig. 6(c) shows the segmentation effect by the VE method, and the flank area is also segmented disorderly. Fig. 6 (d1-d5) shows the segmentation effect by the NVE method, where L is the neighborhood range. The values of L are 5, 10, 15, 20, 25, and the segmentation effect is best when the value is 15. Too small or too large will affect the segmentation effect. Fig. 6 (e1-e4) shows the segmentation effect by the WOV method, where θ i is the weighting coefficient. In Fig. 6 (e1), the parameters θ i = ω 0 . In Fig. 6 (e2-e4) the values of θ i are respectively 0.8, 0.5, and 0.1. It can be seen that the smaller the coefficient, the better the surface segmentation effect of the midsole.
In the case of a single target for VE, it is believed that the ideal threshold should be located at the valley of the bimodal histogram, and the probability of h(t) appearing at the threshold t should be small. The VE method is invalid when the object accounts for a small proportion of the entire scene. The NVE method combines the neighborhood information at the valley point to improve the segmentation quality. To ensure that the best threshold is always at a small probability value while the sum of neighborhood probabilities is small. The WOV method believes that when the histogram is close to a unimodal distribution, the contribution of the target variance to the between-class variance is small, and the threshold is mainly determined by the background variance. So, the parameter θ i , which is set to be less than 1, is weighted background variance item to ensure the segmentation effect.
It can be seen from the above figure that the Otsu method and its improvements are effective for the midsole. Especially, when targeting the surface of the midsole, NVE and WOV can achieve better results by selecting appropriate parameters. However, when facing the entire midsole, the bi-level threshold Otsu defines the midsole flank as the background, filtering out important information in the image.

B. TRI-LEVEL THRESHOLD SEGMENTATION EFFECT
When bi-level threshold segmentation cannot achieve the goal, but it is effective, we try to extend the Otsu method and its improved algorithm to a multi-level threshold algorithm.
In recent years, few people have specifically studied the multilevel threshold algorithm. In this paper, the Otsu, VE, NVE, and WOV algorithms are extended to the tri-level threshold algorithm, and named Otsu3, VE3, NVE3, and WOV3. The formula for selecting the optimal threshold of Otsu3 is (13), The optimal threshold of NVE3 is (15)The optimal threshold of WOV3 is (16)and the optimal threshold of VE3 is selected as: where h 1 (t) = p(t 1 ), h 2 (t) = p(t 2 ).  To visually display regional features, this paper is divided as follows: Fig. 7 shows the segmentation effect of Otsu3, VE3, NVE3, WOV3 by the tri-level threshold. Fig. 7(a) shows the original image of the midsole. Fig. 7(b) is the segmentation result of Otsu3. It can be observed that the segmentation effect between the background and the midsole flank is better, and there are obvious segmentation errors between the front-surface and flank. Fig. 7(c) shows the result of VE3 segmentation. The segmentation between the front-surface and the flank of the midsole has been optimized to some extent, and there are also obvious segmentation errors at the front end of the midsole. Compared with Otsu3, it has been improved. Fig. 7(d1-d4) is the segmentation result of NVE3, and L is the selected neighborhood range. The values of L are respectively 5, 10, 15, 20. When L = 15, the segmentation effect is the best. When it is smaller, part of the front-surface is divided into the flank. So there are some burrs on the flank. When it is larger, the midsole flank appears holes. Fig. 7(e1-e7) shows the segmentation results of WOV3. [36] does not extend the WOV method into multilevel threshold algorithm, so the weight coefficient is only added to the background area item to divide the smaller part. In this paper, after expanding it into tri-level threshold algorithm, the three items are weighted separately, as shown in (21). Fig. 7 (e1) is based on the original theoretical experiment. It can be seen that the segmentation effect is not ideal. Any weighting for a larger area will easily cause the segmentation effect to deteriorate, as shown in Fig. 7(e2-e4). However, adding a weight less than 1 to the flank area can get a better segmentation effect, as shown in Fig. 7(e5-e8). The weight coefficients θ 1 are 0.8, 0.5, 0.3, and 0.1 respectively. It can be seen that 0.3 is the segmentation effect the best. As the weight coefficient decreases, holes will appear on the midsole flank and the area gradually will increase. When the weight coefficient is large, the segmentation is poor at the front end of the midsole. Figure 7(f) shows the results of TT-Otsu.

2) QUANTITATIVE EVALUATION OF SEGMENTATION ACCURACY
Misclassification error (ME) measure [40] is adopted for the quantitative evaluation of the segmentation accuracy. The ME measure is widely used for the performance evaluation of image thresholding segmentation. The ME measure reflects the percentage of background pixels wrongly classified into object, and conversely, object pixels wrongly assigned to background. For a two-class segmentation problem, the ME measure can be simply expressed as: where B gt and O gt represent the background and object of the ground-truth image, respectively; B t and O t denote the background and object in the segmented image by threshold t, and | · | denotes the cardinality of a set. The ME varies from 0 for a perfectly thresholded image to 1 for a totally wrongly thresholded image. For a three-class segmentation problem, the ME measure can be expressed as: (24) where F gt represent the flank of the ground-truth image, and F t denote the flank in the segmented image. Table 1 records ME of Otsu3, VE3, NVE3, WOV3, and TT-Otsu on midsole front-surface.
It can be seen from Fig. 7 and Table 1 that various methods have good effect on the front-surface of the midsole, especially NVE3 (L = 5) and WOV3 (θ 1 = 0.3). But on the back-surface of the midsole, the flank area is narrower, and using the same parameters can cause segmentation errors. Analyzing (16), the weight h 1 (t), h 2 (t) of the between-class variance are interfered with each other, so the two thresholds cannot reach the optimal value, as shown in Fig. 8(b). The coefficient of WOV3 needs to be re-adjusted. The weight coefficients used for different products are different, and there is no adaptive method to calculate the weighting coefficient, as shown in Fig. 8(c). Therefore, this paper combines NVE   and WOV as the detection method. The result of TT-Otsu is shown in Fig. 8(d). Table 2 records ME of NVE3 (L = 5), WOV3 (θ 1 = 0.3), and TT-Otsu on the midsole back-surface. It can be seen that the TT-Otsu with the same parameters has a better effect on the front-surface and back-surface of the midsole. But accuracy still needs to improve.

C. ANALYSIS OF TT-OTSU
Through the above experiment, we prove the necessity and effectiveness of TT-Otsu in the midsole. In the first subsection of this section, we analyzed in detail the influence of different parameters for image segmentation. The second subsection analyzes the effect of edge adjustment.     Table 3 records the calculated optimal threshold T 1 , T 2 and ME when the values of θ are different. We can see that T 2 is independent of the transformation of θ. When θ = ω 0 and θ = 0.6, both ME can be minimized and the segmentation effect is the best.  Table 3 records the calculated optimal threshold T 1 , T 2 and ME when the values of L are different. We can see that T 1 is independent of the transformation of L. When L = 5, ME is the smallest, and the best segmentation effect can be obtained. c: FEASIBILITY ANALYSIS Fig. 9, Fig. 10, and Fig. 11(b) show the segmentation results of the TT-Otsu. The segmentation effect is better, but there are small holes and burrs in the flank area. This is because the contour shape of the inner edge is higher than the frontsurface. So a circle of shadows is formed on the front-surface during image acquisition. That causes the gray value of the surface part near the inner edge is similar to the gray value of the flank. The image segmentation by the global threshold method will form holes and burrs in these areas. Fig. 11(c) and (d) respectively depict the variation trend of the maximum between-class variance with the change of t 1 and t 2 . The value range of the optimal threshold t 1 is 0 ≤ t 1 ≤ t 2 = T, and it can be observed that t 1 has a minimum value at the gray value of 10, which means that the gray level of the background area is mostly concentrated near 10. At the gray value of 48 the between-class variance is the largest, so the optimal threshold T 1 is equal to 48. After the calculation of t 1 is completed, the optimal threshold t 2 is selected in the range of T ≤ t 2 ≤ 255. In Fig. 11(d), it can be observed that t 2 has a minimum between-class variance at the gray value of 180. This is because the gray value of the midsole surface is concentrated around 180. When the gray value is equal to 121, the between-class variance reaches its maximum value, that is, the optimal threshold T 2 = 121. The inflection appears at 150, which is the overlap of the gray value distribution between the midsole flank and frontsurface. The performance on the binary figure is burrs and holes. Fig. 11(e) is the segmentation result after morphological processing. Firstly, the closed operation is used to fill the hole, and then the open operation is used to remove the burrs. The structure element of the morphological open operation is larger than the structural elements of the morphological close operation. Otherwise, the close operation will connect the burrs on the edge while filling the hole. When used the same structural element, the open operation cannot remove the burrs, it will cause rough edges, and there are a lot of errors. Fig. 11(f) is the edge extracted from Fig. 11(e). It can be seen that there are deviations on the edges. Fig. 11(g) is the comparison of the maximum betweenclass variance changing of the TT-Otsu and the traditional Otsu method. Fig. 11(h) is the midsole histogram, where T 1 and T 2 are the optimal thresholds, and T is the optimal threshold obtained by the traditional Otsu method. From the analysis in Fig. 11(g), it can be seen that whether the traditional Otsu method or the TT-Otsu, the between-class variance on the midsole flank tends to be flat. Comparing with the histogram of Fig. 11(h), it can be analyzed that the midsole flank occupies a small proportion in the entire image. This means that the between-class variance in the flank area changes very little, so the calculated optimal threshold will inevitably lead to poor segmentation. Morphological processing does not have the function of correction. So it is necessary to detect and correct the extracted edge from the segmented image.

2) SELF-CHECK AND ADJUSTMENT OF EDGES
According to the discriminant method in this paper, the purpose of detecting the edge accuracy is: 1) If the maximum gradient value of the neighborhood is less than 10, it means that the gray value change in this part of the area is smooth. The reason is that the TT-Otsu is a global threshold segmentation method, which will not be affected by local areas.
2) If the maximum gradient value of the neighborhood is located within 3 pixels of the edge point, that is an error within the allowable range. The reason is that the radius of the disk-shaped structuring element is 3 pixels during morphological processing. 3) If 2/3 of the adjacent edge points are accurate edges, it means that this point is isolated deviation points, which is probably formed to filter burr by morphological.
As shown in Fig. 12, Fig. 12(a) is the detected deviation edge by the TT-Otsu. Two places are detected. Fig. 12(b) and (c) are the enlarged images of the two deviated edges. It can be seen that the detected deviated edges are continuous. Fig. 12(d) and (e) are the image of the adjusted deviated edge according to the TT-Otsu, so that it is adjusted by 2/3 of the deviation distance according to the direction of the gradient extreme point. The excessive adjustment will cause break or breakpoint between the adjusted edge and the original edge. Fig. 12(f) is the deviated edge image detected after twice adjustment. As can be seen from Table 5 and Table 6, the results of the second adjustment have been good., that is, the final edge. We used the edge segmentation image obtained by the adjustment method to measure the segmentation accuracy, the ME as shown in Table 5.
We refer to the performance evaluation method of defect detection accuracy in [10], apply it to edge accuracy detection. redefine the parameters. But we need to redefine what the parameters mean. The false positive rate (FPR) and the false negative rate (FNR) are defined as follows: where TN is the number of true edge pixels, FN denotes the number of pixels that are falsely marked as edge, UP is the number of undetected edge pixels. Namely, FNR is defined as the proportion of pixels that are falsely detected as edge, and FNR is defined as the proportion of pixels that are undetected edge.
The FPR and FNR changes with the increase of adjustment times are shown in Table 6. It can be seen that, with the increase of adjustment times, FPR and FNR gradually become smaller. When it is reduced to a certain extent, it does not change and may fluctuate. FPR and FNR of TT-Otsu are very similar. That is, the error detection edge is equal to the missing detection edge, and the algorithm has strong antiinterference ability.

D. COMPARISON WITH THE EDGE EXTRACTION EFFECT
The basic idea of the Canny edge detection operator is: First a certain GAUSS filter is selected to smooth the image. Then non-maxima suppression technology is used to process the smoothed image to obtain the final edge image. The output of the Canny edge detection algorithm largely depends on the high and low thresholds in the hysteresis threshold stage. When the threshold is low, a lot of noise will be detected and the image will become messy. When the threshold is high, the real edges will be filtered out and the contour will become discontinuous. In this paper, we try to set the threshold to a lower value, but the broken edges still appeared, as shown in Fig. 13(b). Fig. 13(c) shows the edge detection results of active contours without edges (CV model) [41], which is a multiscale edge detection method. It can be seen that the CV model has great accuracy in the detection of single edge. Fig. 13(d) shows the edge detection results of the Frei-Chen filter [42]. Its detection effect is very similar to that of the Canny. The detected edge is discontinuous and there is a lot of noise.
FPR and FNR for the above methods are recorded in Table 7. The reason for the high FPR of the CV model is that it only detected one edge, while TN is the total number of two true edge pixels. FPR of Canny and Frei-Chen is very large, because these two kinds of algorithms have strong ability to detect details, leading to detect many error edges.
According to the data analysis, the TT-Otsu is suitable for the detection of midsole edge. Only FPR is less than 10%, we consider that the edge of sample can be accurately detected.

IV. CONCLUSION
This paper proposes a TT-Otsu method to detect the double edges of the E-TPU midsole, which can accurately detect the edges of the midsole and has good applicability. This research detects 114 sample images and can accurately identify 109 images, the precision rate is 95.61%. The average running time is 1.8s, in which the segmentation algorithm takes 0.02s and the local self-checking takes 1.72s.
In the calculation of the optimal threshold, we use the improved Otsu method, and combine with the NVE and WOV method, and control the range of independent variable selection. Faced with the problem of global threshold algorithm segmentation errors in local regions, the neighborhood gradient extreme arithmetic is used for edge self-checking and adjustment. The experimental results prove that the method is effective and the adjustment result is better.
However, the TT-Otsu method involves two parameters, which will have a greater impact on the actual test results. Their selection values are set artificially according to the environmental conditions, and there is no good automatic selection method. We will continue to discuss this problem in future studies.
In general, the TT-Otsu method can obtain clear and continuous double edges, which lays the foundation for the next step of edge defect detection and surface defect detection of midsoles.
RUIZHI LI received the B.E. degree in civil engineering from the Beijing University of Civil Engineering and Architecture, in 2018. He is currently pursuing the M.S. degree in operational research and cybernetics with the School of Science, Hubei Minzu University, China. His research interests include digital image processing and MATLAB programming. VOLUME 8, 2020 FANG TIAN received the B.S. degree in measurement and control technology and instrument, and the Ph.D. degree in mechatronic engineering from China Agricultural University, in 2013 and 2019, respectively. She is currently a Lecturer with the School of Advanced Materials and Mechatronic Engineering, Hubei Minzu University. Her research interests include image analysis and processing, nondestructive, and rapid detection of defects.
SHIQIANG CHEN received the B.S. degree in mathematics from Hubei Minzu University, in 1997, the M.S. degree in computer software and theory from Guizhou University, in 2005, and the Ph.D. degree in computer science and technology from Sichuan University, in 2017. He is currently a Professor with the School of Advanced Materials and Mechatronic Engineering, Hubei Minzu University. His research interests include software technology, network communication, image engineering, and the Internet of Things.