Automobile precision component surface defect detection method and system based on machine vision

By calculating the local window texture consistency and grayscale imbalance value of the automotive component image, low weights are set for the highlight areas, which solves the problem of misjudgment in the highlight areas of the traditional SSIM algorithm and improves the accuracy and robustness of the detection results.

CN121563991BActive Publication Date: 2026-04-10XIANKE PRECISION COMPONENTS (KUNSHAN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-01-23
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Traditional SSIM algorithms are prone to misjudgment when dealing with localized highlights on automotive components, resulting in a high false alarm rate and an inability to accurately obtain component precision detection results.

Method used

By calculating the texture consistency value and neighborhood imbalance value of the local window of a pixel, adaptive weights are generated for the SSIM algorithm, reducing the influence of local highlight areas and improving the accuracy of detection results.

Benefits of technology

It effectively reduces the interference of localized high-brightness areas on the detection results, significantly reduces the false alarm rate, and improves the accuracy and robustness of automated component precision detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121563991B_ABST
    Figure CN121563991B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of image data processing, and more particularly to a method and system for detecting surface defects of automobile precision components based on machine vision. The method comprises the steps of: determining a texture consistency value of a local window of a pixel in a gray image of a component to be detected, the texture consistency value being used to evaluate the consistency degree of the gradient direction of the pixels in the local window; calculating a neighborhood imbalance value of the pixel based on the gray difference and spatial distance between the pixel and other pixels in the local window; generating a weight for representing the importance degree of the pixel in the calculation of a structural similarity index according to the texture consistency value and the neighborhood imbalance value of the local window of the pixel; and applying the weight of the pixel to an SSIM algorithm to obtain a weighted structural similarity index of the gray image of the component to be detected, thereby obtaining a precision detection result of the gray image of the component to be detected and effectively improving the accuracy of the precision detection result of the component.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image data processing technology, and in particular to a method and system for detecting surface defects in precision automotive components based on machine vision. Background Technology

[0002] In modern industrial manufacturing, the precision of automotive components directly affects the quality of the final product, making efficient and accurate inspection crucial. Computer vision-based automated inspection technology, by acquiring surface images of components, extracting their geometric features such as size, shape, contour, surface flatness, and defects, and comparing them with standard template images, can quickly identify flaws and has become a mainstream inspection method.

[0003] The Structural Similarity Index (SSIM) algorithm is a key technique commonly used to evaluate the similarity between two images. By comparing the brightness, contrast, and structural information of the images, it can effectively reflect the defects on the surface of components.

[0004] However, in real-world industrial environments, automotive components are typically made of metal with complex curved surfaces, making them highly susceptible to localized highlights under lighting conditions. Traditional block-based SSIM algorithms assign equal weight to the SSIM values ​​of all image blocks when calculating overall similarity. When localized highlights exist in the image of the component under test, these highlighted areas differ significantly from the standard image due to their extremely high brightness, resulting in a significantly lower SSIM value for the corresponding block. This lower value is given the same weight as other normal areas in the averaging calculation, excessively lowering the overall SSIM average. This can cause the system to misclassify defective components as substandard due to the presence of highlights, leading to a high false alarm rate.

[0005] Therefore, how to accurately obtain component accuracy detection results based on component images is an urgent problem to be solved. Summary of the Invention

[0006] To address the technical challenge of accurately obtaining component precision detection results based on component images, this invention provides a machine vision-based method and system for detecting surface defects in automotive precision components.

[0007] In a first aspect, the present invention provides a method for detecting surface defects in precision automotive components based on machine vision, employing the following technical solution:

[0008] A machine vision-based method for detecting surface defects in precision automotive components includes the following steps:

[0009] For a local window of a pixel in the grayscale image of the component to be detected, a texture consistency value is determined for that local window. This texture consistency value is used to evaluate the consistency of the pixel gradient direction within the local window. For the local window of a pixel, a neighborhood imbalance value is calculated based on the grayscale difference and spatial distance between that pixel and other pixels in the local window. This neighborhood imbalance value is used to characterize the degree of grayscale imbalance in the local window. Based on the texture consistency value and neighborhood imbalance value of the local window, weights are generated to characterize the importance of the pixel in the calculation of the structural similarity index. The pixel weights are then applied to the SSIM algorithm to obtain the weighted structural similarity index of the grayscale image of the component to be detected, thus obtaining the accuracy detection result of the grayscale image of the component to be detected.

[0010] This invention assesses the similarity between the grayscale image of the component to be detected and the image of a standard component by obtaining a weighted structural similarity index, thus accurately obtaining the precision detection result of the grayscale image of the component to be detected. In obtaining the weighted structural similarity index, this invention considers the relatively chaotic texture and grayscale distribution in local highlight regions. Therefore, by analyzing the consistency of pixel gradient directions and the degree of grayscale imbalance within local windows, this invention determines the texture consistency value and neighborhood imbalance value of the local window of each pixel, accurately identifying regions with chaotic texture and grayscale imbalance caused by highlights. Furthermore, by setting a lower weight for local highlight regions, this invention effectively avoids the possibility of the SSIM algorithm excessively lowering the overall average score due to low SSIM values ​​in highlight regions, thereby effectively improving the accuracy of the precision detection result of the grayscale image of the component to be detected.

[0011] According to the machine vision-based method for detecting surface defects in automotive precision components provided by the present invention, the method for determining the texture consistency value of a local window of a pixel in a grayscale image of the component to be detected further includes: taking a photograph of the automotive component and performing preprocessing to obtain a grayscale image of the component to be detected.

[0012] This invention, through preprocessing, can effectively smooth out the interference of local noise, thereby accurately reflecting the main texture direction, so that the degree of disorder of each pixel gradient can be accurately obtained based on this.

[0013] According to the machine vision-based method for detecting surface defects in precision automotive components provided by the present invention, the local window of a pixel is centered on that pixel. A window of pixels, in which This is the preset side length of the local window.

[0014] According to the machine vision-based method for detecting surface defects in automotive precision components provided by the present invention, determining the texture consistency value of a local window of a pixel includes:

[0015] ;

[0016] For pixels Texture consistency value of a local window For pixels Local window, For pixels The first in the local window The pixel and the The angle between the unit gradient vectors of each pixel , Each pixel The first in the local window The, the Gradient magnitude of each pixel For pixels The cumulative sum of gradient magnitude products among all pixels in a local window. It is the absolute value symbol. It is a sine function. To prevent the parameter from being zero.

[0017] This invention provides a precise method for calculating texture consistency values. By combining the gradient intensity and vector angle between pixels in a local window to evaluate the degree of texture disorder, it is possible to accurately distinguish between uniformly lit areas and local highlight areas, and thus accurately obtain texture consistency values.

[0018] According to the machine vision-based method for detecting surface defects in precision automotive components provided by the present invention, the calculation of the neighborhood imbalance value of a pixel based on the grayscale difference and spatial distance between the pixel and other pixels in a local window includes:

[0019] ;

[0020] For pixels The neighborhood imbalance value, For pixels Local window, , Each pixel Pixels in a local window grayscale value Power of 1 This is the grayscale adjustment coefficient. , Each pixel The x and y coordinates, i and j are the pixel points. x-coordinate and y-coordinate Let be the side length of the local window. For normalization function, It is the absolute value symbol.

[0021] This invention provides a precise method for calculating neighborhood imbalance values. By applying distance weighting to the differences in grayscale values, it can accurately identify the boundaries of large-area highlight regions based on the amplified differences between bright pixels and center pixels, thereby accurately quantifying the grayscale imbalance caused by highlights.

[0022] According to the machine vision-based method for detecting surface defects in precision automotive components provided by the present invention, the step of generating weights to characterize the importance of pixels in the calculation of structural similarity index based on the texture consistency value and neighborhood imbalance value of the local window of a pixel includes:

[0023] ;

[0024] For pixels The weight, For pixels Texture consistency value of a local window For pixels The neighborhood imbalance value, To prevent division by zero, This is the ratio adjustment coefficient.

[0025] According to the machine vision-based method for detecting surface defects in automotive precision components provided by the present invention, the step of applying pixel weights to the SSIM algorithm to obtain a weighted structural similarity index of the grayscale image of the component to be detected includes: obtaining the pixel corresponding to the pixel at the same position in the standard component image in the grayscale image of the component to be detected, and recording it as a reference pixel; obtaining the local window of the reference pixel corresponding to the pixel, and obtaining the SSIM value of the local window of the pixel based on the grayscale distribution between the pixel and the corresponding reference pixel; weighting the SSIM value of the pixel according to the pixel weight to obtain the weighted SSIM value of the pixel, and using the mean of the weighted SSIM values ​​of all pixels in the grayscale image of the component to be detected as the weighted structural similarity index of the grayscale image of the component to be detected.

[0026] This invention uses the weight of each pixel to weight the SSIM value of the local window of that pixel, thereby accurately adjusting the contribution of each local window to the weighted structural similarity index, effectively reducing the influence of local highlight areas on the weighted structural similarity index, and improving the accuracy of the precision detection results.

[0027] According to the machine vision-based method for detecting surface defects in automotive precision components provided by the present invention, the step of obtaining the pixel corresponding to the pixel in the grayscale image of the component to be detected at the same position in the standard component image as the reference pixel is further included before: obtaining the standard component image corresponding to the grayscale image of the component to be detected and performing an alignment operation.

[0028] According to the machine vision-based method for detecting surface defects in automotive precision components provided by the present invention, the step of obtaining the weighted structural similarity index of the grayscale image of the component to be detected and obtaining the accuracy detection result of the grayscale image of the component to be detected includes: if the weighted structural similarity index of the grayscale image of the component to be detected is greater than a preset accuracy threshold, then the accuracy detection result of the grayscale image of the component to be detected is good; otherwise, the accuracy detection result of the grayscale image of the component to be detected is average.

[0029] Secondly, the present invention provides a machine vision-based surface defect detection system for precision automotive components, employing the following technical solution:

[0030] A machine vision-based surface defect detection system for automotive precision components includes a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the aforementioned machine vision-based surface defect detection method for automotive precision components.

[0031] By adopting the above technical solution, the above-mentioned machine vision-based method for detecting surface defects in automotive precision components is generated into a computer program and stored in a memory for loading and execution by a processor. This allows for the creation of a terminal device based on the memory and processor, making it convenient to use.

[0032] The present invention has the following technical effects:

[0033] Based on the above technical solution, the machine vision-based method and system for detecting surface defects in automotive precision components provided by this invention evaluates the similarity between the grayscale image of the component to be detected and the image of a standard component by obtaining a weighted structural similarity index, thereby accurately obtaining the precision detection result of the grayscale image of the component to be detected. In the process of obtaining the weighted structural similarity index, this invention considers the relatively chaotic texture and grayscale distribution in local highlight areas. Therefore, this invention determines the texture consistency value and neighborhood imbalance value of the local window of a pixel by analyzing the consistency of the pixel gradient direction and the degree of grayscale imbalance within the local window, which can accurately identify areas of texture chaos and grayscale imbalance caused by highlights. Furthermore, this invention effectively avoids the possibility of the SSIM algorithm excessively lowering the overall average score due to the low SSIM value of the highlight area by setting a lower weight for the local highlight area, thereby effectively improving the accuracy of the precision detection result of the grayscale image of the component to be detected. Attached Figure Description

[0034] Figure 1 This is a flowchart illustrating a machine vision-based method for detecting surface defects in precision automotive components, as provided in an embodiment of the present invention. Detailed Implementation

[0035] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.

[0036] Localized highlights in the grayscale image of the component to be inspected may cause the SSIM algorithm to incorrectly identify these highlighted areas as defects. Therefore, this invention discloses a machine vision-based method for detecting surface defects in automotive precision components. This method effectively reduces the interference of highlights on the detection results by assigning low weights to highlighted areas with messy textures and unbalanced grayscale, significantly reducing the false alarm rate and thus improving the accuracy and robustness of automated component precision inspection.

[0037] Please see details. Figure 1 As shown, Figure 1 This invention provides a flowchart illustrating a machine vision-based method for detecting surface defects in precision automotive components. The method specifically includes the following steps:

[0038] S1: Obtain the pixels in the grayscale image of the component to be detected.

[0039] For example, in an embodiment of the present invention, obtaining pixels in a grayscale image of a component to be detected includes: taking a photograph of a car component and performing preprocessing to obtain a grayscale image of the component to be detected.

[0040] Specifically, during preprocessing, high-resolution cameras can be used to photograph car components, and the photos can be converted to grayscale images. A Gaussian filter is used to filter random noise from the grayscale image. The Sober operator is used to obtain the gradient vectors of each pixel.

[0041] The specific steps of preprocessing can be implemented using existing technologies, and will not be elaborated upon here in this embodiment of the invention.

[0042] It is understandable that the illumination area on the grayscale image of the component to be detected is divided into a uniform illumination area and a local highlight area. In the uniform illumination area, the grayscale distribution is relatively uniform, the directionality of the component texture is relatively consistent in the local range, and the brightness is similar. In the local highlight area, the grayscale distribution is more chaotic, the component texture is disrupted in the local range, the direction is chaotic, and the brightness difference is large.

[0043] When processing based on the SSIM algorithm, the algorithm slides a window of pixels across the grayscale image of the component to be detected and the corresponding standard component image. After each slide, a local SSIM value is obtained. Finally, the average of all local SSIM values ​​is taken as the structural similarity index of the grayscale image of the component to be detected, in order to quantify the overall similarity between the two images. However, the SSIM value in the window of the highlight region will be significantly lower. If the same weight is used as other normal windows, it will excessively lower the overall structural similarity index, thus misjudging the local highlights on normal components as defects.

[0044] Therefore, the embodiments of the present invention can analyze the texture consistency and brightness distribution in the local window of each pixel through the following steps, thereby quantifying the consistency of pixel gradient direction and grayscale imbalance within the local window, and setting SSIM weights for the local window of each pixel based on this, thereby improving the accuracy of similarity assessment between the grayscale image of the component to be detected and the corresponding standard component image.

[0045] S2: For a local window of a pixel in the grayscale image of the component to be detected, determine the texture consistency value of the local window of the pixel. The texture consistency value is used to evaluate the consistency of the pixel gradient direction within the local window.

[0046] For example, in an embodiment of the present invention, the local window of a pixel is centered on that pixel. A pixel-sized window, which is rectangular.

[0047] in, The default side length of the local window can be set to 11; in the settings... At that time, it can be made The value must be at least greater than the minimum radius of the largest highlight region in the grayscale image of the component to be detected, to ensure that the local window is not completely within the highlight region when constructing the local window of a pixel. The specific value can be set according to actual needs. If the surrounding pixels are insufficient to construct the local window of the current pixel, the grayscale value of the missing pixels in the local window can be recorded as 0.

[0048] It should be noted that in the inspection of precision components, both a highlight area and a highly textured area under uniform lighting can have very high gradient amplitudes. However, the surface texture of automotive precision components has a natural directionality under uniform lighting, and its gradient vector directions are highly consistent. Local highlights can disrupt this inherent texture, resulting in chaotic gradient vector directions in the neighborhood, often perpendicular or at large angles.

[0049] Specifically, when the product of the gradient magnitudes between any two pixels in a local window is large, the directional differences between these pixels can be used to assess the degree of local disorder. Conversely, noise points have small gradient magnitudes, so even if their directions are disordered, they will not significantly affect the degree of local disorder. The sine of the included angle can assess the difference between the directions of two gradient vectors.

[0050] Based on this, embodiments of the present invention can evaluate the directional consistency by obtaining the product of the vector direction angle and gradient magnitude between pixels in a local window of a pixel, so as to accurately distinguish between uniformly lit areas and local highlight areas.

[0051] For ease of understanding, the embodiments of the present invention use pixels. Taking an example to illustrate, it can be understood that pixels... The adaptive weight can be calculated for any pixel in the grayscale image of the component to be detected, that is, any pixel in the grayscale image of the component to be detected can be analyzed in the following way.

[0052] For example, in an embodiment of the present invention, the texture consistency value of a local window of a pixel can be determined by the following relationship:

[0053] ;

[0054] For pixels Texture consistency value of a local window For pixels Local window, For pixels The first in the local window The pixel and the The angle between the unit gradient vectors of each pixel For pixels The first in the local window Gradient magnitude of each pixel For pixels The first in the local window Gradient magnitude of each pixel To prevent the coefficient from being divided by zero, For pixels The cumulative sum of gradient magnitude products among all pixels in a local window. It is the absolute value symbol. It is a sine function. For pixels The first in the local window The pixel and the The sine of the angle between the unit gradient vectors of each pixel. To prevent the parameter from being zero.

[0055] When obtaining the cumulative sum of gradient magnitude products among all pixels in a local window, the gradient magnitude products between any two pixels in the local window can be obtained through permutation and combination. Finally, the sum of all gradient magnitude products is taken as the cumulative sum of gradient magnitude products among all pixels in the local window.

[0056] The coefficient for preventing division by zero can be set to an extremely small positive number; alternatively, in this embodiment of the invention, it can be set to... The specific settings can be configured according to actual needs. Used for normalization.

[0057] In this relation, It is a pixel. The first in the local window The pixel and the The absolute value of the sine of the angle between the unit gradient vectors of the nth pixel points, if the nth pixel is the ... The pixel and the If the gradient vectors of all pixels have the same direction, this term has a value of 0, indicating no directional difference, which conforms to the characteristics of normal texture; if the gradient vectors of all pixels have the same direction, this term has a value of 0, indicating no directional difference, which conforms to the characteristics of normal texture; The pixel and the The direction of the gradient vector of each pixel is perpendicular. The value of this term is 1, which indicates that the direction difference is large, which is consistent with the physical phenomenon of texture disruption in the highlight area.

[0058] Gradient magnitude represents the intensity of a pixel's edge. The larger the gradient magnitude, the clearer the edge, and the more likely it is to be a real texture or defect rather than noise. It is the first The pixel and the The product of the gradient magnitudes of each pixel, when and When both are relatively large, it indicates that the pixel may be located at a strong edge.

[0059] This represents the total disorder within the local window; higher disorder corresponds to lower texture consistency. By weighting the gradient amplitude with the absolute value of the sine of the included angle, noise with disordered gradient directions can contribute less to the disorder level with a smaller gradient amplitude, thus reducing the likelihood of noise being misjudged as texture disorder.

[0060] In summary, the texture consistency value of the local window of the current pixel evaluates the degree of texture orientation disorder of the pixel in the local window. Only when the gradient magnitude of the pixel in the local window is larger and the direction of the strong edges between the pixels is more inconsistent, will the pixels in this group of local windows contribute to the disorder of the current pixel. The larger the value, the more consistent the texture direction within the local window, and the more likely the current pixel belongs to a uniformly lit area; conversely, the smaller the value, the more likely it is. The smaller the value, the more chaotic the texture direction within the local window, and the more likely the current pixel is to belong to a local highlight area.

[0061] Based on the above relationship, the texture consistency value of the local window of each pixel in the grayscale image of the component to be detected can be obtained.

[0062] S3: For a local window of a pixel, calculate the neighborhood imbalance value of the pixel based on the grayscale difference and spatial distance between the pixel and other pixels in the local window. The neighborhood imbalance value is used to characterize the degree of grayscale imbalance in the local window.

[0063] It should be noted that if the brightness distribution within a local window of a pixel in the grayscale image of the component to be detected is uniform, it means that the brightness of the central pixel in the local window is similar to that of other pixels. However, if the local window of a pixel contains a highlight area, the uniformity of the brightness distribution within that local window will be disrupted, and the balance will be broken.

[0064] Based on this, embodiments of the present invention can quantify the degree of grayscale imbalance in a local window according to the grayscale distribution in the local window of a pixel.

[0065] For example, in an embodiment of the present invention, the neighborhood imbalance value of a pixel is calculated based on the grayscale difference and spatial distance between the pixel and other pixels in the local window, which can be achieved through the following relationship:

[0066] ;

[0067] For pixels The neighborhood imbalance value, For pixels Local window, For pixels grayscale value Power of 1 For pixels Pixels in a local window grayscale value Power of 1 This is the grayscale adjustment coefficient. For pixels x-coordinate For pixels The ordinate of the coordinate, where i is the pixel. The x-coordinate, j is the pixel. The ordinate, Let be the side length of the local window. For normalization function, It is the absolute value symbol.

[0068] The grayscale adjustment coefficient can be set to 1.8; the specific grayscale adjustment coefficient can be set according to actual needs.

[0069] It is understandable that, since the local window of the current pixel is constructed with the current pixel as the center, the center pixel of the local window of the current pixel is the current pixel.

[0070] In this relation, The grayscale value difference between the center pixel and each pixel in the local window was evaluated. This allows the influence of local highlights to be amplified when the center pixel is a uniformly illuminated area on the component surface and there are a few highlight pixels in the local window, thus enabling accurate highlight identification.

[0071] This represents the relative distance between the center pixel and all other pixels within the local window, used to amplify the influence of distant pixels. When the center pixel is at the edge of a highlight area, with one side being a highlight area and the other a uniformly lit area, distance weighting allows the brightness difference between the distant highlight pixels and the center pixel to significantly affect the exponent, thus accurately obtaining the neighborhood imbalance value.

[0072] Furthermore, if the central pixel is a defective pixel, the surrounding defective pixels are relatively close, have small differences, and correspondingly smaller distance weights, thus having a smaller impact. Conversely, normal pixels at a distance have a slightly larger impact due to distance weighting. This distance weighting method can accurately identify the boundaries of large highlight areas, improving the accuracy of neighborhood imbalance values.

[0073] Based on the above relationship, the neighborhood imbalance value of each pixel can be obtained. The function can restrict the range of neighborhood imbalance values ​​to between 0 and 1.

[0074] S4: Based on the texture consistency value and neighborhood imbalance value of the local window of the pixel, generate weights to characterize the importance of the pixel in the structural similarity index calculation; apply the pixel weights to the SSIM algorithm to obtain the weighted structural similarity index of the grayscale image of the component to be detected, and obtain the accuracy detection result of the grayscale image of the component to be detected.

[0075] It should be noted that, based on the above steps, the texture consistency value and neighborhood imbalance value of a pixel can be obtained respectively. The higher the texture consistency value and the lower the neighborhood imbalance value of a pixel, the higher the probability that the pixel is in a normal lighting area; conversely, the lower the texture consistency value and the higher the neighborhood imbalance value of a pixel, the higher the probability that the pixel is in a local highlight area.

[0076] Based on this, embodiments of the present invention can construct a weight function for a pixel by using the texture consistency value and neighborhood imbalance value of the local window of the pixel. The weight is used to characterize the importance of the pixel in the calculation of the structural similarity index.

[0077] For example, in an embodiment of the present invention, the weight of a pixel is generated based on the texture consistency value and neighborhood imbalance value of the local window of the pixel, which can be achieved through the following relationship:

[0078] ;

[0079] For pixels The weight, For pixels Texture consistency value of a local window For pixels The neighborhood imbalance value, To prevent division by zero, This is the ratio adjustment coefficient.

[0080] The ratio adjustment coefficient is used to control the influence of the ratio and can be set to a number less than 1 to prevent the weight from being too large or too small. As an example, in this embodiment of the invention, it can be set to 0.7, but the specific value can be set according to actual needs. The zero-prevention parameter can be set to 0.01, but the specific value can be set according to actual needs.

[0081] In this relationship, if the pixel point The greater the probability of being in a uniformly illuminated area, the better. The larger the pixel, the better; conversely, if the pixel is smaller... The greater the likelihood that it is located in a localized highlight area, the better. The smaller.

[0082] Based on the above relationship, the adaptive weight of each pixel can be obtained. Among the methods for obtaining pixel weights, the neighborhood imbalance value... This is used to evaluate the degree of abrupt changes in grayscale within a local neighborhood. By utilizing the weighting effect of the spatial distance term, it can capture abrupt grayscale jumps (such as specular boundaries) caused by local window edges. Furthermore, by combining texture consistency... To address the constraints, this invention achieves comprehensive and accurate correction of the weights of highlight regions with different distribution patterns. By using the weight of each pixel in the SSIM algorithm for weighted calculation, the impact of local highlight region pixels on the similarity accuracy between the grayscale image of the component to be detected and the corresponding standard component image can be effectively reduced.

[0083] Understandably, before calculating the weighted structural similarity index of the grayscale image of the component to be detected, it is necessary to ensure that the grayscale image of the component to be detected and the corresponding standard component image are perfectly aligned to avoid similarity calculation errors caused by misalignment. The standard component image corresponding to the grayscale image of the component to be detected is a normal, defect-free standard image without specular interference. For the preprocessing method of the standard component image, please refer to the preprocessing method of the grayscale image of the component to be detected, which will not be elaborated here.

[0084] For example, in an embodiment of the present invention, the pixel point corresponding to the pixel point in the grayscale image of the component to be detected at the same position in the standard component image is obtained and recorded as the reference pixel point. Before this, the method further includes: obtaining the standard component image corresponding to the grayscale image of the component to be detected and performing an alignment operation.

[0085] Image alignment can be achieved using algorithms such as linear transformation based on Hough transform and phase correlation method. The specific settings can be made according to actual needs, and the embodiments of the present invention do not impose too many restrictions here.

[0086] For example, in this embodiment of the invention, the weights of pixels are applied to the SSIM algorithm to obtain a weighted structural similarity index of the grayscale image of the component to be detected. This includes: obtaining the pixel corresponding to the pixel in the grayscale image of the component to be detected at the same position in the standard component image and recording it as a reference pixel; obtaining the local window of the reference pixel corresponding to the pixel; obtaining the SSIM value of the local window of the pixel based on the grayscale distribution between the pixel and the corresponding reference pixel; weighting the SSIM value of the pixel according to the weight of the pixel to obtain the weighted SSIM value of the pixel; and using the average of the weighted SSIM values ​​of all pixels in the grayscale image of the component to be detected as the weighted structural similarity index of the grayscale image of the component to be detected.

[0087] For example, in an embodiment of the present invention, obtaining the weighted structural similarity index of the grayscale image of the component to be detected and obtaining the accuracy detection result of the grayscale image of the component to be detected includes: if the weighted structural similarity index of the grayscale image of the component to be detected is greater than a preset accuracy threshold, then the accuracy detection result of the grayscale image of the component to be detected is good; otherwise, the accuracy detection result of the grayscale image of the component to be detected is average.

[0088] In this study, the weighted structural similarity index of a defect-free, normal component in a uniformly illuminated area is typically close to 1; conversely, the more defects a component has, the closer this value is to 0. As an example, the accuracy threshold can be set to 0.85, but this can be adjusted according to actual needs.

[0089] For example, when obtaining the weighted structural similarity index of the grayscale image of the component to be detected and obtaining the accuracy detection result of the grayscale image of the component to be detected, the corresponding accuracy score can also be directly generated based on the weighted structural similarity index of the grayscale image of the component to be detected for staff to review. The specific settings can be made according to actual needs, and the embodiments of the present invention do not impose too many restrictions here.

[0090] As can be seen, in this embodiment of the invention, when obtaining the component accuracy detection result, the texture consistency value of the local window of a pixel in the grayscale image of the component to be detected can be determined. The texture consistency value is used to evaluate the consistency of the pixel gradient direction within the local window. For the local window of a pixel, the neighborhood imbalance value of the pixel is calculated based on the grayscale difference and spatial distance between the pixel and other pixels in the local window. The neighborhood imbalance value is used to characterize the degree of grayscale imbalance in the local window. Based on the texture consistency value and neighborhood imbalance value of the local window of the pixel, a weight is generated to characterize the importance of the pixel in the structural similarity index calculation. The pixel weight is applied to the SSIM algorithm to obtain the weighted structural similarity index of the grayscale image of the component to be detected, thereby obtaining the accuracy detection result of the grayscale image of the component to be detected, which effectively improves the accuracy of the component accuracy detection result.

[0091] This invention also discloses a machine vision-based surface defect detection system for automotive precision components, including a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement the machine vision-based surface defect detection method for automotive precision components provided by this invention.

[0092] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and will not be described in detail here.

[0093] In this invention, the aforementioned memory can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0094] The above are all preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.

