Effect of oil adhesion on the measurement of screw thread with machine vision

In the process of screw thread manufacturing, the cooling liquid or lubricating oil will adhere to the screw thread surface, which affects the vision measurement results of the screw thread parameters. To simulate the adhesion behavior of oil on the thread surface during the actual measurement, four different attachment states were set in this experiment. An image measuring instrument was used to collect the screw thread images of different adhesion states. Then, the distribution of the oil film on the screw thread surface was analyzed with computer image processing. The visual inspection method was used to obtain the relative influence rate of the oil adhesion on the measurement result of the screw thread parameters. Finally, an experiment-based pitch diameter compensation method was proposed, and the compensation effect of this method was verified with the test method. Experiments showed that the effect of oil adhesion on the measurement results of the diameter parameters is greater than 7 µm, and the effect on the measurement result of the thread angle is greater than 0.1°. The compensation experiment showed that the compensation efficiency was above 70% for the pitch diameter.


Introduction
Visual measurement technology has great advantages in screw thread measurement. First, machine vision measurement methods have higher measurement efficiency. Second, machine vision measurement methods can be used to achieve an online screw thread measurement. Besides, machine vision measurement methods can detect screw thread parameters that are difficult to obtain with traditional methods. 1 Recently, screw thread parameter detection based on machine vision has been widely studied. 2,3 Gadelmawla 4 introduced a visual detection system that could not only be applied to many types of screw thread measurement but also simultaneously detect 18 parameters of the screw thread. Min 5 designed a visual detection system of screw thread parameters, which was intuitive, efficient, and easy to operate. Mutambi and Yu 6 analyzed the source error in the screw thread measurement program and the effect of calibration on the measurement accuracy. Chen 7 proposed a compensation method for thread profile distortion that had a pitch diameter compensation effect of more than 85% and a thread angle compensation effect of more than 70%. Shen et al. 8 analyzed the problem of thread profile distortion during the machine vision measurement and provided a compensation method. Despite the many achievements in screw thread vision measurement, there have been a few studies on the effect of oil adhering to a screw thread surface using visual measurements. The machine vision measurement method uses the principle of optical imaging, which requires high thread surface cleanliness. 9 Therefore, oil adhesion on a screw thread surface has a large effect on imaging. In a study of the thread sub-pixel edge extraction algorithm, Cai et al. 10 mentioned the influence of the oil attached to the screw thread surface on the visual measurement results and conducted a preliminary analysis of the impact.
Oil plays the role of lubrication and cooling in the process of parts production, and it is essential for modern machinery manufacturing. 11 During screw thread manufacturing, the friction on a tool flank is large, chip removal is difficult, and the heat is not easily carried away by the chips. Generally, the cutting fluid that contains the oil is used to reduce friction and lower the cutting temperature. 12,13 The use of oil improves the tool life and the surface quality of a screw thread. At the same time, the oil adheres to the surface of the screw thread, which affects the online measurement accuracy of the screw thread. The screw thread manufacturing materials are generally low carbon steel, medium carbon steel, alloy steel, and similar substances. Such materials do not have good oleophobic properties. Huang et al. 14 found that during processing, the thickness of the film near a cutting edge was about 15 mm, and the thickness of the film at other positions could reach about 25 mm. When Qin 15 studied the measurement method of lubricating oil film thickness, the measured oil film thickness was about 30 mm. As mentioned in the literature review, oil adherence on the surface of a work-piece has a serious impact on the contour shape of the work-piece. According to Biresaw et al., 16 the greater the viscosity of the oil is, the greater the influence on the contour of the work-piece is. Therefore, it is important to research the influence of oil adhesion on the vision measurement results of a screw thread. Many factors affect the oil adhesion on the screw thread surface during the measurement such as the processing method, surface quality, oil type, and the cleaning method. Therefore, it is difficult to carry out simulation research and theoretical research on the influence of oil adhesion on the vision measurement results of a screw thread.
In this research, from the perspective of the influence of oil adhesion on the screw thread imaging, the visual measurement error of the screw thread parameters was analyzed with the method of experimental detection. In order to reduce the influence of oil adhesion on the visual measurement results of thread diameter, an experimentbased pitch diameter compensation method was proposed. And, the feasibility of this method was verified by experiments. The study is organized into the following sections: the ''Effect of oil adhering to the screw thread surface on the screw thread profile imaging'' section describes the effects of oil adhesion on the imaging of the screw thread profile; the ''Experiment'' section describes the experimental details; in section ''Analysis of the experiment results,'' the experimental and numerical results are presented and discussed; in the ''Pitch diameter compensation method and compensation effect verification'' section, an experiment-based pitch diameter compensation method is proposed, as well as experimental verification of the algorithm is discussed; and finally, the ''Conclusion'' section gives the conclusion.
Effect of oil adhering to the screw thread surface on the screw thread profile imaging As shown in Figure 1, the oil adherence to the screw thread surface affected the profile of the screw thread imaging. There were two types of effects: first, as shown in Figure 1(a), the oil attached to the surface of the screw thread changed the contour shapes of the root, crest, and flank; second, as shown in Figure 1(b), the oil adhered to the surface of the screw thread, leading to the change of the gray gradient of the screw thread profile edge, which made it impossible for the common edge detection operators to extract the screw thread edge profile accurately. The change of the screw thread profile and the position of the extracted edge contour affected the measurement position of the screw thread parameters and caused the measurement result of the screw thread parameters to change.

