A surface scratch detection method

Through image acquisition, preprocessing, edge detection and fusion technology, the problem of unclear scratch edge contour detection in traditional methods is solved, and efficient surface scratch detection is achieved, which is suitable for products made of various materials.

CN115760696BActive Publication Date: 2025-09-16JIANGSU UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211275552.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-18
Publication Date
2025-09-16
Estimated Expiration
2042-10-18

AI Technical Summary

Technical Problem

Traditional surface scratch detection methods are unable to detect the clear and continuous edge contours of scratches and are limited by complex background noise and interference of the detection target.

Method used

Image acquisition equipment is used to collect product surface images, and grayscale, filtering, image enhancement, edge detection and fusion are performed. Combined with threshold segmentation and morphological processing, the clear edge contours of surface scratches are screened out.

Benefits of technology

It effectively removes interference information and noise in the image, quickly detects the clear and continuous edge contours of surface scratches, and is suitable for surface scratch detection on a variety of materials.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115760696B_ABST
    Figure CN115760696B_ABST
Patent Text Reader

Abstract

The present invention provides a surface scratch detection method, which relates to the technical field of machine vision defect detection. The method comprises the following steps: using an image acquisition device to acquire a product surface image, and performing image processing on the acquired surface image to obtain an area to be detected; preprocessing the image of the area to be detected; performing edge detection on the preprocessed image of the area to be detected, and performing image fusion on different edge detection image results to obtain a fused edge detection image; processing the fused edge detection image to obtain an image with marked edges; and performing scratch screening on the image with marked edges to obtain a surface scratch detection result. The method solves the problem that traditional surface scratch detection methods cannot detect a clear and continuous edge contour of scratches, effectively removes interference information and noise in the image, and quickly detects a clear and continuous edge contour of surface scratches.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of machine vision defect detection, and in particular to a surface scratch detection method. Background Art

[0002] Surface scratches are common defects in industrial manufacturing. Surface scratch detection is a very important step in the quality inspection process of modern industrial products. Many industries pay special attention to the appearance of products, such as electronic assembly, automotive processing, screen production, furniture production, etc. The appearance of products directly affects product profits. In the modern industrial inspection process, the technical application of product defect detection through computer vision is becoming more and more extensive.

[0003] In the actual quality inspection process of industrial products, due to the complex noise and interference of the detection target background, and the scratches are very variable in terms of grayscale, continuity and directionality, traditional surface scratch detection methods are unable to detect clear and continuous edge contours of scratches. Summary of the Invention

[0004] The present invention discloses a surface scratch detection method, which solves the problem that traditional surface scratch detection methods cannot detect the clear and continuous edge contours of scratches, effectively removes interference information and noise in images, and quickly detects the clear and continuous edge contours of surface scratches.

[0005] To achieve the above object, the technical solution of the present invention is specifically implemented as follows:

[0006] The present invention discloses a surface scratch detection method, comprising the following steps:

[0007] Using an image acquisition device to acquire a surface image of the product, and performing image processing on the acquired surface image to obtain an area to be inspected;

[0008] Preprocessing the image of the area to be detected;

[0009] Perform edge detection on the pre-processed image of the area to be detected, and fuse the different edge detection image results to obtain a fused edge detection image;

[0010] Processing the fused edge detection image to obtain an image with marked edges;

[0011] Perform scratch screening on the image of the marked edge to obtain the surface scratch detection results.

[0012] Furthermore, the step of preprocessing the image of the area to be detected includes:

[0013] Grayscale the image of the area to be detected;

[0014] Using a filter to filter the grayscale image of the area to be detected;

[0015] Perform image enhancement on the filtered image of the area to be detected.

[0016] Furthermore, the filtered image of the area to be detected is enhanced by using a piecewise linear transformation method, which includes the following steps:

[0017] Use the ostu binarization algorithm to obtain the image threshold t;

[0018] Using the image threshold t, a piecewise linear transformation is adopted;

[0019]

[0020] Where f(i,j) represents the grayscale value of the pixel in the i-th row and j-th column on the piecewise linear transformation input image; e(i,j) represents the grayscale value of the pixel in the i-th row and j-th column on the piecewise linear transformation output image; t is the image threshold; e is the grayscale adjustment value; b1 is the intercept in the first straight line formula, b2 is the intercept in the second straight line formula, k1 is the slope in the first straight line formula, and k2 is the slope in the first straight line formula. Where b1=0, b2=e-k2*t, e is the grayscale adjustment value.

