A transmission shaft component defect detection method and system based on image processing

Through dynamic correction of grayscale values ​​and adaptive filtering technology, the problems of noise residue and edge blur in traditional spline gear edge detection are solved, more accurate defect detection is achieved, and the accuracy and automation level of transmission shaft parts detection are improved. .

CN118552549BActive Publication Date: 2024-11-01SHAANXI LANTONG TRANSMISSION SHAFT
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411031173.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-11-01
Estimated Expiration
2044-07-30

AI Technical Summary

Technical Problem

The Gaussian filtering effect in traditional spline gear edge detection is poor, resulting in noise residue and edge blur, affecting the accuracy of defect detection, especially in areas with high noise or complex textures.

Method used

By calculating the noise level and contrast of each pixel point, dynamically correcting the grayscale value, and combining distance weights and similarity, adaptive filtering is performed to ensure that image details and edge information are preserved while suppressing noise, and thus more precise edges Test.

Benefits of technology

It significantly improves the accuracy and automation of defect detection, enhances the efficiency and accuracy of defect detection of transmission shaft parts, and ensures the quality of parts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118552549B_ABST
    Figure CN118552549B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of image processing technology, and in particular to a method and system for detecting defects in transmission shaft parts based on image processing. The method comprises: selecting an arbitrary pixel point as a central pixel point from a surface grayscale image of a spline gear, evaluating its noise level, comprehensively considering the noise level, the contrast and grayscale difference between the central pixel point and neighboring pixel points, positively correlating the grayscale value of the central pixel point, assigning different distance weights according to the similarity between the neighboring pixel points and the central pixel point, calculating the filtering value of the central pixel point according to the corrected grayscale value of the neighboring pixel point and the distance weight between the neighboring pixel point and the central pixel point, obtaining a filtered image, extracting the spline gear contour by edge detection, and comparing with a preset defect image to determine whether there is damage. The method combines local statistics with weight adjustment to ensure the fidelity of edge details, while effectively suppressing noise interference, thereby improving the accuracy and reliability of defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a method and system for detecting defects of transmission shaft parts based on image processing. Background Art

[0002] Spline is a common transmission shaft component. Through precise rotational motion in the transmission system, it ensures the smooth and lossless transmission of torque, thereby supporting the efficient operation and overall safety of mechanical equipment. However, over time, splines may gradually deform or become damaged due to continuous mechanical stress and wear, or due to slight deviations in the manufacturing process. If these tiny but critical defects are not detected and corrected in time, they will quietly erode the performance of the equipment. In severe cases, they may even trigger safety hazards, threatening the stability of the production line and the safety of operators.

[0003] Traditionally, spline inspection relies on manual visual inspection, which is intuitive but inefficient and limited in accuracy, and cannot meet the needs of modern manufacturing for high precision and automation. Manual inspection is not only time-consuming and labor-intensive, but also restricted by personal experience and visual limitations, making it difficult to ensure consistency and reliability of inspection.

[0004] To meet the above challenges, modern detection technology has begun to turn to image processing, aiming to automatically identify the edge features of spline gears through intelligent image analysis methods to determine whether there are defects. For example, a Chinese patent document with announcement number CN115049667B provides a gear defect detection method, including: obtaining a surface image of the gear to be detected, and then obtaining a gear area image of the surface image; according to the gear area image, determining the gear edge, gear center point and each real corner point, and then determining each suspected corner point and pseudo corner point, thereby determining the distance defect index value, area defect index value and angle defect index value of the gear; combining these three defect index values, calculating the comprehensive defect index value of the gear, and finally determining the defect level of the gear.

[0005] However, the traditional process of edge detection of spline gears relies on Gaussian filtering to pre-process the image for denoising, and edge extraction is performed based on the denoised image. Although Gaussian filtering helps to reduce noise, in areas with high noise, especially salt and pepper noise, the image after Gaussian filtering may still have residual noise, causing the edge detection algorithm to mistakenly identify these areas as noise edges, or make the real edge information blurred. In addition, when processing areas with complex or low-contrast textures containing multiple gears, the smoothing effect of Gaussian filtering may weaken the clarity of the edge, resulting in the edge position identified by the edge detection algorithm to be inaccurate, or generating false edges in areas with rich textures, resulting in errors in the subsequent calculation of gear features, reducing the accuracy of defect detection results. Summary of the invention

