Automobile part surface defect detection method based on image processing

By extracting the textures in the surface image processing of metal plates and analyzing their morphological characteristics, the problem of low detection accuracy of scratch defects in the prior art is solved, and accurate identification and distinction of scratches on the surface of metal plates is achieved.

CN119006460AActive Publication Date: 2024-11-22JIANGYIN PIVOT AUTOMOTIVE PROD CO LTD

Patent Information

Application Number
CN202411481252.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-23
Publication Date
2024-11-22
Estimated Expiration
2044-10-23

AI Technical Summary

Technical Problem

The prior art has low accuracy when detecting scratch defects on the surface of metal plates, especially due to the visual similarity between scratches and flow marks and image distortion, which makes it difficult to accurately distinguish them.

Method used

By collecting the surface images of the metal plate, extracting the texture and filtering the scratched texture according to the gradient direction of the pixel points, quantifying the shape length and bending degree of the texture, combining the grayscale difference and slope, filtering out the scratched texture to improve the detection accuracy.

Benefits of technology

It realizes accurate identification of scratch defects on the surface of metal plates, improves detection accuracy, enhances the ability to identify tiny scratches, and ensures accurate judgment of defects on the surface of metal plates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119006460A_ABST
    Figure CN119006460A_ABST
Patent Text Reader

Abstract

The invention relates to the field of image processing, in particular to an automobile part surface defect detection method based on image processing, and the method comprises the steps: collecting and preprocessing an automobile metal plate surface image, extracting all lines, preliminarily screening a first scratch line according to the gradient direction of pixel points on the lines, and marking the lines except the first scratch lines as residual lines, obtaining the shape length degree and shape bending degree of the residual lines based on the pixel point distribution characteristics of the residual lines, and calculating the shape bending degree of the residual lines according to the gray difference in the pixel point neighborhood range of the residual lines and the slope between the pixel points and the starting point of the residual lines. According to the method, the first scratch lines contained in the remaining lines are screened out, the form clearness of the remaining lines is obtained, the second scratch lines contained in the remaining lines are screened out by comprehensively utilizing the three indexes, and whether the scratch defects exist on the surface of the automobile metal plate or not is determined according to the number of the first scratch lines and the number of the second scratch lines, so that the precision of automobile part surface defect detection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] As the automobile manufacturing industry enters a stage of rapid development, the quality control of automobile parts, especially metal sheets, has become increasingly stringent. As the cornerstone of automobile structure, the quality of the manufacturing process of metal sheets is directly related to the overall safety, durability and aesthetic performance of the automobile. In the production process of metal sheets, surface defects of metal sheets are the decisive factors affecting the qualification of parts and can even induce potential safety risks. Therefore, the screening and identification of surface defects are particularly critical.

[0003] Existing technologies collect images of metal plate surfaces and use image recognition technology to detect potential defects. However, due to the high reflectivity of metal plates and the complex refraction and reflection of light on the metal surface, the captured image information may be distorted.

[0004] A Chinese patent application document with publication number CN117197141A discloses a method for detecting surface defects of automobile parts, which includes: obtaining a grayscale image of the surface of the automobile parts, determining an initial threshold value according to the grayscale value of the pixel points, and then obtaining a threshold value to be tested and a preliminary defect area and a normal area; due to the influence of light, the highlight area will be misjudged, so the defect discontinuity area is screened according to the direction and position relationship between the final defect areas; obtaining a light influence value based on the grayscale value of the pixel points, and then adjusting the grayscale value of the pixel points and obtaining a grayscale adjustment value in combination with the grayscale value of the pixel points in the normal area; obtaining a comparison threshold value according to the grayscale value of the adjusted pixel points and comparing it with the threshold value to be tested, and obtaining an optimal threshold value to perform defect detection on the grayscale image.

[0005] Although the existing technology takes the influence of lighting into consideration, when identifying subtle scratch defects of various shapes on the surface of metal plates, scratches usually appear as irregular marks with clear boundaries, while flow marks appear as continuous lines related to the flow direction of metal. The two are visually very similar. Coupled with the influence of image distortion, it is more difficult to distinguish between scratch defects that may exist on the surface of the metal plate and flow marks on the surface of the metal plate, which affects the accurate judgment of scratch defects on the surface of the metal plate by the existing technology and results in low accuracy of defect detection. Summary of the invention