[0021] Furthermore, the step of obtaining the fused edge detection image includes:

[0022] Use the laplance operator to perform edge detection on the preprocessed image of the area to be detected;

[0023] Use the Sobel operator to perform edge detection on the preprocessed image of the area to be detected;

[0024] The image obtained by edge detection using the Laplance operator and the image obtained by edge detection using the Sobel operator are fused using a certain weight ratio.

[0025] Furthermore, the step of obtaining an image with marked edges includes:

[0026] Performing threshold segmentation and morphological processing on the fused edge detection image to obtain a processed edge detection image;

[0027] Superimposing the edge information of the processed edge detection image onto the pre-processed image of the area to be detected to obtain an image with marked edges;

[0028] Edge information superposition is implemented as follows:

[0029]

[0030] Among them, I A (i, j) represents the grayscale value of the pixel in the i-th row and j-th column of the output image; I B (i, j) represents the grayscale value of the pixel in the i-th row and j-th column of the image of the area to be detected after preprocessing; I b (i, j) represents the grayscale value of the pixel in the i-th row and j-th column on the edge detection image after threshold segmentation and morphological processing of the fused edge detection image; U is the screening threshold.

[0031] Furthermore, the step of screening the image of the marked edge for scratches includes:

[0032] Establish image correspondence using the pixel coordinates of the fused edge detection image, the pre-processed image of the area to be detected, and the blank grayscale image. The fused edge detection image is used as the search image for suspicious pixels, the pre-processed image of the area to be detected is used as the sampling image, and the blank grayscale image is used as the output object.

[0033] Find suspicious pixels, set the suspicious threshold R, and traverse each pixel in the fused edge detection image in turn. If the grayscale value of a pixel is greater than R, the pixel is considered a non-suspicious edge point; if the grayscale value of a pixel is less than R, the pixel is considered a suspicious edge point.

[0034] Local sampling and statistics: construct a square sampling area K=1,2,3,.... with a side length of 2K+1 on the image of the area to be detected after preprocessing, with the pixel coordinates corresponding to the suspicious pixel points as the center. Uniformly sample the pixels on the edge of the square sampling area, and the number of sampling points is G. Use the OSTU binarization algorithm to calculate the grayscale threshold S of the image of the area to be detected after preprocessing, and use this threshold as the dividing value between the bright grayscale value and the dark grayscale value at the sampling points of the image of the area to be detected after preprocessing. Count the number of occurrences of the bright grayscale value and the dark grayscale value of the sampling point, and count the number of occurrences of the bright grayscale value as g1, and the number of occurrences of the dark grayscale value as g2, and g1 and g2 satisfy G=g1+g2.

[0035] Identify suspicious pixels, set the screening threshold U, and 0<U<1. When g1>U×G, the pixel is considered to be a surface scratch edge point, and the grayscale value of the pixel is assigned to 255 on the blank grayscale image; when g1≤U×G, the pixel is considered to be a non-surface scratch edge point, and the grayscale value of the pixel is assigned to 0 on the blank grayscale image;

[0036] Using the connected domain area screening, pixels with a grayscale value of 255 are formed into a connected domain, and the connected domain with the largest area is obtained. Then a ratio value is set, and the area of ​​the largest connected domain is multiplied by the ratio value to obtain the area screening value. The connected domains with an area smaller than the area screening value are removed, thereby removing the noise area and obtaining the scratch edge contour.

[0037] Beneficial technical effects:

[0038] The present invention discloses a surface scratch detection method, comprising the following steps: using an image acquisition device to acquire a product surface image, and performing image processing on the acquired surface image to obtain a to-be-detected area; preprocessing the image of the to-be-detected area; performing edge detection on the preprocessed image of the to-be-detected area, and performing image fusion on different edge detection image results to obtain a fused edge detection image; processing the fused edge detection image to obtain an image with marked edges; and performing scratch screening on the image with marked edges to obtain a surface scratch detection result. The method solves the problem that traditional surface scratch detection methods cannot detect a clear and continuous edge contour of scratches, effectively removes interference information and noise in the image, and quickly detects a clear and continuous edge contour of surface scratches. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for describing the embodiments.

[0040] Figure 1 A flow chart of the steps of a surface scratch detection method disclosed in the present invention;

[0041] Figure 2 is an image of the area to be detected obtained in an embodiment of the present invention;

[0042] Figure 3 is an image of the area to be detected after preprocessing in an embodiment of the present invention;

