要求
获取PCB板上的焊点以及线路端点,如图:
函数
涉及到的主要函数有:
access_channel() 获取一个多通道图像的一个通道。
skeleton() 计算一个区域的框架。
junctions_skeleton() 找到骨架中的结点和终点。
示例:
read_image (Image, 'pcb8102.bmp')
rgb1_to_gray (Image, GrayImage)
threshold (GrayImage, Region, 0, 10)
closing_circle (Region, RegionClosing, 20)
reduce_domain (GrayImage, RegionClosing, ImageReduced)
threshold (ImageReduced, Region1, 128, 255)
fill_up (Region1, RegionFillUp)
connection (RegionFillUp, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 10, 1000)
union1 (SelectedRegions, RegionUnion)
opening_circle (RegionUnion, RegionOpening, 2)
connection (RegionOpening, ConnectedRegions1)
area_center (ConnectedRegions1, Area, Row, Column)
tuple_gen_const (|Row|, 15, Newtuple)
*获取焊点
dev_display (GrayImage)
gen_circle (Circle, Row, Column, Newtuple)
stop()
*************************************************
access_channel (Image, ImageBlue, 3)
threshold (ImageBlue, Region2, 150, 255)
union1 (Circle, RegionUnion1)
difference (Region2, RegionUnion1, RegionDifference)
connection (RegionDifference, ConnectedRegions2)
select_shape (ConnectedRegions2, SelectedRegions1, 'area', 'and', 350, 50000)
fill_up (SelectedRegions1, RegionFillUp1)
closing_circle (RegionFillUp1, RegionClosing2, 5)
skeleton (RegionFillUp1, Skeleton)
junctions_skeleton (Skeleton, EndPoints, JuncPoints)
connection (EndPoints, ConnectedRegions3)
area_center (ConnectedRegions3, Area1, Row1, Column1)
tuple_gen_const (|Row1|, 5, Newtuple1)
gen_circle (Circle1, Row1, Column1, Newtuple1)
*线路端点
dev_display (ImageBlue)
dev_display (Skeleton)
dev_display (Circle1)
结果
获取到的焊点:
线路端点: