Circuit board scratch detection method and system based on image processing

By performing grayscale processing and Gaussian filtering on the circuit board image, and combining template matching to remove the influence of circuit components, high accuracy and high sensitivity detection of all scratches on the circuit board surface is achieved, solving the problem of insufficient detection accuracy and real-time in the prior art.

CN114298996BActive Publication Date: 2025-03-07HEFEI GUOXUAN HIGH TECH POWER ENERGY

Patent Information

Application Number
CN202111592209.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-23
Publication Date
2025-03-07
Estimated Expiration
2041-12-23

AI Technical Summary

Technical Problem

The prior art is difficult to achieve high accuracy and high sensitivity simultaneously in circuit board scratch detection, and cannot meet the real-time requirements of industrial production.

Method used

By performing grayscale processing, Gaussian filtering and template matching on the circuit board image, the influence of circuit components is removed, and all scratches on the circuit board surface can be identified and extracted.

Benefits of technology

It improves the accuracy and sensitivity of detection, reduces the missed detection rate, and meets the real-time requirements of industrial production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114298996B_ABST
    Figure CN114298996B_ABST
Patent Text Reader

Abstract

The present invention provides a circuit board scratch detection method based on image processing, including: obtaining a circuit board surface image; graying and filtering the image to obtain a gray image; performing Gaussian filtering to remove noise on the gray image, and then performing Gaussian smoothing; using circuit components to make a background template, matching the template with the image, and locating the position of the circuit components in the image; removing the circuit components in the image, and obtaining an image of shielded circuit components by area filling; and extracting scratches from the image without circuit components. The advantages of the present invention are: graying the circuit board image first to reduce the amount of data, and then performing Gaussian filtering to remove interference information, and removing the influence of circuit components on scratch recognition by template matching, so that all scratches on the circuit board surface can be identified and extracted, and missed detection can be reduced, and the amount of data processed is small, which can meet the real-time requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of circuit board detection, and in particular to a circuit board scratch detection method and system based on image processing. Background Art

[0002] Printed Circuit Board (PCB) is a basic component of electronic products, and its quality has a great impact on the performance of electronic products. With the miniaturization of electronic products, PCBs are becoming more and more refined, miniaturized and high-density. Various defects may occur in PCBs after solder paste printing, reflow soldering, wave soldering and automatic patching. The existing detection of scratches on circuit boards in the market basically uses human eye observation, which not only has low work efficiency, but is also affected by uncertain factors such as personal thinking and external environment, resulting in no unified standard for the detection results. Machine vision technology based on digital image processing can solve these problems. However, due to the large amount of image data to be tested, it cannot meet the real-time requirements of industrial production.

[0003] The document "Li Yunfeng, Li Shengyang. Printed Circuit Board Defect Detection Based on Gradient Directional Information Entropy [J]. China Mechanical Engineering, 2017, 28(06): 695-701." discloses a method of implementing defect detection through image processing-copper cladding area segmentation-defect extraction-gradient direction detection, and finally using a SVM classifier. However, this method only focuses on the scars in the copper cladding area, that is, only focuses on the scars that may affect the circuit function. However, in circuit board production, it is also necessary to pay attention to the scars on the circuit board surface that do not affect the function. Therefore, this method cannot meet the needs of industrial production. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide a quantum dot immunochromatography signal detection method with both high accuracy and high sensitivity, so as to overcome the problems of the prior art.

[0005] The present invention solves the above technical problems through the following technical solutions, a circuit board scratch detection method based on image processing, comprising:

[0006] Step A: Acquire a circuit board surface image;

[0007] Step B: grayscale and filter the image to obtain a grayscale image;

[0008] Step C: Perform Gaussian filtering to denoise the grayscale image, and then perform Gaussian smoothing;

[0009] Step D: Using circuit components to create a background template, matching the template with the image, and locating the position of the circuit components in the image;

[0010] Step E: removing the circuit components in the image, and obtaining an image of shielded circuit components by region filling;

[0011] Step F: Perform scratch extraction on the image without circuit components.

[0012] The present invention reduces the data volume by first performing grayscale processing on the circuit board image, and then performs Gaussian filtering to remove interference information, and removes the influence of circuit components on scratch recognition through template matching. All scratches on the surface of the circuit board can be identified and extracted to reduce missed detections, and the amount of data processed is small, which can meet real-time requirements.

[0013] Preferably, the smoothing operator of the Gaussian filter is:

[0014]