[0006] In order to solve the problem that in the process of extracting the edge of the spline gear using the edge detection algorithm, the edge detection result is not accurate enough due to the poor Gaussian filtering effect, which affects the accuracy of subsequent defect detection, the present invention proposes a transmission shaft component defect detection method and system based on image processing, which specifically adopts the following scheme:

[0007] In one aspect, the present invention provides a method for detecting defects of transmission shaft parts based on image processing, comprising:

[0008] Obtain a grayscale image of the surface of the spline gear, take any pixel point in the grayscale image as the central pixel point, calculate a first grayscale value variance when the central pixel point is not included in the neighborhood range of the central pixel point, and a second grayscale value variance when the central pixel point is included in the neighborhood range, and use the absolute value of the difference between the first grayscale value variance and the second grayscale value variance as the noise level of the central pixel point; the neighborhood range includes multiple neighborhood pixel points;

[0009] Based on the noise level of the central pixel, the contrast between the grayscale values ​​of the central pixel and a plurality of the neighboring pixels, and the grayscale value difference between the grayscale value of the central pixel and the average grayscale value of a plurality of the neighboring pixels, a corrected grayscale value of the central pixel is calculated, wherein the corrected grayscale value is positively correlated with the noise level, the contrast, and the grayscale value difference;

[0010] Calculate the filter value of the central pixel:

[0011]

[0012] In the formula, For the The filter value of the central pixel, For the The corrected gray value of the neighboring pixels is For the The neighboring pixels and The distance weight of the central pixel is negatively correlated with the distance between the two. For the The neighboring pixels and The similarity of the central pixels, is the number of pixels in the neighborhood;

[0013] A filtered image is obtained based on the filtering values ​​of all central pixels, and edge detection is performed. The defect detection result is obtained by comparing the spline gear edge in the edge detection result with the pre-defect image.

[0014] The above technical solution calculates the grayscale variance within the neighborhood of the central pixel. The larger the variance, the greater the grayscale fluctuation, and the more likely the central pixel is to have noise. This makes a preliminary assessment of the noise possibility of each central pixel, and incorporates the contrast and grayscale value difference between the central pixel and the neighborhood pixel into the calculation of the corrected grayscale value to ensure that while suppressing noise, the details and edge information of the image are effectively retained to avoid edge blurring caused by excessive smoothing. Based on the similarity between the neighborhood pixel and the central pixel, the distance weight in the filtering process is weighted, so that pixels with close distances and similar grayscales contribute more to the filtering process, achieving more refined local adjustments, and calculating the product of the corrected grayscale value of the neighborhood pixel and the weighted distance. Accumulation, as well as the accumulation of weights, obtains the filtering value of the central pixel. This process enhances the adaptability of the filter and can be flexibly adjusted according to the characteristics of different areas. It not only suppresses noise through filtering but also retains high-quality images with image details. Finally, edge detection is performed based on the filtered image, which can more accurately identify the edge of the spline gear, improve the accuracy and reliability of defect detection, and compare the detected edge with the preset defect image template. It can automatically identify and locate potential wear or deformation areas, and improve the degree of automation of defect detection. In short, this method can effectively cope with part defect detection under different background noise and complex texture conditions, improve the efficiency and accuracy of defect detection of transmission shaft components, and ensure part quality to a certain extent.

[0015] Furthermore, the corrected grayscale value of the central pixel is calculated according to the following relationship:

[0016]

[0017] In the formula, For the The gray value of the center pixel after correction, For the The gray value of the center pixel, is the average grayscale value of multiple neighborhood pixels, No. The contrast between the grayscale values ​​of a central pixel and a plurality of the neighboring pixels, For the The noise level of the central pixel is is the natural exponential function, is the ceiling function.