Experiment equipment
During the experiment, four types of metric threads M8 3 1.25, M14 3 2, M30 3 1.5, and M42 3 1.5 were used as test objects. A total of five kinds of lubricating oils with different viscosities (ISOVG10, ISOVG22, ISOVG32, ISOVG46, and ISOVG68) were selected as the experimental medium. The screw thread images were obtained using the GIM-80A automatic image measuring instrument in backlight conditions, as shown in Figure 2. GIM-80A consists of a light-emitting diode parallel backlight source, a 1/2-inch charge-coupled device (CCD) color camera, and an AVITAR63106-S-7 zoom lens. The magnification of the zoom lens is 0.73 to 4.53, and the total magnification of the image is 243 to 1483. The central region of the parallel light source has good straightness, which could sharpen the external contour of the object under measurement. The parallel light could suppress the lens distortion. The use of the telecentric lenses in conjunction with the CCD cameras effectively corrected the parallax of the traditional industrial lenses.

Screw thread image acquisition
During the experiment, the images of the screw thread were collected based on the following suggestions: 1. Root, is the surface at the bottom of groove connecting two adjacent flanks. 2. Crest, is the surface at the top of a ridge connecting two adjacent flanks. and 3. Flank, is the part of the helical thread surface generated by one side of the fundamental triangle which is not parallel to the pitch line of the screw thread.
1. The clean screw thread (CLST) was ultrasonically cleaned and dried. 2. For the screw thread heavily degree adhered by oil (STHDA), the lubricating oil was evenly applied to the surface of the screw thread and it was left to stand for 5 min. 3. For the screw thread moderate degree adhered to by oil (STMDA), the lubricating oil was evenly applied to the surface of the screw thread, and it was placed on a 10-Hz vibration platform for 30 s to make the oil flow evenly. 4. For the screw thread light degree adhered to by oil (STLDA), the lubricating oil was evenly applied to the surface of the screw thread, and it was placed on a 10-Hz vibration platform for 1 min to make the oil flow evenly.
The clamping method of the screw thread during image acquisition is shown in Figure 3. Double top clamping not only ensured uniformity between the screw thread manufacturing datum and the measuring datum but also provided radial and axial positioning of the screw thread. The locating pin was matched with the locating hole on the screw thread to circumferentially locate the screw thread. Three directions were positioned at the same time to ensure that the same position images of the same screw thread under different oil attached states could be acquired.

Image processing
As shown in Figure 4, the acquired image was subjected to differential processing using the image difference algorithm to enhance the contrast of the contour deformation region. 17 Figure 5 shows the difference calculation results between the cleaning image and the oil-attached image of the screw thread M8 3 1.25. Due to the wettability, the oil adhered to the surface of the screw thread and formed an adhesion layer. Under the influence of surface tension, the oil at the crest shrank and formed a bulge. The adhesion layer in contact with the root of the screw thread tended to extend, which caused the oil to contact the air surface and to become concavely curved.
From Figure 5, we can find that the degree of influence on the screw thread profile was different depending on the adherence conditions of the oil. Different degrees of the screw thread profile change have different effects on the screw thread measurement results. Table 1 shows the calculation results of the proportion of profile deformation of the screw thread M8 3 1.25. The greater the degree of oil adhesion on the screw thread surface, the greater the deformation of the screw thread image profile. At the same time, the degree of deformation of the screw thread image profile also increases as the viscosity of the oil increases.
The influence of the oil adherence on different positions of the screw thread profile resulted in changes in the measurement results of the different screw thread parameters. As shown in Figure 1, the influence of the oil on the root affected the minor diameter measurement; the influence on the crest affected the measurement of the major diameter; and the influence on the flank affected the measurement of the pitch diameter and the thread angle. The distribution of oil on the surface of the screw thread was analyzed while relying on the computational statistics for the adherence layer images. As shown in Figure 6(a), five regions on the screw thread image were selected: the left root region I, the left flank region II, the crest region III, the right  flank region IV, and the right root region V. The computational statistics for the distribution of oil in those five sections were determined. Figure 6(b) shows the calculation results of the distribution of the ISOVG32 type lubricating oil that adhered to the surface of the screw thread M8 3 1.25. The adherence of the oil had a serious influence on the root of the screw thread and the flank near the root of the screw thread, and the influences on the crest and the flank were relatively small. Therefore, it was predicted that the impact of the minor diameter measurement results would be greater than that of the pitch diameters and the major diameters.