[0043] Figure 4 is the edge detection image after fusion in an embodiment of the present invention;

[0044] Figure 5 An image with edge markings according to an embodiment of the present invention;

[0045] Figure 6 This is an image of the surface scratch detection result in an embodiment of the present invention. DETAILED DESCRIPTION

[0046] The following describes embodiments of the present invention in detail. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended only to explain the present invention and are not to be construed as limiting the present invention.

[0047] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0048] In order to verify the surface scratch detection method disclosed in the present invention, the area to be detected should contain background and other interference information, such as detection objects and pattern edges. The embodiment of the present invention takes the metal housing of an electronic product as an example.

[0049] The present invention discloses a surface scratch detection method, see Figure 1 , specifically including the following steps:

[0050] S1: using an image acquisition device to acquire a surface image of a product, and performing image processing on the acquired surface image to obtain an area to be inspected;

[0051] Specifically, in the embodiment of the present invention, a camera is used to collect the surface image of the metal shell of the electronic product. The camera uploads the collected image to the computer for image processing to obtain the area to be detected of the metal shell of the electronic product. Figure 2 ;

[0052] S2: Preprocessing the image of the area to be detected;

[0053] Specifically, the steps of preprocessing the image of the area to be detected include:

[0054] S21: grayscale the image of the area to be detected;

[0055] S22: Using a filter to filter the grayscale image of the area to be detected;

[0056] Specifically, a Gaussian filter is used to perform low-pass filtering on the grayscale image of the area to be detected to remove some noise;

[0057] S23: Perform image enhancement on the filtered image of the area to be detected.

[0058] Specifically, the filtered image of the area to be detected is enhanced by using a piecewise linear transformation method, and the image enhancement includes the following steps:

[0059] Use the ostu binarization algorithm to obtain the image threshold t;

[0060] Using the image threshold t, a piecewise linear transformation is adopted;

[0061]

[0062] Where f(i,j) represents the grayscale value of the pixel in the i-th row and j-th column on the piecewise linear transformation input image; e(i,j) represents the grayscale value of the pixel in the i-th row and j-th column on the piecewise linear transformation output image; t is the image threshold; e is the grayscale adjustment value; b1 is the intercept in the first straight line formula, b2 is the intercept in the second straight line formula, k1 is the slope in the first straight line formula, and k2 is the slope in the first straight line formula. Where b1=0, b2=e-k2*t, e is the grayscale adjustment value, and different enhancement effects can be achieved by changing the e value.

[0063] If a suitable e value can be selected so that k1 < 1 and k2 > 1, the pixel values ​​with grayscale values ​​in [0, t] are compressed and the pixel values ​​with grayscale values ​​in [t, 255] are expanded. Through this transformation, the pixels in the dark part are compressed and the pixels in the bright part are expanded, thereby achieving the effect of enhancing the image contrast and providing the prerequisite for subsequent edge detection and scratch recognition. In this embodiment, the image threshold t = 151 obtained by the ostu binarization method, and the e value is selected as e = 100 based on the empirical value. The final piecewise linear transformation result is as follows: Figure 3 As shown;

[0064] S3: performing edge detection on the pre-processed image of the area to be detected, and performing image fusion on different edge detection image results to obtain a fused edge detection image;

[0065] Specifically, the steps of obtaining the fused edge detection image include:

[0066] Use the laplance operator to perform edge detection on the preprocessed image of the area to be detected;

[0067] Use the Sobel operator to perform edge detection on the preprocessed image of the area to be detected;

[0068] The image obtained by edge detection using the Laplance operator and the image obtained by edge detection using the Sobel operator are fused by a certain weight ratio. The fused image in this embodiment is shown in FIG. Figure 4 ,Depend on Figure 4 It can be seen that there are a large number of noise points and non-edge information in the fused edge detection result image, including the edge information of the electronic product shell and the edge of the product logo. These interference information often bring great difficulties to the detection and screening of scratches.

[0069] S4: Processing the fused edge detection image to obtain an image with marked edges;

[0070] Specifically, threshold segmentation and morphological processing are performed on the fused edge detection image to obtain a processed edge detection image;

[0071] The edge information of the processed edge detection image is superimposed on the pre-processed image of the area to be detected to obtain an image with marked edges. The image with marked edges in this embodiment is referred to Figure 5 ;

[0072] Edge information superposition is implemented as follows:

[0073]