[0006] In order to solve the technical problem that the existing technology has low accuracy in detecting scratch defects on the surface of metal plates, the present invention proposes a method for detecting surface defects of automobile parts based on image processing, which improves the accuracy of detecting surface defects of automobile parts. The specific scheme is as follows: The method for detecting surface defects of automobile parts based on image processing includes: Collect and pre-process the surface image of the automobile metal plate to obtain the image to be detected; Extract all the lines in the image to be detected, preliminarily screen the first scratch line according to the gradient direction of all the pixels on each line, and take the lines other than the first scratch line among all the lines as the remaining lines; Based on the difference in Euclidean distance between adjacent pixel points on each remaining texture and the starting point of the texture, the length of each remaining texture is determined; According to the difference in gradient directions of adjacent pixel points on each remaining texture, the degree of morphological curvature of each remaining texture is obtained; Setting a first neighborhood range and a second neighborhood range for each pixel point on each remaining texture, wherein the first neighborhood range is smaller than the second neighborhood range; Determine the morphological clarity of each remaining texture based on the grayscale difference between the first neighborhood range and the second neighborhood range of each pixel point on each remaining texture, and the slope between each pixel point and the starting point of the texture; The second scratch lines included in all the remaining lines are screened out by using the length, curvature and clarity of each remaining line; Whether there is a scratch defect on the surface of the automobile metal plate is determined according to the number of the first scratch lines and the second scratch lines included in the image to be detected.

[0007] The present invention accurately extracts all the textures of the surface image of the automobile metal plate, preliminarily selects the first scratch texture and the remaining texture according to the gradient direction of the pixel point, realizes the fine division of the texture, and quantifies the morphological length of the remaining texture by analyzing the difference in the Euclidean distance between the adjacent pixel points on the remaining texture and the starting point of the remaining texture. Combined with the difference in the gradient direction of the adjacent pixel points, the morphological curvature of the remaining texture is obtained. These two features can reflect the unique morphological characteristics of the scratches, and improve the accuracy of recognition. In the conventional automobile parts defect detection process, it is difficult to effectively distinguish the subtle difference between scratches and flow marks. The present invention accurately evaluates the morphological clarity of the remaining texture according to the grayscale difference within the first neighborhood and the second neighborhood of each pixel point, and the slope between the pixel point and the starting point of the remaining texture, and enhances the recognition ability of small and fuzzy scratches. By comprehensively considering the three key features of the morphological length, morphological curvature and morphological clarity of the remaining texture, the second scratch texture is selected, and the defects on the surface of the automobile metal plate are quantified according to the number of the first scratch texture and the second scratch texture, thereby improving the accuracy of automobile parts surface defect detection.

[0008] Furthermore, the second scratch lines included in all the remaining lines are screened out by using the length, curvature and clarity of each remaining line, including: Set the weights of shape length, shape curvature, and shape clarity; The length, curvature and clarity of each remaining line are weighted and summed, and the obtained value is used as the probability that the remaining line is the second scratch line; If the probability that a certain remaining pattern is a second scratch pattern is greater than the probability threshold, the remaining pattern is the second scratch pattern; if the probability that a certain remaining pattern is a second scratch pattern is not greater than the probability threshold, the remaining pattern is not the second scratch pattern.

[0009] In this way, different weights are set according to the influence of the length, curvature and clarity of the shape on whether the remaining lines are scratches, which can further improve the accuracy of the judgment of the remaining lines.

[0010] Furthermore, the weight of the length of the form is smaller than the weight of the curvature of the form, and the weight of the curvature of the form is smaller than the weight of the clarity of the form.

[0011] Furthermore, the shape and length of each remaining line satisfy the following relationship: ; In the formula, For the The shape and length of the remaining lines, is the total number of pixels on the remaining texture, is the sequence number of the pixel points on the remaining texture, The value of All integers in the range, For the The remaining lines Pixels and The Euclidean distance from the starting point of the remaining lines, For the The remaining lines Pixels and The Euclidean distance from the starting point of the remaining lines, To calculate the absolute value, The natural constant An exponential function with base .

[0012] In this way, the Euclidean distance between each pixel on each remaining texture and the starting point of the texture is calculated, and the difference in the Euclidean distance between adjacent pixels is considered to quantify the extension length and distribution of the texture in space. Through calculation and normalization, a value is obtained to characterize the length of the remaining texture, which can then assist in determining whether the texture is a scratch or a flow mark.

[0013] Furthermore, the degree of curvature of each remaining grain satisfies the following relationship: ; In the formula, For the The curvature of the remaining lines. is the total number of pixels on the remaining texture, is the sequence number of the pixel points on the remaining texture, The value of All integers in the range, For the The remaining lines The gradient direction of each pixel is For the The remaining lines The gradient direction of each pixel is is the inverse tangent function.

[0014] In this way, the bending changes of the texture are reflected by comparing the gradient direction differences between consecutive pixel points on the texture. The curvature of the remaining texture is quantitatively evaluated through the cumulative statistics of the gradient direction changes of all adjacent pixel points on the texture. Textures with higher curvature are more likely to show scratch defect characteristics.

[0015] Furthermore, the morphological clarity of each remaining texture is obtained by: Calculate the difference between the grayscale mean of the pixel point in the first neighborhood range and the grayscale mean of the pixel point in the second neighborhood range for each pixel point on the remaining texture, and obtain the absolute value as the neighborhood grayscale difference of the pixel point; The morphological clarity of each remaining texture is calculated according to the following formula: ; In the formula, For the The clarity of the remaining lines. is the total number of pixels on the remaining texture, is the sequence number of the pixel points on the remaining texture, The value of All integers in the range, For the The remaining lines Pixels and The slope between the starting points of the remaining lines, For the The remaining lines The grayscale difference of the neighborhood of pixels is The natural constant An exponential function with base .

[0016] In this way, by calculating the difference (absolute value) of the grayscale mean of each pixel in its first neighborhood and second neighborhood, the neighborhood grayscale difference is obtained. The neighborhood grayscale difference reflects the degree of drastic change in the local grayscale of the pixel. This change is usually more obvious in defects such as scratches. Combining the neighborhood grayscale difference can better capture and identify clear features such as scratches.

[0017] Furthermore, the step of setting the first neighborhood range and the second neighborhood range of each pixel point on each remaining texture includes: Get the maximum width of the remaining texture , the total number of adjacent pixels on the left and right sides of each pixel pixels, as the first neighborhood range, and the total number of adjacent pixels on the left and right sides of each pixel pixels as the second neighborhood range.

[0018] Further, determining whether there is a scratch defect on the surface of the automobile metal plate according to the number of the first scratch pattern and the second scratch pattern included in the image to be detected includes: Adding the number of the first scratch patterns and the number of the second scratch patterns to obtain the total number of scratch patterns in the image to be detected; The ratio of the total number of scratch lines to the total number of all lines is used as the scratch defect degree of the automobile metal plate surface; Preset scratch defect level threshold; If the scratch defect degree on the surface of the automobile metal plate exceeds the scratch defect degree threshold, then there is a scratch defect on the surface of the automobile metal plate; otherwise, there is no scratch defect.

[0019] Furthermore, the first scratch pattern is initially screened according to the gradient direction of all pixels on each pattern, including: The average value of the gradient directions of all pixels on each texture is taken as the overall direction of the texture; Count the number of lines in each overall direction, and take the overall direction with the largest number of lines as the main gradient direction of the flow mark, denoted as , the main direction range of the flow mark gradient is , is the default value; According to the gradient direction The gradient direction of each texture other than The difference between The probability that each pattern other than is the first scratch pattern; Presetting a probability threshold of the first scratch pattern; If the gradient direction is If the probability that a certain pattern other than the first scratch pattern is the first scratch pattern exceeds the probability threshold of the first scratch pattern, then the pattern is the first scratch pattern; otherwise, the pattern is not the first scratch pattern.

[0020] In this way, according to the difference between the distribution characteristics of flow mark defects and the distribution characteristics of scratch defects, the lines inconsistent with the distribution direction of flow mark defects are detected. As scratch defects, scratches inconsistent with the flow mark arrangement direction can be preferentially detected.

[0021] Furthermore, the gradient direction is The probability that each pattern other than is the first scratch pattern includes: The gradient direction of the texture is The absolute value of the difference is normalized to obtain the probability that the texture is the first scratch.

[0022] The present invention has the following effects: The present invention firstly collects and preprocesses the surface image of the automobile metal plate to accurately extract all the textures, preliminarily screens out the first scratch texture and the remaining texture according to the gradient direction of the pixel point, realizes the fine division of the texture, quantifies the morphological length of the remaining texture by analyzing the difference in Euclidean distance between adjacent pixel points on the remaining texture and the starting point of the remaining texture, and obtains the morphological curvature of the remaining texture in combination with the gradient direction difference of the adjacent pixel points. The two features can reflect the unique morphological characteristics of the scratches, and improve the accuracy of recognition. According to the grayscale difference within the first neighborhood and the second neighborhood of each pixel point, and the slope between the pixel point and the starting point of the remaining texture, the morphological clarity of the remaining texture is accurately evaluated, and the recognition ability of small and fuzzy scratches is enhanced. By comprehensively considering the three key features of the morphological length, morphological curvature and morphological clarity of the remaining texture, the second scratch texture is screened out, and the defects on the surface of the automobile metal plate are quantified according to the number of the first scratch texture and the second scratch texture, thereby improving the accuracy of surface defect detection of automobile parts. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] 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: Figure 1 It is a schematic flow chart of the method of the present invention. DETAILED DESCRIPTION

