Defect detection method and system for PCB hole processing based on machine vision
By analyzing the grayscale and gradient features of PCB slice images, a column-based method is used to determine the resin filling area in the plug hole and extract the bubble edge. This solves the accuracy problem of PCB board plug hole processing defect detection in the existing technology and achieves higher detection accuracy.
Patent Information
- Application Number
- CN202511087176.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-05
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-08-05
AI Technical Summary
The existing technology has low accuracy in defect detection results in PCB board plugging processing, especially it is difficult to accurately distinguish the boundary between the resin-filled area and the non-filled area in the plugged hole, and to extract fuzzy and irregular bubble defects.
By analyzing the grayscale and gradient features of pixels in PCB slice images, a column-based method is used to determine the resin filling area in the plug hole. The bubble edge is extracted by combining the grayscale standard deviation and gradient features. The bubble probability is calculated using the Euclidean distance and gradient angle difference to achieve accurate positioning of the bubble area.
The accuracy of defect detection for PCB plug hole processing is improved, and it can effectively identify the resin filling area and bubble defects in the plug hole, reduce the possibility of unclear edges caused by close colors, and improve the accuracy of detection results.
Smart Images

Figure CN120598941B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image data processing, and in particular to a defect detection method and system for PCB hole processing based on machine vision. BACKGROUND
[0002] Printed circuit board (PCB) is a key component of electronic equipment, and its manufacturing quality directly affects the performance and reliability of electronic equipment. In the PCB manufacturing process, hole processing is one of the important links, through which resin fills the through hole or blind hole to achieve electrical isolation, prevent short circuit or meet the demand of surface mounting process. The filling quality of the hole, especially the fullness of the ink resin, plays a decisive role in the overall performance of the PCB, so defect detection is needed for hole filling.
[0003] At present, Canny edge detection algorithm and convolutional neural network (CNN) are two relatively efficient detection methods. Canny edge detection algorithm can identify edge information in the image to a certain extent through Gaussian filtering, gradient calculation, non-maximum suppression and double threshold detection; CNN can automatically extract image features through multi-layer convolution and pooling operation, and realize defect detection of hole filling.
[0004] However, the above-mentioned prior art has obvious limitations in practical application. On the one hand, due to the fact that the color of the resin filling area in the hole is very similar to that of the non-filling area outside the hole, the Canny edge detection algorithm cannot accurately distinguish the boundary between the two, and edge misjudgment or missed detection may occur; on the other hand, the edge of the bubble existing in the hole often presents a fuzzy and irregular shape, and neither Canny edge detection algorithm nor CNN can accurately extract such fuzzy and irregular edge, so as to accurately judge the size, shape and position of the bubble, and affect the comprehensive detection of the hole filling defects. The above problems ultimately lead to low accuracy of the defect detection result of the PCB hole processing. Therefore, a detection method is needed to overcome the above defects and improve the quality detection precision of the PCB hole processing. SUMMARY
[0005] In order to solve the technical problem of low accuracy of the defect detection result of the PCB hole processing, the present application provides a defect detection method and system for PCB hole processing based on machine vision.
[0006] In the first aspect, the present application provides a defect detection method for PCB hole processing based on machine vision, which adopts the following technical scheme:
[0007] The defect detection method for PCB hole processing based on machine vision comprises the following steps:
[0008] The pixel points in the PCB slice image are acquired; the number of gray-scale similar pixel points on the column where the pixel point is located is determined according to the gray-scale difference between the pixel point and the pixel points in the same column; the probability that the pixel point on the column is in the resin filling area in the hole is calculated according to the number of gray-scale similar pixel points on the column, the number of peak values and the maximum gray-scale, so as to determine the resin filling area in the hole in the PCB slice image; the candidate pixel point in the resin filling area in the hole in the PCB slice image is determined by the gray-scale standard deviation of the neighborhood pixel points of the pixel point; any adjacent column on the left and right sides of the candidate pixel point is taken as the target column of the candidate pixel point, the first two candidate pixel points in the descending order of the distance between the candidate pixel point and each candidate pixel point in the target column are respectively recorded as the target point and the feature point of the candidate pixel point, the probability that the candidate pixel point and the target point are in the same bubble edge in the target column is calculated according to the gradient amplitude difference and the gradient angle difference between the candidate pixel point and the target point, and the Euclidean distance between the target point and the feature point in the target column, so as to determine the bubble area and obtain the defect detection result for PCB hole processing.
[0009] After accurately positioning the resin filling area in the hole in the PCB slice image, the difference between the bubble and the resin filling background area is analyzed, the bubble defect can be accurately extracted from the resin filling area in the hole, and the accuracy of the defect detection result for PCB hole processing is effectively improved. In the process of positioning the resin filling area in the hole, the gray-scale distribution characteristics of each column of pixel points are analyzed in units of columns, the resin filling area in the hole in the PCB slice image can be accurately positioned, and the possibility that the edge of the resin filling area in the hole is not clear due to close color is effectively reduced. On this basis, the degree to which the gray-scale and gradient of each pixel point in the resin filling area in the hole meet the continuity characteristics, ring gradient characteristics and gray-scale mutation characteristics of the bubble edge is analyzed, the pixel points meeting the bubble edge can be accurately extracted from the resin filling area in the hole, and thus the bubble defect in the PCB slice image can be accurately obtained, and the accuracy of the defect detection result for PCB hole processing is effectively improved.
[0010] According to the defect detection method for PCB hole processing based on machine vision provided by the application, the pixel points in the PCB slice image are acquired, and the method further comprises the following steps: slicing after the PCB is completed and cured, preprocessing after the slice photo is taken, obtaining the PCB slice image, recording the lower left corner of the PCB slice image as the coordinate origin, constructing the coordinate axis of the PCB slice image with the horizontal right direction of the coordinate origin as the horizontal axis and the vertical upward direction of the coordinate origin as the vertical axis, and determining the coordinates of each pixel point and the pixel points in the same column.
[0011] The present invention processes the captured slice photos through a series of preprocessing means, which can effectively improve the quality of the image, so that subsequent image analysis can be accurately performed based on the image and reduce the interference of irrelevant factors.
[0012] According to the machine vision-based defect detection method for PCB via plugging provided by the present invention, the method of determining the number of grayscale similar pixels on the column where the pixel point is located based on the grayscale difference between the pixel point and the pixels in the same column includes: obtaining the grayscale maximum value on the column where the pixel point is located, obtaining the pixels in the same column whose difference with the grayscale maximum value is less than a difference threshold on the column, and obtaining the number of grayscale similar pixels on the column.
[0013] The present invention takes into account that the pixels in the resin-filled area of the plug hole are usually off-white, and therefore obtains the proportion of off-white pixels on each column to accurately measure the possibility that the column is in the resin-filled area of the plug hole.
[0014] According to the defect detection method for PCB plug hole processing based on machine vision provided by the present invention, the probability of the pixel points on the column being in the resin filling area in the plug hole to determine the resin filling area in the plug hole in the PCB slice image includes: recording the ratio of the number of grayscale similar pixels on the column to the total number of pixels on the column as the similarity index of the column, calculating the probability of the pixel points on the column being in the resin filling area in the plug hole, and determining the resin filling area in the plug hole in the PCB slice image. The probability that the pixel point on the column is in the resin filling area inside the plug hole :
[0015] ;
[0016] 、 、 Respectively Grayscale maximum value, similarity index, peak number on the column, 、 are the maximum similarity index and the maximum peak number in all columns, is the absolute value symbol, is an exponential function with base e. If the probability that a pixel point on a column is in the resin-filled area in the plug hole is greater than the probability threshold, then the column is in the resin-filled area in the plug hole.
[0017] According to the machine vision-based defect detection method for PCB board plugging processing provided by the present invention, the method for obtaining the number of peaks on a column includes: constructing a grayscale histogram for each column, recording the grayscale value in the grayscale histogram whose number of pixels corresponding to the grayscale value is greater than a number threshold as a peak value, and obtaining the number of peaks on each column.
[0018] The present invention takes into account that the pixels in the resin-filled area of the plug hole are usually grayish white, while the pixels in the non-resin-filled area of the PCB board are usually black-gray gradients. Therefore, the present invention obtains the number of grayscale peaks in each column of pixels to obtain the possibility of the existence of a gradient.
[0019] According to the machine vision-based defect detection method for PCB via plugging provided by the present invention, the candidate pixel points in the PCB slice image are determined by the grayscale standard deviation of the neighboring pixel points of the pixel point in the resin filling area within the plugging hole, including: presetting the neighborhood size of the pixel point, constructing a neighborhood with the pixel point as the center among the surrounding pixels of the pixel point, obtaining the neighboring pixel points in the neighborhood of the pixel point, and determining the grayscale standard deviation of all the neighboring pixel points of the pixel point; and recording the pixel point whose grayscale standard deviation of the neighboring pixel points is greater than the fluctuation threshold as a candidate pixel point.
[0020] According to the machine vision-based defect detection method for PCB via plugging provided by the present invention, the calculation of the probability that the candidate pixel point and the target point in the target column are located at the same bubble edge includes:
[0021] ;
[0022] 、 、 Respectively The probability that the candidate pixel point and the target point in the i-th target column are on the same bubble edge, the absolute value of the gradient amplitude difference, and the absolute value of the gradient angle difference, For the The Euclidean distance between the target point and the feature point in the i-th target column of the candidate pixel, is the normalization function, is an exponential function with base e.
[0023] The present invention takes into account the continuity characteristics, ring gradient characteristics and large grayscale difference characteristics of the bubble edge, and therefore provides an accurate probability calculation method for a candidate pixel point and a target point in its target column to be on the same bubble edge. Through the gradient amplitude difference, gradient angle difference and Euclidean distance, the possibility that the candidate pixel point and the target point in its target column are on the same bubble edge can be accurately evaluated, so that the bubble area in the resin filling area in the plug hole can be accurately obtained based on this.
[0024] According to the defect detection method for PCB hole processing based on machine vision provided by the application, the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is calculated to determine the bubble area, and the method comprises the following steps: if the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is greater than the bubble probability threshold, the candidate pixel point and the target point in the target column are connected to obtain an edge; all the connected edges are processed by using a connected domain to obtain a complete bubble area.
[0025] According to the defect detection method for PCB hole processing based on machine vision provided by the application, the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is calculated to determine the bubble area, and the method comprises the following steps: if the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is greater than the bubble probability threshold, the candidate pixel point and the target point in the target column are connected to obtain an edge; all the connected edges are processed by using a connected domain to obtain a complete bubble area.
[0026] In a second aspect, the application provides a defect detection system for PCB hole processing based on machine vision, which adopts the following technical scheme:
[0027] The defect detection system for PCB hole processing based on machine vision comprises a processor and a memory, and the memory stores computer program instructions, which are executed by the processor to realize the defect detection method for PCB hole processing based on machine vision.
[0028] By adopting the above technical scheme, the defect detection method for PCB hole processing based on machine vision is generated into a computer program and stored in the memory to be loaded and executed by the processor, so that a terminal device is manufactured according to the memory and the processor, and the use is facilitated.
[0029] The application has the following technical effects:
[0030] Based on the above technical solution, the present invention provides a machine vision-based defect detection method and system for PCB via hole processing. After accurately locating the resin-filled area within the via hole in a PCB slice image, the method and system can accurately extract bubble defects from the resin-filled area within the via hole by analyzing the difference between the bubble and the resin-filled background area, effectively improving the accuracy of the defect detection results for PCB via hole processing. In the process of locating the resin-filled area within the via hole, the present invention analyzes the grayscale distribution characteristics of each column of pixels on a column-by-column basis, accurately locating the resin-filled area within the via hole within the PCB slice image, effectively reducing the possibility of unclear edges of the resin-filled area within the via hole due to color proximity. On this basis, the present invention also analyzes the degree to which the grayscale and gradient of each pixel in the resin-filled area within the via hole conform to the continuity characteristics, ring gradient characteristics, and grayscale mutation characteristics of the bubble edge, accurately extracting pixels from the resin-filled area within the via hole that conform to the bubble edge. Based on this, the bubble defect in the PCB slice image can be accurately obtained, effectively improving the accuracy of the defect detection results for PCB via hole processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A schematic diagram of a process flow in a method for detecting defects in PCB via plugging based on machine vision provided by an embodiment of the present invention;
[0032] Figure 2 A schematic diagram of a PCB slice image provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, but not all of the embodiments.
[0034] An embodiment of the present invention discloses a defect detection method for plugging vias on PCBs based on machine vision. The method accurately extracts the resin-filled area within the plugged vias in the PCB slice image by analyzing the distribution characteristics and grayscale characteristics of pixels in the PCB slice image. Furthermore, based on the grayscale characteristics and gradient characteristics of each column in the resin-filled area, the method accurately extracts bubble defects from the resin-filled area within the plugged vias. This method can effectively improve the accuracy of defect detection results for plugging vias on PCBs.
[0035] For details, please see Figure 1 As shown, Figure 1 This is a flow chart of a method for detecting defects in a PCB via plugging process based on machine vision according to an embodiment of the present invention. The method specifically includes the following steps:
[0036] S1: Get pixel points in the PCB slice image.
[0037] For example, in an embodiment of the present invention, pixel points in a PCB slice image are obtained, and the process also includes: slicing the PCB after solidification is completed, taking a photo of the slice and performing preprocessing to obtain a PCB slice image, recording the lower left corner of the PCB slice image as the coordinate origin, constructing the coordinate axis of the PCB slice image with the horizontal right direction of the coordinate origin as the horizontal axis and the vertical upward direction of the coordinate origin as the vertical axis, and determining the coordinates of each pixel point and the pixel points in the same column.
[0038] Specifically, after the PCB is cured in a vacuum environment, slices are taken. When photographing the slices, the camera and light source can be calibrated to ensure that the images captured are clear and distortion-free. The dried and cured PCB slice samples are placed on the sample stage, ensuring that the samples are flat and securely fixed. Camera parameters, such as exposure time, resolution, and magnification, are set to obtain optimal quality slice photographs. These parameters can be set based on actual needs and are not subject to further limitations in this embodiment of the present invention.
[0039] After capturing slice images, preprocessing can include using filters (such as Gaussian filtering or median filtering) to remove noise. Converting captured color images to grayscale can reduce subsequent processing steps. Using methods such as histogram equalization can enhance image contrast and detail clarity. Using geometric transformations can also adjust image morphology.
[0040] The preprocessing method can be specifically set according to actual needs, and the embodiment of the present invention does not impose too many restrictions on this.
[0041] According to the above steps, PCB slice images can be collected. For details, please refer to Figure 2 As shown, Figure 2 A schematic diagram of a PCB slice image provided by an embodiment of the present invention, from Figure 2 It can be seen that in the longitudinal direction, the PCB slice image includes the resin-filled area in the middle plug hole and the surrounding substrate of the non-resin-filled area outside the plug hole on both sides. The surrounding substrate may include the PCB conductive layer, insulation layer, etc.
[0042] Based on the above steps, a PCB slice image can be obtained. By establishing a coordinate axis in the PCB slice image, the coordinates of each pixel point and the column in which each pixel point is located in the coordinate axis can be obtained. By analyzing the grayscale characteristics of the pixel points, the resin filling area in the plug hole can be accurately extracted, and thus the bubble defect can be accurately extracted based on this, that is, the following steps can be performed.
[0043] S2: determining the number of gray-scale similar pixel points on the column where the pixel point is located according to the gray-scale difference between the pixel point and the pixel points in the same column; and calculating the probability of the pixel point being in the resin filling area in the hole to determine the resin filling area in the hole in the PCB slice image.
[0044] It should be noted that in the PCB slice image, the pixel points in the column in the non-resin filling area outside the hole are mostly gray and black, while the pixel points in the column in the resin filling area in the hole are mostly gray and white, and the gray and white pixel points in the resin filling area in the hole are mostly in each column. In addition, in the PCB slice image, due to the annular ring of the copper pad outside the hole and the difference in material and structure between the hole wall and the surrounding substrate, there is a gradual transition from the hole wall to the substrate, resulting in a gray-scale gradient feature in the column of pixel points in the non-resin filling area outside the hole.
[0045] Based on this, the embodiment of the present application can analyze whether the maximum value of the gray-scale value corresponding to the pixel points in each column is close to white, the proportion of the number of pixel points close to white in each column to the number of all pixel points in the column, and the number of peak values in the gray-scale histogram of each column to measure the gradient feature, which jointly assist in determining whether each column belongs to the resin filling area in the hole.
[0046] For example, in the embodiment of the present application, the number of gray-scale similar pixel points on the column where the pixel point is located is determined according to the gray-scale difference between the pixel point and the pixel points in the same column, which includes: obtaining the maximum gray-scale value on the column where the pixel point is located, obtaining the pixel points in the same column on the column whose difference from the maximum gray-scale value is less than the difference threshold value, and obtaining the number of gray-scale similar pixel points on the column.
[0047] The difference threshold value can be set to 20, and can be set according to actual needs.
[0048] For example, the ratio of the number of gray-scale similar pixel points on the column to the total number of pixel points on the column is referred to as the similarity index of the column.
[0049] It can be understood that there are white pixel points in the pixel points on the column where the pixel point is located, so the maximum gray-scale value is usually close to the gray-scale value of the white pixel points, and the similar pixel points whose gray-scale difference from the white pixel points is less than the difference threshold value are white pixel points or pixel points whose gray is close to white. The proportion of gray and white pixel points on each column can be accurately obtained by the proportion of the number of similar pixel points on each column.
[0050] For example, in the embodiment of the present application, the peak value number obtaining method on the column includes: constructing a gray-scale histogram of each column, recording the gray-scale values in the gray-scale histogram whose corresponding pixel point number is greater than the number threshold value as the peak values, and obtaining the peak value number on each column.
[0051] The number threshold may be set to 50, and the number threshold may be specifically set according to actual needs.
[0052] It can be understood that the peak value in the grayscale histogram of each column of pixels is the grayscale value that appears most frequently in that column. For columns with very chaotic grayscale, there may be many different grayscale values, resulting in the number of pixels corresponding to each grayscale value being less than the number threshold. For the grayscale histogram of such columns, the median of the number of pixels corresponding to each grayscale value in the grayscale histogram can be used as the segmentation threshold, and the number of pixels greater than the segmentation threshold can be used as the peak value.
[0053] After obtaining the number of grayscale similar pixels, the number of peaks, and the maximum grayscale value on each column based on the above steps, the probability of the pixel on each column being in the resin-filled area in the plug hole can be calculated based on this.
[0054] For example, in an embodiment of the present invention, calculating the probability that a pixel point on each column is located in the resin-filled area of the plug hole includes:
[0055] ;
[0056] For the The probability that the pixel point on the column is in the resin filling area inside the plug hole, For the The maximum grayscale value on the column, is the maximum grayscale value in all columns, For the Similar indicators on columns, is the maximum value of similarity index in all columns, For the The number of peaks on the column, is the maximum number of peaks in all columns, is the absolute value symbol, It is an exponential function with base e, where e is a natural constant.
[0057] In this calculation method, It is The normalized difference between the grayscale maximum value on the column and the global grayscale maximum value of the PCB slice image. The smaller the value, the higher the grayscale value. The grayscale maximum value on the column is closer to white. It is The normalized difference between the similarity index on the column and the maximum value of the global similarity index of the PCB slice image. The smaller the value, the better. The closer the proportion of gray and white pixels in the column is to the global maximum value. It is The normalized difference between the number of peaks on the column and the maximum value of the global peak number of the PCB slice image. The larger the value, the higher the value. The closer the number of peaks on a column is to the global maximum number of peaks, the greater the possibility that a black-gray gradient exists on the column.
[0058] In the The closer the maximum grayscale value on the column is to white, the The higher the proportion of gray-white pixels on the column, the The smaller the possibility of black-gray gradient on the column, the The more the grayscale distribution characteristics of the column conform to the characteristics of the resin-filled area in the plug hole, the greater the probability that the column is in the resin-filled area in the plug hole.
[0059] According to the above steps, the probability of the pixel points in each column of the PCB slice image being in the resin filling area in the plug hole can be obtained. The higher the probability, the greater the possibility that the pixel points in this column are in the resin filling area in the plug hole.
[0060] For example, in an embodiment of the present invention, the columns on which the probability of the pixel points being in the resin filling area in the plug hole is greater than the probability threshold can be used as the resin filling area in the plug hole, and all columns in the resin filling area in the plug hole on the PCB slice image are obtained.
[0061] The probability threshold may be set to 0.7; the probability threshold may be specifically set according to actual needs.
[0062] After accurately extracting the resin filling area in the plug hole on the PCB slice image based on the above steps, the bubble area can be accurately extracted by analyzing the difference between normal pixels and bubble pixels in the resin filling area in the plug hole, that is, continue to perform the following steps.
[0063] S3: Determine a candidate pixel point in the PCB slice image based on the grayscale standard deviation of the neighboring pixel points in the resin filling area of the plug hole; calculate the probability that the candidate pixel point and the target point in the target column are on the same bubble edge to determine the bubble area.
[0064] It should be noted that the interior of the bubble is primarily air or other gas, with a much lower density than the ink resin material. When capturing PCB slice images, the gas in the resin-filled area of the plug hole has a weaker ability to absorb the ambient light source. Therefore, the interior of the bubble appears as a low-reflectivity area in the image, corresponding to a lower grayscale value. The edge of the bubble is the interface between the gas and the resin. The ink resin material has a strong light absorption capacity, so there is a significant difference in the refractive index of light between the bubble and the ink resin material at the bubble edge, resulting in a bright edge at the bubble edge. The resulting appearance of the bubble in the resin-filled area of the plug hole is darker inside and brighter at the edge, with more dramatic grayscale changes at the edge.
[0065] Based on this, the embodiment of the present application can measure the fluctuation degree of the gray scale change of each pixel point in the resin filling area in the hole by obtaining the gray scale standard deviation of each pixel point in the local range, so as to locate the candidate pixel point of the bubble edge in the resin filling area in the hole, thereby accurately extracting the bubble area.
[0066] For example, in the embodiment of the present application, the candidate pixel point in the PCB slice image is determined by the gray scale standard deviation of the neighborhood pixel point of the pixel point in the resin filling area in the hole, comprising: presetting the neighborhood size of the pixel point, constructing the neighborhood around the pixel point with the pixel point as the center to obtain the neighborhood pixel point in the neighborhood of the pixel point, and determining the gray scale standard deviation of all neighborhood pixel points of the pixel point; the pixel point whose gray scale standard deviation of the neighborhood pixel point is greater than the fluctuation threshold is recorded as the candidate pixel point.
[0067] Wherein, the neighborhood size can be set to 5*5, and the fluctuation threshold can be set to 0.5; the neighborhood size and the fluctuation threshold can be set according to actual needs, which is not limited too much in the embodiment of the present application.
[0068] It can be understood that the candidate pixel point obtained based on the above steps is a pixel point with large gray scale fluctuation in the neighborhood range, and such pixel point has a higher possibility of being a bubble edge pixel point, but in the PCB slice image, other factors may cause high variance, which is not the real bubble edge. The gradient amplitude of the real bubble edge is usually much higher than the resin background, the gray scale change is significant, and the gradient direction of the bubble edge points to the bubble center, forming a ring-shaped gradient field, so that the gradient angle difference of adjacent pixel points is small. In addition, the edge of the bubble also has spatial continuity.
[0069] Therefore, the embodiment of the present application takes the pixel point screened out by the gray scale fluctuation as the candidate pixel point, and further analyzes the gradient amplitude, gradient angle and continuous feature of the candidate pixel point to evaluate the possibility that the candidate pixel point can be connected with the candidate pixel points in the adjacent columns on both sides as the bubble edge, thereby realizing the edge connection of the real bubble edge pixel point.
[0070] For example, in the embodiment of the present application, any adjacent column on both sides of the candidate pixel point can be taken as the target column of the candidate pixel point, the first two candidate pixel points in the descending order of the distance between the candidate pixel point and each candidate pixel point in the target column are respectively recorded as the target point and the feature point of the candidate pixel point, and the probability that the candidate pixel point and the target point are in the same bubble edge in the target column is calculated according to the gradient amplitude difference, the gradient angle difference between the candidate pixel point and the target point, and the Euclidean distance between the target point and the feature point in the target column.
[0071] It can be understood that each candidate pixel point has a left adjacent column and a right adjacent column. If there is no candidate pixel point in one side adjacent column, the next adjacent column of the side adjacent column can be taken as the adjacent column of the candidate pixel point across the column.
[0072] The maximum number of columns across the column can be set to 5 columns, and can be set according to actual needs.
[0073] For example, the acquisition method of the adjacent columns on both sides of the current candidate pixel point is as follows: if the current candidate pixel point is in the 10th column, the 9th column is taken as the left adjacent column of the current candidate pixel point, and the 11th column is taken as the right adjacent column of the current candidate pixel point. If there is no candidate pixel point in the left 9th column, the 8th column can be taken as the left adjacent column of the current candidate pixel point, and if there is no candidate pixel point in the 8th column, the 7th column is continued to be determined whether there is a candidate pixel point. In this way, if there is still no candidate pixel point in the 5th column, only the right adjacent column of the current candidate pixel point can be analyzed.
[0074] According to the above steps, the adjacent columns on both sides of each candidate pixel point and the candidate pixel points in the adjacent columns can be obtained. It can be understood that in the distance descending order arrangement between the current candidate pixel point and each candidate pixel point in the target column, the closer the distance between the candidate pixel point in the target column and the current candidate pixel point, the higher the ranking. The target point is the candidate pixel point in the target column closest to the current candidate pixel point, and the feature point is the candidate pixel point in the target column ranking second to the current candidate pixel point.
[0075] The distance can be the Euclidean distance between the candidate pixel points.
[0076] However, for some current candidate pixel points, the number of candidate pixel points in the target column closest to the current candidate pixel point can be two. At this time, when constructing the distance descending order arrangement, the gradient amplitude difference between the two candidate pixel points and the current candidate pixel point can be obtained, the candidate pixel point corresponding to the maximum of the two gradient amplitude differences is taken as the candidate pixel point closest to the current candidate pixel point, and the candidate pixel point corresponding to the minimum of the two gradient amplitude differences is taken as the feature point of the current candidate pixel point.
[0077] The gradient amplitude difference is the absolute value of the difference of the gradient amplitude.
[0078] Based on the above steps, the target point and the feature point of each candidate pixel point in the target column can be obtained.
[0079] For example, in the embodiment of the present application, the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is calculated, comprising:
[0080] ;
[0081] For the i-th target column of the j-th candidate pixel point, For the i-th target column of the j-th candidate pixel point, For the i-th target column of the j-th candidate pixel point, For the i-th target column of the j-th candidate pixel point, For the i-th target column of the j-th candidate pixel point, For the i-th target column of the j-th candidate pixel point, For the i-th target column of the j-th candidate pixel point, For the i-th target column of the j-th candidate pixel point, is a normalization function, is an exponential function with base e, and e is a natural constant.
[0082] In this calculation method, the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is the probability that the candidate pixel point and the closest candidate pixel point in the target column are on the same bubble edge.
[0083] The gradient amplitude reflects the rate of gray level change in the neighborhood of the candidate pixel. If the gradient amplitude of the i-th target column of the j-th candidate pixel point is larger, it means that the gray level change between the i-th target column of the j-th candidate pixel point and the target point is more significant, which is more consistent with the feature that the gray level changes significantly at the bubble edge, and the probability that they are on the same bubble edge is also higher. The smaller the gradient angle of the i-th target column of the j-th candidate pixel point and the target point is, the higher the consistency of the gradient direction of the i-th target column of the j-th candidate pixel point and the target point is, which is more consistent with the feature of the bubble ring-shaped gradient field, and thus the possibility of belonging to the same edge is also higher.
[0084] The smaller the Euclidean distance between the i-th target column of the j-th candidate pixel point and the feature point is, the closer the target point and the feature point are, and both the target point and the feature point are candidate pixel points that are close to the j-th candidate pixel point, so the smaller the Euclidean distance is, which means that the j-th candidate pixel point is more likely to be on the same edge as the i-th target column of the j-th candidate pixel point.
[0085] The spatial continuity feature of the bubble makes the edge pixel points of adjacent columns have spatial proximity and orderliness. The smaller the Euclidean distance between the i-th target column of the j-th candidate pixel point and the feature point is, the closer the target point and the feature point are, and both the target point and the feature point are candidate pixel points that are close to the j-th candidate pixel point, so the smaller the Euclidean distance is, which means that the j-th candidate pixel point is more likely to be on the same edge as the i-th target column of the j-th candidate pixel point. The better the continuity between the candidate pixel point and the target point and the feature point, the greater the possibility that the candidate pixel point belongs to the same bubble edge.
[0086] In summary, by evaluating the degree to which the candidate pixel point and the target point in the target column meet the edge essential feature through the gradient amplitude, and by evaluating the continuity and geometric feature of the edge through the gradient angle and the Euclidean distance, the probability that each candidate pixel point and the target point in each target column are on the same bubble edge can be accurately obtained. Based on this, the probability that the target points between the candidate pixel point and its adjacent columns on both sides are on the same bubble edge can be accurately obtained, so as to evaluate the degree to which the candidate pixel point and the candidate pixel points on the adjacent columns can be connected by the edge.
[0087] For example, in the embodiment of the present application, the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is calculated to determine the bubble region, which includes: if the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is greater than the bubble probability threshold, then the candidate pixel point and the target point in the target column are connected to obtain an edge; all connected edges are processed using a connected domain to obtain a complete bubble region.
[0088] The bubble probability threshold can be set to 0.5, and the bubble probability threshold can be set according to actual needs.
[0089] It can be understood that if the probability that the candidate pixel point and the nearest candidate pixel point in the target column are on the same bubble edge is greater than the bubble probability threshold, it means that the gradient feature and the gray feature meet the bubble edge feature to a higher degree. All candidate pixel points meeting the bubble edge feature are connected by the edge, and then processed by the connected domain, so that each complete bubble region can be obtained to obtain the defect detection result for PCB hole processing. If the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is not greater than the bubble probability threshold, it means that the gradient feature and the gray feature do not meet the bubble edge feature, and therefore no processing is performed.
[0090] The step of obtaining a complete bubble region by connected domain processing can be realized by existing technology, and the embodiment of the present application will not be repeated here.
[0091] S4: obtaining a defect detection result for PCB hole processing according to the bubble region in the PCB slice image.
[0092] For example, in the embodiment of the present application, the defect detection result for PCB hole processing is obtained, which includes: determining the defect detection result according to the proportion of the bubble region in the resin filling area in the PCB hole.
[0093] Specifically, the number of pixel points in the bubble region can be regarded as the area of the bubble region.
[0094] For example, if the proportion of the bubble area in the resin filling area in the PCB hole is greater than the defect threshold, it indicates that the PCB hole processing does not meet the process requirements.
[0095] It can be understood that when the defect detection result of the resin filling area in the PCB hole is positioned, defects meeting the actual process requirements need to be extracted, and some very small bubble defects can be removed and not regarded as defects. Therefore, the defect threshold can be set according to the actual process requirements, and the embodiments of the present application do not make too many limitations here.
[0096] It can be seen that in the embodiments of the present application, when the defect detection result for PCB hole processing is obtained, the pixel points in the PCB slice image can be obtained; the number of gray similar pixel points on the column where the pixel point is located is determined according to the gray difference between the pixel point and the pixel points in the same column; the probability of the pixel point in the column being in the resin filling area in the hole is calculated according to the number of gray similar pixel points on the column, the number of peaks and the maximum gray value, so as to determine the resin filling area in the hole in the PCB slice image; the candidate pixel points in the PCB slice image are determined by the gray standard deviation of the neighborhood pixel points of the pixel points in the resin filling area in the hole; any adjacent column on the left and right of the candidate pixel point is taken as the target column of the candidate pixel point, the first two candidate pixel points in the descending order of the distance between the candidate pixel point and each candidate pixel point in the target column are respectively recorded as the target point and the feature point of the candidate pixel point, the probability that the candidate pixel point and the target point are on the same bubble edge in the target column is calculated according to the gradient amplitude difference and the gradient angle difference between the candidate pixel point and the target point, and the Euclidean distance between the target point and the feature point in the target column, so as to determine the bubble area and obtain the defect detection result for PCB hole processing, which effectively improves the accuracy of the defect detection result for PCB hole processing.
[0097] The embodiments of the present application also disclose a machine vision-based defect detection system for PCB hole processing, which comprises a processor and a memory, and the memory stores computer program instructions. When the computer program instructions are executed by the processor, the machine vision-based defect detection method for PCB hole processing provided by the present application is realized.
[0098] The above system also includes a communication bus and a communication interface and other components familiar to those skilled in the art, the settings and functions of which are known in the art, and therefore will not be described here.
[0099] In the present application, the aforementioned memory can be any tangible medium containing or storing a program, which can be used or combined with an instruction execution system, device or apparatus.
[0100] The above are preferred embodiments of the present application, and do not limit the protection scope of the present application, so: any equivalent changes made according to the structure, shape, principle of the present application should be covered within the protection scope of the present application.
Claims
1. A defect detection method for PCB via plugging based on machine vision, characterized in that: include: Get the pixel points in the PCB slice image; Determine the number of similar grayscale pixels on the column where the pixel is located based on the grayscale difference between the pixel and the pixels in the same column; According to the number of grayscale similar pixels, the number of peaks and the maximum grayscale value on the column, the probability that the pixel points on the column are in the resin filling area in the plug hole is calculated to determine the resin filling area in the plug hole in the PCB slice image, including: recording the ratio of the number of grayscale similar pixels on the column to the total number of pixels on the column as the similarity index of the column, calculating the probability that the pixel points on the column are in the resin filling area in the plug hole, and determining the resin filling area in the plug hole in the PCB slice image. The probability that the pixel point on the column is in the resin filling area inside the plug hole : ; 、 、 Respectively Grayscale maximum value, similarity index, peak number on the column, 、 are the maximum similarity index and the maximum peak number in all columns, is the absolute value symbol, is an exponential function with base e. If the probability that a pixel point on a column is in the resin-filled area inside the plug hole is greater than the probability threshold, then the column is in the resin-filled area inside the plug hole. A candidate pixel point in a PCB slice image is determined by the grayscale standard deviation of the neighboring pixel points of the pixel point in the resin filling area of the plug hole; any adjacent columns on both sides of the candidate pixel point are used as the target column of the candidate pixel point, and the first two candidate pixels in descending order of the distance between the candidate pixel point and each candidate pixel point in the target column are recorded as the target point and feature point of the candidate pixel point, respectively. Based on the gradient amplitude difference and gradient angle difference between the candidate pixel point and the target point, as well as the Euclidean distance between the target point and the feature point in the target column, the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is calculated to determine the bubble area and obtain the defect detection result for PCB plug hole processing; The calculating the probability that the candidate pixel point and the target point in the target column are located at the same bubble edge includes: ; 、 、 Respectively The probability that the candidate pixel point and the target point in the i-th target column are on the same bubble edge, the absolute value of the gradient amplitude difference, and the absolute value of the gradient angle difference, For the The Euclidean distance between the target point and the feature point in the i-th target column of the candidate pixel, is the normalization function.
2. The method for defect detection of PCB via plugging based on machine vision according to claim 1, characterized in that: The step of obtaining pixel points in the PCB slice image also includes: After the PCB is cured, it is sliced and preprocessed after taking slice photos to obtain the PCB slice image. The lower left corner of the PCB slice image is recorded as the coordinate origin. The horizontal axis to the right of the coordinate origin is used as the horizontal axis, and the vertical axis upward from the coordinate origin is used as the vertical axis to construct the coordinate axis of the PCB slice image. The coordinates of each pixel point and the pixels in the same column are determined.
3. The method for defect detection of PCB via plugging based on machine vision according to claim 1, characterized in that: The step of determining the number of grayscale-similar pixels on the column where the pixel is located based on the grayscale difference between the pixel and the pixels in the same column includes: Get the grayscale maximum value on the column where the pixel is located, get the pixels in the same column whose difference with the grayscale maximum value is less than the difference threshold, and get the number of grayscale similar pixels on the column.
4. The method for detecting defects in PCB via plugging based on machine vision according to claim 1, wherein: Methods for obtaining the number of peaks on a column include: Construct a grayscale histogram for each column, record the grayscale value in the grayscale histogram whose number of pixels corresponding to the grayscale value is greater than the number threshold as the peak value, and obtain the number of peaks on each column.
5. The method for detecting defects in PCB via plugging based on machine vision according to claim 1, wherein: The method of determining a candidate pixel point in the PCB slice image by using the grayscale standard deviation of neighboring pixel points of the pixel point in the resin filling area in the plug hole includes: The neighborhood size of the pixel point is preset, and a neighborhood is constructed with the pixel point as the center among the surrounding pixels of the pixel point to obtain the neighboring pixels in the neighborhood of the pixel point, and the grayscale standard deviation of all the neighboring pixels of the pixel point is determined; the pixel point whose grayscale standard deviation of the neighboring pixels of the pixel point is greater than the fluctuation threshold is recorded as a candidate pixel point.
6. The method for detecting defects in PCB via plugging based on machine vision according to claim 1, wherein: Calculating the probability that the candidate pixel point and the target point in the target column are located at the same bubble edge to determine the bubble area includes: If the probability that the candidate pixel point and the target point in the target column are on the same bubble edge is greater than the bubble probability threshold, the candidate pixel point is connected to the target point in the target column to obtain an edge; the connected domain is used to process all connected edges to obtain a complete bubble area.
7. The method for detecting defects in PCB via plugging based on machine vision according to claim 1, wherein: Obtaining defect detection results for PCB via plugging processing includes: The defect detection result is determined based on the proportion of the bubble area in the resin filling area in the PCB plug hole.
8. A machine vision-based defect detection system for PCB via processing, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a defect detection method for PCB hole plugging processing based on machine vision is implemented according to any one of claims 1 to 7.
Citation Information
Patent Citations
Skin injury surface three-dimensional reconstruction method based on surface structured light
CN112102491A
Vacuum printed circuit board defect detection system based on machine vision
CN119693359A