Study on Image Position Algorithm of the PCB Detection

With the continuous development of electronic technology, automatic detection of the PCB board has become particularly important, and the key step of the detection is to identify and locate the location mark (usually it is a round). Hough transform is one of the most widely used circle detection method, but it is complex in computing and requires much resource. For these conditions, a new idea of circle detection is proposed to get the rough location of the circle with the template matching, and then the precise positioning is accomplished by an improved Hough transform which is to draw two non-parallel strings on the orientation round and the center of the circle shall locate the strings’ perpendicular intersection. Experiments show that the method is simple and effective, and can accomplish the PCB image positioning accurately.


Introduction
The methods used by the automatic detection of the PCB is a computer vision positioning.The basic process is to set up two location mark (usually round) in the design and manufacture of the PCB, and stepper motor controlled by computer drives a camera to intake the photograph of these two signs respectively, then find the center of the two circles.According to the coordinates of the two rounds in the CAD files, you can determine the ratio between actual coordinates and CAD coordinates, and finally according to this ratio and the coordinates of the objects in CAD files, we will be able to determine their actual position (Zhang, Gao, & Wang, 1999).
Circle detection mainly refers to the striking of characteristic parameters of the image of the hole or arc, such as the center coordinates and radius.The traditional methods of detection of circular feature is the Hough Transform, which uses the correspondence between image space and parameter space to transform image space to parameter space, and by a simple cumulative statistics in the parameter space to complete the inspection task (Fu & Chen, 2010).The method is characterized by high reliability, and in the noisy and distortion state, even in the of loss of the regional information, this method can still achieve the desired results, but its drawback is of complex computation, high resource requirements, and the interference of the complex image background information will bring a large number of unwanted accumulation, so that the performance of the algorithm greatly reduced, and even unable to effectively extract the round.This paper presents a new method to detect PCB positioning circle.The method is simple in principle, of fast calculation, high accuracy and can meet the needs of the PCB testing occasions.

A Rough Location Based on Template Matching
For the positioning of the circuit board image, you first need to select the appropriate reference point to ensure convenient, reliable and accurate positioning.Under normal circumstances, the circuit board has its own round for positioning, so it is appropriate to select the round as the positioning reference of the board.The positioning round is shown in Figure 1(a).We can see that the camera captures an image of the board, including the positioning round, which contains a wealth of information, and the information of interest is only the positioning round, so in order to locate accurately, the first step is to conduct the rough location and extract the general area of the orientation round, as far as possible to eliminate irrelevant information.So as to get the rough region of  ( , ) ( , ) T mn T mn S mn T mn ( ( , ) ( ,  After getting the rough region of positioning round, the next step is to get the center coordinate of the circle.In this paper the used camera is a black and white one, and the image is gray-scale.So in the extraction of the positioning circle, we can't start from the color.The image limited in the area is shown in Figure 2(c) (Figure 1 is a scaled image, so the positioning rounds of Figure 1 and Figure 2 are deferent in size).For the processed image of positioning circle, if its noise is relatively low, it will be processed with the binarization of threshold 80.After the above series of image processing, a position image, which is full and of clear outline, is achieved, and the calculation of the center coordinates is the next step.

Average Pixel Coordinates Method
So-called average pixel coordinates method is a statistical method, which records the x and y coordinates and the number of pixels with 255 values (white) by scanning the whole lot of binary image, and then accumulate x and y coordinates of white pixels, and the average coordinates are the center coordinates of the positioning round.(5) Among them, n refers to the number of white pixel respectively, and ∑x i , ∑y i refer to the total value of all white pixels cumulative gross x and y coordinates, /x, /y to the center coordinates.According to Equation ( 5), the center coordinates of Figure 2(g) is (83,471).

The Traditional Hough Transform
Assume that the collection of the composition points of the image circle is { , | 1, 2 , 3 , ..., } i i x y i n  , (x, y) is any point in this collection, so its equation in the parametric coordinate system can be expressed as: This equation is a three-dimensional cone in space.So if put any point of the image into (6), the corresponding result is a three-dimensional cone to the analytic geometry knowledge.Putting set of points on the circumference into the Equation ( 6), the result consists of the conical surface cluster For the points on the same circle, the conical surface cluster is bound to intersect at one point (a0, b0, r0), and this intersection is the required radius and center coordinates (Ioannoua, Hudab, & Lainec, 1999).Equation ( 6) in the discrete image can be rewritten as: The letter  in the above formula refer to the digital compensation of the image.
The specific transformation process: 1) Select the appropriate a, b, r, to create a conical surface clusters.
2) Create a three-dimensional array A (a, b, r) used to accumulate; according to Equation ( 6), with the change of a and b, corresponding r is calculated, and after calculating r, A (a, b, r) cumulative one more time: A (a, b, r) = A (a, b, r) +1.
3) Obtained the local maximum of three-dimensional array A (a, b, r), this value is the required radius and center coordinates.