[0015] Here, σ is the Gaussian distribution parameter.

[0016] Preferably, the method for matching the template with the image is: constructing a three-layer pyramid, starting from the bottom layer, with each additional layer, the image side length is reduced by 1 / 2, and the number of pixels becomes 1 / 4, first scanning the image through the top pyramid, moving one pixel each time, and matching the area scanned each time with the template.

[0017] Preferably, the scratch extraction method is:

[0018] Step 1: Count the total number of pixels in the image and the total number of pixels of each gray value, and calculate the probability value of each gray value in the image;

[0019] Step 2: Calculate the scratch and background distribution probabilities in the image respectively;

[0020] Step 3: Calculate the average gray value of the background and scratches;

[0021] Step 4: Calculate the inter-class difference of each gray value;

[0022] Step 5: The grayscale value corresponding to the maximum inter-class difference is used as the threshold of the scratch and background grayscale values.

[0023] Preferably, the method for calculating the scratch and background distribution probabilities is:

[0024] The image is divided into L grayscale levels according to the grayscale value. The grayscale value of the scratch is [0, k], and the grayscale value range of the background is [k+1, L-1]. The distribution probabilities of scratches and background are:

[0025]

[0026] ρ2(k)=1-ρ1(k)

[0027] Among them, Pi is the distribution probability of the pixel point with gray value i.

[0028] Preferably, the average gray value of the background and scratches is

[0029]

[0030]

[0031] Then the inter-class difference of each gray value is,

[0032]

[0033] in, represents pixel variance, and B(K) is the image pixel value matrix.

[0034] Preferably, the method further includes a step of performing a region growing operation on the scratch based on the directional gradient, and the method of calculating the grayscale gradient is:

[0035] For pixel (a, b), the gradient in the x and y directions of the image is expressed as

[0036] g x (a, b) = f(a, b) - f(a-1, b)

[0037] g y (a, b) = f(a, b) - f(a, b - 1)

[0038] Among them, f(a, b) is the pixel point (a , b) Gray value, g x (a, b) is the gradient of the pixel point (a, b) along the x and y directions of the coordinate axis, then the gradient direction angle and gradient modulus of the pixel point (a, b) are

[0039]

[0040]

[0041] Among them, θ is the angle between the gradient direction and the y-axis, |g(a, b)| is the gradient modulus, that is, the absolute value of the gradient value; by counting the gradient data of each scratch gray value, the minimum gradient direction is taken as the growth direction of the scratch;

[0042] When two scratches meet the judgment condition, the two scratches are attributed to the same scratch and the two endpoints are added as seed points; the judgment condition is

[0043]

[0044]

[0045] Among them, tanθ1 and tanθ2 are the gradient directions of the scratched areas at both ends, n is the direction accuracy; (a1, b1) and (a2, b2) are the two end points of the scratched area respectively; the distance between the two end points is D;

[0046] The scratch growth method is:

[0047] The neighborhood of the seed point is searched. If the neighborhood point meets the judgment condition, the neighborhood point is added to the seed point and the growth continues until no neighborhood point that meets both judgment conditions is found. The scratch growth operation ends.

[0048] The present invention also provides a circuit board scratch detection system based on image processing, comprising:

[0049] An image acquisition module, for acquiring an image of the circuit board surface;

[0050] Grayscale processing module, grayscale and filter the image to obtain a grayscale image;

[0051] Denoising module, which performs Gaussian filtering and denoising on the grayscale image, and then performs Gaussian smoothing;

[0052] The component recognition module uses circuit components to create a background template, matches the template with the image, and locates the position of the circuit components in the image;

[0053] A component removal module removes circuit components from the image and obtains an image of shielded circuit components by region filling;

[0054] The scratch extraction module extracts scratches from images without circuit components.

[0055] The present invention also provides an electronic processing device, comprising at least one processor and a storage device storing at least one execution program. When the at least one execution program is executed by the at least one processor, the at least one processor implements the circuit board scratch detection method.

[0056] The present invention also provides a computer-readable storage medium storing a computer program, wherein the computer program can implement the circuit board scratch detection method when executed by a processor.

[0057] The advantages of the circuit board scratch detection method based on image processing provided by the present invention are: grayscale processing is first performed on the circuit board image to reduce the data volume, and then Gaussian filtering is performed to remove interference information, and the influence of circuit components on scratch recognition is removed by template matching, so that all scratches on the circuit board surface can be identified and extracted to reduce missed detection, and the amount of data processed is small, which can meet the real-time requirements. The scratch area is expanded based on gradient growth to ensure that all scratches can be detected and improve accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 A flowchart of a circuit board scratch detection method based on image processing provided by an embodiment of the present invention;