[0024] 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.

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

[0026] Reference Figure 1 The method for detecting surface defects of automobile parts based on image processing includes steps S1 to S7, which are specifically as follows: S1: Collect the surface image of the automobile metal plate and perform preprocessing to obtain the image to be detected.

[0027] In this step, each metal plate to be inspected will pass through a specially designed workbench in turn in the automotive metal plate quality inspection line, where high-definition surface images are collected. To ensure the quality of the shot, the camera equipped on the workbench needs to capture the surface image of the metal plate from a suitable angle under uniform and sufficient light conditions in order to accurately detect surface defects. Considering the large number of metal plates on the assembly line, the camera needs to work continuously for a long time, and the heating of the internal components of the camera may cause the collected surface image of the metal plate to contain noise, affecting the accurate identification of surface defects of the metal plate.

[0028] To this end, the following preprocessing steps are performed on the surface image of the metal sheet: Image cropping and sorting: First, adjust the size of the collected metal plate surface image to ensure that the image only contains complete metal plate information and eliminates the interference of the workbench background on the image content; Color to grayscale processing: Convert color images to grayscale images to simplify the computational complexity of subsequent image analysis; Image noise suppression: remove the noise in the image through adaptive filtering, optimize the image contrast, enhance the brightness difference between different areas on the metal plate surface, and facilitate the identification of potential defect features; Edge sharpening: Use the Sobel operator to detect and sharpen the image edges, enhance the visibility of tiny scratches and other details, and further reduce the impact of noise on image quality.

[0029] Through the above preprocessing steps, an image to be detected suitable for defect detection is finally obtained.

[0030] S2: extracting all the lines in the image to be detected, preliminarily screening the first scratch line according to the gradient direction of all the pixels on each line, and taking the lines other than the first scratch line among all the lines as the remaining lines.

[0031] The Canny edge detection algorithm is used to obtain all edge pixels on the image to be detected, and the edge pixels contained in the eight neighborhoods of each edge pixel are connected to obtain the texture in the image to be detected.

[0032] The first scratch pattern is initially screened according to the gradient direction of all pixels on each pattern, including: (1) Obtain the gradient direction of the pixel points on each texture. Specifically, the direction can be obtained by using the Sobel operator. For any texture, the average value of the gradient directions of all the pixel points on the texture is taken as the overall direction of the texture. The overall direction of all the textures is obtained by this method. (2) Traverse all the textures on the image to be detected and draw a histogram of the overall direction of the textures. The horizontal axis of the histogram is each overall direction, and the vertical axis is the number of textures contained in each overall direction. According to the histogram of the overall direction of the textures, the overall direction containing the largest number of textures is selected as the main gradient direction of the flow mark, which is recorded as , the main direction range of the flow mark gradient is , is the preset value, which is set to When the difference between the overall direction of the texture and the main direction of the flow mark is within 5 degrees, the difference is small and the two directions are similar, so the texture can be regarded as within the main direction of the flow mark.

[0033] In the metal plate casting process, naturally formed flow marks are the product of the flow and solidification process of molten metal. Such flow marks often present a uniform distribution, regular arrangement and a certain curvature on the surface of the metal plate, and usually do not have a substantial impact on the normal function of the metal plate. Scratches on the metal plate surface caused by uneven molds or improper operation are irregularly distributed, random in direction, and have a large degree of curvature. Therefore, in the texture gradient direction histogram, the gradient direction corresponding to the largest number of textures is most likely to be the main direction of the flow mark. Since the total gradient direction corresponding to the largest number of textures also has a large number of textures in its closer range, it is necessary to consider this part of the total gradient direction as possible The main direction of the flow mark. Therefore, in an exemplary setting, the total gradient direction within 5° of the total gradient direction corresponding to the largest number of textures belongs to the main direction range of the flow mark.

[0034] (3) According to the gradient direction of each texture outside the main direction range of the flow mark, The probability that each line whose gradient direction is outside the main direction of the flow mark is the first scratch line is calculated based on the difference between The probability that each line whose gradient direction is outside the main direction range of the flow mark is a first scratch line includes: The gradient direction of the texture is The absolute value of the difference is normalized to obtain the probability that the texture is the first scratch.

[0035] The gradient direction is outside the main direction of the flow mark. Take a line as an example, and calculate the probability that it is the first scratch line, which can be expressed as: ; In the formula, The gradient direction is outside the main direction of the flow mark. The probability that a line is the first scratch line, For this The gradient direction of the texture, is the main gradient direction of the flow mark, Indicates the calculation of absolute value. is the normalization function, Used for Perform normalization.