Improved Hough Transform
The traditional Hough transform for circle detection involves too many points, too high cumulative array dimension and large computation load.Therefore, to reduce the dimension of the cumulative array is one of the keys to improve the efficiency of Hough transform.According to the above principle, we improved Hough transform.In Figure 3(a), we take a point called A on the edge of the image, point B taken after some interval points, and connect A and B. For the line AB, perpendicular intersects the circle at two points called C and J, and we can see by the knowledge of geometry, segment CJ go through the center called O point of the circle.Similarly, from the point B, point D taken after some interval points, you can get a segment called EI.The Intersection of the segments CJ and EI is to the center of the circle to calculate (Yue & Xiang, 2006).
The steps of improved Hough Transform: once a time of search is completed, the neighbor point of point A in the clockwise direction is taken as a new starting point.The neighbor point of this new starting point is the starting point for the next search.Repeat the above steps until back to the point near the initial point A. In the search process, a two-dimensional accumulator is just needed to accumulate the center of the circle.Compared to the traditional Hough transform, the new method needs less storage space and it is less complex.Finally, the maximum of the accumulator is the center coordinates.Set up the coordinates of the points A, B, and C, respectively, (x1, y1), (x2, y2) and (x3, y3), then the equation of straight line CJ and EI is: According to Equation ( 7) and ( 8), the intersection of two lines is the center coordinates.The process of Hough transform circle detection is shown in Figure 3.The first step is to extract the circular contour, and then the Hough transform is used to get the center coordinates (89,460).Compared to the previous method, in theory, this algorithm is more accurate, and need less calculation time.Overall, using the improved Hough transform can improve the detection accuracy, and it is ideal for situations which require high accuracy.

Conclusion
In this paper, Firstly, the template matching method is used to get the coarse position and then a full positioning image of clear outline is achieved after the binary method, size filtering and negative processing.Finally, complete the orientation circle detection using an improved Hough transform method.Compared with the pixel average coordinates method and the traditional Hough transform method, this new method is simple, effective and accurate in the image positioning for the PCB.

Figure
Figure 1.Sear rch graph and t ar (i, j) position e matching po tween time and on of NC valu h graph, and co egree of simila rder to improv n a small step ce 1) is a registra te image in the My and searc ece of the searc the sub-graph ≤N-M.

Figure 2
Figure 2(a) as a template, Figure 1 is searched for locate round, and the result is shown in Figure 2(b) with a matched orientation round surrounded by a black box.
Figure 2(d) shows the results.It can be seen from the figure, the binarization positioning circle is displayed with white in black background.Obviously, the positioning circle has been split out, but some small areas of interference still exist.To get extent possible, accurate positioning circular coordinates, we should get rid of these small areas.The Size Filtering Method can achieve the goal, and the results are show in Figure 2(e).Size filtering method only eliminates the black interference, and you need negative phase in Figure 2(e) to remove the white part of the small areas.The final results are shown in Figure 2(g).
Eliminates the black interference (f) Negative phase object (g) Final result Figure 2. The extraction process positioning round (a) Access to the center of the circle (b) Contour extraction for Figure 2(g) (c) Improved Hough Transform (d) Center of the circle to calculate Figure 3.The circle detection processes of improved Hough transform