[0059] Figure 2 A schematic diagram of a picture processed by the circuit board scratch detection method based on image processing provided by an embodiment of the present invention;

[0060] Figure 3 A schematic diagram of a circuit board scratch detection system based on image processing provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0061] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the technical solution of the present invention is clearly and completely described below in combination with specific embodiments and with reference to the accompanying drawings. 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 ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0062] Example 1

[0063] like Figure 1 As shown, this embodiment provides a method for detecting quantum dot immunochromatography signals based on image enhancement, comprising:

[0064] Step A: Acquire a circuit board surface image;

[0065] Step B: grayscale and filter the image to obtain a grayscale image;

[0066] Step C: Perform Gaussian filtering to denoise the grayscale image, and then perform Gaussian smoothing;

[0067] Step D: Using circuit components to create a background template, matching the template with the image, and locating the position of the circuit components in the image;

[0068] Step E: removing the circuit components in the image, and obtaining an image of shielded circuit components by region filling;

[0069] Step F: Perform scratch extraction on the image without circuit components.

[0070] This embodiment first performs grayscale processing on the circuit board image to reduce the data volume, then performs Gaussian filtering to remove interference information, and removes the influence of circuit components on scratch recognition through template matching. It can identify and extract all scratches on the surface of the circuit board and reduce missed detections. In addition, the amount of data processed is small, which can meet real-time requirements.

[0071] Specifically, the scratch detection method provided in this embodiment includes:

[0072] Step A: Acquire a circuit board surface image;

[0073] Step B: grayscale and mean filter the image to obtain a grayscale image;

[0074] Through grayscale processing, the color image is converted into a grayscale image;

[0075] Step C: Perform Gaussian filtering to remove noise on the grayscale image, and then perform Gaussian smoothing to smooth the pixel value distribution of the image and blur the processing edge;

[0076] When performing Gaussian filtering, the smoothing operator of Gaussian filtering is:

[0077]

[0078] Where σ is the Gaussian distribution parameter.

[0079] The expression of one-dimensional Gaussian distribution is

[0080]

[0081] The expression of the two-dimensional Gaussian distribution is

[0082]

[0083] Step D: Using circuit components to create a background template, matching the template with the image, and locating the position of the circuit components in the image;

[0084] The method for matching the template with the image is as follows: construct a three-layer pyramid, starting from the bottom layer. With each additional layer, the image side length is reduced by 1 / 2 and the number of pixels becomes 1 / 4. The image is first scanned through the top pyramid, moving one pixel at a time, and matching each scanned area with the template.

[0085] Step E: removing the circuit components in the image, and obtaining an image of shielded circuit components by region filling;

[0086] When filling an area, the circuit component area can be filled to be consistent with the circuit board background, or it can be filled with other grayscale values.

[0087] Step F: Perform scratch extraction on the image without circuit components.

[0088] The method for scratch extraction is:

[0089] Step 1: Count the total number of pixels in the image and the total number of pixels of each gray value, and calculate the probability value of each gray value in the image;

[0090] Step 2: Calculate the scratch and background distribution probabilities in the image respectively;

[0091] The image is divided into L grayscale levels according to the grayscale value. The grayscale value of the scratch is [0, k], and the grayscale value range of the background is [k+1, L-1]. The distribution probabilities of scratches and background are:

[0092]

[0093] ρ2(k)=1-ρ1(k)

[0094] Among them, Pi is the distribution probability of the pixel with gray value i;

[0095] Step 3: Calculate the average gray value of the background and scratches;

[0096] The average gray value of the background and scratches is

[0097]

[0098]

[0099] Step 4: Calculate the inter-class difference of each gray value;

[0100]

[0101] in, represents pixel variance, B(K) is the image pixel value matrix;

[0102] Step 5: The grayscale value corresponding to the maximum inter-class difference is used as the threshold of the scratch and background grayscale values, that is, the area with a grayscale value less than the threshold is the scratch area, so the scratch area can be extracted based on the grayscale value.

[0103] refer to Figure 2 The scratch detection method provided in this embodiment also includes the step of performing a region growing operation on the scratch based on the directional gradient, and the method for calculating the grayscale gradient is:

[0104] For pixel (a, b), the gradient in the x and y directions of the image is expressed as