[0018] The above technical solution corrects the grayscale value by combining the noise level and contrast. The formula can perform more intense smoothing in high-noise areas in a targeted manner, while retaining more details in low-noise or edge areas, thereby achieving an effective balance between noise suppression and detail retention. The product of the natural exponential function and the contrast in the formula ensures that the grayscale value correction of the pixel point can be dynamically adjusted according to its noise level and the contrast of the surrounding environment.

[0019] Furthermore, the distance weights between the neighborhood pixel points and the central pixel point satisfy the following relationship:

[0020]

[0021] In the formula, For the The neighboring pixels and The distance weight of the center pixel, For the The neighboring pixels and The Euclidean distance between the center pixels.

[0022] The above technical solution defines the distance weights of neighborhood pixels and central pixels. The distance weights are inversely related to the Euclidean distance between the two. This formula ensures that the neighboring pixels have a greater influence on the filtering value of the central pixel, effectively maintaining the local features and details of the image. As the distance increases, the distance weights of the pixels decrease, which makes the noise points in the distance have less influence on the filtering value of the central pixel, thereby automatically suppressing the noise far away from the center point during the filtering process and improving the accuracy of the filtering process.

[0023] Furthermore, the similarity between the neighborhood pixel and the central pixel is calculated based on the grayscale difference between the neighborhood pixel and the central pixel, and satisfies the following formula:

[0024]

[0025] In the formula, For the The neighboring pixels and The similarity of the central pixels, For the The gray value of the neighboring pixels, For the The gray value of the center pixel, is the average of the differences between the grayscale values ​​of the plurality of neighboring pixels and the grayscale value of the central pixel, is the number of neighborhood pixels, is a natural exponential function.

[0026] The above technical solution calculates similarity based on grayscale difference. The formula can accurately measure the grayscale matching degree between the neighborhood pixels and the central pixel, ensuring that the information with grayscale close to the central pixel is retained first during the filtering process, effectively protecting the details and texture of the image and avoiding information loss. In addition, the formula construction weakens the influence of the neighborhood pixels with large grayscale difference on the central pixel, which helps to automatically suppress noise when processing images. At the same time, due to the use of the average grayscale difference of the neighborhood pixels, ,This method can adaptively adjust the weight of similarity and balance noise suppression and ,retention of key features.

[0027] Furthermore, the method for obtaining the contrast between the grayscale values ​​of the central pixel and the plurality of neighboring pixel points is as follows:

[0028] According to the grayscale value difference between the maximum grayscale value and the minimum grayscale value of the plurality of neighborhood pixels and the standard deviation of the grayscale values ​​of the central pixel and the plurality of neighborhood pixels, the contrast of the grayscale values ​​of the central pixel and the plurality of neighborhood pixels is calculated, and the contrast is positively correlated with the grayscale value difference and negatively correlated with the standard deviation of the grayscale value.

[0029] Furthermore, the contrast between the grayscale values ​​of the central pixel and the plurality of neighboring pixel points satisfies the following relationship:

[0030]

[0031] In the formula, For the The contrast between the grayscale values ​​of a central pixel and a plurality of the neighboring pixels, For the The maximum gray value among the central pixel and the plurality of neighboring pixel points, For the The minimum gray value among the central pixel and the plurality of neighboring pixel points, For the The standard deviation of the grayscale values ​​of a central pixel and a plurality of the neighborhood pixels.

[0032] The above technical solution calculates the maximum and minimum differences in the grayscale values ​​of the central pixel and the neighboring pixels, and divides it by the standard deviation of the grayscale values. This formula can highlight the edges and high-contrast areas in the image, and effectively enhance the sensitivity of the image processing algorithm to details and boundary information. In areas with high noise or little change in grayscale values, the contrast will be relatively low, so that the noise in these areas will be more strongly suppressed in subsequent processing. In subsequent processing, a stronger enhancement effect is provided for high-contrast areas (such as edges and details), while sharpening is reduced for low-contrast or smooth areas, thereby improving image clarity while avoiding artifacts or distortion caused by over-sharpening.