Detection method
Detection method for the major diameter influence. The change of the major diameter measurement results was mainly caused by the change of the thread crest profile. To analyze the influence of oil adherence on the result of the major diameter measurement, the relative position change of the crest was detected during the research. Since the images of the same screw thread were collected in the same conditions (clamping position, magnification, and focal length), the images in the different oil adherence states were in the same coordinate system.
During the detection process, the screw thread crest fitting line of the clean screw thread and the oilattached screw thread was sampled. Set the sampling step to 0.1 pixels and set the number of sampling points to n. Mark the sampling points on the clean screw thread and the oil-attached screw thread as (x i , y i ) and (x j , y j ), respectively. Calculate the average distance between the corresponding points to obtain the position change of the thread crest. The calculation method is shown in equation (1) Detection method for the minor diameter influence. The change of the minor diameter measurement results was mainly caused by the change of the screw thread root   profile. To analyze the influence of oil adherence on the result of the minor diameter measurement, the relative position change of the root was detected during the research.
During the detection process, the screw thread root fitting line of the clean screw thread and the oilattached screw thread was sampled. Set the sampling step to 0.1 pixels and set the number of sampling points to m. Mark the sampling points on the clean screw thread and the oil-attached screw thread as (x o , y o ) and (x p , y p ), respectively. Calculate the average distance between the corresponding points to obtain the position change of the thread root. The calculation method is shown in equation (2) Detection method for the pitch diameter influence. The change of the pitch diameter measurement results was mainly caused by the change of the screw thread flank profile. In order to analyze the influence of the oil adherence on the result of the pitch diameter measurement, the relative position change of the pitch line was tested during the research. As shown in Figure 7(a), the groove width c r and the ridge thickness f r were calculated using the distance between the line parallel to the axis and the thread flank line intersections. The thickness difference was defined as follows In order to increase the calculation speed, the upper detection limit and the lower detection limit were set on the screw thread image, as shown in Figure 7(a). For example, the thickness difference detection result of the screw thread M8 3 1.25 was as shown in Figure 7(b). The position where the difference in thickness was the smallest was the position of the pitch line.
The cleaning screw thread pitch line was set to L 1 . The expression of L is shown in equation (4) The pitch line of the screw thread affected by the adhesion of the oil was L 2 . The expression of L 2 is shown in equation (5) The change in the position of the pitch line was calculated as shown in equation (6) Detection method for the thread angle influence. Using the least squares fitting flank lines, the slopes k 1 and k 2 of the adjacent flank lines were obtained. The calculation of thread angle is shown in equation (7). The thread angle a of the cleaning screw thread and the thread angle a 0 of the oil-attached screw thread were detected a = arctan k 1 À k 2 1 + k 1 3k 2 ð7Þ The calculation of the influence amount on the measurement result of the thread angle is shown in equation

Analysis of the experiment results
Using the detection methods in section ''Detection method,'' 11 experiments were performed on the screw threads of different oil adherence states, and the experiment results were analyzed.

