CN108510513A - A kind of PCB image circle detection method based on PCA and segmentation RHT - Google Patents
A kind of PCB image circle detection method based on PCA and segmentation RHT Download PDFInfo
- Publication number
- CN108510513A CN108510513A CN201810205002.2A CN201810205002A CN108510513A CN 108510513 A CN108510513 A CN 108510513A CN 201810205002 A CN201810205002 A CN 201810205002A CN 108510513 A CN108510513 A CN 108510513A
- Authority
- CN
- China
- Prior art keywords
- circle
- image
- pca
- rht
- segmentation
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000001514 detection method Methods 0.000 title claims abstract description 29
- 230000011218 segmentation Effects 0.000 title claims description 10
- 238000003708 edge detection Methods 0.000 claims abstract description 8
- 238000000034 method Methods 0.000 claims description 11
- 238000009825 accumulation Methods 0.000 claims description 3
- 239000011159 matrix material Substances 0.000 claims description 3
- 238000012216 screening Methods 0.000 claims description 3
- 230000007423 decrease Effects 0.000 claims 1
- 230000000452 restraining effect Effects 0.000 claims 1
- 230000009466 transformation Effects 0.000 claims 1
- 238000000513 principal component analysis Methods 0.000 abstract description 13
- 238000012545 processing Methods 0.000 abstract description 4
- 238000004458 analytical method Methods 0.000 description 3
- 230000007547 defect Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000000717 retained effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000007430 reference method Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/13—Edge detection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/10—Segmentation; Edge detection
- G06T7/136—Segmentation; Edge detection involving thresholding
Landscapes
- Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Image Analysis (AREA)
Abstract
本发明公开了一种基于PCA和分段RHT的PCB图像圆检测方法,包括以下步骤:S1.载入原始彩色PCB板图像;S2.对图像进行灰度二值化,采用边缘检测算法提取图像边缘,除去交叉次数较多的点;S3.对灰度二值化图像中的线段进行标记,找出长度大于所设阈值t的线段;S4.对每条线段进行主成分分析,得到特征值,保留类圆曲线段;S5.对类圆曲线段进行圆拟合,得到粗略圆参数,在类圆曲线段中筛选出有效曲线段;S6.对有效曲线段进行分段圆检测,得到精确圆参数。本发明的优点在于,对圆的检测更加精确,对非圆曲线的去除更加有效,圆的参数误差更小,处理速度上也有优势。
The invention discloses a PCB image circle detection method based on PCA and segmented RHT, comprising the following steps: S1. loading the original color PCB board image; S2. performing grayscale binarization on the image, and extracting the image by using an edge detection algorithm Edge, remove points with more crossing times; S3. Mark the line segments in the grayscale binarized image, find out the line segments whose length is greater than the set threshold t; S4. Perform principal component analysis on each line segment to obtain the eigenvalue , keep the circle-like curve segment; S5. Carry out circle fitting on the circle-like curve segment to obtain the rough circle parameters, and filter out the effective curve segment from the circle-like curve segment; S6. Perform segmented circle detection on the effective curve segment to obtain the accurate circle parameters. The invention has the advantages of more accurate detection of circles, more effective removal of non-circular curves, smaller parameter errors of circles, and advantages in processing speed.
Description
技术领域technical field
本发明涉及图像处理与机器视觉领域,更具体地,涉及一种基于PCA和分段RHT的PCB图像圆检测方法。The present invention relates to the field of image processing and machine vision, and more specifically, to a PCB image circle detection method based on PCA and segmented RHT.
背景技术Background technique
目前,印刷电路板(PCB)缺陷检测常用的方法是参考法,将待匹配板与参考模版图像配准,其中圆形孔的检测与定位最为重要。现有的发明与技术中,有些只适合内容较单一的印刷电路板(PCB)图像,有些不能保证较好的精确度,有些处理会引入很多的噪声,鲁棒性差。At present, the commonly used method for printed circuit board (PCB) defect detection is the reference method, which registers the image of the board to be matched with the reference template, and the detection and positioning of circular holes is the most important. Among the existing inventions and technologies, some are only suitable for printed circuit board (PCB) images with relatively single content, some cannot guarantee better accuracy, and some processing will introduce a lot of noise, so the robustness is poor.
发明内容Contents of the invention
本发明为克服上述现有技术所述的缺陷,提供一种基于PCA和分段RHT的PCB图像圆检测方法。In order to overcome the above-mentioned defects in the prior art, the present invention provides a PCB image circle detection method based on PCA and segmented RHT.
为解决上述技术问题,本发明的技术方案如下:In order to solve the problems of the technologies described above, the technical solution of the present invention is as follows:
一种基于PCA和分段RHT的PCB图像圆检测方法,包括以下步骤:A PCB image circle detection method based on PCA and segmented RHT, comprising the following steps:
S1.载入原始彩色PCB板图像;S1. Load the original color PCB board image;
S2.对图像进行灰度二值化,采用边缘检测算法提取图像边缘,除去交叉次数较多的点;S2. Carry out grayscale binarization to the image, adopt the edge detection algorithm to extract the edge of the image, and remove the points with more crossing times;
S3.对灰度二值化图像中的线段进行标记,找出长度大于所设阈值t的线段;S3. Mark the line segments in the grayscale binarized image, and find out the line segments whose length is greater than the set threshold t;
S4.对每条线段进行主成分分析(Principal Component Analysis,PCA),得到特征值,保留类圆曲线段;S4. Perform Principal Component Analysis (PCA) on each line segment to obtain eigenvalues and retain the circle-like curve segment;
S5.对类圆曲线段进行圆拟合,得到粗略圆参数,在类圆曲线段中筛选出有效曲线段;S5. Carry out circle fitting to the circle-like curve segment to obtain rough circle parameters, and select effective curve segments in the circle-like curve segment;
S6.对有效曲线段进行分段圆检测,得到精确圆参数。S6. Perform segmented circle detection on the effective curve segment to obtain precise circle parameters.
上述的工作原理为:首先对图像进行灰度二值化,通过边缘检测算法提取图像边缘并出去交叉次数多的点;对图像中的线段均进行标记,通过主成分分析,筛选出类圆曲线段;对类圆曲线段进行圆拟合,得到粗略圆参数,并筛选出有效曲线段;最后采用分段的方式对有效曲线段进行圆检测,得到精确圆参数。The above working principle is as follows: firstly, grayscale binarization is performed on the image, and the edge of the image is extracted through the edge detection algorithm and points with a large number of intersections are removed; all line segments in the image are marked, and the circle-like curve is screened out through principal component analysis segment; the circle fitting is performed on the circle-like curve segment to obtain rough circle parameters, and the effective curve segment is screened out; finally, the circle detection is performed on the effective curve segment in a segmented manner to obtain accurate circle parameters.
优选地,所述步骤S4的PCA方向分析具体步骤如下:Preferably, the specific steps of the PCA direction analysis in step S4 are as follows:
对于每条线段,设像素为N,任一点坐标(xi,yi),根据以下公式:For each line segment, let the pixel be N, any point coordinates ( xi , y i ), according to the following formula:
得出S11,S12,S21和S22,用于构成以下协方差矩阵:S 11 , S 12 , S 21 and S 22 are obtained to form the following covariance matrix:
得出S的特征根λ1和λ2;Get the characteristic roots λ 1 and λ 2 of S;
判断线段是否为满足条件1≤λ1/λ2≤t的类圆曲线段,如果是,则保留,否则就除去。Determine whether the line segment is a circle-like curve segment satisfying the condition 1≤λ 1 /λ 2 ≤t, if yes, keep it, otherwise remove it.
优选地,所述步骤S5中圆拟合的具体过程如下:Preferably, the specific process of circle fitting in the step S5 is as follows:
采用带约束的最小二乘圆拟合法,近似得到圆的圆心和半径,用于筛选曲线段。Using the least squares circle fitting method with constraints, the center and radius of the circle are approximated for screening curve segments.
优选地,所述步骤S6中分段圆检测采用随机霍夫变换(Random Hough Transform,RHT),具体过程如下:Preferably, the segmented circle detection in the step S6 adopts Random Hough Transform (Random Hough Transform, RHT), and the specific process is as follows:
设D为保留下来的图像边缘点集,对有效曲线段进行标记,按照标记顺序依次进行随机霍夫变换:Let D be the retained image edge point set, mark the effective curve segment, and perform random Hough transform in sequence according to the marking order:
从曲线段点集中随机选取3个点,确定一个候选圆参数,通过证据积累计算曲线段点集中落在该候选圆上的点数,若大于圆所必需的最小点数,则确认该候选圆为真实圆,从D中删除该圆上的点,然后继续进行下一个圆的检测,直到所有的曲线段都检测完毕。Randomly select 3 points from the curve segment point set, determine a candidate circle parameter, and calculate the number of points in the curve segment point set that fall on the candidate circle through evidence accumulation. If it is greater than the minimum number of points necessary for a circle, then confirm that the candidate circle is real circle, delete the points on the circle from D, and then proceed to the detection of the next circle until all the curve segments are detected.
优选地,所述步骤S6在得到精确圆参数后,在图像空间删除对应的像素点,直到所有的曲线段检测完毕。Preferably, in the step S6, after the precise circle parameters are obtained, the corresponding pixel points are deleted in the image space until all the curve segments are detected.
优选地,所述阈值t为1.5。Preferably, the threshold t is 1.5.
优选地,所述边缘检测算法为canny算子。Preferably, the edge detection algorithm is a canny operator.
与现有技术相比,本发明技术方案的有益效果是:Compared with the prior art, the beneficial effects of the technical solution of the present invention are:
本发明在使用主成分分析的基础上,采用随机霍夫变换进行分段圆检测,对圆的检测更加精确,对非圆曲线的去除更加有效,圆的参数误差更小,处理速度上也有优势。On the basis of principal component analysis, the present invention adopts random Hough transform for segmented circle detection, more accurate detection of circles, more effective removal of non-circular curves, smaller parameter errors of circles, and advantages in processing speed .
附图说明Description of drawings
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention. Those skilled in the art can also obtain other drawings based on these drawings without creative work.
图1是基于PCA和分段RHT的PCB图像圆检测方法示意图。Figure 1 is a schematic diagram of a PCB image circle detection method based on PCA and segmented RHT.
具体实施方式Detailed ways
附图仅用于示例性说明,不能理解为对本专利的限制;The accompanying drawings are for illustrative purposes only and cannot be construed as limiting the patent;
对于本领域技术人员来说,附图中某些公知结构及其说明可能省略是可以理解的。For those skilled in the art, it is understandable that some well-known structures and descriptions thereof may be omitted in the drawings.
下面结合附图和实施例对本发明的技术方案做进一步的说明。The technical solutions of the present invention will be further described below in conjunction with the accompanying drawings and embodiments.
一种基于PCA和分段RHT的PCB图像圆检测方法,如图1所示,包括以下步骤:A kind of PCB image circle detection method based on PCA and segmentation RHT, as shown in Figure 1, comprises the following steps:
S1.载入原始彩色PCB板图像;S1. Load the original color PCB board image;
S2.对图像进行灰度二值化,采用边缘检测算法提取图像边缘,除去交叉次数较多的点;S2. Carry out grayscale binarization to the image, adopt the edge detection algorithm to extract the edge of the image, and remove the points with more crossing times;
S3.对灰度二值化图像中的线段进行标记,找出长度大于所设阈值t的线段;S3. Mark the line segments in the grayscale binarized image, and find out the line segments whose length is greater than the set threshold t;
S4.对每条线段进行PCA方向分析,得到特征值,保留类圆曲线段;S4. Carry out PCA direction analysis to each line segment, obtain eigenvalue, keep the circle-like curve segment;
S5.对类圆曲线段进行圆拟合,得到粗略圆参数,在类圆曲线段中筛选出有效曲线段;S5. Carry out circle fitting to the circle-like curve segment to obtain rough circle parameters, and select effective curve segments in the circle-like curve segment;
S6.对有效曲线段进行分段圆检测,得到精确圆参数。S6. Perform segmented circle detection on the effective curve segment to obtain precise circle parameters.
在本实施例中,步骤S4的PCA方向分析具体步骤如下:In this embodiment, the specific steps of the PCA direction analysis in step S4 are as follows:
对于每条线段,设像素为N,任一点坐标(xi,yi),根据以下公式:For each line segment, let the pixel be N, any point coordinates ( xi , y i ), according to the following formula:
得出S11,S12,S21和S22,用于构成以下协方差矩阵:S 11 , S 12 , S 21 and S 22 are obtained to form the following covariance matrix:
得出S的特征根λ1和λ2;Get the characteristic roots λ 1 and λ 2 of S;
判断线段是否为满足条件1≤λ1/λ2≤t的类圆曲线段,如果是,则保留,否则就除去。Determine whether the line segment is a circle-like curve segment satisfying the condition 1≤λ 1 /λ 2 ≤t, if yes, keep it, otherwise remove it.
在本实施例中,步骤S5中圆拟合的具体过程如下:In this embodiment, the specific process of circle fitting in step S5 is as follows:
采用带约束的最小二乘圆拟合法,近似得到圆的圆心和半径,用于筛选曲线段。Using the least squares circle fitting method with constraints, the center and radius of the circle are approximated for screening curve segments.
在本实施例中,步骤S6中分段圆检测采用随机霍夫变换,具体过程如下:In this embodiment, the segmented circle detection in step S6 adopts random Hough transform, and the specific process is as follows:
设D为保留下来的图像边缘点集,对有效曲线段进行标记,按照标记顺序依次进行随机霍夫变换:Let D be the retained image edge point set, mark the effective curve segment, and perform random Hough transform in sequence according to the marking order:
从曲线段点集中随机选取3个点,确定一个候选圆参数,通过证据积累计算曲线段点集中落在该候选圆上的点数,若大于圆所必需的最小点数,则确认该候选圆为真实圆,从D中删除该圆上的点,然后继续进行下一个圆的检测,直到所有的曲线段都检测完毕。Randomly select 3 points from the curve segment point set, determine a candidate circle parameter, and calculate the number of points in the curve segment point set that fall on the candidate circle through evidence accumulation. If it is greater than the minimum number of points necessary for a circle, then confirm that the candidate circle is real circle, delete the points on the circle from D, and then proceed to the detection of the next circle until all the curve segments are detected.
在本实施例中,步骤S6在得到精确圆参数后,在图像空间删除对应的像素点,直到所有的曲线段检测完毕。In this embodiment, after the accurate circle parameters are obtained in step S6, the corresponding pixel points are deleted in the image space until all the curve segments are detected.
在本实施例中,阈值t为1.5。In this embodiment, the threshold t is 1.5.
在本实施例中,边缘检测算法为canny算子。In this embodiment, the edge detection algorithm is a canny operator.
显然,本发明的上述实施例仅仅是为清楚地说明本发明所作的举例,而并非是对本发明的实施方式的限定。对于所属领域的普通技术人员来说,在上述说明的基础上还可以做出其它不同形式的变化或变动。这里无需也无法对所有的实施方式予以穷举。凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明权利要求的保护范围之内。Apparently, the above-mentioned embodiments of the present invention are only examples for clearly illustrating the present invention, rather than limiting the implementation of the present invention. For those of ordinary skill in the art, on the basis of the above description, other changes or changes in different forms can also be made. It is not necessary and impossible to exhaustively list all the implementation manners here. All modifications, equivalent replacements and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the claims of the present invention.
Claims (7)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810205002.2A CN108510513A (en) | 2018-03-13 | 2018-03-13 | A kind of PCB image circle detection method based on PCA and segmentation RHT |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810205002.2A CN108510513A (en) | 2018-03-13 | 2018-03-13 | A kind of PCB image circle detection method based on PCA and segmentation RHT |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108510513A true CN108510513A (en) | 2018-09-07 |
Family
ID=63376561
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810205002.2A Pending CN108510513A (en) | 2018-03-13 | 2018-03-13 | A kind of PCB image circle detection method based on PCA and segmentation RHT |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108510513A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111402283A (en) * | 2020-02-25 | 2020-07-10 | 上海航天控制技术研究所 | Mars image edge feature self-adaptive extraction method based on gray variance derivative |
CN111861997A (en) * | 2020-06-24 | 2020-10-30 | 中山大学 | A method, system and device for detecting the size of circular holes in a patterned plate |
CN113640445A (en) * | 2021-08-11 | 2021-11-12 | 贵州中烟工业有限责任公司 | Characteristic peak identification method based on image processing, computing equipment and storage medium |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103886597A (en) * | 2014-03-24 | 2014-06-25 | 武汉力成伟业科技有限公司 | Circle detection method based on edge detection and fitted curve clustering |
-
2018
- 2018-03-13 CN CN201810205002.2A patent/CN108510513A/en active Pending
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103886597A (en) * | 2014-03-24 | 2014-06-25 | 武汉力成伟业科技有限公司 | Circle detection method based on edge detection and fitted curve clustering |
Non-Patent Citations (1)
Title |
---|
刘政 等: "基于PCA和分段RHT的PCB板圆Mark点定位", 《重庆理工大学学报(自然科学)》 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111402283A (en) * | 2020-02-25 | 2020-07-10 | 上海航天控制技术研究所 | Mars image edge feature self-adaptive extraction method based on gray variance derivative |
CN111402283B (en) * | 2020-02-25 | 2023-11-10 | 上海航天控制技术研究所 | Mars image edge characteristic self-adaptive extraction method based on gray variance derivative |
CN111861997A (en) * | 2020-06-24 | 2020-10-30 | 中山大学 | A method, system and device for detecting the size of circular holes in a patterned plate |
CN111861997B (en) * | 2020-06-24 | 2023-09-29 | 中山大学 | Method, system and device for detecting circular hole size of patterned plate |
CN113640445A (en) * | 2021-08-11 | 2021-11-12 | 贵州中烟工业有限责任公司 | Characteristic peak identification method based on image processing, computing equipment and storage medium |
CN113640445B (en) * | 2021-08-11 | 2024-06-11 | 贵州中烟工业有限责任公司 | Characteristic peak identification method based on image processing, computing device and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109671052B (en) | Through hole detection method of flexible IC packaging substrate based on circular contour extraction | |
JP6598162B2 (en) | Visual identification method of multi-type BGA chip based on linear clustering | |
CN104915963B (en) | A kind of detection and localization method for PLCC elements | |
CN105139386B (en) | A kind of image processing method of fast automatic detecting electric connector solder joint defective work | |
CN109839385B (en) | Self-adaptive PCB defect visual positioning detection and classification system | |
CN108918526B (en) | A kind of notch defect detection method of flexible IC package substrate circuit | |
CN103258201B (en) | A kind of form lines extracting method of amalgamation of global and local message | |
CN114693610B (en) | A method, device and medium for detecting weld surface defects based on machine vision | |
CN107315012B (en) | Composite polycrystal-diamond end face collapses the intelligent detecting method at angle | |
CN104700112B (en) | Parasite egg detecting method in a kind of excrement based on morphological feature | |
CN108389179A (en) | A kind of cover detection method of surface flaw based on machine vision | |
CN108629775A (en) | A kind of hot high-speed rod surface image processing method | |
CN105066892A (en) | BGA element detecting and positioning method based on linear clustering analysis | |
CN108802051B (en) | A system and method for detecting bubbles and crease defects in straight lines of flexible IC substrates | |
CN104680550A (en) | Method for detecting defect on surface of bearing by image feature points | |
CN111583216A (en) | Defect detection method for PCBA | |
CN112102287B (en) | An image-based automatic detection and identification method of green ball cracks | |
CN112070766B (en) | Defect detection method and device, detection equipment and readable storage medium | |
CN107016394B (en) | Cross fiber feature point matching method | |
CN108038838A (en) | A kind of cotton fibriia species automatic testing method and system | |
CN108510513A (en) | A kind of PCB image circle detection method based on PCA and segmentation RHT | |
CN106097368A (en) | A kind of recognition methods in veneer crack | |
CN106447673A (en) | Chip pin extraction method under non-uniform illumination condition | |
CN104867145A (en) | IC element solder joint defect detection method based on VIBE model | |
CN115690670A (en) | Intelligent identification method and system for wafer defects |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20180907 |