Claims

1. A method for detecting surface defects of a precise component of an automobile based on machine vision, characterized in that, The method comprises the following steps: For a local window of a pixel in the grayscale image of the component to be detected, determine the texture consistency value of the local window of the pixel, including: , For pixels Texture consistency value of a local window For pixels Local window, For pixels The first in the local window The pixel and the The angle between the unit gradient vectors of each pixel , Each pixel The first in the local window The, the Gradient magnitude of each pixel For pixels The cumulative sum of gradient magnitude products among all pixels in a local window. It is the absolute value symbol. It is a sine function. To prevent division by zero, the texture consistency value is used to evaluate the consistency of pixel gradient directions within the local window. For a local window of a pixel point, a neighborhood imbalance value of the pixel point is calculated based on a gray difference and a spatial distance between the pixel point and other pixel points in the local window, comprising: , is a gray value of the pixel point , , is a gray value of the pixel point , a gray value of the pixel point , is a gray value of the pixel point , , is a horizontal coordinate of the pixel point , is a horizontal coordinate of the pixel point , is a vertical coordinate of the pixel point , is a vertical coordinate of the pixel point is a normalization function; is a side length of the local window, a value of the pixel point is at least greater than a minimum radius in a maximum highlight area in a detected component gray image, so as to ensure that the local window is not completely in the highlight area when the local window of the pixel point is constructed; the neighborhood imbalance value is used to represent a gray imbalance degree of the local window; According to the texture consistency value and the neighborhood imbalance value of the local window of the pixel point, a weight for representing the importance of the pixel point in the calculation of the structural similarity index is generated. The weight of the pixel point is applied to the SSIM algorithm to obtain the weighted structural similarity index of the gray image of the component to be detected, and the precision detection result of the gray image of the component to be detected is obtained.