Impact analysis of the major diameter experiment results
The average value of the influence of the major diameter experiment results is shown in Figure 8. The results show that as the viscosity of the oil and the degree of oil accumulation increase, the amount of change in the measurement result of the major diameter of the screw thread becomes larger and larger. The analysis of the experimental results found that the relative influence of oil adhesion on the major diameter measurement results of the screw thread selected in the experiment is as follows. The relative influence rate is the ratio between the major diameter and the thread height. The relative influence rate on the major diameter measurement result of the screw thread M8 3 1.25 is 0.82%-2.92%. The relative influence rate on the major diameter measurement result of the screw thread M14 3 2 is 1.10%-3.08%. The relative influence rate on the major diameter measurement result of the screw thread M30 3 1.5 is 1.70%-2.52%. The relative influence rate on the major diameter measurement result of the screw thread M42 3 1.5 is 1.62%-3.45%. The experiments showed that the major diameter measurement was greater than the value before the oil was attached. Although the attachment of oil to a screw thread surface in actual production is greatly affected by the working environment, the relative influence rate on the measurement result of the major diameter of the screw thread was generally controlled at 0.82%-3.45% in this study.

Impact analysis of the minor diameter experiment results
The average value of the influence of the minor diameter experiment results is shown in Figure 9. The results show that as the viscosity of the oil and the degree of oil accumulation increase, the amount of change in the measurement result of the minor diameter of the screw thread becomes larger and larger.
The analysis of the experimental results found that the relative influence of oil adhesion on the minor diameter measurement results of the screw thread selected in the experiment is as follows. The relative influence rate is the ratio between the minor diameter and the thread height. The relative influence rate on the minor diameter measurement result of the screw thread M8 3 1.25 is 5.28%-10.36%. The relative influence rate on the minor diameter measurement result of the screw thread M14 3 2 is 4.68%-9.04%. The relative influence rate on the minor diameter measurement result of the screw thread M30 3 1.5 is 2.58%-9.42%. The relative influence rate on the minor diameter measurement result of the screw thread M42 3 1.5 is 3.80%29.10%. The experiments showed that the minor diameter measurement was greater than the value before the oil was attached. Although the attachment of oil to a screw thread surface in actual production is greatly affected by the working environment, the relative influence rate on the measurement result of the minor diameter of the screw thread was generally controlled at 2.62%-10.36% in this study.

Impact analysis of the pitch diameter experiment results
The average value of the influence of the pitch diameter experiment results is shown in Figure 10. The results show that as the viscosity of the oil and the degree of oil accumulation increase, the amount of change in the measurement result of the pitch diameter of the screw thread becomes larger and larger.
The analysis of the experimental results found that the relative influence of oil adhesion on the pitch diameter measurement results of the screw thread selected in the experiment is as follows. The relative influence rate is the ratio between the pitch diameter and the thread height. The relative influence rate on the pitch diameter measurement result of the screw thread M8 3 1.25 is 0.9%-3.1%. The relative influence rate on the pitch diameter measurement result of the screw thread M14 3 2 is 1.1%-3.1%. The relative influence rate on the pitch diameter measurement result of the screw thread M30 3 1.5 is 1.44%-2.20%. The relative influence rate on the pitch diameter measurement result of the screw thread M42 3 1.5 is 1.04%-2.59%. The experiments showed that the pitch diameter measurement was greater than the value before the oil was attached. Although the attachment of oil to a screw thread surface in actual production is greatly affected by the working environment, the relative influence rate on the measurement result of the pitch diameter of the screw thread was generally controlled at 1.04%-3.10% in this study.

Impact analysis of the thread angle experiment results
The average value of the influence of the thread angle experiment results is shown in Figure 11. For the screw thread affected by the adherence of the oil, the thread angle measurement was greater than the cleaning screw thread.
The analysis of the experimental results found that the relative influence of oil adhesion on the thread angle measurement results of the screw thread selected  in the experiment is as follows. The relative influence rate is the ratio between the change of thread angle and the thread angle. The relative influence rate on the thread angle measurement result of the screw thread M8 3 1.25 is 0.83%-3.10%. The relative influence rate on the thread angle measurement result of the screw thread M14 3 2 is 0.20%-2.67%. The relative influence rate on the thread angle measurement result of the screw thread M30 3 1.5 is 0.21%-2.88%. The relative influence rate on the thread angle measurement result of the screw thread M42 3 1.5 is 1.04%-2.59%. Although the adherence of oil to a screw thread surface in actual production is greatly affected by the working environment, the relative influence rate on the measurement result of the thread angle of the screw thread was generally controlled at 0.20%-3.10% in this study.