[0036] When Gradient direction of the stripe Main direction of flow mark The greater the difference, the Probability of the streak being a scratch The bigger it is, the Gradient direction of the stripe Main direction of flow mark The smaller the difference, the Probability of the streak being a scratch The smaller it is.

[0037] (4) A probability threshold of the first scratch pattern is preset. If the probability that a certain pattern whose gradient direction is outside the main direction range of the flow mark is the first scratch pattern exceeds the probability threshold of the first scratch pattern, the pattern is the first scratch pattern. Otherwise, the pattern is not the first scratch pattern.

[0038] Specifically, the probability threshold of the first scratch pattern is set to 0.5. The texture of The streaks are scratches. In this way, the scratches with large differences in direction from the flow marks are preliminarily screened out as the first scratches. However, there may be scratches with small differences in direction from the flow marks in the image. The gradient direction comparison in this step alone cannot be used for further fine division. Therefore, among all the scratches, except the first scratch, the remaining scratches are recorded as the remaining scratches. The remaining scratches include the scratches with gradient directions outside the main direction of the flow marks and small differences from the flow marks. The texture and gradient direction are within the main direction of the flow mark and have little difference with the flow mark direction. The textures in the remaining range will be further analyzed in the subsequent process.

[0039] This step detects the lines that are inconsistent with the distribution direction of the flow mark defects from the difference between the distribution characteristics of the flow mark defects and the distribution characteristics of the scratch defects. As a scratch defect, since the flow mark is a normal phenomenon caused by process reasons, the arrangement direction on the metal plate surface is basically consistent and the number is large, while the scratch is an abnormal phenomenon caused by improper operation and other reasons. The arrangement direction on the metal plate surface may be consistent or inconsistent with the arrangement direction of the flow mark, and the number is small. According to the actual situation, the traces that are inconsistent with the arrangement direction of the flow marks are considered to be scratches, and the traces that are consistent with the arrangement direction of the flow marks are uncertain whether they are scratches, so the scratches that are inconsistent with the arrangement direction of the flow marks are detected first.

[0040] S3: Determine the length of each remaining texture based on the difference in Euclidean distance between adjacent pixel points on each remaining texture and the starting point of the texture.

[0041] Scratches are usually caused by sharp objects, have clear, short boundaries, and the degree of curvature varies unevenly; flow marks are usually caused by liquid metal flow forming during the production of parts, have fuzzy, long boundaries, and the degree of curvature varies evenly.

[0042] Jordi The remaining lines are scratches, and the perimeter of the area surrounded by its pixels is small. The remaining lines are flow marks, and the perimeter of the area surrounded by its pixels is larger, so the The starting point of the remaining lines is used as the reference to calculate the The Euclidean distance between each pixel on the remaining texture and the starting point.

[0043] The length and shape of each remaining pattern satisfy the following relationship: ; In the formula, For the The shape and length of the remaining lines, is the total number of pixels on the remaining texture, is the sequence number of the pixel points on the remaining texture, The value of All integers in the range, For the The remaining lines Pixels and The Euclidean distance from the starting point of the remaining lines, For the The remaining lines Pixels and The Euclidean distance from the starting point of the remaining lines, To calculate the absolute value, The natural constant The exponential function with base , Indicates The Euclidean distance between the pixel and the starting point With The Euclidean distance between the pixel and the starting point The difference Indicates The sum of the Euclidean distances between all two adjacent pixels in the remaining textures, Express The values ​​are normalized.

[0044] The meaning of this formula is to quantify the spatial extension length and distribution of the texture by calculating the Euclidean distance between each pixel on each remaining texture and the starting point of the texture, and considering the difference in the Euclidean distance between adjacent pixels. Specifically, the numerator in the formula is the cumulative sum of the absolute value of the difference in the Euclidean distance between each pixel and the starting point, which reflects the degree of tortuosity of the texture in space. The denominator is the normalization of the natural exponential function form of the sum of the Euclidean distances between all adjacent pixels, the purpose of which is to normalize the calculation results to a fixed interval, so as to facilitate the comparison of the length of different textures. The overall meaning of the formula is to obtain a numerical value to characterize the length of the remaining texture through calculation and normalization, and then assist in judging whether the texture is a scratch or flow mark. Scratches usually have a short perimeter and clear boundaries, while flow marks may have a longer perimeter and a more continuous shape. By quantifying this feature, it is helpful to more accurately distinguish and identify scratches and flow mark defects on the surface of metal plates in image processing and analysis.

[0045] S4: According to the difference in gradient directions of adjacent pixel points on each remaining texture, the degree of morphological curvature of each remaining texture is obtained.

