一个halcon处理的例子
目录
- 处理要求:
- 原图:
- 处理程序:
- 处理结果:
处理要求:
根据客户给的宽度,计算出电路宽度太窄的为NG
原图:
处理程序:
read_image (Image, '1.png')
rgb1_to_gray(Image, GrayImage)
threshold(GrayImage, Region, 130, 255)
connection (Region, ConnectedRegions)
select_shape(ConnectedRegions, SelectedRegions, 'area', 'and', 10000, 99999)
opening_circle(SelectedRegions, RegionOpening, 2.5)
get_image_size (GrayImage, Width, Height)
distance_transform (RegionOpening, DistanceImage, 'city-block', 'true', Width, Height)
threshold (DistanceImage, Regions, 6, 127)
fill_up(Regions, RegionFillUp)
erosion_circle (RegionFillUp, RegionErosion, 2.5)
skeleton (RegionErosion, Skeleton)
junctions_skeleton (Skeleton, EndPoints, JuncPoints)
dilation_circle (EndPoints, RegionDilation, 10.5)
dilation_circle (JuncPoints, RegionDilation1, 5.5)
difference (Skeleton, RegionDilation, RegionDifference)
difference (RegionDifference, RegionDilation1, RegionDifference1)
gen_contours_skeleton_xld (RegionDifference1, Contours, 1, 'filter')
union_adjacent_contours_xld (Contours, UnionContours, 50, 5, 'attr_keep')
smooth_contours_xld (UnionContours, SmoothedContours, 23)
select_shape_xld(SmoothedContours, SelectedXLD, 'contlength', 'and', 500, 99999)
dev_display (GrayImage)
dev_display (SelectedXLD)