[0033] Furthermore, the method for obtaining the corrected grayscale values ​​of the plurality of neighborhood pixels is the same as the method for obtaining the corrected grayscale value of the central pixel.

[0034] On the other hand, the present invention also provides a transmission shaft component defect detection system based on image processing, the defect detection system includes a memory and a processor, the memory stores a computer program, and the processor executes the computer program to implement any step of the monitoring method.

[0035] The present invention has the following effects:

[0036] The present invention realizes adaptive filtering of images by evaluating the noise level of images and adaptively adjusting the grayscale values ​​of pixels. This method effectively suppresses noise while finely preserving image details and edges, avoiding over-smoothing, and significantly improving image quality. Based on the optimized image, edge detection is more accurate, and wear and deformation can be automatically identified by comparison with preset defect templates, thereby improving the accuracy and automation level of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:

[0038] Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION

[0039] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0040] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0041] Reference Figure 1 , a transmission shaft component defect detection method based on image processing, comprising steps S1 to S4, specifically as follows:

[0042] S1: Collect the surface image of the spline gear.

[0043] An industrial camera is used to collect images in an environment with uniform lighting. According to the size and shape of the spline area surface of the transmission shaft, a suitable shooting angle and distance are selected to ensure that the surface details of the spline component area can be fully captured. The collected image is grayscaled to obtain a surface grayscale map. The grayscale image is traversed to obtain the grayscale value of each pixel. Then, any pixel is taken as the central pixel, and its eight neighboring pixels are used as the neighborhood range of the central pixel.

[0044] S2: Calculate the corrected grayscale value of each central pixel.

[0045] S21: Evaluate the noise level of each central pixel as follows:

[0046] Calculate the first gray value variance when the neighborhood does not include the central pixel point, and the second gray value variance when the neighborhood includes the central pixel point, and take the absolute value of the difference between the first gray value variance and the second gray value variance as the noise level of the central pixel point.

[0047] This method calculates the absolute value of the grayscale variance difference when the central pixel is not included in the neighborhood and when the central pixel is included. This method can accurately quantify the degree of abnormality of the central pixel relative to its surrounding environment, effectively distinguish noise points from normal image information, and is particularly suitable for processing random noise such as salt and pepper noise.

[0048] S22: Evaluate the contrast between the grayscale values ​​of the central pixel and the plurality of neighboring pixel points. Specifically, the contrast between the grayscale values ​​of the central pixel and the plurality of neighboring pixel points is obtained by:

[0049] According to the grayscale value difference between the maximum grayscale value and the minimum grayscale value of the plurality of the neighborhood pixels, and the standard deviation of the grayscale values ​​of the central pixel and the plurality of the neighborhood pixels, the contrast of the grayscale values ​​of the central pixel and the plurality of the neighborhood pixels is calculated. The contrast is positively correlated with the grayscale value difference and negatively correlated with the standard deviation of the grayscale value, and is expressed by the formula:

[0050]

[0051] In the formula, For the The contrast between the grayscale values ​​of a central pixel and a plurality of the neighboring pixels, For the The maximum gray value among the central pixel and the plurality of neighboring pixel points, For the The minimum gray value among the central pixel and the plurality of neighboring pixel points, For the The standard deviation of the grayscale values ​​of a central pixel and a plurality of the neighborhood pixels.

[0052] This formula can accurately evaluate the contrast significance of the central pixel by calculating the difference in grayscale values ​​between each pixel and the darkest and brightest pixels in its neighborhood, as well as the ratio of these differences to the average difference in grayscale values ​​of the neighborhood pixels. A high ratio usually indicates that the pixel has significant contrast and may be located in the edge area of ​​the image or affected by noise.

[0053] S23: Calculate the corrected grayscale value of the central pixel, wherein the corrected grayscale value is positively correlated with the noise level, the contrast, and the grayscale value difference.