[0046] Jordi The remaining lines are scratches, then the change in the degree of bending is uneven. The remaining lines are flow marks, and the change in the degree of bending is uniform. Analyze all the pixels of the remaining textures and obtain the The gradient direction of each pixel in the stripe reflects the gradient direction of the first pixel according to the change of the gradient direction of all pixels. The degree of curvature of the stripes.

[0047] For example, The remaining lines The gradient direction of a pixel is , No. The remaining lines Pixels, The gradient direction of the pixel With The gradient direction of the pixel The difference between The degree of curvature of the remaining lines The mathematical expression of The degree of curvature of each remaining grain satisfies the following relationship: ; In the formula, For the The curvature of the remaining lines. is the total number of pixels on the remaining texture, is the sequence number of the pixel points on the remaining texture, The value of All integers in the range, For the The remaining lines The gradient direction of each pixel is For the The remaining lines The gradient direction of each pixel is () is the inverse tangent function, It is The gradient direction of the pixel With The gradient direction of the pixel The difference between and.

[0048] This formula is used to calculate the degree of curvature of each remaining texture. It reflects the curvature change of the texture by comparing the gradient direction differences between consecutive pixels on the texture. Specifically, the numerator of the formula The function calculates the Pixels and The angle difference between the gradient directions of pixels, The function can obtain a value between arrive The radian value between represents the relative change angle of the two gradient directions. The angular difference between all consecutive pixels is accumulated and summed (the absolute value is taken), and then divided by the total number of pixels minus one (because every two consecutive pixels form a combination). The result is the average angular change degree of the entire texture in spatial distribution. The calculation result is converted into a value in the interval [0,1] through normalization, which is convenient for comparison between different textures. Therefore, the significance of this formula is to quantitatively evaluate the curvature of the remaining texture through the cumulative statistics of the gradient direction changes of all adjacent pixels on the texture. Textures with higher curvature are more likely to show scratch defect characteristics.

[0049] S5: Set the first neighborhood range and the second neighborhood range of each pixel point on each remaining texture, and determine the morphological clarity of each remaining texture based on the grayscale difference between the first neighborhood range and the second neighborhood range of each pixel point on each remaining texture, and the slope between each pixel point and the starting point of the texture.

[0050] The step of setting the first neighborhood range and the second neighborhood range of each pixel point on each remaining texture includes: Get the maximum width of the remaining texture , the total number of adjacent pixels on the left and right sides of each pixel pixels, as the first neighborhood range, and the total number of adjacent pixels on the left and right sides of each pixel pixel points as a second neighborhood range, and the first neighborhood range is smaller than the second neighborhood range.

[0051] The morphological clarity of each remaining texture is obtained by: Calculate the difference between the grayscale mean of the pixel point in the first neighborhood range and the grayscale mean of the pixel point in the second neighborhood range for each pixel point on the remaining texture, and obtain the absolute value as the neighborhood grayscale difference of the pixel point; The morphological clarity of each remaining texture is calculated according to the following formula: ; In the formula, For the The clarity of the remaining lines. is the total number of pixels on the remaining texture, is the sequence number of the pixel points on the remaining texture, The value of All integers in the range, For the The remaining lines Pixels and The slope between the starting points of the remaining lines, For the The remaining lines The grayscale difference of the neighborhood of pixels is Indicated by natural constant An exponential function with base .

[0052] The above formula is used to calculate the morphological clarity of each remaining texture. Its significance lies in the quantitative analysis of the local grayscale changes of the texture. First, by calculating the grayscale mean difference (absolute value) of each pixel in its first neighborhood and second neighborhood, the neighborhood grayscale difference is obtained. The neighborhood grayscale difference reflects the degree of drastic change in the local grayscale of the pixel. This change is usually more obvious at defects such as scratches. That is, the greater the neighborhood grayscale difference of the pixel, the more likely the pixel is a pixel with a scratch defect. Then, the formula is used to combine the neighborhood grayscale difference with the slope from the pixel to the starting point of the texture to calculate the morphological clarity of each remaining texture. The slope information can reflect the texture at the The direction and change trend in the image space, for the slope between the pixel point and the starting point of the texture, the slope can indicate the curvature of the texture. The greater the curvature, the more likely it is a pixel point with a scratch defect. Combining the neighborhood grayscale difference can better capture and identify the clear features of the scratch. The formula accumulates and normalizes the product of the neighborhood grayscale difference and the slope of all pixels to quantitatively evaluate the overall texture clarity of each remaining texture. The higher the value of the remaining texture clarity, the clearer the morphology of the texture, and the more likely it is a defect such as a scratch; conversely, the lower the value, the more blurred the texture, and the more likely it is a natural flow mark or other non-defect feature.