[0105] g x (a, b) = f(a, b) - f(a-1, b)

[0106] g y (a, b) = f(a, b) - f(a, b - 1)

[0107] Among them, f(a, b) is the gray value of pixel (a, b), g x (a, b) is the gradient of the pixel point (a, b) along the x and y directions of the coordinate axis, then the gradient direction angle and gradient modulus of the pixel point (a, b) are

[0108]

[0109]

[0110] Among them, θ is the angle between the gradient direction and the y-axis, |g(a, b)| is the gradient modulus, that is, the absolute value of the gradient value; by counting the gradient data of each scratch gray value, the minimum gradient direction is taken as the growth direction of the scratch;

[0111] When two scratches meet the judgment condition, the two scratches are attributed to the same scratch and the two endpoints are added as seed points; the judgment condition is

[0112]

[0113]

[0114] Among them, tanθ1 and tanθ2 are the gradient directions of the scratched areas at both ends, n is the direction accuracy; (a1, b1) and (a2, b2) are the two end points of the scratched area respectively; the distance between the two end points is D;

[0115] The scratch growth method is:

[0116] The neighborhood of the seed point is searched. If the neighborhood point meets the judgment condition, the neighborhood point is added to the seed point and the growth continues until no neighborhood point that meets both judgment conditions is found. The scratch growth operation ends. The image after scratch recognition and extraction is as follows: Figure 3 shown.

[0117] Example 2

[0118] refer to Figure 3 This embodiment also provides a circuit board scratch detection system based on image processing, including:

[0119] An image acquisition module, for acquiring an image of the circuit board surface;

[0120] Grayscale processing module, grayscale and filter the image to obtain a grayscale image;

[0121] Denoising module, which performs Gaussian filtering and denoising on the grayscale image, and then performs Gaussian smoothing;

[0122] The component recognition module uses circuit components to create a background template, matches the template with the image, and locates the position of the circuit components in the image;

[0123] A component removal module removes circuit components from the image and obtains an image of shielded circuit components by region filling;

[0124] The scratch extraction module extracts scratches from images without circuit components.

[0125] Example 3

[0126] This embodiment further provides an electronic processing device, including at least one processor and a storage device storing at least one execution program, when the at least one execution program is executed by the at least one processor, the at least one processor performs the following method:

[0127] Step A: Acquire a circuit board surface image;

[0128] Step B: grayscale and filter the image to obtain a grayscale image;

[0129] Step C: Perform Gaussian filtering to denoise the grayscale image, and then perform Gaussian smoothing;

[0130] Step D: Using circuit components to create a background template, matching the template with the image, and locating the position of the circuit components in the image;

[0131] Step E: removing the circuit components in the image, and obtaining an image of shielded circuit components by region filling;

[0132] Step F: Perform scratch extraction on the image without circuit components.

[0133] Example 4

[0134] This embodiment further provides a computer-readable storage medium storing a computer program, which can implement the following method when executed by a processor:

[0135] Step A: Acquire a circuit board surface image;

[0136] Step B: grayscale and filter the image to obtain a grayscale image;

[0137] Step C: Perform Gaussian filtering to denoise the grayscale image, and then perform Gaussian smoothing;

[0138] Step D: Using circuit components to create a background template, matching the template with the image, and locating the position of the circuit components in the image;

[0139] Step E: removing the circuit components in the image, and obtaining an image of shielded circuit components by region filling;

[0140] Step F: Perform scratch extraction on the image without circuit components.

[0141] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A circuit board scratch detection method based on image processing, characterized in that: include, Step A: Acquire a circuit board surface image; Step B: grayscale and filter the image to obtain a grayscale image; Step C: Perform Gaussian filtering to denoise the grayscale image, and then perform Gaussian smoothing; Step D: Using circuit components to create a background template, matching the template with the image, and locating the position of the circuit components in the image; Step E: removing the circuit components in the image, and obtaining an image of shielded circuit components by region filling; Step F: extracting scratches from the image without circuit components; The method of scratch extraction is: Step 1: Count the total number of pixels in the image and the total number of pixels of each gray value, and calculate the probability value of each gray value in the image; Step 2: Calculate the scratch and background distribution probabilities in the image respectively; Step 3: Calculate the average gray value of the background and scratches; Step 4: Calculate the inter-class difference of each gray value; Step 5: The gray value corresponding to the maximum inter-class difference is used as the threshold of the scratch and background gray values; The method for calculating the scratch and background distribution probabilities is: The image is divided into L grayscale levels according to the grayscale value. The grayscale value of the scratch is [0, k], and the grayscale value range of the background is [k+1, L-1]. The distribution probabilities of scratches and background are: ρ2(k)=1-ρ1(k) Among them, Pi is the distribution probability of the pixel with gray value i; The average gray value of the background and scratches is, Then the inter-class difference of each gray value is, in, represents pixel variance, and B(K) is the image pixel value matrix.