2. The method for detecting surface defects of a precise component of an automobile based on machine vision according to claim 1, characterized in that, Before determining the texture consistency value of the local window of the pixel point in the gray image of the component to be detected, the method further comprises the following steps: A photo of the automobile component is taken and pretreated to obtain the gray image of the component to be detected.

3. The method for detecting surface defects of a precise component of an automobile based on machine vision according to claim 1, characterized in that, The local window of the pixel point is a window with the pixel point as a center The window of the pixel, wherein The side length of the preset local window.

4. The method for detecting surface defects of a precise component of an automobile based on machine vision according to claim 1, characterized in that, According to the texture consistency value and the neighborhood imbalance value of the local window of the pixel point, a weight for representing the importance of the pixel point in the calculation of the structural similarity index is generated. ; weight of the pixel point, weight of the pixel point, texture consistency value of the local window, texture consistency value of the local window, neighbor imbalance value of the pixel point, neighbor imbalance value of the pixel point, prevention zero parameter, ratio adjustment coefficient.

5. The method for detecting surface defects of a precise component of an automobile based on machine vision according to claim 1, characterized in that, The weight of the pixel point is applied to the SSIM algorithm to obtain the weighted structural similarity index of the gray image of the component to be detected. The pixel point corresponding to the pixel point in the same position in the standard component image is recorded as a control pixel point; the local window of the control pixel point corresponding to the pixel point is obtained, and the SSIM value of the local window of the pixel point is obtained according to the gray distribution between the local window of the pixel point and the control pixel point; the SSIM value of the pixel point is weighted according to the weight of the pixel point, and the weighted SSIM value of the pixel point is obtained; and the average value of the weighted SSIM values of all pixel points in the gray image of the component to be detected is taken as the weighted structural similarity index of the gray image of the component to be detected.

