Visual counting method for tooth number of spiral bevel gear
Through the Hough transformation and equivalent area method, the applicability problem of high-precision detection of spiral bevel gears is solved, and high-precision counting of spiral bevel gears is realized, and the operation process is simplified.
Patent Information
- Application Number
- CN202510515844.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-08-08
AI Technical Summary
The existing gear number detection method is difficult to be applicable to spiral bevel gears, especially high-precision detection. The traditional method is sensitive to image resolution and noise, requires professional knowledge and poor applicability.
The visual counting method of spiral bevel gear teeth based on Hough transformation and equivalent area method is used to calculate the mask circle area to divide the gear area and realize the counting of teeth through image preprocessing, positioning the center of the circle, morphological filling and connecting area marking.
Improves the accuracy and applicability of the detection of the number of teeth of the spiral bevel gear, overcomes the limitations of traditional methods, and is suitable for complex gears without professional knowledge.
Smart Images

Figure CN120451070A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to a method for visually counting the number of teeth on a spiral bevel gear. Background Art
[0002] Spiral bevel gears are important mechanical transmission components, widely used in various industrial fields. Their primary function is to transmit power and motion to enable mechanical equipment to operate. Their functions include: transmitting power and motion, changing transmission direction, improving transmission efficiency, reducing noise and vibration, withstanding high loads, and adapting to complex operating conditions.
[0003] Machine vision gear tooth count detection is primarily focused on cylindrical spur gears. Currently, there are two main approaches for detecting the tooth count of cylindrical gears. One method uses the maximum inscribed circle and the minimum circumscribed circle to derive the tooth count. While this method can rapidly detect the tooth count, it is limited by image resolution, noise, and the accuracy of edge detection algorithms. It is sensitive to gear shape, relies on clear gear edges and high-quality images, and lacks universal applicability. The other method utilizes the periodicity of trigonometric functions to detect the tooth count of gears. Its advantages are that it does not rely on assumptions about gear geometry and can handle complex tooth shapes. Trigonometric methods can capture subtle variations in the gear profile, and through signal processing techniques such as Fourier transforms, high-precision tooth count detection can be achieved. However, the trigonometric method relies on accurate extraction of the gear profile. Inaccurate profile extraction can lead to spectral analysis errors. Trigonometric methods involve signal processing and spectral analysis, requiring specialized operator expertise. With advances in industrial technology and increasing product quality requirements, spiral bevel gears, as high-precision transmission components, face increasing challenges in detection technology. However, for cylindrical spur gears, the tooth profile is simple, with the tooth line parallel to the axis and no helix angle. This method is not suitable for spiral bevel gear testing. Summary of the Invention
[0004] Purpose of the invention: In response to the problems pointed out in the background technology, the present invention proposes a method for visual counting of the number of teeth of spiral bevel gears. Based on the equivalent area method, the area of the mask circle used to segment and extract the gear tooth area is obtained, the gear tooth visual counting method is improved, and the visual tooth counting of spiral spur gears is realized.
[0005] Technical solution: The present invention discloses a method for visually counting the number of teeth of spiral bevel gears, comprising the following steps:
[0006] Step 1: Obtain the spiral bevel gear image and preprocess the image;
[0007] Step 2: Use Hough transform to determine the gear positioning circle and obtain the coordinates of the circle center;
[0008] Step 3: Use morphological filling to fill the binary image inside the gear, calculate the overall area, regard the overall area as the equivalent area of the mask circle, and then calculate the mask circle diameter;
[0009] Step 4: segment the gear binary image mask circle to obtain the gear tooth area;
[0010] Step 5: Get the number of teeth based on the connected area marking.
[0011] Furthermore, the preprocessing in step 1 includes performing Gaussian filtering to remove noise from the image and performing image segmentation using the maximum inter-class variance method, specifically:
[0012] 1) By using the weighted average method and the characteristics of the Gaussian function to smooth the noise, the noise on the image is removed while retaining the edges and details of the gear image:
[0013]
[0014] Where (x, y) is the coordinate of the pixel point, σ is the standard deviation, which controls the smoothness of the filter;
[0015] 2) The image is binarized using the maximum inter-class variance method, and the optimal segmentation threshold is automatically calculated using automatic threshold selection.
[0016] Furthermore, in step 2, the gear positioning circle is determined using Hough transform, and the coordinates of the center point are obtained as follows:
[0017] Each edge point (x i ,y i ) to scan and obtain all circles that satisfy the following equations. If the edge point (x i ,y i ) belongs to a circle with radius r, then the center (a, b) must satisfy:
[0018] (ax i ) 2 +(by i ) 2 =r 2
[0019] Among them: The trajectory of the center (a, b) is (x i ,y i ) as the center and the radius r;
[0020] Then for the radius range [r min ,r max ] to obtain the circle within the target radius. The formula is as follows:
[0021]
[0022] Where: δ is the impulse function, and N is the total number of edge points.
[0023] Furthermore, in step 3, the binary image is filled with the hole filling in morphological filling to fill the inside of the gear. The binary image obtained by image preprocessing is subjected to connectivity analysis, and the gear is recorded as the foreground pixel area, and the completely surrounded gear hole area is recorded as the external background area for pixel value filling. The filling process gradually fills the gear hole area starting from the seed point through iterative expansion operation, and the complement of the original gear image is used as a constraint condition.
[0024] Furthermore, the morphological hole filling reconstruction formula is:
[0025]
[0026] Where I is the original image, F is the labeled image, is the conditional reconstruction operator;
[0027] Connectivity analysis is used to record the background components on the boundary as external background, and the background components surrounded by the foreground as holes. The external background and foreground are defined as follows:
[0028]
[0029] Furthermore, the specific method for obtaining the mask circle diameter in step 3 is:
[0030] The number of effective pixels of the gear is counted by the pixel calculation method, and the area of the filled gear image is calculated. The pixel calculation method formula is as follows.
[0031]
[0032] Where: BW is the M*N matrix in the binary image, A is the pixel area, BW( i ,j)=1 is the foreground gear image area, BW( i ,j)=0 is the background area;
[0033] Based on the principle of conservation of conversion area, the filled gear image is converted into an equivalent circle with the same area, and then the diameter of the circle with the same area is determined. The diameter calculation is:
[0034]
[0035] Among them, A is the pixel area of the gear after pixel calculation, D eq is the diameter.
[0036] Furthermore, in step 4, the gear binary image mask circle is segmented to obtain the gear tooth region, specifically as follows:
[0037] Create an all-zero matrix with the same size as the original gear image as the basic template. The initial value of each pixel is zero, and its row and column sizes are strictly consistent with the gear image.
[0038] Using the gear center circle diameter parameters calculated in step 3, a circular mask is constructed on this all-zero matrix. The key parameter setting of the circular mask is the diameter directly adopting the gear center circle diameter, while the center position is located according to the center coordinates determined by the image processing algorithm in step 2. The circular mask will serve as a region selection tool for subsequent image processing operations, where pixels within the mask area will remain visible, while the outer area will be masked.
[0039] Circular mask in gear image
[0040]
[0041] Where: (x c ,y c ) is the coordinate of the center of the circle, r is the radius of the circle, and (x, y) is the pixel coordinate on the image plane;
[0042] Since the circular mask covers the center circle area of the gear, and the teeth of the gear are usually distributed outside the circumference, it effectively removes the center interference and retains the outer edge tooth structure of the gear;
[0043] I masked (x,y)=I(x,y)*M(x,y)
[0044] Where: I(x,y) is the original image, M(x,y) is the mask matrix, I masked (x,y) is the output image.
[0045] Furthermore, the specific process of step 5 is as follows:
[0046] Scan the gear image processed in step 4, mark the foreground of the current pixel, and then perform area screening on the marked area to remove the noise area. The formula for marking the connected area by scanning the image and applying the equivalence relationship is as follows:
[0047]
[0048] where k∈{1,2,...,N};
[0049] Mark each connected area identified as a tooth in a different color, mark its center point with a serial number, and finally count the number of valid connected areas, which is the number of teeth on the gear.
[0050] Beneficial effects:
[0051] The present invention provides a method for counting the number of teeth of spiral bevel gears based on Hough transform combined with the equivalent mask circle area method. The equivalent area mask circle is obtained by applying hole filling in morphological filling to the gear image. The number of effective pixels of the gear is counted by the pixel calculation method, and the area of the filled gear image is calculated, and then the area is equivalent to the area of the mask circle. The present invention proposes obtaining the mask circle area for segmenting and extracting the gear tooth area based on the equivalent area method, improving the gear tooth visual counting method, and realizing the visual tooth counting of spiral spur gears. This method can not only overcome the shortcomings of traditional spur gear visual tooth counting, but also has good applicability for complex gears. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 This is a detection flow chart of the present invention.
[0053] Figure 2 The tooth number detection process of 3D printed cylindrical spur gears.
[0054] Figure 3 The tooth number detection process of 3D printed spiral bevel gears.
[0055] Figure 4 The tooth number detection process for machining spiral bevel gears. DETAILED DESCRIPTION
[0056] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and are not intended to limit the scope of protection of the present invention.
[0057] The present invention provides a method for visually counting the number of teeth on spiral bevel gears. First, in image preprocessing, the image is Gaussian filtered to remove noise, and then the maximum inter-class variance method is used to segment the image. Next, the gear positioning circle is determined using Hough transform to obtain the coordinates of the circle center. Then, the interior of the binary image gear is filled, and its entire area is calculated. The entire area is regarded as the equivalent area of the mask circle, and the mask circle diameter is then obtained. On this basis, the gear binary image mask circle is segmented to obtain the gear tooth area. Finally, the number of teeth is obtained based on the connected area marking. The specific implementation steps are as follows:
[0058] S1: Image preprocessing
[0059] In image preprocessing, Gaussian filtering is first used to reduce image noise. By using weighted averaging, the characteristics of the Gaussian function are used to smooth the noise, removing the noise from the image while preserving the edges and details of the gear image.
[0060]
[0061] (x,y) are the coordinates of the pixel. σ is the standard deviation, which controls the smoothness of the filter: a larger σ means a stronger filter and a more blurred image. A smaller σ means a weaker filter and more detail is preserved.
[0062] The image is then binarized using the maximum inter-class variance method, and the most effective segmentation threshold is automatically calculated using automatic threshold selection, making the difference between the gear and the background in the image more obvious and achieving better segmentation effect.
[0063] S2: Gear positioning circle determination based on Hough transform
[0064] Based on S1, each edge point (x i ,y i ) to scan and obtain all circles that satisfy the following equation. If the edge point (x i ,y i ) belongs to a circle with radius r, then the center of the circle (a, b) must satisfy:
[0065] (ax i ) 2 +(by i ) 2 =r 2
[0066] Among them: The trajectory of the center (a, b) is (x i ,y i ) as the center and radius r is a circle.
[0067] Then for the radius range [r min ,r max ] to obtain the circle within the target radius. The formula is as follows:
[0068]
[0069] Where: δ is the impulse function, and N is the total number of edge points.
[0070] S3: Obtain mask circle by equivalent area
[0071] Based on S2, the hole filling method based on morphological filling is applied to the gear image. Connectivity analysis is performed on the binary image obtained through image preprocessing. The gear is marked as the foreground pixel region, and the completely enclosed gear hole region is marked as the outer background region for pixel filling. The filling process uses iterative dilation operations to gradually fill the gear hole region starting from the seed point, while using the complement of the original gear image as a constraint. Hole filling relies primarily on morphological and connectivity analysis.
[0072] Morphological hole filling reconstruction formula:
[0073]
[0074] Where: I is the original image, F is the labeled image, is the conditional reconstruction operator
[0075] Connectivity analysis is used to record the background components on the boundary as external background and the background components surrounded by foreground as holes. The external background and foreground are defined as follows.
[0076]
[0077] The pixel calculation method counts the number of effective pixels in the gear and calculates the area of the filled gear image. The pixel calculation method formula is as follows. Based on the principle of conservation of converted area, the filled gear image is converted into an equivalent circle with the same area, and the diameter of the circle with the same area is then determined.
[0078]
[0079] Where: BW is the M*N matrix of the binary image, A is the pixel area, BW(i,j)=1 represents the foreground gear image area, and BW(i,j)=0 represents the background area.
[0080] Then, the filled area of the gear image is equivalent to a circle and the diameter is calculated:
[0081]
[0082] Where A is the pixel area of the gear after pixel calculation. eq is the diameter.
[0083] S4: Gear mask circle segmentation to obtain gear tooth area
[0084] To process the gear teeth in the image, we need to create an all-zero matrix with the exact same dimensions as the original gear image as a base template. Each pixel in this matrix is initially zero, and its row and column dimensions strictly match those of the gear image. Next, we construct a circular mask on this all-zero matrix using the gear center circle diameter parameters calculated by S3. The key parameters of this circular mask are as follows: its diameter is directly measured using S3, while its center is located based on the (x, y) coordinates of the circle determined by S2 using the image processing algorithm. This circular mask serves as a region selection tool for subsequent image processing operations. Pixels within the masked area remain visible, while those outside are masked out. This precise size matching and parameter transfer ensures that subsequent image analysis and processing accurately focus on the gear teeth.
[0085] Z=0m*n*c
[0086] Among them, Z is an all-zero matrix, m is the image height (number of rows), n is the image width (number of columns), and c is the number of channels (grayscale image c=1).
[0087] For a circular mask in the gear image:
[0088]
[0089] Where: (x c ,y c ) is the coordinate of the center of the circle, r is the radius of the circle, and (x,y) is the pixel coordinate on the image plane.
[0090] Because the circular mask covers the central circle of the gear, and gear teeth are typically distributed outside the circumference, this operation effectively removes central interference, retaining only the outer edge of the gear. This allows image target statistics to more accurately focus on the gear tooth profile features, reducing interference from noise and redundant information.
[0091] I masked (x,y)=I(x,y)*M(x,y)
[0092] Where: I(x,y) is the original image, M(x,y) is the mask matrix, I masked (x,y) is the output image.
[0093] S5: Get the number of teeth based on the connected area marking
[0094] First, scan the gear image processed by S4, mark the foreground of the current pixel (tooth part), and then filter the marked area to remove the small noise area. The formula for marking the connected area by scanning the image and applying the equivalence relation is as follows:
[0095]
[0096] where k∈{1,2,...,N}.
[0097] Mark each connected area identified as a tooth in a different color, mark its center point with a serial number, and finally count the number of valid connected areas, which is the number of teeth on the gear.
[0098] The total number of targets is the process of counting the number of all non-overlapping connected regions:
[0099]
[0100] Where: N is the total number of gears.
[0101] See also Figures 2 to 4The present invention performs a tooth number detection process on 3D printed cylindrical spur gears, 3D printed spiral bevel gears, and machined spiral bevel gears. Figure 4 Since the background of the captured image is black and the machined spiral bevel gear is also black, the encounter of the two has a serious impact on image recognition. Therefore, a white background is laid at the bottom of the machined spiral bevel gear to significantly improve the contrast between the target gear and the background and effectively avoid the visual fusion of the black machined spiral bevel gear and the black background. Figures 2 to 4 It can be seen from the experimental data that the present invention can realize the visual tooth number counting of spiral spur gears, and the present invention can overcome the shortcomings of traditional visual tooth number counting of spur gears, and has good applicability for complex gears and high accuracy.
[0102] The above embodiments are intended only to illustrate the technical concepts and features of the present invention. Their purpose is to enable those skilled in the art to understand the contents of the present invention and implement them accordingly. They are not intended to limit the scope of protection of the present invention. Any equivalent transformations or modifications made in accordance with the present invention are intended to be encompassed within the scope of protection of the present invention.
Claims
1. A method for visually counting the number of teeth on spiral bevel gears, characterized in that: The steps include: Step 1: Obtain the spiral bevel gear image and preprocess the image; Step 2: Use Hough transform to determine the gear positioning circle and obtain the coordinates of the circle center; Step 3: Use morphological filling to fill the binary image inside the gear, calculate the overall area, regard the overall area as the equivalent area of the mask circle, and then calculate the mask circle diameter; Step 4: segment the gear binary image mask circle to obtain the gear tooth area; Step 5: Get the number of teeth based on the connected area marking.
2. A method for visually counting the number of teeth of spiral bevel gears according to claim 1, characterized in that: The preprocessing in step 1 includes performing Gaussian filtering to remove noise from the image and performing image segmentation using the maximum inter-class variance method, specifically: 1) By using the weighted average method and the characteristics of the Gaussian function to smooth the noise, the noise on the image is removed while retaining the edges and details of the gear image: Where (x, y) is the coordinate of the pixel point, σ is the standard deviation, which controls the smoothness of the filter; 2) The image is binarized using the maximum inter-class variance method, and the optimal segmentation threshold is automatically calculated using automatic threshold selection.
3. A method for visually counting the number of teeth of spiral bevel gears according to claim 1, characterized in that: In step 2, the gear positioning circle is determined by using Hough transform, and the coordinates of the center point are obtained as follows: Each edge point (x i ,y i ) to scan and obtain all circles that satisfy the following equations. If the edge point (x i ,y i ) belongs to a circle with radius r, then the center (a, b) must satisfy: (a-x i ) 2 +(b-y i ) 2 =r 2 Among them: The trajectory of the center (a, b) is (x i ,y i ) as the center and the radius is r; Then for the radius range [r min ,r max ] to obtain the circle within the target radius. The formula is as follows: Where: δ is the impulse function, and N is the total number of edge points.
4. A method for visually counting the number of teeth of spiral bevel gears according to claim 1, characterized in that: In step 3, the binary image is filled with the hole filling in morphological filling to fill the inside of the gear. The binary image obtained by image preprocessing is subjected to connectivity analysis, and the gear is recorded as the foreground pixel area, and the completely surrounded gear hole area is recorded as the external background area for pixel value filling. The filling process gradually fills the gear hole area starting from the seed point through iterative expansion operation, and uses the complement of the original gear image as a constraint condition.
5. A method for visually counting the number of teeth of spiral bevel gears according to claim 4, characterized in that: Morphological hole filling reconstruction formula: Where I is the original image, F is the labeled image, is the conditional reconstruction operator; Connectivity analysis is used to record the background components on the boundary as external background, and the background components surrounded by the foreground as holes. The external background and foreground are defined as follows:
6. A method for visually counting the number of teeth of spiral bevel gears according to claim 1, characterized in that: The specific method for obtaining the mask circle diameter in step 3 is: The number of effective pixels of the gear is counted by the pixel calculation method, and the area of the filled gear image is calculated. The pixel calculation method formula is as follows. Where: BW is the M*N matrix in the binary image, A is the pixel area, BW(i,j)=1 is the foreground gear image area, and BW(i,j)=0 is the background area; Based on the principle of conservation of conversion area, the filled gear image is converted into an equivalent circle with the same area, and then the diameter of the circle with the same area is determined. The diameter calculation is: Among them, A is the pixel area of the gear after pixel calculation, D eq is the diameter.
7. A method for visually counting the number of teeth of spiral bevel gears according to claim 1, characterized in that: In step 4, the gear binary image mask circle is segmented to obtain the gear tooth area, specifically as follows: Create an all-zero matrix with the same size as the original gear image as the basic template. The initial value of each pixel is zero, and its row and column sizes are strictly consistent with the gear image. Using the gear center circle diameter parameters calculated in step 3, a circular mask is constructed on this all-zero matrix. The key parameter setting of the circular mask is the diameter directly adopting the gear center circle diameter, while the center position is located according to the center coordinates determined by the image processing algorithm in step 2. The circular mask will serve as a region selection tool for subsequent image processing operations, where pixels within the mask area will remain visible, while the outer area will be masked. Circular mask in gear image Where: (x c ,y c ) is the coordinate of the center of the circle, r is the radius of the circle, and (x, y) is the pixel coordinate on the image plane; Since the circular mask covers the center circle area of the gear, and the teeth of the gear are usually distributed outside the circumference, it effectively removes the center interference and retains the outer edge tooth structure of the gear; I masked (x,y)=I(x,y)*M(x,y) Where: I(x,y) is the original image, M(x,y) is the mask matrix, I masked (x,y) is the output image.
8. A method for visually counting the number of teeth of spiral bevel gears according to claim 1, characterized in that: The specific process of step 5 is: Scan the gear image processed in step 4, mark the foreground of the current pixel, and then perform area screening on the marked area to remove the noise area. Scan the image and apply the equivalence relationship to mark the connected area formula as follows: where k∈{1,2,...,N}; Mark each connected area identified as a tooth in a different color, mark its center point with a serial number, and finally count the number of valid connected areas, which is the number of teeth on the gear.