2. The circuit board scratch detection method based on image processing according to claim 1, characterized in that: The smoothing operator of the Gaussian filter is: Among them, σ is the Gaussian distribution parameter, and (x, y) represents the coordinate axis.

3. The circuit board scratch detection method based on image processing according to claim 1, characterized in that: The method for matching the template with the image is as follows: construct a three-layer pyramid, starting from the bottom layer, with each additional layer, the image side length is reduced by 1 / 2, and the number of pixels is reduced to 1 / 4, and the image is first scanned through the top pyramid, moving one pixel each time, and matching each scanned area with the template.

4. The circuit board scratch detection method based on image processing according to claim 1, characterized in that: The step of performing a region growth operation on the scratch based on the directional gradient is also included, and the method for calculating the grayscale gradient is: For pixel (a, b), the gradient in the x and y directions of the image is represented by g x (a,b)=f(a,b)-f(a-1,b) g y (a,b)=f(a,b)-f(a,b-1) Among them, f(a,b) is the gray value of pixel (a,b), g x (a,b) is the gradient of the pixel point (a,b) along the x and y directions of the coordinate axis, then the gradient direction angle and gradient modulus of the pixel point (a,b) are Among them, θ is the angle between the gradient direction and the y-axis, |g(a,b)| is the gradient modulus, that is, the absolute value of the gradient value; by counting the gradient data of the grayscale values ​​of each scratch, the minimum gradient direction is taken as the growth direction of the scratch; When two scratches meet the judgment condition, the two scratches are attributed to the same scratch and the two endpoints are added as seed points; the judgment condition is Among them, tanθ1 and tanθ2 are the gradient directions of the scratched areas at both ends, n is the direction accuracy; (a1, b1) and (s2, b2) are the two end points of the scratched area respectively; the distance between the two end points is D; The scratch growth method is: The neighborhood of the seed point is searched. If the neighborhood point meets the judgment condition, the neighborhood point is added to the seed point and the growth continues until no neighborhood point that meets both judgment conditions is found. The scratch growth operation ends.

5. A circuit board scratch detection system based on image processing, characterized in that: include, An image acquisition module, for acquiring an image of the circuit board surface; Grayscale processing module, grayscale and filter the image to obtain a grayscale image; Denoising module, which performs Gaussian filtering and denoising on the grayscale image, and then performs Gaussian smoothing; The component recognition module uses circuit components to create a background template, matches the template with the image, and locates the position of the circuit components in the image; A component removal module removes circuit components from the image and obtains an image of shielded circuit components by region filling; A scratch extraction module is used to extract scratches from images without circuit components; The method of scratch extraction is: Step 1: Count the total number of pixels in the image and the total number of pixels of each gray value, and calculate the probability value of each gray value in the image; Step 2: Calculate the scratch and background distribution probabilities in the image respectively; Step 3: Calculate the average gray value of the background and scratches; Step 4: Calculate the inter-class difference of each gray value; Step 5: The gray value corresponding to the maximum inter-class difference is used as the threshold of the scratch and background gray values; The method for calculating the scratch and background distribution probabilities is: The image is divided into L grayscale levels according to the grayscale value. The grayscale value of the scratch is [0, k], and the grayscale value range of the background is [k+1, L-1]. The distribution probabilities of scratches and background are: ρ2(k)=1-ρ1(k) Among them, Pi is the distribution probability of the pixel with gray value i; The average gray value of the background and scratches is, Then the inter-class difference of each gray value is, in, represents pixel variance, and B(K) is the image pixel value matrix.

6. An electronic processing device, characterized in that: The method comprises at least one processor and a storage device storing at least one execution program. When the at least one execution program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 4.

7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 can be implemented.

Citation Information

Patent Citations

  • Intelligent image acquisition method and device, storage medium and terminal

    CN112489004A

  • Board line defect detection method and system for printed circuit board and storage medium

    CN112801948A

Cited By

  • Ceramic circuit board production parameter optimization method and device

    CN120805837A