Pitch diameter compensation method
The adhesion of the oil to the surface of the screw thread was affected by factors such as the oil viscosity, screw thread type, screw thread surface quality, and processing methods. However, the screw thread visual inspection method based on the projection imaging principle was affected not only by the above factors but also by the on-site illumination intensity, imaging exposure time, and ambient temperature. Due to the complicated influencing factors, it was difficult to eliminate the influence of the oil adhesion on the visual measurement of the pitch diameter with theoretical calculation. According to the statistics of the experimental results of the thread parameter measurement, the influence of the pitch diameter measurement result could be predicted by the relationship between the major diameter of the screw thread and the oil film thickness at the root. The oil adhesion coefficient was established as equation (9) where d is the major diameter, and U is the oil film thickness at the root. According to the experimental results, the numerical interval of t was divided into a light attachment interval ½0, t 1 , a moderate attachment interval ½t 1 , t 2 , and a severe attachment interval ½t 2 , +'. In each attachment interval, there was a pitch diameter influence coefficient l related to the thread height h and the amount of influence of the pitch diameter Dd 2 , as shown in equation (10) The screw thread was measured multiple times in each oil adhesion interval to obtain the pitch diameter influence coefficients. The pitch diameter influence coefficient measured by the experiment in each interval was averaged to obtain the average influence coefficient of the light attachment interval, the severe attachment interval, and the moderate attachment interval, l½1, l½2, and l½3, respectively. In the actual measurement process, the oil adhesion coefficient of each thread root b ii was calculated as shown in equation (11) where S is the number of thread roots, and U ii is the thickness of the oil film at each root. The average oil adhesion coefficient b of the screw thread to be tested was calculated with equation (12) The oil adhesion interval where b was located was determined, the average influence coefficient l½1 or l½2 or l½3 was selected, and the pitch diameter compensation coefficient g was calculated using equation (13). The compensation algorithm is shown in Figure 12.
Compensation effect verification In the compensate verification, the M8 3 1.25 screw thread affected by the adherence of the ISOVG32 lubricant was selected. The pitch diameter compensation ratio was set to l½ = fl 1 , l 2 , l 3 g = f1:2%, 2:3%, 1:8%g. Under the influence of different degrees of oil adhesion, 10-time pitch diameter compensation tests were carried out. The calculation method for the compensation efficiency u was as shown in equation (14) where A is the measured value of the pitch diameter after compensation, B is the measured value of the pitch diameter before compensation, and C is the measured value of the pitch diameter of the screw thread after cleaning.
The verification results of the pitch diameter compensation are shown in Table 2. We can find that the experimental-based compensation method had a compensation efficiency of more than 70% for the pitch diameter of the selected thread.
In order to verify the wide applicability of the pitch diameter compensation method, the same compensation tests were performed on the screw threads M14 3 2, M30 3 1.5, and M42 3 1.5. The test results are shown in Table 3. The verification results show that the experiment-based compensation method has certain feasibility for screw thread measurement.

Conclusion
In this research, a machine vision measurement experiment of oil-attached screw threads was performed. The experiment results indicated that the oil adherence on the screw surface made the measurements of the diameter parameters and thread angle too large. The influence on the minor diameter measurement results was much larger than the influences on the major diameter and pitch diameter. The experiment found that the effect of oil adherence on the online measurement results was also related to the viscosity of the oil. The greater the viscosity of the oil was, the more severe the effect was on the measurement results of the diameter parameters of screw thread. As the degree of oil adherence increased, the influence of the oil adherence on the major diameter, minor diameter, and pitch diameter measured results became greater. During the experiment, the effects of the selected oil on the selected screw thread of the experiment were as follows: the relative change rate of the major diameter measurement results was 0.87%23.45%; the relative change rate of the minor diameter measurement results was 2.58%210.36%; the relative change rate of the pitch diameter measurement results was 0.89%23.22%; and the relative change rate of the thread angle measurement results was 0.20%23.10%. The influence of the oil adherence on the online visual measurement results of the thread could not be ignored.
In order to improve the measurement accuracy of the pitch diameter, an experiment-based pitch diameter compensation method is proposed in this paper. The screw threads M8 3 1.25, M14 3 2, M30 3 1.5, and M42 3 1.5 under the influence of the adherence of the ISOVG32 oil were compensated and verified. The compensation efficiency was above 70%. With the development of mechanical automation and precision, the measurement technology is increasingly demanding efficiency and accuracy. The influence of oil adherence on the online visual measurement results of a screw thread has great research significance. This study has laid the foundation for the visual measurement of screw thread.

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 receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by the Shaanxi Key Laboratory of Industrial Automation and Shaanxi University of Technology Talent Startup Fee (Grant No. SLGQD1812).