[0053] S6: Filter out the second scratch lines included in all the remaining lines by using the length, curvature and clarity of each remaining line.

[0054] Among them, the second scratch pattern contained in all the remaining patterns is screened out, as follows: (1) Calculate the probability that each remaining pattern is the second scratch pattern, including: Setting respective weights of the length, curvature and clarity of the shape, wherein the weight of the length is smaller than the weight of the curvature, and the weight of the curvature is smaller than the weight of the clarity; According to the weights of the length, curvature and clarity of each remaining line, the length, curvature and clarity of each remaining line are weighted and summed, and the obtained value is used as the probability that the remaining line is the second scratch line, which is specifically expressed by the formula: ; in, It is The probability that the remaining lines are the second scratch, , 、C Respectively The shape and length of the remaining lines , degree of curvature And the clarity of the shape The weight, for example, is , , ,in, , because in judging When the remaining lines are scratches, the clarity of the remaining lines has the greatest impact on the judgment, the degree of curvature of the lines has the second greatest impact, and the length of the lines has the least impact on the judgment.

[0055] (2) Determining whether each remaining line is a second scratch line, including: Preset probability threshold, in this embodiment, the probability threshold is set to , you can set it by yourself; If the probability that a certain remaining pattern is the second scratch pattern is greater than the probability threshold, then the remaining pattern is the second scratch pattern. If the probability that a certain remaining pattern is the second scratch pattern is not greater than the probability threshold, then the remaining pattern is not the second scratch pattern. Take the remaining lines as an example. If greater than 0.5, then The remaining lines are the second scratch lines, otherwise, The remaining lines are not the second scratch lines.

[0056] S7: Determine whether there is a scratch defect on the surface of the automobile metal plate according to the number of the first scratch lines and the second scratch lines included in the image to be detected.

[0057] Wherein, the method for judging whether there is a scratch defect on the surface of the automobile metal plate is: Adding the number of the first scratch patterns and the number of the second scratch patterns to obtain the total number of scratch patterns in the image to be detected; The ratio of the total number of scratch lines to the total number of all lines is used as the scratch defect degree of the automobile metal plate surface; The formula is: ; In the formula, Indicates the degree of defects on the metal plate surface. is the number of first scratch lines in the image to be detected, is the number of second scratch patterns in the image to be detected, is the total number of the first scratch pattern and the second scratch pattern.

[0058] A scratch defect degree threshold is preset. In this embodiment, the scratch defect degree threshold is set to 0.4, and the specific value can be set by the user. If the scratch defect degree on the surface of the automobile metal plate exceeds the scratch defect degree threshold, then the surface of the automobile metal plate has scratch defects and needs to be processed specifically; otherwise, the surface of the metal plate has no scratch defects.

[0059] 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.

[0060] 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 method for detecting surface defects of automobile parts based on image processing, characterized in that: include: Collect and pre-process the surface image of the automobile metal plate to obtain the image to be detected; Extract all the lines in the image to be detected, preliminarily screen the first scratch line according to the gradient direction of all the pixels on each line, and take the lines other than the first scratch line among all the lines as the remaining lines; Based on the difference in Euclidean distance between adjacent pixel points on each remaining texture and the starting point of the texture, the length of each remaining texture is determined; According to the difference in gradient directions of adjacent pixel points on each remaining texture, the degree of morphological curvature of each remaining texture is obtained; Setting a first neighborhood range and a second neighborhood range for each pixel point on each remaining texture, wherein the first neighborhood range is smaller than the second neighborhood range; Determine the morphological clarity of each remaining texture based on the grayscale difference between the first neighborhood range and the second neighborhood range of each pixel point on each remaining texture, and the slope between each pixel point and the starting point of the texture; The second scratch lines included in all the remaining lines are screened out by using the length, curvature and clarity of each remaining line, including: setting the weights of the length, curvature and clarity of the lines; According to the respective weights of the length, curvature and clarity of each remaining line, the length, curvature and clarity of each remaining line are weighted and summed, and the obtained value is used as the probability that the remaining line is the second scratch line; if the probability that a certain remaining line is the second scratch line is greater than the probability threshold, the remaining line is the second scratch line; if the probability that a certain remaining line is the second scratch line is not greater than the probability threshold, the remaining line is not used as the second scratch line; Whether there is a scratch defect on the surface of the automobile metal plate is determined according to the number of the first scratch lines and the second scratch lines included in the image to be detected.

2. The method for detecting surface defects of automobile parts based on image processing according to claim 1, characterized in that: The weight of the length of the shape is smaller than the weight of the curvature of the shape, and the weight of the curvature of the shape is smaller than the weight of the clarity of the shape.