[0054] Specifically, the corrected grayscale value of the central pixel is calculated according to the following relationship:

[0055]

[0056] In the formula, For the The gray value of the center pixel after correction, For the The gray value of the center pixel, is the average grayscale value of multiple neighborhood pixels, No. The contrast between the grayscale values ​​of a central pixel and a plurality of the neighboring pixels, For the The noise level of the central pixel is is the natural exponential function, is the ceiling function.

[0057] The formula aims to dynamically correct the grayscale value of each central pixel in the image by comprehensively considering the noise level, contrast, and grayscale value difference of the central pixel, so as to achieve a balance between noise suppression and detail preservation. Specifically:

[0058] The noise level in the formula is positively correlated with the corrected grayscale value, which means that the greater the noise of the central pixel, the greater the correction amplitude of its grayscale value, thereby effectively suppressing the noise; the contrast is also positively correlated with the corrected grayscale value, indicating that in the edge or high-contrast area, the grayscale value correction of the pixel will be more conservative to prevent the blurring of the edge information, thereby retaining the key features of the image; the use of the natural exponential function introduces a nonlinear effect, so that the influence of the noise level and contrast significance on the grayscale value correction is not a simple linear relationship, but increases exponentially with the increase of these two parameters, which enhances the noise suppression effect while protecting the details; and introduces the difference between the average grayscale value of the central pixel and the neighborhood pixel. , identify the abnormality of the gray value of the central pixel relative to the neighboring pixels.

[0059] By dynamically adjusting the grayscale value, the noise is moderately smoothed while avoiding excessive smoothing of the real details and edges in the image.

[0060] S3: Determine the filtering value of the central pixel according to the corrected grayscale value of each central pixel, the similarity between the neighborhood pixels and the central pixel, and the distance weight between the neighborhood pixels and the central pixel.

[0061] Although the grayscale value of the image has been initially corrected based on contrast and noise level in step S2, this single-dimensional adjustment strategy may lead to an imbalance in the correction, especially for high-contrast pixels, which are easily misjudged as noise and suffer from over-correction. In fact, these points are often the carriers of image features or edge information. To circumvent this limitation, the idea of ​​Gaussian filtering in the traditional LoG (Laplacian of Gaussian) operator is borrowed, and innovative upgrades are made on this basis. Although the traditional Gaussian filtering uses the distance between pixels as the weight for filtering, ensuring the consideration of spatial position, it ignores the correlation between the grayscale values ​​​​of pixels, which is particularly unfavorable in edge areas, because simple Gaussian filtering tends to smooth the image, which may blur the edge features and affect the clarity and detail retention of the image.

[0062] Therefore, this step introduces a new filtering strategy that combines the correlation between spatial distance and grayscale value. It aims to distinguish edge pixels from pixels far away from the edge through precise distance weights when processing edge pixels, avoid blurring of edge information due to excessive influence of neighboring pixels, ensure the sharpness of image edges and retention of details, and ensure that the filtering process not only smooths noise, but also retains or enhances key features of the image, such as edges and textures.

[0063] S31: Analyze the similarity between the neighborhood pixel points and the central pixel point. Specifically, the similarity between the neighborhood pixel points and the central pixel point is calculated based on the grayscale difference between the neighborhood pixel points and the central pixel point.

[0064] In the field of image processing, the similarity and consistency of grayscale values ​​between pixels are key indicators for evaluating local image features and performing noise suppression. The grayscale similarity between pixels is calculated in order to use the grayscale similarity to adjust the distance weight and obtain an accurate distance weight.

[0065] Among them, the similarity between the neighborhood pixel and the central pixel satisfies the following formula:

[0066]

[0067] In the formula, For the The neighboring pixels and The similarity of the central pixels, For the The gray value of the neighboring pixels, For the The gray value of the center pixel, is the average of the differences between the grayscale values ​​of the plurality of neighboring pixels and the grayscale value of the central pixel, is the number of the plurality of neighborhood pixels, is a natural exponential function.