6. The machine vision based surface defect detection method for precise automobile components as claimed in claim 5 wherein, The pixel point corresponding to the pixel point in the same position in the standard component image is recorded as a control pixel point; the local window of the control pixel point corresponding to the pixel point is obtained, and the SSIM value of the local window of the pixel point is obtained according to the gray distribution between the local window of the pixel point and the control pixel point; the SSIM value of the pixel point is weighted according to the weight of the pixel point, and the weighted SSIM value of the pixel point is obtained; and the average value of the weighted SSIM values of all pixel points in the gray image of the component to be detected is taken as the weighted structural similarity index of the gray image of the component to be detected. If the weighted structural similarity index of the gray image of the component to be detected is greater than a preset precision threshold, the precision detection result of the gray image of the component to be detected is good; otherwise, the precision detection result of the gray image of the component to be detected is general.

7. The machine vision based surface defect detection method of precise automobile components as claimed in claim 1 wherein, The method comprises the following steps: A processor and a memory, the memory stores computer program instructions, when the computer program instructions are executed by the processor, the method for detecting surface defects of automobile precision components based on machine vision according to any one of claims 1-7 is realized.

8. A machine vision based system for detecting surface defects in precision components of automobiles, characterized in that, ​ ​

Citation Information

Patent Citations

  • Intelligent detection method for defects of clock steel pipe

    CN117095008A

  • Online detection method and system for surface defects of automobile parts

    CN121258956A