3. The method for detecting surface defects of automobile parts based on image processing according to claim 1, characterized in that: The length and shape of each remaining pattern satisfy the following relationship: ; In the formula, For the The shape and length of the remaining lines, is the total number of pixels on the remaining texture, is the sequence number of the pixel points on the remaining texture, The value of All integers in the range, For the The remaining lines Pixels and The Euclidean distance from the starting point of the remaining lines, For the The remaining lines Pixels and The Euclidean distance from the starting point of the remaining lines, To calculate the absolute value, The natural constant An exponential function with base .

4. The method for detecting surface defects of automobile parts based on image processing according to claim 1, characterized in that: The degree of curvature of each remaining grain satisfies the following relationship: ; In the formula, For the The curvature of the remaining lines, is the total number of pixels on the remaining texture, is the sequence number of the pixel points on the remaining texture, The value of All integers in the range, For the The remaining lines The gradient direction of each pixel is For the The remaining lines The gradient direction of each pixel is is the inverse tangent function.

5. The method for detecting surface defects of automobile parts based on image processing according to claim 1, characterized in that: The morphological clarity of each remaining texture is obtained by: Calculate the difference between the grayscale mean of the pixel point in the first neighborhood range and the grayscale mean of the pixel point in the second neighborhood range for each pixel point on the remaining texture, and obtain the absolute value as the neighborhood grayscale difference of the pixel point; The morphological clarity of each remaining texture is calculated according to the following formula: ; In the formula, For the The clarity of the remaining lines. is the total number of pixels on the remaining texture, is the sequence number of the pixel points on the remaining texture, The value of All integers in the range, For the The remaining lines Pixels and The slope between the starting points of the remaining lines, For the The remaining lines The grayscale difference of the neighborhood of pixels is The natural constant An exponential function with base .

6. The method for detecting surface defects of automobile parts based on image processing according to claim 5, characterized in that: The step of setting the first neighborhood range and the second neighborhood range of each pixel point on each remaining texture includes: Get the maximum width of the remaining texture , the adjacent pixels on both sides of each pixel pixels as the first neighborhood range, and the adjacent pixels on both sides of each pixel are pixels as the second neighborhood range.

7. The method for detecting surface defects of automobile parts based on image processing according to claim 1, characterized in that: Determining whether there is a scratch defect on the surface of the automobile metal plate according to the number of the first scratch pattern and the second scratch pattern contained in the image to be detected includes: Adding the number of the first scratch patterns and the number of the second scratch patterns to obtain the total number of scratch patterns in the image to be detected; The ratio of the total number of scratch lines to the total number of all lines is used as the scratch defect degree of the automobile metal plate surface; Preset scratch defect level threshold; If the scratch defect degree on the surface of the automobile metal plate exceeds the scratch defect degree threshold, then there is a scratch defect on the surface of the automobile metal plate; otherwise, there is no scratch defect.

8. The method for detecting surface defects of automobile parts based on image processing according to claim 1, characterized in that: The first scratch pattern is initially screened based on the gradient direction of all pixels on each pattern, including: The average value of the gradient directions of all pixels on each texture is taken as the overall direction of the texture; Count the number of lines in each overall direction, and record the overall direction with the largest number of lines as , the main direction range of the flow mark gradient is [ ], is the default value; According to the gradient direction of each texture outside the main gradient direction range of the flow mark, The probability that each line whose gradient direction is outside the main gradient direction range of the flow mark is the first scratch line is calculated based on the difference between the two lines. Presetting a probability threshold of the first scratch pattern; If the probability that a certain line whose gradient direction is outside the main gradient direction range of the flow mark is a first scratch line exceeds the probability threshold of the first scratch line, then the line is the first scratch line; otherwise, the line is not the first scratch line.

9. The method for detecting surface defects of automobile parts based on image processing according to claim 8, characterized in that: The probability that each line whose gradient direction is outside the gradient main direction range of the flow mark is a first scratch line includes: The gradient direction of the texture is The absolute value of the difference is normalized to obtain the probability that the texture is the first scratch.

Citation Information

Patent Citations

  • Automobile part surface defect detection method

    CN117197141A

  • Blow molding bag production defect detection method

    CN115082419A

  • Visual inspection system for polishing effect of aluminum alloy surface

    CN117173189A

  • Automobile part paint surface abnormity detection method

    CN117218115A

  • Terminal liquid crystal surface defect detection method based on image processing

    CN118587216A

Cited By

  • Injection molding pipe fitting laser welding defect identification method based on image processing

    CN119963558A