[0068] This formula combines the grayscale difference between pixels and the statistical characteristics of the grayscale value distribution in the neighborhood, aiming to provide more refined distance weight adjustment for subsequent image processing steps to ensure the accuracy of image processing and detail retention.

[0069] For The center pixel is Grayscale difference of neighboring pixels The smaller it is, the closer the grayscale values ​​of the two pixels are, which means that the grayscale consistency within the neighborhood is high.

[0070] in the formula This part calculates the average of the difference between the grayscale values ​​of multiple neighborhood pixels and the grayscale value of the central pixel. The standard deviation is a key statistical indicator to measure the degree of dispersion of a data set. It reflects the fluctuation of the grayscale difference between all neighboring pixels and the central pixel. The smaller the value, the more consistent the grayscale difference between all neighboring pixels and the central pixel, which means that the grayscale difference between the central pixel and the neighboring pixels is small. The higher the confidence level, the The neighboring pixels and The similarity of the central pixels The higher.

[0071] In the formula The function converts the product of the grayscale difference and the neighborhood distribution into a similarity weight, and amplifies or reduces the influence of similarity in an exponential form. When the product of the grayscale difference and the neighborhood distribution is large, The value of will decrease rapidly, and vice versa it will increase slowly, thus forming a nonlinear similarity adjustment mechanism to adaptively adjust the similarity weights between the neighborhood pixels and the central pixel, ensuring that when processing images, noise can be effectively suppressed while retaining image details and edge information, thereby improving the accuracy and robustness of image processing.

[0072] S32: Setting the distance weight between the neighborhood pixel point and the central pixel point. Specifically, the distance weight between the neighborhood pixel point and the central pixel point satisfies the following relationship:

[0073]

[0074] In the formula, For the The neighboring pixels and The distance weight of the center pixel, For the The neighboring pixels and The Euclidean distance between the center pixels.

[0075] This formula is used to adjust the influence of the neighborhood pixels on the central pixel. The formula shows that the weight of the neighborhood pixels is inversely proportional to the distance between the neighborhood pixels and the central pixel, which means that the closer the neighborhood pixels are to the central pixel, the greater their influence on the filter value of the central pixel. On the contrary, the farther the distance, the smaller the influence. This weight distribution mechanism ensures that the local characteristics in image processing are preserved, avoiding the excessive influence of distant pixels on the central pixel value, thereby protecting the details and edge information of the image.

[0076] S33: Determine the filtering value of the central pixel. Specifically, the filtering value of the central pixel satisfies the following relationship:

[0077]

[0078] In the formula, For the The filter value of the central pixel, For the The grayscale value of the center pixel is corrected, and the method for obtaining the grayscale value of each neighboring pixel after correction is the same as the method for obtaining the grayscale value of the center pixel after correction. For the The neighboring pixels and The distance weight of the central pixel is negatively correlated with the distance between the two. For the The neighboring pixels and The similarity of the gray values ​​of the central pixels, is the number of pixels in the neighborhood.

[0079] In this formula, Is to use the The neighboring pixels and The similarity of the central pixels is The neighboring pixels and The distance weights of the central pixels are weighted. The reasons for this operation are:

[0080] The distance between the neighborhood pixel and the center pixel reflects the spatial proximity between the neighborhood pixel and the center pixel. In theory, the closer the pixels are in space, the more likely they are to share the same structural properties, suggesting that they may belong to the same region or feature in the image. However, there are exceptions in reality. For example, the pixels in the edge area may be closest to the pixels in the normal area. This physical proximity is not always equivalent to the structural or feature association. Therefore, simply relying on spatial distance to adjust pixel weights may introduce misleading information, especially in tasks such as edge detection or feature recognition. In order to solve this problem, it is necessary to further analyze the grayscale similarity of pixels in the neighborhood. Grayscale similarity not only reflects the visual consistency between pixels, but also indirectly indicates their association at the image feature level. Pixels with high grayscale similarity are more likely to belong to the same image region or feature, while pixels with large differences may mark the existence of edges, details or noise. By introducing grayscale similarity to dynamically adjust weights, the algorithm can effectively distinguish and protect key edge information while suppressing noise interference during image smoothing.

