Positioning method for PCB processing based on image processing
By constructing a sampling area on the PCB circuit board to calculate the radial structural contrast and gradient direction voting, and filtering the gradient convergence field peak points, the problem that Hough circular transform cannot distinguish between reference points and interference objects is solved, thus improving positioning accuracy and reliability.
Patent Information
- Application Number
- CN202511299431.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-12
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-09-12
AI Technical Summary
In existing technologies, the Hough circle transform cannot effectively distinguish between the real reference point and geometrically similar interference objects in PCB circuit board positioning, resulting in insufficient positioning accuracy and reliability.
By constructing a sampling region to calculate the radial structure contrast, and combining gradient direction and angle weighted voting, the peak points of the gradient convergence field are screened, and candidate scores are calculated to identify the true reference point and eliminate interference.
It enables accurate identification of real reference points, improving the positioning accuracy and reliability of automated PCB manufacturing.
Smart Images

Figure CN120807644B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing. More particularly, the present application relates to a positioning method for PCB circuit board processing based on image processing. BACKGROUND
[0002] In modern electronic manufacturing industry, printed circuit board (PCB) is the cornerstone of carrying electronic components and connecting circuits. In the automatic processing flow of PCB circuit board, such as surface mount (SMT), automatic optical inspection (AOI), drilling and flying probe test, etc., it is necessary to quickly and accurately position the PCB circuit board through a machine vision system, which is usually achieved by recognizing the fiducial mark on the PCB circuit board. The fiducial mark is generally a standard circular pattern with high contrast.
[0003] Hough circle transformation can effectively detect circular features in an image by mapping edge points in the image space to the parameter space for voting. It has a certain robustness to the partial occlusion or incompleteness of the circular edge. Currently, Hough circle transformation is commonly used for positioning the fiducial mark in the PCB circuit board.
[0004] However, Hough transformation is a kind of isolated shape analysis method, which only votes for edge pixel points that meet the geometric constraints of the circle. In the voting process, all edge pixel points are treated equally, which makes it impossible to distinguish the true positioning target (fiducial mark) from a large number of interference objects on the PCB circuit board, such as circular pads, vias, etc., which have extremely similar geometric shapes. This may cause the processing equipment to be positioned at the wrong position, affecting the accuracy and reliability of the PCB circuit board processing.
[0005] Therefore, there is an urgent need for a positioning method for PCB circuit board processing based on image processing. SUMMARY
[0006] To solve the technical problem of poor positioning accuracy caused by relying only on geometric features in the above-mentioned traditional method, the present application provides a positioning method for PCB circuit board processing based on image processing, comprising:
[0007] edge pixel points are extracted by performing edge detection on the gray image of the PCB circuit board; two sampling regions are constructed along the gradient direction and the opposite direction of the edge pixel points, and the radial structure contrast of the edge pixel points is determined according to the gray mean value difference of the two sampling regions and the variance of each sampling region; the included angle between the gradient directions is not equal to 90 degrees, and the included angle between the gradient directions and the radial structure contrast of the edge pixel points are used as the feature vector of the edge pixel points. and Any two edge pixels constitute an edge point pair. The intersection of the gradient extension lines of the two edge pixels is taken as the gradient intersection point of the edge point pair. Based on the angle between the gradient directions of the edge pixels in the edge point pair and the radial structural contrast of the edge pixels, votes are cast for the gradient intersection point. The votes at the same position in the grayscale image are accumulated to obtain the gradient convergence intensity. The gradient convergence intensities at all positions constitute the gradient convergence field. Peak points in the gradient convergence field are selected as candidate center points. The associated edge pixels of the candidate center points are obtained and divided into two categories. Based on the gradient convergence intensity of the candidate center points, the standard deviation of the distance from each category of associated edge pixels to the candidate center points, and the mean radial structural contrast of all associated edge pixels, the candidate score of the candidate center points is determined. Based on the candidate score, the center of the reference point is determined to achieve PCB circuit board positioning.
[0008] This invention constructs sampling regions along the gradient direction and its opposite direction and calculates radial structural contrast. It utilizes the grayscale mean difference to reflect the material differences inside and outside the edge, and the variance to reflect the uniformity of the sampling region, enabling radial structural contrast to distinguish between the true reference point and geometrically similar interference objects. This invention uses the intersection of edge points with gradient extension lines as voting targets, combining gradient angles and radial structural contrast voting. This allows the center of the true reference point to form a high gradient convergence intensity due to voting by a large number of high-quality, geometrically consistent point pairs, while interference positions have no significant peak due to dispersed voting. This invention selects the peak points of the gradient convergence field as candidate center points, and calculates candidate scores by combining gradient convergence intensity, the standard deviation of the distance from each type of associated edge pixel to the candidate center point, and the mean structural contrast of the associated edge pixels. This achieves accurate identification of the true reference point, enabling machine vision systems to intelligently distinguish interference objects with different functions but the same shape, improving the positioning accuracy and reliability in PCB automated processing.
[0009] Preferably, both sampling areas are rectangular areas of 3×5 pixels, and the edge pixels are located on the extension line of the line connecting the midpoints of the two short sides of the rectangle.
[0010] Preferably, the radial structural contrast satisfies the expression: In the formula, Represents edge pixels Radial structural contrast; Represents edge pixels First sampling area The average grayscale value of all pixels in the image; Represents edge pixels Second sampling area The average grayscale value of all pixels in the image; Represents edge pixels First sampling area the variance of the gray value of all the pixel points in the second sampling region; representing the edge pixel point of the second sampling region the variance of the gray value of all the pixel points in the second sampling region; representing the absolute value symbol; representing normalization.
[0011] Preferably, the voting of the gradient intersection point according to the included angle between the gradient directions of the edge pixel points in the edge point pair and the radial structure contrast of the edge pixel points comprises: the voting value of the voting of the gradient intersection point satisfies the expression: ; in the expression, representing the edge point pair the voting value of the corresponding gradient intersection point thereof; representing the radial structure contrast of the edge pixel point ; representing the radial structure contrast of the edge pixel point ; representing the included angle of the gradient direction of the edge pixel point and the edge pixel point ; representing the angle weight.
[0012] The present application utilizes the geometric characteristics that the gradient directions of the antipodal points on a real circular edge are opposite, ensures that only the edge point pair that geometrically meets the antipodal point feature can contribute a high-weight vote through the angle weight function, and combines the radial structure contrast to evaluate the physical characteristics of the edge point, so that the fiducial edge with uniform material on the inside and outside of the edge obtains a high confidence, while the interference edge such as the solder pad and via connected to the trace leading to uneven texture obtains a low confidence, so that the center position of the real fiducial point forms a significant peak value due to the high-weight and high-confidence voting, while the interference object is dispersed and low in strength due to the lack of geometric and physical consistency, thereby realizing accurate positioning of the fiducial point and improving the positioning reliability of the PCB.
[0013] Preferably, the angle weight satisfies the expression: ; in the expression, representing the standard deviation parameter.
[0014] Preferably, the filtering of the peak points in the gradient convergence field as the center candidate points comprises: obtaining the peak points with the maximum gradient convergence strength in the gradient convergence field as the center candidate points; wherein the gradient convergence strength of the peak point is greater than all the points in the 8-neighborhood thereof, and the local maximum value detection algorithm is adopted to obtain , which is a preset number of peak points.
[0015] Preferably, the associated edge pixel point of the circle center candidate point is obtained, and the associated edge pixel point is divided into two categories, including: for the circle center candidate point , if the gradient intersection point of the edge point pair falls within a circle with the circle center and the radius , the edge pixel point and the edge pixel point are taken as the associated edge pixel point of the circle center candidate point ; all the associated edge pixel points are clustered into two categories according to the distance from each associated edge pixel point to the circle center candidate point , wherein is a preset radius threshold.
[0016] The present application can capture the edge pixel points constituting the potential circle by setting the radius threshold, taking the edge pixel points in all the edge point pairs contributing to the circle center candidate point as the associated edge pixel point of the circle center candidate point, excluding the interference edge pixel points irrelevant to the current circle center candidate point, providing a data basis for the subsequent candidate score calculation, and improving the high precision and high reliability of the PCB reference point positioning; the present application can effectively identify the double-ring structure feature of the reference point by clustering the associated edge pixel points into two categories, providing a basis for the subsequent candidate score calculation.
[0017] Preferably, the candidate score of the circle center candidate point satisfies the expression: ; in the expression, represents the candidate score of the circle center candidate point ; represents the gradient convergence strength of the circle center candidate point ; represents the set of associated edge pixel points of the circle center candidate point ; represents the average value of the radial structure contrast of all the associated edge pixel points of the circle center candidate point ; represents the standard deviation of the distance from the first type of associated edge pixel point to the circle center candidate point ; represents the standard deviation of the distance from the second type of associated edge pixel point to the circle center candidate point ; represents the normalization.
[0018] The application considers that the real reference point forms a significant peak in the gradient convergence field and has a concentric double-ring structure in the image, so that the distance of the associated edge pixel points of the same category to the center of the circle is highly consistent, and the edge pixel points have a structure characteristic conforming to the physical characteristics of the reference point, therefore, the gradient convergence strength, the standard deviation of the distance of each category of associated edge pixel points to the center of the circle candidate point, and the structure contrast average of the associated edge pixel points are comprehensively used to obtain the candidate score of the center of the circle candidate point, the candidate score can effectively exclude the interference objects that only meet part of the conditions, so as to improve the accuracy of the reference point positioning.
[0019] Preferably, the method further comprises: determining the center of the reference point according to the candidate score, including: taking the center of the circle candidate point with the candidate score greater than or equal to a score threshold as an effective reference point; in response to the absence of the effective reference point, outputting a positioning failure result and prompting to reacquire the PCB circuit board image; in response to the number of the effective reference points being less than , outputting prompt information that the number of the effective reference points is insufficient; in response to the number of the effective reference points being greater than or equal to , taking the effective reference points with the highest candidate scores as the reference point centers, wherein is a preset number of reference points.
[0020] The application can exclude low-quality candidate points caused by noise, interference objects or poor image quality by screening the reference points through the candidate score, realize accurate identification of the real reference point, and improve the positioning accuracy and reliability in the PCB automatic processing.
[0021] Preferably, the method further comprises: taking any two edge pixel points with the included angle between the gradient directions not equal to and not equal to and the spatial distance less than a distance threshold as an edge point pair.
[0022] The beneficial effects of the present application are that the present application constructs a sampling area along the gradient direction of the edge pixel point, and calculates the radial structure contrast combined with the gray mean value difference and the variance, which can accurately distinguish the real reference point and the interference; the present application uses the characteristic that the opposite gradient directions of the circular pair of points, filters the geometric consistent edge point pairs through the Gaussian angle weight function, calculates the voting value combined with the radial structure contrast, forms the gradient convergence field, makes the real reference point circle center form a significant peak value due to the high weight and high confidence voting, filters the peak point as the circle center candidate point, calculates the multi-dimensional candidate score combined with the gradient convergence intensity, the standard deviation of the distance of each type of associated edge pixel point to the circle center candidate point, and the structure contrast mean value of all associated edge pixel points, filters the reference point according to the candidate score, can exclude low-quality candidate points and pseudo-reference points, realizes the accurate identification of the real reference point, and improves the positioning accuracy and reliability in the automatic processing of the PCB. BRIEF DESCRIPTION OF DRAWINGS
[0023] Figure 1 is a flow chart schematically showing a positioning method for PCB circuit board processing based on image processing in the present application;
[0024] Figure 2 is a RGB image of a PCB circuit board;
[0025] Figure 3 is a gray scale image of a PCB circuit board;
[0026] Figure 4 is an edge image of a PCB circuit board;
[0027] Figure 5 is a schematic diagram of a first sampling area and a second sampling area;
[0028] Figure 6 is a detection result of an effective reference point. DETAILED DESCRIPTION
[0029] The technical solutions in the embodiments of the present application will be described clearly and completely in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the present application.
[0030] The specific embodiments of the present application will be described in detail in combination with the drawings.
[0031] The embodiments of the present application disclose a positioning method for PCB circuit board processing based on image processing, referring to Figure 1 , including steps S1 to S5:
[0032] S1, collect the gray-scale image of the PCB circuit board, and perform edge detection on the gray-scale image to extract edge pixel points.
[0033] An image of the PCB circuit board is collected by a high-resolution industrial camera, and is subjected to gray-scale processing to obtain a gray-scale image of the PCB circuit board. A Canny edge detection algorithm is used to perform edge detection on the gray-scale image to obtain all edge pixel points in the gray-scale image. Figure 2 for the RGB image of the PCB circuit board, Figure 3 for the gray-scale image of the PCB circuit board, Figure 4 for the edge image.
[0034] It should be noted that the Canny edge detection algorithm can effectively extract continuous edges through non-maximum suppression and double threshold processing. In the image of the PCB circuit board, the reference points, pads, vias and other circular structures will produce clear edges, but these edges are extremely similar in geometric shape, and it is difficult to distinguish them only by the position information of the edges. Considering that the gradient direction of the edge pixel point is perpendicular to the edge direction, for an ideal circular edge, its gradient direction should point to or away from the center of the circle, therefore, for each edge pixel point, the gradient direction obtained in the Canny edge detection process is recorded.
[0035] S2, a first sampling region and a second sampling region of the edge pixel point are constructed along the gradient direction of the edge pixel point and the opposite direction of the gradient direction, and the radial structure contrast of the edge pixel point is determined according to the gray-scale mean value difference and the standard deviation of the first sampling region and the second sampling region.
[0036] Specifically, for each edge pixel point, a first sampling region is defined along the gradient direction of the edge pixel point , and a second sampling region is defined along the opposite direction of the gradient direction of the edge pixel point In the present application, the first sampling region and the second sampling region are both rectangular regions with a size of pixels, and the edge pixel point is located on the extension line of the midpoint of the two short sides of the rectangular region, which ensures that the first sampling region covers the inside and outside of the edge along the gradient direction. Exemplarily, Figure 5 is a schematic view of the first sampling region and the second sampling region, Figure 5 the curve in the middle represents the edge, P is an edge pixel point on the edge, Figure 5 the direction indicated by the arrow in the middle is the gradient direction of the edge pixel point P, is the first sampling region of the pixel point P, is the second sampling region of the pixel point P.
[0037] It should be noted that the size selection of the first and second sampling regions needs to balance the capture of local features and the suppression of noise. If the first or second sampling region is too small, it will be difficult to reflect local texture features; if the first or second sampling region is too large, it may contain too much irrelevant information, reducing feature discrimination. In the PCB circuit board positioning process, since the reference point size is usually 1-2mm, corresponding to about 20-40 pixels in the image, a length of 5 pixels is sufficient to capture the feature differences between the inner and outer sides of the reference point.
[0038] Furthermore, based on the grayscale values of all pixels in the first sampling region and the grayscale values of all pixels in the second sampling region, the radial structural contrast of the edge pixels is determined:
[0039]
[0040] In the formula, Represents edge pixels Radial structural contrast; Indicates the first sampling region; Represents edge pixels The second sampling area; Represents edge pixels The set of grayscale values of all pixels in the first sampling region; Represents edge pixels The set of grayscale values of all pixels in the second sampling region; Represents the mean function, Represents edge pixels The mean grayscale value of all pixels in the first sampling region. Represents edge pixels The mean grayscale value of all pixels in the second sampling region; Represents the variance function. Represents edge pixels The variance of the grayscale values of all pixels in the first sampling region Represents edge pixels The variance of grayscale values of all pixels in the second sampling region; Indicates the absolute value symbol; The normalization method is represented by linear normalization in this invention. However, implementers can also choose a normalization algorithm based on the actual implementation situation.
[0041] In the formula, This represents the difference in grayscale mean between the inner and outer regions of an edge pixel. The true reference point is a double-ring structure. The outer ring is covered with green solder resist ink, the area between the outer and inner rings is marked with black ink, and the inner ring contains copper foil. When the edge pixel... When the outer ring of the true reference point is located at its edge, the inner and outer sides of the outer ring edge are respectively a black marking area and green solder resist ink. The grayscale mean values of the black marking area and the green solder resist ink differ significantly, resulting in a large difference in the grayscale mean values between the first sampling area and the second sampling area. The variance is relatively large, and the uniform grayscale distribution of the black marked area and the green solder resist ink results in a relatively small variance. and Both are relatively small, which in turn reduces the contrast of the radial structure. Larger; when edge pixels When the inner ring of the true reference point is located at its edge, the inner and outer sides of the inner ring's edge are respectively copper foil and black marked areas. The large difference in the average grayscale values between the copper foil and black marked areas results in a significant difference in the average grayscale values between the first and second sampling areas. The variance is relatively large, and the uniform grayscale distribution in the copper foil and black marked areas results in a relatively small variance. and Both are relatively small, which in turn reduces the contrast of the radial structure. Larger. The pad is a single metal area, when the edge pixels... When a pad is connected to a trace, the inner area of its edge is uniform, but the outer area has a complex texture due to the presence of traces, resulting in variance. and There exists a smaller value and a larger value, thus making The larger value results in a greater radial structural contrast of the edge pixels of the pads. The value is suppressed, resulting in a smaller radial structure contrast compared to the edge pixels of the reference point. Vias are metallized holes on a PCB used to connect electrical traces between different layers. They have a double-ring structure: the outer ring is covered with green solder resist, the middle of the outer and inner rings is metal, and the inner ring contains the hole. When the edge pixels... When the sample is located at the edge of the outer ring of a via, the inner and outer sides of the outer ring edge are respectively green solder resist ink and metal. The grayscale mean values of the green solder resist ink and metal differ significantly, resulting in a large difference in the grayscale mean values between the first and second sampling areas. The variance is relatively large, and the uniform grayscale distribution of the green solder resist ink and metal results in a relatively small variance. and Both are relatively small, which in turn reduces the contrast of the radial structure. Larger; when edge pixels When the inner ring of a via is at its edge, the outer region of the inner ring edge is metallic with a uniform grayscale distribution, while the inner region is a hole. The inside of the hole may contain shadows, irregular reflections, etc., which affects the variance. and There exists a smaller value and a larger value, thus making The radial structure contrast of the edge pixel points of the inner ring of the via is small , and the radial structure contrast of the edge pixel points of the reference point is large. When the edge pixel points belong to pseudo-edges composed of random noise, the gray scale distribution of the regions on both sides of the edge where the edge pixel points are located is chaotic, and the difference between the average gray scales may be small, while the variance and are large, so that the radial structure contrast is small.
[0042] S3, any two edge pixel points with an included angle between the gradient directions not equal to and form an edge point pair, the intersection of the gradient extension lines of the two edge pixel points is taken as the gradient intersection point of the edge point pair, and a vote is cast to the gradient intersection point according to the included angle between the gradient directions of the edge pixel points in the edge point pair and the radial structure contrast of the edge pixel points, so as to obtain the gradient convergence strength of the same position in the gray scale image by accumulating the voting values, and the gradient convergence strengths of all positions form a gradient convergence field.
[0043] Specifically, a two-dimensional array equal in size to the original image is initialized as the gradient convergence field, all elements of which are initialized to 0, indicating the gradient convergence strength at the coordinate , and the larger the value is, the more likely the position is a candidate point of the center of the circle.
[0044] It should be noted that the intersection of the gradient extension lines of the two edge pixel points on the circle can indicate the position of the center of the circle. Ideally, the gradient directions of the opposite points on a complete circle should be completely opposite, with an included angle of 180°, that is, when the two edge pixel points are located at the two ends of the diameter of the circle, the gradient directions of the two edge pixel points are opposite, and the included angle between the gradient directions is close to 180°, at which time the two edge pixel points have the strongest pointing property to the center of the circle, and the intersection position is the most accurate. When the two edge pixel points in the edge point pair are located on the same side of the circle, the gradient directions of the two edge pixel points are similar, and the included angle between the gradient directions is close to 0°, at which time the intersection position may be far away from the true center of the circle, or even at infinity. In actual implementation, when the included angle between the gradient directions of the two edge pixel points is exactly 0° or 180°, the two gradient extension lines are parallel or coincide, and a unique intersection point cannot be determined. Therefore, the present application screens the edge point pair according to the included angle between the edge pixel points, and increases a voting value of the gradient intersection point of the edge point pair in the gradient convergence field GCF according to the included angle between the gradient directions of the two edge pixel points in the edge point pair and the radial structure contrast of each edge pixel point in the edge point pair, so as to locate the center of the circle.
[0045] Specifically, for any two edge pixels, the angle between the gradient directions of the two edge pixels is obtained, and in response to the angle not being equal to... And not equal to When the two edge pixels are paired, the intersection of the gradient extension lines of the two edge pixels in the edge pixel pair is obtained and denoted as the gradient intersection point of the edge pixel pair. The gradient extension line is a straight line that extends infinitely along the gradient direction of the edge pixel and in the opposite direction.
[0046] Furthermore, the voting value satisfies the expression:
[0047]
[0048] In the formula, Represents edge point pairs The vote value at its corresponding gradient intersection point; Represents edge pixels Radial structural contrast; Represents edge pixels Radial structural contrast; Represents edge pixels With edge pixels The angle between the gradient directions, Indicates angle weight: ,in, The standard deviation parameter is used in this invention. Set as The personnel responsible for implementation can be adjusted based on the actual implementation situation.
[0049] It should be noted that this invention uses a Gaussian function to obtain the angle weights. ,when It reaches its maximum value of 1 when it approaches 180°, and as... The exponential decay of features due to deviations of 180° ensures that only features of two edge pixels that are geometrically close to their opposite points contribute high-weighted votes, such as when two edge pixels are located near the ends of a diameter on a circle. The larger, the more The larger the value, the greater the radial structural contrast between the two edge pixels in the edge point pair. and The summation serves as the structural confidence score, ensuring that only edge pixel pairs whose physical characteristics conform to the baseline structure can cast a high-value vote. For example, when both edge pixels belong to the true baseline, ... and Both are close to 1, if the angle weights of the two edge pixels are at this time The larger the value, the higher the vote value. The closer to 2, if two edge pixel points belong to interference or noise, , The smaller, so that the voting value will be significantly reduced.
[0050] Further, for each gradient intersection point of each edge point pair, the voting value of the edge point pair to its corresponding gradient intersection point is added to the corresponding position of the gradient intersection point in the gradient convergence field, and after traversing all edge point pairs that meet the calculation condition and completing the voting value addition, the final gradient convergence intensity of each position is obtained. It should be noted that, since the image coordinates are discrete, in actual implementation, the coordinates of the gradient intersection point are rounded off, or the voting value is distributed to the four nearest pixel points from the gradient intersection point by using bilinear interpolation to improve the positioning accuracy. In the present application, the rounding off method is used, and the implementer can select the coordinate rounding method according to the actual implementation situation.
[0051] It should be further noted that, in order to reduce the calculation amount, in another embodiment, the gradient intersection points of the edge point pairs with a spatial distance less than a distance threshold and the voting values of the edge point pairs to the gradient intersection points can be limited to be calculated, because the edge points far apart are not likely to belong to the same circle, and the distance threshold can be set according to the size of the reference point, for example, set to 1.5 times the diameter of the reference point.
[0052] S4, screening the peak points in the gradient convergence field as the center candidate points, obtaining the associated edge pixel points of the center candidate points, and dividing the associated edge pixel points into two categories, determining the candidate score of the center candidate points according to the gradient convergence intensity of the center candidate points, the standard deviation of the distance of each category of associated edge pixel points to the center candidate points, and the average radial structure contrast of all associated edge pixel points.
[0053] It should be noted that, in an ideal case, for a real reference point, a large number of edge point pairs formed by edge pixel points belonging to the reference point will produce high-weight voting pointing to the same center, so that the gradient convergence field forms a clear peak at the position, and for the edge point pairs generated by the interference or noise, due to the lack of geometric consistency and physical consistency, their voting will be scattered in different positions of the gradient convergence field , and cannot form a significant peak. Therefore, the present application obtains the points that may be the center according to the peaks in the gradient convergence field.
[0054] Specifically, the gradient convergence intensity of the gradient convergence field is obtained, and the peak points with the maximum gradient convergence intensity are obtained as the center candidate points, wherein the gradient convergence intensity of the peak points is greater than all points in the 8-neighborhood, and a local maximum value detection algorithm is used to obtain. The number of preset peak points is 3 in the present application, and the implementer can select the number of peak points according to the actual implementation situation. is set to 10, and the implementer can adjust the value according to the actual implementation.
[0055] Further, for each circle center candidate point , , the associated edge pixel points of the circle center candidate point are obtained: if the gradient intersection point of the edge point pair falls within a circle with the circle center and a radius of , then the edge pixel point and the edge pixel point are taken as the associated edge pixel points of the circle center candidate point , and the set composed of all the associated edge pixel points is denoted as In the present application, is set to 2 pixels, and the implementer can adjust the value according to the actual implementation. It should be noted that, since the PCB reference point is a double-ring structure, the outer ring is a green solder resist ink area, the middle between the outer ring and the inner ring is a black mark area, and the inside of the inner ring is a copper foil area, forming clear concentric edges of the inner and outer rings on the image, therefore, the associated edge pixel point set of the reference point contains the edge pixel points of the outer ring and the edge pixel points of the inner ring, and therefore, the present application clusters the associated edge pixel points into two categories.
[0056] It should be noted that, since the PCB reference point is a double-ring structure, the outer ring is a green solder resist ink area, the middle between the outer ring and the inner ring is a black mark area, and the inside of the inner ring is a copper foil area, forming clear concentric edges of the inner and outer rings on the image, therefore, the associated edge pixel point set of the reference point contains the edge pixel points of the outer ring and the edge pixel points of the inner ring, and therefore, the present application clusters the associated edge pixel points into two categories.
[0057] Specifically, the associated edge pixel points of the circle center candidate point are clustered, and the associated edge pixel points are divided into two categories, and the set composed of the associated edge pixel points of each category is respectively denoted as , The present application adopts K-means clustering, and in other embodiments, the implementer can select a clustering algorithm according to the actual implementation.
[0058] Further, according to the gradient convergence strength of the circle center candidate point, the standard deviation of the distance of each category of associated edge pixel points to the circle center candidate point, and the average radial structure contrast of all the associated edge pixel points, the candidate score of the circle center candidate point is determined:
[0059]
[0060] In the formula, denotes the candidate score of the circle center candidate point ; denotes the gradient convergence strength of the circle center candidate point ; denotes the set of associated edge pixel points of the circle center candidate point ; denotes the distance of the circle center candidate point the mean of the radial structure contrast of all the associated edge pixels of the circle center candidate point the standard deviation of the distance from the first type of associated edge pixels to the circle center candidate point the standard deviation of the distance from the second type of associated edge pixels to the circle center candidate point the standard deviation of the distance from the second type of associated edge pixels to the circle center candidate point the standard deviation of the distance from the second type of associated edge pixels to the circle center candidate point denotes normalization, the present application adopts linear normalization, and the implementer can also select a normalization algorithm according to the actual implementation situation.
[0061] It should be noted that, reflects the original intensity of the circle center candidate point in the gradient convergence field; reflects the accuracy of the circle center candidate point as a geometric center, for an ideal concentric circle ring, the distances from the edge pixels of the inner ring and the outer ring to the center should be very constant, that is, and should be close to 0, so that is large, close to 1, if the edge pixels are distributed randomly or are not concentric, the standard deviation will increase, so that will be significantly reduced, thereby suppressing the candidate score of the circle center candidate point of the non-real circle center. reflects the structural consistency of the associated edge pixels of the circle center candidate point , the real reference point contains a double circle ring structure, the two sides of the outer ring and the inner ring edges and the two sides of the inner ring edge are uniform areas of different materials, so that the radial structure contrast of the edge pixels on the edges of the outer ring and the inner ring is higher, and then is large; while the outside of the edge of the circular pad is complex in texture due to the connection of the trace, so that the radial structure contrast of the edge pixels of the circular pad is smaller than that of the edge pixels of the real reference point, and then corresponding to the center of the circular pad is smaller than corresponding to the center of the real reference point; the via is a double circle ring structure, the inside of the inner ring edge is the inside of the hole, which may have shadows, irregular reflections or backgrounds, etc., so that the radial structure contrast of the corresponding edge pixels is small, thereby corresponding to the center of the via is smaller than corresponding to the center of the real reference point. The present application comprehensively considers the gradient convergence intensity , , the structural consistency to obtain the candidate score of the circle center candidate point , when , , are large, the circle center candidate point More likely to be the reference point circle center.
[0062] S5, according to the candidate score of the circle center candidate point, determine the reference point circle center, realize the PCB circuit board positioning.
[0063] Specifically, the circle center candidate point with a candidate score greater than or equal to a score threshold is taken as an effective reference point. In response to the absence of an effective reference point, a positioning failure result is output and a reacquisition of the PCB circuit board image is prompted; in response to the number of effective reference points being less than , a prompt information of insufficient number of effective reference points is output, and the implementer can select to retain the existing effective reference points for auxiliary positioning or terminate the positioning process according to the actual scene; in response to the number of effective reference points being greater than or equal to , the effective reference points with the highest candidate scores are taken as the reference point circle centers. Wherein is a preset reference point number, which can be set by the implementer according to the PCB circuit board design specification, for example , the empirical value of the score threshold is 0.7, and in other embodiments, it can also be set by the implementer according to the actual implementation situation, but it should be noted that the value range of the candidate score is [0, 1], so the score threshold cannot exceed the range. Figure 6 is the detection result of the effective reference point.
Claims
1. A positioning method for PCB circuit board processing based on image processing, characterized in that, include: Edge detection is performed on the grayscale image of the PCB circuit board to extract edge pixels; Two sampling regions are constructed along the gradient direction and the opposite direction of the edge pixel. Based on the difference in grayscale mean between the two sampling regions and the variance of each sampling region, the radial structural contrast of the edge pixel is determined, including: , edge pixels Radial structure contrast, , They are edge pixels. First sampling area The mean and variance of the grayscale values of all pixels in the image. , They are edge pixels. Second sampling area The mean and variance of the grayscale values of all pixels in the image. It is the absolute value symbol. For normalization; The angle between the gradient directions is not equal to as well as Any two edge pixels form an edge point pair, and the intersection of the gradient extension lines of the two edge pixels is taken as the gradient intersection point of the edge point pair; Based on the angle between the gradient directions of edge points and mid-edge pixels, and the radial structural contrast of edge pixels, votes are cast for gradient intersection points, including: , For edge point pairs The vote value of its corresponding gradient intersection point edge pixels Radial structure contrast, edge pixels With edge pixels The angle between the gradient directions, For angle weighting; The gradient convergence intensity is obtained by accumulating the votes at the same location in the grayscale image, and the gradient convergence intensity at all locations constitutes the gradient convergence field. In the gradient convergence field, peak points are selected as candidate center points, the associated edge pixels of the candidate center points are obtained, and the associated edge pixels are divided into two categories based on the clustering algorithm; The candidate score for the center candidate point is determined based on the gradient convergence intensity of the center candidate point, the standard deviation of the distance from each class of associated edge pixels to the center candidate point, and the mean radial structure contrast of all associated edge pixels. This includes: , , , , Candidate points for the center of the circle The candidate scores, gradient convergence intensity, set of associated edge pixels, and mean radial structure contrast of all associated edge pixels are used to determine the candidate scores. For the first type of associated edge pixels to the circle center candidate point The standard deviation of the distance, For the second type of associated edge pixels to circle center candidate points The standard deviation of the distance; Based on the candidate scores, the center of the reference point is determined to achieve PCB circuit board positioning.
2. The positioning method for PCB circuit board processing based on image processing according to claim 1, characterized in that, Both sampling areas are rectangular areas of 3×5 pixels, with the edge pixels located on the extension line connecting the midpoints of the two short sides of the rectangle.
3. The positioning method for PCB circuit board processing based on image processing according to claim 1, characterized in that, The angle weights satisfy the expression: ; In the formula, This represents the preset standard deviation parameter.
4. The positioning method for PCB circuit board processing based on image processing according to claim 1, characterized in that, The step of selecting peak points in the gradient convergence field as candidate center points includes: Obtain the gradient convergence strength in the gradient convergence field. A number of peak points are selected as candidate center points; wherein the gradient convergence intensity of a peak point is greater than that of all points within its 8-neighborhood, and a local maximum detection algorithm is used to obtain the center point. The preset number of peak points.
5. The positioning method for PCB circuit board processing based on image processing according to claim 1, characterized in that, The process involves obtaining the associated edge pixels of the candidate center point and dividing them into two categories based on a clustering algorithm: For the candidate center point If the edge points are correct The gradient intersection points fall within the... With center at and radius at, Within the circle, the edge pixels are... and edge pixels As a candidate point for the center The associated edge pixels; based on the candidate center point of each associated edge pixel. The distance is used to cluster all associated edge pixels into two categories, where, This is a preset radius threshold.
6. The positioning method for PCB circuit board processing based on image processing according to claim 1, characterized in that, The step of determining the center of the reference point circle based on the candidate score includes: Candidates with scores greater than or equal to the score threshold The candidate center point is used as the effective reference point; If no valid reference point exists, output a positioning failure result and prompt for re-acquiring the PCB circuit board image; if the number of valid reference points is insufficient... If the number of valid reference points is insufficient, a message indicating insufficient valid reference points will be output; if the number of valid reference points is greater than or equal to [a certain value], a message indicating insufficient valid reference points will be output. The candidate with the highest score One effective benchmark point as The center of each reference point circle, among which The number of preset reference points.
7. The positioning method for PCB circuit board processing based on image processing according to claim 1, characterized in that, Also includes: The angle between the gradient directions is not equal to as well as Any two edge pixels whose spatial distance is less than the distance threshold constitute an edge point pair.
Citation Information
Patent Citations
Traffic sign recognition method and device, and vehicle
CN105740877A
Printed circuit board (PCB) positioning and multifunctional testing integrated device based on visual identification
CN120510108A