[0074] Among them, I A (i, j) represents the grayscale value of the pixel in the i-th row and j-th column of the output image; I B (i, j) represents the grayscale value of the pixel in the i-th row and j-th column of the image of the area to be detected after preprocessing; I b (i, j) represents the grayscale value of the pixel in the i-th row and j-th column on the edge detection image after threshold segmentation and morphological processing of the fused edge detection image; U is the screening threshold;

[0075] S5: Perform scratch screening on the image of the marked edge to obtain the surface scratch detection result.

[0076] The scratches on the image of the marked edge are screened using the local texture features of the scratches to remove most of the interference information and noise. The area of ​​the connected domain is then used to remove the smaller noise areas to obtain the scratch information. The specific steps include:

[0077] S51: Establishing an image correspondence relationship, establishing a correspondence relationship between the pixel coordinates of the fused edge detection image, the pre-processed image of the area to be detected, and the blank grayscale image, performing an operation based on the correspondence between the pixel coordinates of the three images, using the fused edge detection image as the search image for suspicious pixels, the pre-processed image of the area to be detected as the sampling image, and the blank grayscale image as the output object;

[0078] S52: Find suspicious pixels, set a suspicious threshold R, and traverse each pixel in the fused edge detection image in turn. If the grayscale value of a pixel is greater than R, the pixel is considered a non-suspicious edge point; if the grayscale value of a pixel is less than R, the pixel is considered a suspicious edge point. The process can be expressed by the following formula:

[0079]

[0080] Among them, I A (i, j) represents the grayscale value of the pixel in the i-th row and j-th column of the fused edge detection image; I C(i, j) is the grayscale value of the pixel in the i-th row and j-th column of the blank grayscale image;

[0081] Suspected point means that the pixel is regarded as a suspicious pixel;

[0082] S53: local sampling and statistics. On the image of the area to be detected after preprocessing, a square sampling area K=1,2,3,... with a side length of 2K+1 is constructed with the pixel coordinates corresponding to the suspicious pixel points as the center. The pixel points on the edge of the square sampling area are uniformly sampled, and the number of sampling points is G. The grayscale threshold S of the image of the area to be detected after preprocessing is calculated using the OSTU binarization algorithm. The threshold is used as the boundary value between the bright grayscale value and the dark grayscale value at the sampling points of the image of the area to be detected after preprocessing, and the number of occurrences of the bright grayscale value and the dark grayscale value of the sampling point is counted. The number of occurrences of the bright grayscale value is counted as g1, and the number of occurrences of the dark grayscale value is counted as g2, and g1 and g2 satisfy G=g1+g2.

[0083] S54: Identify suspicious pixels, set a screening threshold U, and set 0<U<1. When g1>U×G, the pixel is determined to be a surface scratch edge point, and the grayscale value of the pixel is assigned to 255 on the blank grayscale image; when g1≤U×G, the pixel is determined to be a non-surface scratch edge point, and the grayscale value of the pixel is assigned to 0 on the blank grayscale image;

[0084] The process can be expressed by the following formula:

[0085]

[0086] Among them, I C (i, j) represents the grayscale value of the pixel in the i-th row and j-th column of the blank grayscale image;

[0087] S55: Using the connected domain area screening, pixels with a grayscale value of 255 are formed into a connected domain, and the connected domain with the largest area is obtained. Then a ratio value is set, and the area of ​​the largest connected domain is multiplied by the ratio value to obtain an area screening value. The connected domains with an area smaller than the area screening value are removed, thereby removing the noise area and obtaining the scratch edge contour.

[0088] According to the size of the image and the characteristics of the scratches in this embodiment, the suspicious threshold R=1, the gray threshold S=190, the screening threshold U=0.6, K=9, and G=16 are respectively taken. The final scratch detection result is as follows: Figure 6 shown.

[0089] The surface scratch detection method disclosed in the present invention can detect surface scratches in a high-noise and multi-interference background, and can effectively remove interference information and noise. The surface scratch detection method disclosed in the present invention has a wide applicability and can effectively detect surface scratches of different materials such as metal, glass, and paper.

[0090] Throughout this specification, reference to terms such as "one embodiment," "some embodiments," "examples," "specific examples," or "some examples" means that a specific feature, structure, material, or characteristic described in conjunction with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.

[0091] The above embodiments are merely descriptions of preferred implementations of the present invention and are not intended to limit the scope of the present invention. Without departing from the spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary engineers and technicians in this field should fall within the scope of protection determined by the claims of the present invention.