[0081] therefore, The larger the value, the The neighboring pixels and The closer the spatial distance between the center pixels and the higher the similarity of the grayscale values, the closer the center pixels are. The neighboring pixel pairs The central pixel has a greater influence and should be given a greater weight in the correction process.

[0082] The numerator in the formula calculates the corrected grayscale value of all neighboring pixels. The sum of the products of their corresponding distance weights and similarities, is the gray value corrected for noise level and contrast, and and They respectively reflect the distance relationship between the neighborhood pixels and the central pixel and the similarity of the grayscale values. This calculation method ensures that pixels with close distances and similar grayscale values ​​contribute more to the filter value of the central pixel, reflecting the algorithm's adaptability and detail retention capabilities. The denominator in the formula serves as a normalization factor, ensuring that the calculation of the filter value is within a reasonable range.

[0083] By comprehensively considering the corrected grayscale value, distance weight, and grayscale value similarity of neighboring pixels, the formula can adaptively adjust the filter value of the central pixel to adapt to the characteristics of different areas in the image. In areas with more noise, the combined effect of distance weight and similarity will prompt the algorithm to focus more on smoothing, while in areas with edges or obvious features, the algorithm will pay more attention to preserving details and avoiding edge blurring caused by over-smoothing.

[0084] At this point, according to the method in S1-S3, the filtering values ​​of all pixels can be obtained, the filtering process of the image is completed, and a high-quality filtered image is obtained.

[0085] S4: Perform edge detection based on the filtered image, and perform defect detection based on the edge detection result.

[0086] The classic edge detection algorithm is applied to perform edge detection on the filtered image to generate a clear edge binary image to ensure that the contour structure of the spline gear in the image is accurately depicted. Then, the spline gear edge in the edge detection result is compared with the pre-defect image to obtain the corresponding defect detection result. Here, the template matching algorithm can be used to match the pre-defect edge image with the edge of the spline gear in the edge detection result. If the match with a certain defect edge image is successful, it means that this type of defect exists and the staff is reminded. If no match is successful, there is no defect and no reminder is given.

[0087] Among them, the classic edge detection algorithms include:

[0088] The Canny edge detection algorithm is a multi-stage edge detection algorithm that first applies a Gaussian filter to smooth the image to reduce noise, then calculates the gradient magnitude and direction of the image, refines the edge and suppresses false responses through non-maximum suppression (NMS) and double threshold detection, and finally performs edge connection to determine the final edge.

[0089] The LoG operator is actually a combination of a Gaussian filter and a Laplace operator. It first applies a Gaussian filter to the image and then applies the Laplace operator to the result, thereby finding zero crossing points in the image as edge locations. Although the Sobel operator itself is not directly combined with a Gaussian filter, it is often used in conjunction with a Gaussian filter. First, a Gaussian filter is applied to reduce noise, and then the Sobel operator is used to calculate the gradient of the image to detect edges.

[0090] For any of the above algorithms, Gaussian filtering is performed on the image before edge detection to reduce noise and smooth the image, and then edge detection is performed on the image after Gaussian filtering. In practical applications, the Gaussian filtering before edge detection is replaced by the filtering scheme of the present invention to obtain an image with better filtering effect, thereby enabling accurate edge detection and ensuring the accuracy and reliability of defect detection.

[0091] The present invention also provides a transmission shaft component defect detection system based on image processing, the defect detection system includes a memory and a processor, the memory stores a computer program, and the processor executes the computer program to implement the steps of any one of the monitoring methods.

[0092] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.

[0093] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.

Claims

