A kind of printed circuit board patch defect inspection method
Technical field
The present invention relates to field of machine vision and printed circuit board (PCB) detecting field, more particularly to one kind to be based on machine vision skill
The printed circuit board patch defect inspection method of art.
Background technique
Circuit board is the important component of Modern Industry Products, and in the manufacture craft of printed circuit board, product testing is
One of important process.Patch is one of the basic unit that Modern circuit boards realize function.The development trend of current patch is essence
Densification and miniaturization need the detection method of accurate, efficient printed circuit board (PCB).
The picture of general camera shooting is two dimensional image, but the surface features of patch both ends scolding tin are three-dimensional detection mesh
Mark.RGB three-color light source irradiation patch is widely used in modern PCB detection industry, reflects the scolding tin of different gradients different colors
Coloured silk, to react scolding tin surface nature.
Printed circuit board patch in the features such as patch location, angle, solder joint shape there is fine distinction, but phase
For the size of patch, the influence of this nuance be can not ignore.And traditional image-recognizing method, such as image comparison
Method, it is too sensitive to nuance, it be easy to cause erroneous judgement.But other morphologic image recognition algorithms, such as wavelet transformation are breathed out
, then there is the disadvantages of computationally intensive, to be influenced by background interference, testing result cannot fully meet requirement in husband's transformation.
Based on the above issues, it the invention proposes a kind of method for detecting patch defect, is irradiated and is welded using RGB three-color light source
The image that tin obtains carries out image recognition, can detecte patch common deficiency, and such as Short Item, Component Displacement, is set up a monument, solder joint at wrong part
Defect etc..User uses template patch, according to algorithm routine calculating threshold value, it can be achieved that the detection of patch defect.
Summary of the invention
The present invention is a kind of printed circuit board patch defect inspection method, is mainly solved in standard industry detection platform environment
Under, the identification problem of printed circuit board patch defect, can detecte Short Item, wrong part, Component Displacement, set up a monument, welding point defect etc. lacks
It falls into.
The purpose of the present invention is what is be achieved through the following technical solutions:
A kind of printed circuit board patch defect inspection method, includes the following steps:
1) patch positioning and size calculate:
1a) positions whole patch location by framing technology according to PCB patch location information and intercept patch figure
Picture;Separate picture red channel carries out binarization operation to the red channel image isolated, index for selection threshold value, and to figure
As carrying out a Denoising disposal.
Threshold segmentation skill 1b) is utilized using the metrics-thresholds of selection according to the red component of above-mentioned patch location and image
Art is partitioned into the red area of two end pad of patch, as flat site.
1c) all connected regions in the region being partitioned into are marked, left side white area is denoted as 1st area, and right side is white
Color region is denoted as 2nd area;In the horizontal and vertical coordinate in 1st area minimum value and maximum value be denoted as respectively minx1, miny1, maxx1,
maxy1;Minimum value and maximum value are denoted as minx2, miny2, maxx2, maxy2 respectively in the horizontal and vertical coordinate in 2 area;According to
Formula 1 calculates separately index t1、t2、t3、t4、t5、t6, and compared with corresponding index upper limit threshold and index lower threshold
Compared with.
If index in the range of index upper limit threshold and index lower threshold, determines that patch size is correct, otherwise
It is recorded as not meeting the project of metrics-thresholds bound.
1d) according to the angular coordinate in the image upper left corner and the lower right corner, image interception, intercept method are carried out are as follows: with an image left side
As coordinate origin, abscissa is the direction y at upper angle, and the patch y direction length after cutting is y1;Ordinate is the direction x, is cut
Patch x direction length afterwards is x1;Wherein, interception angular coordinate choose (miny1-2, minx1-2) and (maxy2+2,
Maxx2+2), interception area area is (maxy2-miny1+4) × (maxx2-minx1+4).
2) patch region color analysis:
6 block feature regions 2a) are intercepted from the patch image after step 1d) interception, are denoted as region A, region B, area respectively
Domain C, region D, region E, region F record the area starting point coordinate and area of interception.
Color analysis 2b) is carried out respectively to 6 block feature regions in step 2a), using pixel red component in region
Average value (mcol) is used as index, and formula is as follows:
Wherein, col is each pixel red color component value in region;N is pixel number in region.
Every piece of Regional Red component average value is calculated according to formula 2.
When pixel red component average value (mcol) meets red component upper limit threshold and red point in every piece of region
When measuring lower threshold, then solder joint zero defect is determined;If there is not meeting red component upper limit threshold and red component lower limit threshold
The case where value, then determines that solder joint is defective, and records defect area.
3) patch type identifier:
The identification of 3A. number: after completing the solder joint detection in the color analysis of patch region, digital identification is carried out.
3a) on the basis of patch image in the step 1d) after interception, according to the size of template image in testing image
Intercept numeric area image;Binary conversion treatment is carried out to digital block area image, determines metrics-thresholds, and once gone to image
Noise processed.
Three numeric areas in image are respectively labeled as 1st ' area, 2nd ' area, 3rd ' area by the 3b) method of using area label.Meter
Calculate the y of each connected domain, maximum and minimum value in x coordinate value, be denoted as (max1 ' y, max1 ' x), (max2 ' y, max2 ' x),
(max3 ' y, max3 ' are x), (min1 ' y, min1 ' are x), (min2 ' y, min2 ' are x), (min3 ' y, min3 ' is x);According to corresponding y, x
The maximum value and minimum value of coordinate intercept corresponding numeric area as the upper left corner and bottom right angular coordinate;The numeric area of interception is big
In the region being calculated;For connected component labeling be 1 ' region, angular coordinate be (max1 ' y+2, max1 ' x+2) and
(min1 ' y-2, min1 ' x-2);For connected component labeling be 2 ' region, angular coordinate be (max2 ' y+2, max2 ' x+2) and
(min2 ' y-2, min2 ' x-2);For connected component labeling be 3 ' region, angular coordinate be (max3 ' y+2, max3 ' x+2) and
(min3 ' y-2, min3 ' x-2).
The white area for taking the upper left of image, lower-left, upper right, bottom right, is respectively labeled as A ', B ', C ', D ', each region
White pixel point quantity is denoted as NA ', NB ', NC ', ND ' respectively.
Then, individual digit image is identified;It is index by connected domain quantity in the image of background of numeric area
The number that may be characterized to image is classified, and classification method is as follows:
If 3b1) connected domain quantity is 3, the number of characterization image is 8;
If 3b2) connected domain quantity is 2, the number of characterization image is one of 9,6,0, carries out further number at this time and knows
Not, NA ', NB ', NC ', ND ' are compared with the template threshold value of formula 3-5, thus judge the number of characterization image, it is specific to judge
Process are as follows: when NA ', NB ', NC ', ND ' coincidence formula 3, then determine that number is 9;Work as NA ', NB ', NC ', ND ' and does not meet formula
3 and when coincidence formula 4, then determine that number is 6;When NA ', NB ', NC ', ND ' do not meet formula 3 and 4 and coincidence formula 5, then
Determine that number is 0.
Wherein, formula 3,4,5 is as follows:
(NA’+NC’+ND’)/3-NB’>φ1Formula 3
(NA’+NB’+ND’)/3-NC’>φ2Formula 4
|NA’-(NA’+NB’+NC’+ND’)|+|NB’-(NA’+NB’+NC’+ND’)|+|NC’-(NA’+NB’+NC’+
ND’)|+|ND’-(NA’+NB’+NC’+ND’)|>φ3
Formula 5
Wherein, φ1、φ2、φ3The respectively template threshold value of formula 3,4,5.
According to above-mentioned process and formula, passes sequentially through template matching and judge whether number is 9,6,0;If above-mentioned formula is equal
It is unsatisfactory for, then determines that image can not identify.
If 3b3) connected domain quantity is 1, the number of characterization image is one of 1,2,3,4,5,7, is carried out at this time further
Number identification, picture traverse and NA ', NB ', NC ', ND ' is compared with the template threshold value of formula 6-12, to judge image
The number of characterization, specifically judges process are as follows:
When picture traverse coincidence formula 6, then determine that number is 1;When picture traverse does not meet formula 6, according to NA ',
NB ', NC ', ND ' continue to judge;When NC ' coincidence formula 7, continue to judge NA ', NC ', ND ' whether coincidence formula 8;When
When NA ', NC ', ND ' coincidence formula 8, then determine that number is 4;When NA ', NC ', ND ' do not meet formula 8 and coincidence formula 9, then
Determine that number is 7;When NC ' coincidence formula 7 and NA ', NC ', ND ' do not meet formula 8 and formula 9, then image fails to identify.
When NC ' does not meet formula 7, continue to judge NA ', NC ', ND ' whether coincidence formula 10;When coincidence formula 10, then
Determine that number is 5;When NA ', NC ', ND ' do not meet formula 10 and NA ', NB ', NC ', ND ' coincidence formula 11, then number is determined
It is 2;When NA ', NB ', NC ', ND ' do not meet formula 10 and formula 11 and coincidence formula 12, then determine that number is 3;Work as NA ',
When NB ', NC ', ND ' do not meet formula 7, formula 10, formula 11 and formula 12, then image fails to identify.
Wherein formula 6-12 is as follows:
width<η1Formula 6
NC’<η2Formula 7
|NA’-(NA’+NC’+ND’)/3|<η3Formula 8
|NC’-(NA’+ND’)/2|>η4Formula 9
|NA’-(NA’+NC’+ND’)/3|<η5Formula 10
NB’+NC’-NA’-ND’>η6Formula 11
NB’+ND’-NA’-NC’>η7Formula 12
Wherein, width is picture traverse;η1、η2、η3、η4、η5、η6、η7Respectively template threshold value of the formula 6 to formula 12.
According to above-mentioned process and formula, pass sequentially through picture traverse calculate, template matching, judge number whether be
1,2,3,4,5,7;If above-mentioned formula is not satisfied, determine that image can not identify.
3B. is compared with template number, determines whether number is correct, therefore, it is determined that whether element model is correct.
Number identification number in a kind of patch model identification step of printed circuit board patch defect inspection method
Three times for each repetition of figures identification.
A kind of binarization operation of the printed circuit board patch defect inspection method use Two-peak method, metrics-thresholds with
Template Threshold uses normal distribution method.
The beneficial effects of the present invention are:
This method adaptability is stronger, and it is more comprehensive to can detect patch defect kind.
This method is made using being identified based on the position for the pixel number for meeting threshold condition, color and quantity
Recognizer is realized with less calculation amount.
This method is easy, and according to process, to element, whole, solder joint and patch number identify that detection project is complete respectively
Face is adapted to different detection operating conditions, can detect program for different patch designs.
Detailed description of the invention
Fig. 1 is hardware device composition schematic diagram of the invention;
Fig. 2 is a kind of flow chart of printed circuit board patch defect inspection method of the present invention;
Fig. 3 is present invention patch image to be processed;
Fig. 4 is the red area image after present invention image segmentation to be processed;
Fig. 5 is present invention image cropping bak stay image to be processed;
Fig. 6 is present invention patch feature regional images to be processed;
Fig. 7 is the numeric area image after present invention image cropping to be processed;
Fig. 8 is digital identification process figure of the invention;
Fig. 9 is the area schematic after present invention image digitization area image interception to be processed;
Figure 10 is printing digital angle point typical case's legend of the present invention;
Figure 11 is overhaul flow chart when connected domain is 2 in digital identification process of the invention;
Figure 12 is overhaul flow chart when connected domain is 1 in digital identification process of the invention;
Figure 13 is binarization operation Two-peak method schematic diagram of the present invention;
Figure 14 is patch feature regional images to be processed of the embodiment of the present invention;
Figure 15 is the red area image after image segmentation to be processed of the embodiment of the present invention;
Figure 16 is patch feature regional images to be processed of the embodiment of the present invention;
Figure 17 is the area schematic after image digitization area image interception to be processed of the embodiment of the present invention.
Appended drawing reference
11 computer, 12 industrial camera
13 telecentric lens, 14 light source
1 connected region, 1st area, 2 connected region, 2nd area
A characteristic area A B characteristic area B
C characteristic area C D characteristic area D
E characteristic area E F characteristic area F
1 ' numeric area, 1 ' 2 ' numeric area 2 '
The white area A ' of 3 ' numeric area, 3 ' A ' interception
The white area C ' of the white area B ' C ' interception of B ' interception
15 workbench of white area D ' of D ' interception
Specific embodiment
With reference to the accompanying drawings and examples, specific embodiments of the present invention will be described in further detail.
Emphasis of the invention is defect identification method, Blob analytic approach and color analysis method is based on, by related objective
The features such as size, pixel quantity, color component value analysis, calculated using normal distribution model based on several template images
Then dependent thresholds target to be detected are compared with dependent thresholds, by the method for characteristic matching, identify patch defect.
Hardware device composition of the invention is as shown in Figure 1, right by kilomega network control industrial camera 12 using computer 11
Printed circuit board carries out Image Acquisition.Industrial camera 12 connects telecentric lens 13.Light source 14 is carried out using arbitrary source control machine
Control detects dedicated RGB annular light source for AOI, be irradiated to scolding tin surface can make the plane reflection of different inclination angle it is red,
Green, blue three-color light.
The hardware device course of work of the invention:
(1) 12 relevant parameter of industrial camera (white balance, time for exposure) and the combination of light source lighting color device debugging: are adjusted
(central region field color is adjusted to by white by the combination of tri- kinds of colors of RGB in the present invention);
(2) PCB patch to be measured is placed on workbench 15, it is corresponding with the light source 14 above it.Make work of computerizeing control
Industry camera 12 acquires PCB patch image and is stored in computer 11;
(3) image procossing is carried out, identifies patch defect.
As shown in Fig. 2, a kind of printed circuit board patch defect inspection method of the present invention, includes the following steps:
1) patch positioning and size calculate:
Patch to be measured is as shown in Figure 3.
1a) positions whole patch location by framing technology according to PCB patch location information and intercept patch figure
Picture.Separate picture red channel carries out binarization operation to the red channel image isolated, index for selection threshold value, and to figure
As carrying out a Denoising disposal.
Wherein, binarization operation uses Two-peak method, and metrics-thresholds determine method using normal distribution method.
Binarization operation uses Two-peak method:
Figure 13 is the coordinate diagram of image Color Channel or gray scale, wherein x-axis characterizes color component value, and y-axis characterizes image
The quantity of the pixel of middle corresponding x-axis color component, segmentation threshold select background and prospect it is bimodal between minimum point, i.e. pixel
The point of minimum number.
Preferably, the binarization threshold of above-mentioned binarization operation is 0.233 × 255.
Metrics-thresholds determine method using normal distribution method:
(1) multiple template image is selected, calculates the sample value (a at threshold value differentiation using algorithm1,a2,a3……an) (can
To be size, it is also possible to the quantity of qualified point);
(2) normal distribution model is used, the mean μ and variance ε of normal distribution are calculated;
(3) image to be detected is analyzed, numerical value a at metrics-thresholds differentiation is calculated, and compared with normal distribution model, such as a
It falls within the scope of ± 3 ε of u, then determines to meet metrics-thresholds condition, otherwise, it is determined that parameter does not meet metrics-thresholds herein.
Threshold segmentation skill 1b) is utilized using the metrics-thresholds of selection according to the red component of above-mentioned patch location and image
Art is partitioned into the red area of two end pad of patch, as flat site.Red area after segmentation is as shown in Figure 4.
1c) all connected regions in the region being partitioned into are marked, left side white area is denoted as 1st area, and right side is white
Color region is denoted as 2nd area.In the horizontal and vertical coordinate in 1st area minimum value and maximum value be denoted as respectively minx1, miny1, maxx1,
maxy1;Minimum value and maximum value are denoted as minx2, miny2, maxx2, maxy2 respectively in the horizontal and vertical coordinate in 2 area.Then
Index t is calculated separately according to formula 11、t2、t3、t4、t5、t6, and carried out with corresponding index upper limit threshold and index lower threshold
Compare, if index in the range of index upper limit threshold and index lower threshold, determines that patch size is correct, otherwise records
For the project for not meeting metrics-thresholds bound.
1d) according to the angular coordinate in the image upper left corner and the lower right corner, image interception, intercept method are carried out are as follows: with an image left side
As coordinate origin, abscissa is the direction y at upper angle, and the patch y direction length after cutting is y1, ordinate is the direction x, is cut
Patch x direction length afterwards is x1.It is as shown in Figure 5 to intercept bak stay image.Considered based on algorithm robustness, wherein interception
Angular coordinate chooses (miny1-2, minx1-2) and (maxy2+2, maxx2+2), and interception area area is (maxy2-miny1+
4)×(maxx2-minx1+4)。
2) patch region color analysis
2a) as shown in fig. 6, intercepting 6 block feature regions from the patch image after step 1d) interception, it is denoted as region respectively
A, region B, region C, region D, region E, region F record the area starting point coordinate and area of interception.The picture of interception originates
Point and area are as shown in table 1.
The starting point and area intercept method of 1 image representative region of table interception
Color analysis 2b) is carried out respectively to 6 block feature regions in step 2a), using pixel red component in region
Average value (mcol) be used as index, formula is as follows:
Wherein, col is each pixel red color component value in region;N is pixel number in region.
Every piece of Regional Red component average value is calculated according to formula 2.Red component Threshold is using normal state point
Cloth method is identical as the determination step of metrics-thresholds.
When pixel red component average value (mcol) meets red component upper limit threshold and red point in every piece of region
When measuring lower threshold, then solder joint zero defect is determined;If there is not meeting red component upper limit threshold and red component lower limit threshold
The case where value, then determines that solder joint is defective, and records defect area.
3) patch type identifier:
The identification of 3A. number: after completing the solder joint detection in the color analysis of patch region, digital identification is carried out, number is known
Other flow chart is as shown in Figure 8.
3a) on the basis of patch image in the step 1d) after interception, according to the size of template image in testing image
Numeric area image is intercepted, the numeric area image after interception is as shown in Figure 7.Binary conversion treatment is carried out to digital block area image,
It determines metrics-thresholds, and a Denoising disposal is carried out to image.
Wherein, binary conversion treatment and the determination method of metrics-thresholds are identical with step 1a).
3b) the method for using area label, numeric area in image is marked respectively.As shown in fig. 7, three numeric areas
Labeled as 1st ' area, 2nd ' area, 3rd ' area.The y of each connected domain, the maximum and minimum value in x coordinate value are calculated, be denoted as (max1 ' y,
Max1 ' x), (max2 ' y, max2 ' x), (max3 ' y, max3 ' x), (min1 ' y, min1 ' x), (min2 ' y, min2 ' x),
(min3 ' y, min3 ' is x).According to corresponding y, the maximum value of x coordinate and minimum value as the upper left corner and the interception pair of bottom right angular coordinate
The numeric area answered.In view of algorithm robustness, the numeric area of interception is greater than the region being calculated.As shown in figure 9, for
The region that connected component labeling is 1 ', angular coordinate are (max1 ' y+2, max1 ' x+2) and (min1 ' y-2, min1 ' x-2);For
The region that connected component labeling is 2 ', angular coordinate are (max2 ' y+2, max2 ' x+2) and (min2 ' y-2, min2 ' x-2);For
The region that connected component labeling is 3 ', angular coordinate are (max3 ' y+2, max3 ' x+2) and (min3 ' y-2, min3 ' x-2).
The white area for intercepting the upper left, lower-left of image, upper right, bottom right in Fig. 9, is respectively labeled as A ', B ', C ', D ', cuts
Take method as follows: as shown in figure 9, abscissa is the direction y, the patch side y after cutting using the image upper left corner as coordinate origin
It is y to length2, ordinate is the direction x, and the patch x direction length after cutting is x2, the starting point coordinate of cut out areas and face
Product is as shown in table 2:
The starting point coordinate and area of 2 cut out areas of table
Each region white pixel point quantity is denoted as NA ', NB ', NC ', ND ' respectively.
By the shape feature of printing digital it is found that the shape that four angles of digital picture are likely to occur is as shown in Figure 10
Three types: a type, b type and c type, by white pixel point quantity sort, c type is most, and b type takes second place, and a type is minimum.Inhomogeneity
White pixel point quantity difference is larger between the angle point of type, and the white pixel quantitative difference between the angle point of same type is smaller.
Then, individual digit image is identified.It is index by connected domain quantity n in the image of background of numeric area
(for example, number is 0 in Fig. 9, connected domain quantity is then that 2), the number that may be characterized to image is classified, and classification method is such as
Under:
If 3b1) connected domain quantity n is 3, the number of characterization image is 8;
If 3b2) connected domain quantity n is 2, the number of characterization image is one of 9,6,0, carries out further number at this time and knows
Not, process is as shown in figure 11, NA ', NB ', NC ', ND ' is compared with the template threshold value of formula 3-5, to judge characterization image
Number, specifically judge process are as follows: when NA ', NB ', NC ', ND ' coincidence formula 3, then determine number for 9;Work as NA ', NB ',
NC ', ND ' do not meet formula 3 when coincidence formula 4, then determine that number is 6;Work as NA ', NB ', NC ', ND ' and does not meet formula 3 and 4
And when coincidence formula 5, then determine that number is 0.
Wherein, formula 3,4,5 is as follows:
(NA’+NC’+ND’)/3-NB’>φ1(formula 3)
(NA’+NB’+ND’)/3-NC’>φ2(formula 4)
|NA’-(NA’+NB’+NC’+ND’)|+|NB’-(NA’+NB’+NC’+ND’)|+|NC’-(NA’+NB’+NC’+
ND’)|+|ND’-(NA’+NB’+NC’+ND’)|>φ3
(formula 5)
Wherein, φ1、φ2、φ3, the respectively template threshold value of formula 3,4,5.Template Threshold is using normal state point
Cloth method is identical as the determination step of metrics-thresholds.
According to above-mentioned process and formula, passes sequentially through template matching and judge whether number is 9,6,0.If above-mentioned formula is equal
It is unsatisfactory for, then determines that image can not identify.
If 3b3) connected domain quantity n is 1, the number of characterization image is one of 1,2,3,4,5,7, is carried out at this time further
Number identification, process is as shown in figure 12, by picture traverse and NA ', NB ', NC ', ND ' compared with the template threshold value of formula 6-12
Compared with specifically judging process to judge the number of characterization image are as follows:
When picture traverse coincidence formula 6, then determine that number is 1;When picture traverse does not meet formula 6, according to NA ',
NB ', NC ', ND ' continue to judge;When NC ' coincidence formula 7, continue to judge NA ', NC ', ND ' whether coincidence formula 8;When
When NA ', NC ', ND ' coincidence formula 8, then determine that number is 4;When NA ', NC ', ND ' do not meet formula 8, coincidence formula 9, then
Determine that number is 7;When NC ' coincidence formula 7 and NA ', NC ', ND ' do not meet formula 8 and formula 9, then image fails to identify.
When NC ' does not meet formula 7, continue to judge NA ', NC ', ND ' whether coincidence formula 10;When coincidence formula 10, then
Determine that number is 5;When NA ', NC ', ND ' do not meet formula 10 and NA ', NB ', NC ', ND ' coincidence formula 11, then number is determined
It is 2;When NA ', NB ', NC ', ND ' do not meet formula 10 and formula 11 and coincidence formula 12, then determine that number is 3;Work as NA ',
When NB ', NC ', ND ' do not meet formula 7, formula 10, formula 11 and formula 12, then image fails to identify.
Wherein formula 6-12 is as follows:
width<η1(formula 6)
NC’<η2(formula 7)
|NA’-(NA’+NC’+ND’)/3|<η3(formula 8)
|NC’-(NA’+ND’)/2|>η4(formula 9)
|NA’-(NA’+NC’+ND’)/3|<η5(formula 10)
NB’+NC’-NA’-ND’>η6(formula 11)
NB’+ND’-NA’-NC’>η7(formula 12)
Wherein, width is picture traverse;η1、η2、η3、η4、η5、η6、η7Respectively template threshold value of the formula 6 to formula 12.
Template Threshold uses normal distribution method, identical as the determination step of metrics-thresholds.
According to above-mentioned process and formula, pass sequentially through picture traverse calculate, template matching, judge number whether be
1,2,3,4,5,7.If above-mentioned formula is not satisfied, determine that image can not identify.
3B. according to above-mentioned process, each repetition of figures identification three times, respectively to three number identifications of Fig. 7, then with mould
Plate number is compared, and determines whether number is correct, therefore, it is determined that whether element model is correct.
Finally, complete by patch positioning and size calculating, three patch region color analysis, patch type identifier steps
The detection of pairs of patch.
Embodiment
Illustrate implementation process of the invention below by way of specific embodiment:
According to a kind of printed circuit board patch defect inspection method as shown in Figure 2, calculated by patch positioning and size,
Three patch region color analysis, patch type identifier steps realize patch defects detection.
The present embodiment test object is size 0402 (metric system), the patch that patch type figure is " 002 ", such as Figure 14 institute
Show.Detecting step is as follows:
1) patch positioning and size calculate:
1a) positions whole patch location by framing technology according to PCB patch location information and intercept patch figure
Picture.Separate picture red channel carries out binarization operation to the red channel image isolated, index for selection threshold value, and to figure
As carrying out a denoising.
Wherein, binarization operation uses Two-peak method, and metrics-thresholds determine method using normal distribution method.
Binarization operation uses Two-peak method:
Figure 13 is the coordinate diagram of image Color Channel or gray scale, wherein x-axis characterizes color component value, and y-axis characterizes image
The quantity of the pixel of middle corresponding x-axis color component, segmentation threshold select background and prospect it is bimodal between minimum point, i.e. pixel
The point of minimum number.
Preferably, the binarization threshold is selected as 0.233 × 255.
Metrics-thresholds determine method using normal distribution method:
(1) multiple template image is selected, calculates the sample value (a at threshold value differentiation using algorithm1,a2,a3……an) (can
To be size, it is also possible to the quantity of qualified point);
(2) normal distribution model is used, the mean μ and variance ε of normal distribution are calculated;
(3) image to be detected is analyzed, numerical value a at metrics-thresholds differentiation is calculated, and compared with normal distribution model, such as a
It falls within the scope of ± 3 ε of u, then determines to meet metrics-thresholds condition, otherwise, it is determined that parameter does not meet metrics-thresholds herein.
Threshold segmentation skill 1b) is utilized using the metrics-thresholds of selection according to the red component of above-mentioned patch location and image
Art is partitioned into the red area of two end pad of patch, as flat site.
1c) all connected regions in the region being partitioned into are marked, left side white area is denoted as 1st area, and right side is white
Color region is denoted as 2nd area.In the horizontal and vertical coordinate in 1st area minimum value and maximum value be denoted as respectively minx1, miny1, maxx1,
maxy1;Minimum value and maximum value are denoted as minx2, miny2, maxx2, maxy2 respectively in the horizontal and vertical coordinate in 2 area.Then
Index t is calculated separately according to formula 11、t2、t3、t4、t5、t6, and carried out with corresponding index upper limit threshold and index lower threshold
Compare, if index in the range of index upper limit threshold and index lower threshold, determines that patch size is correct, otherwise records
For the project for not meeting metrics-thresholds.
It is sample that 50 width template images are used in this example, is based on normal distribution model, calculated metrics-thresholds and calculating
Value such as table 3.
3 metrics-thresholds of table
1d) according to the angular coordinate in the image upper left corner and the lower right corner, image interception is carried out, intercept method is as shown in table 1.It cuts
Take bak stay image as shown in figure 14.Considered based on algorithm robustness, wherein the angular coordinate of interception choose (miny1-2,
Minx1-2) and (maxy2+2, maxx2+2), interception area area are (maxy2-miny1+4) × (maxx2-minx1+4), figure
As long and width is recorded as y1、x1.Y in this example1It is 271, x1It is 55.
2) patch region color analysis:
2a) as shown in figure 16,6 block feature regions are intercepted from the patch image after step 1d) interception, is denoted as region respectively
A, region B, region C, region D, region E, region F.The area starting point and area intercepted in this example is as shown in table 4.
The starting point and area of 4 image representative region of table interception
Color analysis 2b) is carried out respectively to above-mentioned 6 block feature region.
Every piece of Regional Red component average value is calculated according to formula 2.It is sample, base that 50 width template images are used in this example
In normal distribution model, calculated red component threshold value and average value such as table 5.
5 characteristic area red component threshold value of table and average value
* note: the area E and the area F are used only image red component upper limit threshold and are judged in this example
As shown in Table 3, pixel red component average value (mcol) meets the red component upper limit in every piece of region of this example
Threshold value and red component lower threshold, therefore can determine that solder joint zero defect.
3) patch type identifier:
The identification of 3A. number: after completing the solder joint detection in the color analysis of patch region, digital identification is carried out, number is known
Other process is as shown in Figure 8.
3a) on the basis of patch image in the step 1d) after interception, according to the size of template image in testing image
Intercept numeric area image.Binary conversion treatment is carried out to digital block area image, determines metrics-thresholds, the index threshold in the present embodiment
Value is 57, and carries out a Denoising disposal to image.
Wherein, binary conversion treatment and the determination method of metrics-thresholds are identical with step 1a).
Then, the method for using area label, numeric area in image is marked respectively.As shown in figure 17, three numbers
Zone marker is 1st ' area, 2nd ' area, 3rd ' area.It calculates the y of each connected domain, maximum and minimum value in x coordinate value, is recorded as (max1 '
Y, max1 ' x), (max2 ' y, max2 ' x), (max3 ' y, max3 ' x), (min1 ' y, min1 ' x), (min2 ' y, min2 ' x),
(min3 ' y, min ' 3x).(53,113) are followed successively by this example, (117,113), (182,113), (3,21), (64,18), (128,
18).Corresponding digital block is intercepted as in left comer and bottom right angular coordinate according to corresponding y, the maximum value of x coordinate and minimum value
Domain.In view of algorithm robustness, the numeric area of interception is more bigger than the region being calculated.The area for being 1 ' for connected component labeling
Domain, angular coordinate are (max1 ' y+2, max1 ' x+2) and (min1 ' y-2, min1 ' x-2);The area for being 2 ' for connected component labeling
Domain, angular coordinate are (max2 ' y+2, max2 ' x+2) and (min2 ' y-2, min2 ' x-2);The area for being 3 ' for connected component labeling
Domain, angular coordinate are (max3 ' y+2, max3 ' x+2) and (min3 ' y-2, min3 ' x-2);1 ' region angular coordinate is in this example
(55,115) and (1,19);2 ' region angular coordinates are (119,115) and (62,16);3 ' region angular coordinates are (184,115)
(126,16) carry out image interception according to above-mentioned angular coordinate.
The white area for taking the upper left of image, lower-left, upper right, bottom right, is respectively labeled as A ', B ', C ', D ', each region
White pixel point quantity is denoted as NA ', NB ', NC ', ND ' respectively.Interception rule such as table 2.In the present embodiment, patch includes three numbers
Word, y2Respectively 52,53,54;x2Respectively 94,95,95.The interception starting point coordinate and area of each digital picture such as table 6-
8。
The image interception starting point coordinate and area of 6 first digit of table " 0 "
The image interception starting point coordinate and area of 7 second digit of table " 0 "
The image interception starting point coordinate and area of 8 third digit of table " 2 "
By the feature of printing digital it is found that the possibility shape at four angles of image is divided into three types as shown in Figure 10
Type: a type, b type and c type sort by the quantity of white pixel point, and c type is most, and b type takes second place, and a type is minimum.Different types of angle point
Between white pixel point quantity difference it is larger, and the white pixel quantitative difference between the angle point of same type is smaller.The present embodiment
In, the corresponding white pixel point number such as table 9 of each number.
The white pixel point quantity of 9 different digital white area of table
Then, individual digit image is identified.It is index by connected domain quantity in the image of background of numeric area.
In this example, patch number is respectively " 0 ", " 0 " and " 2 ", therefore connected domain n is respectively 2,2 and 1.
When connected domain quantity is 2, according to flow chart 11, further judgement is digital.
It is sample that 50 width template images are used in this example, is based on normal distribution model, calculated template threshold value such as table 10
(only calculating required unilateral threshold value).
Template threshold value when 10 connected domain quantity of table is 2
By formula 3, formula 4 and formula 5 it is found that the white pixel point quantity (NA ', NB ', NC ', ND ') of white area with
The relationship of template threshold value is unsatisfactory for formula 3 and formula 4, meets formula 5, then can determine whether that digital picture is " 0 ".
When connected domain quantity is 1, number is further judged according to Figure 12.It is sample that 50 width template images are used in this example
This, is based on normal distribution model, and calculated template threshold value such as table 11 (only calculates required unilateral threshold value).
Template threshold value when 11 connected domain quantity of table is 1
By formula 6-12 it is found that the picture traverse of white area be unsatisfactory for formula 6, white pixel point quantity (NA ', NB ',
NC ', ND ') with the relationship of template threshold value it is unsatisfactory for formula 7 and formula 10, meet formula 11, then can determine whether that digital picture is
“2”。
According to above-mentioned process, each repetition of figures identification three times, respectively to three number identifications of Figure 17, then with template
Digital threshold is compared, and determines whether number is correct, therefore, it is determined that whether element model is correct.
Finally, real by patch positioning and size calculating, three patch region color analysis, patch type identifier steps
Now to the detection of patch.