A Cylindrical Helical Spring Direction Determination Method Based on Image Processing
By binarizing, morphologically processing, and extracting the skeleton from the end face image of a cylindrical helical spring, and combining this with grayscale counting, the spring's rotation direction can be automatically determined. This solves the problem of springs with different rotation directions being mixed in the detection batch, achieving efficient and accurate rotation direction determination.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TIANJIN UNIVERSITY OF TECHNOLOGY
- Filing Date
- 2023-10-08
- Publication Date
- 2026-05-26
AI Technical Summary
In the automated production process of cylindrical helical springs, existing technologies are unable to effectively distinguish springs with different directions of rotation, resulting in mixed batches being tested and affecting testing accuracy and efficiency.
By performing binarization, morphological opening, skeleton extraction, and circle fitting on the spring end face image, and combining it with gray-level counting in the neighborhood, the spring rotation direction is automatically determined. The maximum inter-class variance method and morphological processing methods are used to identify the spring end face features, thus achieving accurate determination of the spring rotation direction.
It enables automatic and reliable determination of the spring's rotation direction, is applicable to any placement posture, does not require manual setting of image processing references, and improves the accuracy and efficiency of detection.
Smart Images

Figure CN117387881B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing methods, specifically a method for determining the rotation direction of a cylindrical helical spring based on image processing. Background Technology
[0002] Springs, as fundamental components, serve industries such as machinery, electronics, instrumentation, and transportation. Springs can be categorized by shape into disc springs, ring springs, torsion bar springs, and cylindrical helical springs, among which cylindrical helical springs are the most widely used. Currently, machine vision technology has been successfully applied to the basic dimensional measurement of cylindrical helical springs. Compared with traditional manual inspection methods, image processing-based machine vision inspection significantly improves dimensional measurement accuracy, effectively reduces measurement errors, and increases inspection efficiency.
[0003] In the automated production of cylindrical helical springs, machine vision inspection is mainly used for dimensional defect detection. However, in the preceding automated production processes, springs with different helical directions may be mixed into the inspection batch. For example, during automatic spring cleaning, springs with different helical directions from previous batches may remain and be mixed into subsequent batches. When the dimensions of springs with different helical directions are not significantly different from those in the current inspection batch, only helical direction detection can be used for identification and rejection. The conventional spring helical direction detection method involves placing the spring upright and flat, with a camera directly facing the spring to capture images. Based on image processing, the pitch distribution characteristics are identified; if the pitch is higher on the left, it is left-handed, and if the pitch is higher on the right, it is right-handed. However, when the spring is placed upright, the camera depth of field needs to span the spring's diameter. To clearly image the spring pitch characteristics, the larger the diameter of the spring, the greater the depth of field required, increasing the requirements for the camera imaging system. In contrast, the height and undulations of the spring end face are not significant, the requirements for camera imaging depth of field are not high, and it is easier to ensure clear imaging. Therefore, this patent proposes an image processing method based on the image features of the spring end face to achieve automatic determination of the rotation direction of a cylindrical helical spring.
[0004] The following publicly disclosed existing patent technologies were found through a search:
[0005] A direction determination system and method for mobile terminals (Publication No. CN105160688B) is disclosed. The direction determination method includes: acquiring a tree stump annual ring image; analyzing the distribution of tree stump annual rings in the image to obtain density information of the tree stump annual rings; and inferring corresponding direction information based on the density information of the tree stump annual rings. This invention can infer corresponding direction information from the density distribution of tree stump annual rings in an image, indicating a relatively correct direction for the user. This solves the problem in existing technologies where the lack of corresponding directional tools on mobile terminals prevents the correct direction from being indicated, thus improving the user experience.
[0006] Upon comparison, the technical problem solved by this patent application differs significantly from that in the prior art. Therefore, the specific extraction and calculation methods used are clearly different, and the prior art does not affect the novelty of this patent application. Summary of the Invention
[0007] The purpose of this invention is to provide a reliable image processing method for determining the rotation direction of cylindrical helical springs based on machine vision, thereby achieving automatic determination of the spring rotation direction.
[0008] The technical problem solved by this invention is achieved through the following technical solution:
[0009] A method for determining the helix direction of a cylindrical helical spring based on image processing, characterized by the following specific steps:
[0010] S1: Binarize the original spring end face image to obtain a binary image I1;
[0011] S2: Perform a morphological opening operation on the original image to make the image features at the bend of the spring tend to form a notch, obtaining Figure I. open ;
[0012] S3: For Figure I open Binarization is performed to obtain a binary image I2 with gap features;
[0013] S4: Perform skeleton extraction on Figure I2 to obtain a refined skeleton figure I3 and a skeleton point set P. i ;
[0014] S5: For the skeleton point set P i Perform circle fitting to obtain the center O. c ;
[0015] S6: Using the neighborhood row and column gray-level counting strategy, perform skeleton endpoint search in Figure I3 to find the two endpoints at the gap and P. e1 and P e2 ;
[0016] S7: Obtain the corresponding P from the binary graph I1 obtained in S1. e1 and P e2 The radial width W of the spring at the location e1 and W e2 ;
[0017] S8: According to W e1 and W e2 The size relationship, combined with P e1 and P e2 The positional relationship is used to ultimately determine the direction of spring rotation.
[0018] Moreover, the specific steps of S1 are as follows:
[0019] The binarization process employs the maximum inter-class variance method to binarize the original image of the spring end face. Based on the grayscale characteristics of the image, the image is divided into two parts: foreground and background. When the optimal threshold is selected, the difference between the two parts is maximized, thus obtaining the optimal binarization threshold and acquiring the binary image I1.
[0020] Moreover, the specific steps of S2 are as follows:
[0021] The morphological opening operation employs a combined process of erosion and dilation of the image. This morphological processing of the original image eliminates small objects or details and smooths object boundaries, thereby removing noise and causing the image features at the bend of the spring to form gaps, resulting in Figure I. open .
[0022] Moreover, the specific steps of S3 are as follows:
[0023] The corresponding graph I was obtained using the Otsu's method. open The optimal binarization threshold for Figure I open Perform binarization to obtain the binary image I2.
[0024] Moreover, the specific steps of S6 are as follows:
[0025] In Figure I3, for each P i Gray-level counting is performed within the 3×3 neighborhood of each point. Utilizing the gray-level distribution characteristics of the endpoints' neighborhoods, which differ from other skeleton points, the skeleton point set P is analyzed. i We will analyze each case individually to find the two endpoints P at the gap. e1 and P e2 The specific process is as follows:
[0026] 1) For P i The grayscale counts of the previous and next rows are calculated. If each row has a pixel with a grayscale value of 1, the flag_row value is set to 1; otherwise, the flag_row value is set to 0.
[0027] 2) For P i The left and right columns are counted for grayscale. If each column has a pixel with a grayscale value of 1, the flag_col value is set to 1; otherwise, the flag_col value is set to 0.
[0028] 3) Iterate through each P i Calculate the corresponding flag_row i and flag_col i ;
[0029] 4)Use flag_row i and flag_coli Perform endpoint checks; if flag_row i and flag_col i Both are 0, indicating that P i If a point has both a row and a column with all gray levels equal to 0 within its 3×3 neighborhood, which matches the gray level distribution characteristics of the endpoint's neighborhood, then the point is determined to be a point P. i Point P is the endpoint of the gap, thus obtaining the two endpoints P of the gap. e1 and P e2 .
[0030] Moreover, the specific steps of S7 are as follows:
[0031] 1) In Figure I1, with the center O c and endpoint P e1 Constructing a radial vector With P e1 Starting from, along The grayscale boundary point Q in the spring width direction was found. 11 and Q 12 Calculate Q 11 and Q 12 The distance between them is denoted as P. e1 The radial width W of the spring at that location e1 ;
[0032] 2) Same as above, with center O c and endpoint P e2 Constructing a radial vector With P e2 Starting from, along The grayscale boundary point Q along the spring width direction was found. 21 and Q 22 Calculate Q 21 and Q 22 The distance between them is denoted as P. e2 The radial width W of the spring at that location e2 .
[0033] Moreover, the specific steps of S8 are as follows:
[0034] According to W e1 and W e2 The size, combined with P e1 and P e2 Based on the positional relationship, the direction of rotation is determined. The rule is that if the direction from the thinner end to the thicker end is clockwise, it is left-handed; otherwise, it is right-handed. The specific description is as follows: If W... e1 >W e2 , arrive If the direction is clockwise, then it is a left-handed spring. arrive If the direction is counterclockwise, then it is a right-handed spring; if W e1 <W e2 Then the judgment rule is the opposite of the above; if W e1 =W e2 If the spring is not found to be in good condition, it will be rejected and await further manual inspection.
[0035] The advantages and positive effects of this invention are:
[0036] The method of this invention is applicable to the determination of the helix direction of cylindrical helical springs. By performing image processing on the spring end face image, the helix direction of the spring can be accurately determined. Specifically, it has the following advantages:
[0037] (1) The method of the present invention does not have strict requirements on the position and angle of the spring end face in the image. The spring can be placed arbitrarily within the field of view, and the method will process it adaptively.
[0038] (2) The method of the present invention does not require manual setting of reference frames, lines, etc. for image processing, and relies entirely on the structural features of the spring end face to automatically identify. Attached Figure Description
[0039] Figure 1 This is a flowchart of the method in an embodiment of the present invention.
[0040] Figure 2 These are images of the spring end faces of left-handed and right-handed springs. (a) shows a left-handed spring, and (b) shows a right-handed spring.
[0041] Figure 3 These are the processing results of the first step of the method in this invention example. (a) shows a left-handed spring, and (b) shows a right-handed spring.
[0042] Figure 4 These are the processing results of the second step of the method in this invention example. (a) shows a left-handed spring, and (b) shows a right-handed spring.
[0043] Figure 5 These are the processing results of the fourth step of the method in this invention example. (a) shows a left-handed spring, and (b) shows a right-handed spring.
[0044] Figure 6 These are the processing results of the fifth step of the method in this invention example. (a) shows a left-handed spring, and (b) shows a right-handed spring.
[0045] Figure 7 The following are the processing results of the sixth step of the method in this invention example: (a) shows a left-handed spring, and (b) shows a right-handed spring.
[0046] Figure 8 The following are the processing results of the seventh step of the method in the example of the present invention: (a) shows a left-handed spring, and (b) shows a right-handed spring. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this application clearer and easier to understand, the present invention will be further described below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit the scope of this application.
[0048] Figure 1 The diagram shows a flowchart of a cylindrical helical spring rotation direction determination method based on image processing according to an embodiment of the present invention. First, the original spring end face image is binarized to obtain a binary image I1; then, a morphological opening operation is performed on the original image to make the image features at the spring bending point tend to form a notch, resulting in image I. open ; then, regarding Figure I open Binarization is performed to obtain a binary image I2 with notch features; then, skeleton extraction is performed on image I2 to obtain a refined skeleton image I3 and a skeleton point set; finally, circle fitting is performed on the skeleton point set to obtain the circle center O. c Then, using a neighborhood-based row and column grayscale counting strategy, an endpoint search is performed on the skeleton point set to find the two endpoints at the gap and P. e1 and P e2 Subsequently, the corresponding P is obtained in Figure I1. e1 and P e2 The radial width W of the springs at both locations e1 and W e2 Finally, according to W e1 and W e2 The size relationship, combined with P e1 and P e2 The positional relationship is used to ultimately determine the direction of spring rotation.
[0049] Combination Figure 1 As shown, the present invention provides a method for determining the helix direction of a cylindrical helical spring based on image processing. The specific implementation steps are as follows:
[0050] (1) Original Figure 2 Binarization: The optimal binarization threshold is obtained using the maximum inter-class variance method. Figure 2 The original image of the spring end face shown is binarized to obtain... Figure 3 The binary image I1 is shown. The Otsu algorithm, also known as the maximum inter-class variance method, is a widely used adaptive method for determining the binarization threshold. Based on the image's grayscale characteristics, the image is divided into foreground and background parts. The optimal threshold should maximize the difference between the two parts; the Otsu algorithm uses the common maximum inter-class variance as the criterion for measuring this difference.
[0051] (2) Morphological processing of the original image: Morphological opening is performed on the original image. Morphological opening is a combination of erosion and dilation of the image. Morphological processing of the original image is used to eliminate small objects or details and smooth the boundaries of objects. This removes noise and makes the image features at the bending points of the spring tend to form gaps, thus obtaining... Figure 4 Figure I shown open .
[0052] (3) Figure I open Binarization: The corresponding graph I is obtained using the maximum inter-class variance method. open The optimal binarization threshold for Figure I open Perform binarization to obtain the binary image I2.
[0053] (4) Skeleton Refinement and Extraction: The skeleton of Figure I2 is extracted to form... Figure 5 The skeleton diagram I3 shown is used to obtain the refined skeleton point set P. i .
[0054] (5) Obtain the center of the skeleton: See Figure 6 The skeleton point set P shown i Perform circle fitting to obtain the center O. c .
[0055] (6) Obtain the skeleton endpoints: In Figure I3, for each P i Gray-level counting is performed within the 3×3 neighborhood of each point. Utilizing the gray-level distribution characteristics of the endpoints' neighborhoods, which differ from other skeleton points, the skeleton point set P is analyzed. i We will analyze each case individually to find the two endpoints P at the gap. e1 and P e2 See Figure 7 As shown, the specific process is as follows:
[0056] 5) For P i The grayscale counts of the previous and next rows are calculated. If each row has a pixel with a grayscale value of 1, the flag_row value is set to 1; otherwise, the flag_row value is set to 0.
[0057] 6) For P i The left and right columns are counted for grayscale. If each column has a pixel with a grayscale value of 1, the flag_col value is set to 1; otherwise, the flag_col value is set to 0.
[0058] 7) Iterate through each P i Calculate the corresponding flag_row i and flag_col i ;
[0059] 8)Use flag_row iand flag_col i Perform endpoint checks; if flag_row i and flag_col i Both are 0, indicating that P i If a point has both a row and a column with all gray levels equal to 0 within its 3×3 neighborhood, which matches the gray level distribution characteristics of the endpoint's neighborhood, then the point is determined to be a point P. i Point P is the endpoint of the gap, thus obtaining the two endpoints P of the gap. e1 and P e2 .
[0060] (7) Obtain the radial width of the spring: See Figure 8 As shown,
[0061] 3) In Figure I1, with the center O c and endpoint P e1 Constructing a radial vector With P e1 Starting from, along The grayscale boundary point Q along the spring width direction was found. 11 and Q 12 Calculate Q 11 and Q 12 The distance between them is denoted as P. e1 The radial width W of the spring at that location e1 ;
[0062] 4) Same as above, with center O c and endpoint P e2 Constructing a radial vector With P e2 Starting from, along The grayscale boundary point Q along the spring width direction was found. 21 and Q 22 Calculate Q 21 and Q 22 The distance between them is denoted as P. e2 The radial width W of the spring at that location e2 .
[0063] (8) Determine the direction of rotation: based on W e1 and W e2 The size, combined with P e1 and P e2 Based on the positional relationship, the direction of rotation is determined by the following rule: if the direction from the thinner end to the thicker end is clockwise, it is left-handed; otherwise, it is right-handed. The specific description is as follows: If W... e1 >W e2 , arrive If the direction is clockwise, then it is a left-handed spring. arrive If the direction is counterclockwise, then it is a right-handed spring; if W e1 <W e2 Then the judgment rule is the opposite of the above; if W e1 =W e2 If the spring is not found to be in good condition, it will be rejected and await further manual inspection.
[0064] The final experimental results prove that the method is stable and reliable. It does not have strict requirements on the position and angle of the spring end face in the image, and does not require manual setting of reference boxes, lines, etc. for image processing. It relies entirely on the structural features of the spring end face to automatically determine the direction of spring rotation.
[0065] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for determining the direction of rotation of a cylindrical coil spring based on image processing, characterized in that: The specific steps are as follows: S1: binaryzation of the original spring end face image, to obtain binary image I 1; S2: morphological opening operation is performed on the original image, so that the image features at the spring bending part tend to form a notch, and a image I open ; S3: To the graph I open The binarization processing is performed to obtain a binary graph with a notch feature I 2; S4: Graph I 2. Perform skeleton extraction processing to obtain a detailed skeleton diagram. I 3 and skeleton point set P i ; S5: For skeleton point sets P i Perform circle fitting to obtain the center of the circle. O c ; S6: Utilize the neighborhood row and column grayscale counting strategy in the graph. I In step 3, perform a skeleton endpoint search to find the two endpoints at the gap. P e1 and P e2 The specific steps are as follows: In the figure I In 3, for each P i Gray-level counting is performed within the 3×3 neighborhood of each point. The gray-level distribution characteristics of the endpoints, which differ from those of other skeleton points, are used to analyze the skeleton point set. P i We will examine each one individually to find the two endpoints of the gap. P e1 and P e2 The specific process is as follows: 1) To P i The grayscale count is performed on the previous and next rows. If each row has pixels with a grayscale value of 1, then the flag value is set. flag_row Assign a value of 1, otherwise flag_row Assign the value 0; 2) To P i The left and right columns are counted for grayscale. If each column has pixels with a grayscale value of 1, then a flag value is set. flag_col Assign a value of 1, otherwise flag_col Assign the value 0; 3) Iterate through each P i Calculate the corresponding flag_row i and flag_col i ; 4) Take advantage of flag_row i and flag_col i Perform endpoint checks, if flag_row i and flag_col i All are 0, indicating P i If a point has both a row and a column with all gray levels equal to 0 within its 3×3 neighborhood, which matches the gray level distribution characteristics of an endpoint's neighborhood, then it is determined that the point... P i Point is the endpoint of the gap, thus obtaining the two endpoints of the gap. P e1 and P e2 ; S7: Binary image obtained in S1 I Obtain the corresponding in 1 P e1 and P e2 The radial width of the spring at the location W e1 and W e2 ; S8: According to W e1 and W e2 The size relationship, combined with P e1 and P e2 The positional relationship is used to ultimately determine the direction of spring rotation.
2. The method for determining the helix direction of a cylindrical helical spring based on image processing according to claim 1, characterized in that: The specific steps of S1 are as follows: The binarization process employs the maximum inter-class variance method to binarize the original image of the spring end face. Based on the image's grayscale characteristics, the image is divided into foreground and background parts. The optimal binarization threshold is obtained when the difference between the two parts is maximized, thus yielding the binary image. I 1.
3. The method for determining the helix direction of a cylindrical helical spring based on image processing according to claim 1, characterized in that: The specific steps of S2 are as follows: The morphological opening operation employs a combined process of erosion and dilation of the image. This morphological processing of the original image eliminates small objects or details and smooths object boundaries, thereby removing noise and causing image features at the bend of the spring to form gaps, resulting in a better image. I open .
4. The method for determining the helix direction of a cylindrical helical spring based on image processing according to claim 1, characterized in that: The specific steps of S3 are as follows: The corresponding graph was obtained using the Otsu's method. I open The optimal binarization threshold for the graph I open Perform binarization to obtain a binary image. I 2.
5. The method for determining the helix direction of a cylindrical helical spring based on image processing according to claim 1, characterized in that: The specific steps of S7 are as follows: 1) In the figure I In 1, with the center of the circle O c and endpoints P e1 Constructing a radial vector ,by P e1 Starting from, along The grayscale boundary point in the spring width direction was found. Q 11 and Q 12 ,calculate Q 11 and Q 12 The distance between them is denoted as P e1 radial width of the spring at the location W e1 ; 2) Same as above, with the center of the circle O c and endpoints P e2 Constructing a radial vector ,by P e2 Starting from, along The grayscale boundary point in the spring width direction was found. Q 21 and Q 22 ,calculate Q 21 and Q 22 The distance between them is denoted as P e2 The radial width of the spring at that location W e2 .
6. The method for determining the helix direction of a cylindrical helical spring based on image processing according to claim 1, characterized in that: The specific steps of S8 are as follows: according to W e1 and W e2 The size, combined with P e1 and P e2 Based on the positional relationship, the direction of rotation is determined. The rule is that if the direction from the thinner end to the thicker end is clockwise, it is left-handed; otherwise, it is right-handed. The specific description is as follows: If... W e1 > W e2 , arrive If the direction is clockwise, it is a left-handed spring. arrive If the direction is counterclockwise, then it is a right-hand spring; if W e1 < W e2 Then the judgment rule is the opposite of the above; if W e1 = W e2 If the spring is not found to be in good condition, it will be rejected and await further manual inspection.