1. A transmission shaft component defect detection method based on image processing, characterized in that: include: Obtain a grayscale image of the surface of the spline gear, take any pixel point in the grayscale image as the central pixel point, calculate a first grayscale value variance when the central pixel point is not included in the neighborhood range of the central pixel point, and a second grayscale value variance when the central pixel point is included in the neighborhood range, and use the absolute value of the difference between the first grayscale value variance and the second grayscale value variance as the noise level of the central pixel point; the neighborhood range includes multiple neighborhood pixel points; Based on the noise level of the central pixel, the contrast between the grayscale values ​​of the central pixel and a plurality of the neighboring pixels, and the grayscale value difference between the grayscale value of the central pixel and the average grayscale value of a plurality of the neighboring pixels, a corrected grayscale value of the central pixel is calculated, wherein the corrected grayscale value is positively correlated with the noise level, the contrast, and the grayscale value difference; Calculate the filter value of the central pixel: ; In the formula, For the The filter value of the central pixel, For the The corrected gray value of the neighboring pixels is For the The neighboring pixels and The distance weight of the central pixel is negatively correlated with the distance between the two. For the The neighboring pixels and The similarity of the central pixels, is the number of pixels in the neighborhood; A filtered image is obtained based on the filtering values ​​of all the central pixels, and edge detection is performed. The defect detection result is obtained by comparing the spline gear edge in the edge detection result with the pre-defect image; The corrected grayscale value of the central pixel is calculated according to the following relationship: ; In the formula, For the The gray value of the center pixel after correction, For the The gray value of the center pixel, is the average grayscale value of multiple neighborhood pixels, No. The contrast between the grayscale values ​​of a central pixel and a plurality of the neighboring pixels, For the The noise level of the central pixel is is the natural exponential function, is the ceiling function.

2. The transmission shaft component defect detection method based on image processing according to claim 1 is characterized in that: The distance weights between the neighborhood pixel points and the central pixel point satisfy the following relationship: ; In the formula, For the The neighboring pixels and The distance weight of the center pixel, For the The neighboring pixels and The Euclidean distance between the center pixels.

3. The transmission shaft component defect detection method based on image processing according to claim 1 is characterized in that: The similarity between the neighborhood pixel and the central pixel is calculated based on the grayscale difference between the neighborhood pixel and the central pixel, and satisfies the following formula: ; In the formula, For the The neighboring pixels and The similarity of the central pixels, For the The gray value of the neighboring pixels, For the The gray value of the center pixel, is the average of the differences between the grayscale values ​​of the plurality of neighboring pixels and the grayscale value of the central pixel, is the number of neighborhood pixels, is a natural exponential function.

4. The transmission shaft component defect detection method based on image processing according to claim 1 is characterized in that: The method for obtaining the contrast between the grayscale values ​​of the central pixel and the plurality of neighboring pixel points is as follows: According to the grayscale value difference between the maximum grayscale value and the minimum grayscale value of the plurality of neighborhood pixels and the standard deviation of the grayscale values ​​of the central pixel and the plurality of neighborhood pixels, the contrast of the grayscale values ​​of the central pixel and the plurality of neighborhood pixels is calculated, and the contrast is positively correlated with the grayscale value difference and negatively correlated with the standard deviation of the grayscale value.

5. The transmission shaft component defect detection method based on image processing according to claim 4 is characterized in that: The contrast between the grayscale values ​​of the central pixel and the plurality of neighboring pixels satisfies the following relationship: ; In the formula, For the The contrast between the grayscale values ​​of a central pixel and a plurality of the neighboring pixels, For the The maximum gray value among the central pixel and the plurality of neighboring pixel points, For the The minimum gray value among the central pixel and the plurality of neighboring pixel points, For the The standard deviation of the grayscale values ​​of a central pixel and a plurality of the neighborhood pixels.

6. The transmission shaft component defect detection method based on image processing according to claim 5 is characterized in that: The method for obtaining the corrected grayscale values ​​of the plurality of neighborhood pixels is the same as the method for obtaining the corrected grayscale value of the central pixel.

7. A transmission shaft component defect detection system based on image processing, characterized in that: The defect detection system comprises a memory and a processor, wherein a computer program is stored in the memory, and the processor executes the computer program to implement the steps of the defect detection method according to any one of claims 1 to 6.