A method for locating circular mark points based on EDLines
Through the EDLines algorithm and twice circle fitting technology, the problems of circular Mark point positioning accuracy and speed in the existing technology are solved, and more efficient and accurate circular Mark point positioning is achieved.
Patent Information
- Application Number
- CN202110962145.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-20
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-08-20
AI Technical Summary
In the existing technology, the positioning of circular Mark points in template matching and fitting methods is easily affected by sample scaling, rotation, and lighting changes, resulting in inaccurate template matching, large fitting errors, and slow speed.
The EDLines algorithm is used to extract line segments in the gradient image through Gaussian filtering and Sobel operator. The anchor points are selected based on the local gradient maximum value, and circle fitting is performed twice. The least squares method and Helmholtz principle are used to optimize the edge pixel chain. Improve positioning accuracy and speed.
It effectively reduces the generation of error circles, increases the positioning speed, reduces the error rate of edge detection, and overcomes the impact of incomplete samples and harsh sampling environment conditions on positioning.
Smart Images

Figure CN113674243B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of visual inspection technology, and specifically relates to a method for locating circular Mark points based on EDLines. Background Art
[0002] During the PCB design stage, designers usually make circular Mark points as positioning references to lay a good foundation for subsequent effective detection. The Mark points of PCB boards are the position identification points used by PCBs on automatic placement machines in circuit board design, also called marking points or feature points.
[0003] The basic principle of visual inspection of PCB boards is: after image processing, the position of the mark is determined based on the statistics of the pixel points, and then the detected mark points are compared with the standard positioning points. If errors are found, they are compensated to improve the positioning accuracy of the PCB board.
[0004] The existing traditional circular mark point positioning usually uses template matching and circle fitting methods. The template matching method is often unable to accurately complete the template matching due to the influence of factors such as sample scaling, rotation, and illumination changes. The existing circle fitting method has a large error after one fitting and is slow. Summary of the invention
[0005] The purpose of this application is to provide a method for locating circular Mark points based on EDLines, so as to achieve accurate positioning of circular Mark points.
[0006] In order to achieve the above purpose, the technical solution adopted by this application is:
[0007] A method for locating a circular Mark point based on EDLines, the method for locating a circular Mark point based on EDLines comprising:
[0008] Step S1, collecting a grayscale image containing a circular Mark point;
[0009] Step S2, using the EDLines algorithm to extract line segments in the grayscale image to locate the circular Mark points, including:
[0010] Step S2.1, performing Gaussian filtering on the grayscale image to obtain a smoothed image;
[0011] Step S2.2, taking the gradient direction templates of the Sobel operator including six directions of 0°, 45°, 90°, 135°, 180°, and 270°, convolving each pixel point in the smoothed image based on the gradient direction templates in the six directions to obtain six values, taking the largest value among the six values to replace the pixel value of the corresponding pixel point, and obtaining a gradient image;
[0012] Step S2.3, selecting anchor points based on the gradient image using the local gradient maximum, and connecting the anchor points to obtain edge pixel chains;
[0013] Step S2.4, first circle fitting: divide all anchor points into three different groups, connect each anchor point with each anchor point in different groups to form a line segment, select the four longest line segments from all the line segments, take the intersection of the four selected line segments as the center of the circle, and take the sum of the lengths of the four selected line segments divided by 8 as the radius of the circle to obtain the first fitting circle;
[0014] Step S2.5, using the least square method to fit the edge pixel chain to obtain a new pixel line segment, and removing the wrong pixel line segment based on the Helmholtz principle to obtain the final straight line segment set;
[0015] Step S2.6, second circle fitting: fitting the pixel line segments in the straight line segment set by least squares circle fitting to obtain the center and radius of the second fitting circle;
[0016] Step S2.7, make the difference between the centers of the first fitting circle and the second fitting circle. If the difference is within the preset error range, take any one of the first fitting circle and the second fitting circle as the circle corresponding to the circular Mark point; otherwise, the positioning fails and returns to step S2.3 to continue execution.
[0017] Several optional methods are also provided below, but they are not intended to be additional limitations on the above-mentioned overall solution, but are merely further supplements or preferences. Under the premise that there are no technical or logical contradictions, each optional method can be combined with the above-mentioned overall solution separately, and multiple optional methods can also be combined.
[0018] Preferably, the gradient direction templates in the six directions of 0°, 45°, 90°, 135°, 180° and 270° are:
[0019] The gradient direction template in the 0° direction is:
[0020] The gradient direction template in the 45° direction is:
[0021] The gradient direction template in the 90° direction is:
[0022] The gradient direction template in the 135° direction is:
[0023] The gradient direction template in the 180° direction is:
[0024] The gradient direction template in the 270° direction is:
[0025] Preferably, the method of selecting anchor points based on the gradient image by using the local gradient maximum value and connecting the anchor points to obtain an edge pixel chain comprises:
[0026] Step S2.3.1, raster scan the gradient image using row priority order, eliminate pixels whose gradient values are less than the gradient threshold, and obtain the edge area;
[0027] Step S2.3.2, according to the preset anchor point threshold, use non-maximum suppression to filter out anchor points from the edge area;
[0028] Step S2.3.3: Connect the selected anchor points to obtain an edge pixel chain.
[0029] Preferably, all anchor points are divided into three different groups, including:
[0030] The gradient image is regarded as a circle with the image center as the center, and any point on the circumference of the circle is taken as the starting point. The circle is divided into three sector-shaped areas based on the starting point to complete the division of the anchor points.
[0031] The method for locating circular Mark points based on EDLines provided in this application combines the EDLines algorithm and the curve fitting method. The use of two circle fittings greatly reduces the generation of error circles. At the same time, the EDlines algorithm is combined to speed up the positioning speed, effectively overcome the influence of incomplete samples and harsh sampling environment on positioning, and reduce the error rate of edge detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 This is a flow chart of the method for locating circular Mark points based on EDLines of the present application;
[0033] Figure 2 A flowchart of a specific embodiment of locating circular Mark points provided in this application. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0035] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0036] In one of the embodiments, a method for locating circular Mark points based on EDLines is provided. The method can overcome the positioning problems when the circular Mark points are partially missing and the noise interference is large through two circle fittings, and has good application in PCB board visual inspection.
[0037] like Figure 1 As shown, the method for locating circular Mark points based on EDLines in this embodiment includes:
[0038] Step S1, collecting a grayscale image containing circular Mark points.
[0039] Step S2: Using the EDLines algorithm to extract line segments in the grayscale image.
[0040] The EDLines algorithm is a straight line segment detection algorithm that has powerful and accurate detection results and a fast speed for obtaining straight line segments. Figure 2 As shown, the process of the EDLines algorithm used in locating the circular Mark point in this embodiment is as follows:
[0041] Step S2.1, performing Gaussian filtering on the grayscale image to obtain a smoothed image.
[0042] Gaussian filtering is a linear smoothing filter that has a good suppressive effect on noise that obeys normal distribution, making it easier to extract edge pixel chains later. It should be noted that Gaussian filtering is a conventional operation in the field of image processing, and the Gaussian filtering method used in this application is not limited here.
[0043] Step S2.2, take the gradient direction template of the Sobel operator including six directions of 0°, 45°, 90°, 135°, 180° and 270°, convolve each pixel point in the smoothed image based on the gradient direction template in the six directions to obtain six values, take the largest value among the six values to replace the pixel value of the corresponding pixel point, and obtain the gradient image.
[0044] The traditional Sobel operator uses 3×3 convolution templates in the horizontal and vertical directions to calculate the first-order derivatives of the image to obtain the edge points of the image. The Sobel operator of this embodiment adds four gradient direction templates of 45°, 135°, 180°, and 270° on the basis of the original two directions of 0° and 90°. Among them, two directions in the three sets of data of 0° and 90°, 45° and 135°, and 180° and 270° are perpendicular to each other and have the highest coverage rate. In the case of avoiding duplication, the perpendicular gradient directions are selected, which ensures both the detection speed and the detection accuracy.
[0045] Although the traditional two-direction Sobel operator is simple to calculate and widely used, it is easy to lose edge information. In this embodiment, adding four gradient directions can be more accurate, where the gradient direction template in the 0° direction is: The gradient direction template in the 45° direction is: The gradient direction template in the 90° direction is: The gradient direction template in the 135° direction is: The gradient direction template in the 180° direction is: The gradient direction template in the 270° direction is:
[0046] Step S2.3, based on the gradient image, select anchor points using the local gradient maximum value, and connect the anchor points to obtain edge pixel chains, specifically:
[0047] Step S2.3.1, use row priority to perform raster scanning on the gradient image, eliminate the pixels whose gradient values are less than the gradient threshold, and obtain the edge area; in this embodiment, the raster scanning interval is set to 2.
[0048] Step S2.3.2, according to the preset anchor point threshold, use non-maximum suppression to filter out anchor points from the edge area; selecting a suitable anchor point threshold can effectively improve the accuracy of subsequent extraction of edge segments. After multiple experiments, this embodiment sets the anchor point threshold to 7, which is most convenient for extracting high-quality segments.
[0049] Step S2.3.3: Connect the selected anchor points to obtain an edge pixel chain.
[0050] Step S2.4, first circle fitting: divide all anchor points into three different groups, connect each anchor point with each anchor point in different groups to form a line segment, select the four longest line segments of all the line segments, use the intersection of the selected four line segments as the center of the circle, and use the sum of the lengths of the four selected line segments divided by 8 as the radius of the circle to obtain the first fitting circle.
[0051] Since the anchor points are not necessarily evenly distributed, in order to obtain a better division result, this embodiment adopts the following method when dividing the anchor points: the gradient image is regarded as a circle with the image center of the gradient image as the center of the circle, and any point on the circumference of the circle is taken as the starting point. The circle is divided into three sector-shaped areas based on the starting point to complete the division of the anchor points. The dividing line that divides the circle into equal parts corresponds to the gradient image and extends to the image edge of the gradient image, which can be regarded as the division of the gradient image. The anchor points divided into the same area in the gradient image are regarded as the same group to obtain the result after division.
[0052] The above anchor point division method can make each area have relatively uniform anchor points, which is beneficial to the subsequent circle fitting. In other embodiments, other division methods can also be selected according to actual needs.
[0053] Step S2.5: Use the least square method to fit the edge pixel chain to obtain new pixel line segments, and remove erroneous pixel line segments based on the Helmholtz principle to obtain the final set of straight line segments.
[0054] In this embodiment, the Helmholtz principle is used to detect pixel line segments, including:
[0055]
[0056] Among them, N 4 : In an image of size N×N, each pixel line segment has two points, and each point has N 2 There are N choices in total 4 line segments; p: the accuracy of the pixel line segment direction; n,k: the length of pixel line segment A is n, and the gradient direction of at least k pixels is the same as that of pixel line segment A.
[0057] If NFA(n,k)≤ε (ε is the error threshold), it means that the pixel line segment is valid; otherwise, it is invalid. In this application, ε is preferably 1.
[0058] Step S2.6, second circle fitting: Fit the pixel line segments in the straight line segment set by least squares circle fitting to obtain the center and radius of the second fitting circle. The least squares circle fitting can be implemented in an existing manner.
[0059] Step S2.7, make the difference between the centers of the first fitting circle and the second fitting circle. If the difference is within the preset error range, take any one of the first fitting circle and the second fitting circle as the circle corresponding to the circular Mark point; otherwise, the positioning fails and returns to step S2.3 to continue execution.
[0060] In actual recognition, since the edges of the circular Mark points are relatively fuzzy, this embodiment performs circle fitting twice to improve the accuracy, and determines the circle corresponding to the final circular Mark point based on the result of the secondary circle fitting to ensure the accuracy of the circular Mark point positioning.
[0061] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0062] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for locating circular Mark points based on EDLines, characterized in that: The method for locating circular Mark points based on EDLines includes: Step S1, collecting a grayscale image containing a circular Mark point; Step S2, using the EDLines algorithm to extract line segments in the grayscale image to locate the circular Mark points, including: Step S2.1, performing Gaussian filtering on the grayscale image to obtain a smoothed image; Step S2.2, taking the gradient direction templates of the Sobel operator including six directions of 0°, 45°, 90°, 135°, 180°, and 270°, convolving each pixel point in the smoothed image based on the gradient direction templates in the six directions to obtain six values, taking the largest value among the six values to replace the pixel value of the corresponding pixel point, and obtaining a gradient image; Step S2.3, selecting anchor points based on the gradient image using the local gradient maximum, and connecting the anchor points to obtain edge pixel chains; Step S2.4, first circle fitting: divide all anchor points into three different groups, connect each anchor point with each anchor point in different groups to form a line segment, select the four longest line segments among all the line segments, take the intersection of the selected four line segments as the center of the circle, and take the sum of the lengths of the selected four line segments divided by 8 as the radius of the circle to obtain the first fitting circle; wherein, dividing all anchor points into three different groups includes: taking the image center of the gradient image as the center of the circle and regarding the gradient image as a circle, taking any point on the circumference of the circle as the starting point, dividing the circle into three sector-shaped areas based on the starting point, and corresponding the dividing line of the circle to the gradient image and extending to the image edge of the gradient image as the division of the gradient image, and regarding the anchor points divided into the same area in the gradient image as the same group, to obtain the result after division; Step S2.5, using the least square method to fit the edge pixel chain to obtain a new pixel line segment, and removing the wrong pixel line segment based on the Helmholtz principle to obtain the final straight line segment set; Step S2.6, second circle fitting: fitting the pixel line segments in the straight line segment set by least squares circle fitting to obtain the center and radius of the second fitting circle; Step S2.7, make the difference between the centers of the first fitting circle and the second fitting circle. If the difference is within the preset error range, take any one of the first fitting circle and the second fitting circle as the circle corresponding to the circular Mark point; otherwise, the positioning fails and returns to step S2.3 to continue execution.
2. The method for locating circular Mark points based on EDLines as claimed in claim 1, characterized in that: The gradient direction templates for the six directions of 0°, 45°, 90°, 135°, 180°, and 270° are: The gradient direction template in the 0° direction is: The gradient direction template in the 45° direction is: The gradient direction template in the 90° direction is: The gradient direction template in the 135° direction is: The gradient direction template in the 180° direction is: The gradient direction template at 270° is:
3. The method for locating circular Mark points based on EDLines as claimed in claim 1, characterized in that: The method of selecting anchor points based on the gradient image by using the local gradient maximum value and connecting the anchor points to obtain an edge pixel chain includes: Step S2.3.1, raster scan the gradient image using row priority order, eliminate pixels whose gradient values are less than the gradient threshold, and obtain the edge area; Step S2.3.2, according to the preset anchor point threshold, use non-maximum suppression to filter out anchor points from the edge area; Step S2.3.3: Connect the selected anchor points to obtain an edge pixel chain.
Citation Information
Patent Citations
Liquid crystal display Mark point positioning method based on line feature matching
CN110533647A
A method of evaluating cross-sectional geometry parameters of sample
CN111524099A
Visual edge inspection method based on EDLines and LSM
CN111754422A
Image processing method and image processing device
JP2012203612A