Claims

1. A surface scratch detection method, characterized in that: The following steps are involved: Using an image acquisition device to acquire a surface image of the product, and performing image processing on the acquired surface image to obtain an area to be inspected; Preprocessing the image of the area to be detected; Perform edge detection on the pre-processed image of the area to be detected, and fuse the different edge detection image results to obtain a fused edge detection image; Processing the fused edge detection image to obtain an image with marked edges; The steps to obtain the fused edge detection image include: Use the laplance operator to perform edge detection on the preprocessed image of the area to be detected; Use the Sobel operator to perform edge detection on the preprocessed image of the area to be detected; The image obtained by edge detection using the Laplance operator and the image obtained by edge detection using the Sobel operator are fused using a certain weight ratio. Perform scratch screening on the image of the marked edge to obtain the surface scratch detection result; The steps for scratch screening an image of a marked edge include: Establish image correspondence using the pixel coordinates of the fused edge detection image, the pre-processed image of the area to be detected, and the blank grayscale image. The fused edge detection image is used as the search image for suspicious pixels, the pre-processed image of the area to be detected is used as the sampling image, and the blank grayscale image is used as the output object. Find suspicious pixels and set suspicious thresholds , traverse each pixel in turn on the fused edge detection image, if the gray value of a pixel is greater than , then the pixel is considered a non-suspicious edge point; if the gray value of a pixel is less than , then the pixel is regarded as a suspicious edge point; Local sampling and statistics, after preprocessing, the image of the area to be detected is centered on the pixel coordinates corresponding to the suspicious pixel point, and a pixel with a side length of Square sampling area , uniformly sample the pixels on the edge of the square sampling area, and the number of sampling points is ;use ostu The binarization algorithm calculates the grayscale threshold of the image of the area to be detected after preprocessing , the threshold is used as the dividing value between the bright grayscale value and the dark grayscale value at the sampling point of the image of the area to be detected after preprocessing, and the number of occurrences of the bright grayscale value and the dark grayscale value of the sampling point is counted, and the number of occurrences of the bright grayscale value is counted as , the number of occurrences of dark gray value is counted as ,and 、 satisfy ; Identify suspicious pixels and set screening thresholds ,and ,when When , the pixel point is identified as the edge point of the surface scratch, and the gray value of the pixel point is assigned to 255 on the blank gray image; when When , this pixel is considered as a non-surface scratch edge point, and the gray value of the pixel is assigned to 0 on the blank gray image; Using the connected domain area screening, pixels with a grayscale value of 255 are formed into a connected domain, and the connected domain with the largest area is obtained. Then a ratio value is set, and the area of ​​the largest connected domain is multiplied by the ratio value to obtain the area screening value. The connected domains with an area smaller than the area screening value are removed, thereby removing the noise area and obtaining the scratch edge contour.

2. A surface scratch detection method according to claim 1, characterized in that: The step of preprocessing the image of the area to be detected includes: Grayscale the image of the area to be detected; Using a filter to filter the grayscale image of the area to be detected; Perform image enhancement on the filtered image of the area to be detected.

3. A surface scratch detection method according to claim 2, characterized in that: The filtered image of the area to be detected is enhanced using a piecewise linear transformation method, which includes the following steps: Use the ostu binarization algorithm to obtain the image threshold t; Using the image threshold t, a piecewise linear transformation is adopted; The expression of the piecewise linear transformation is as follows: (1) in, Represents the piecewise linear transformation of the input image Rank Grayscale value of the pixel in the column; Represents the piecewise linear transformation output image Rank Grayscale value of the pixel in the column; is the image threshold; is the grayscale adjustment value; is the intercept in the first straight line formula, is the intercept in the second straight line formula, is the slope of the first straight line formula, is the slope of the first straight line formula, where , , , , is the grayscale adjustment value.

4. A surface scratch detection method according to claim 1, characterized in that: The steps to obtain an edge-marked image include: Performing threshold segmentation and morphological processing on the fused edge detection image to obtain a processed edge detection image; Superimposing the edge information of the processed edge detection image onto the pre-processed image of the area to be detected to obtain an image with marked edges; Edge information superposition is implemented as follows: (2) in, Indicates the output image Rank Grayscale value of the pixel in the column; Represents the first Rank Grayscale value of the pixel in the column; Indicates the edge detection image after threshold segmentation and morphological processing of the fused edge detection image. Rank Grayscale value of the pixel in the column.