halcon学习二

read_image(image,'E:/circle.jpg')
rgb1_to_gray(image,grayimage)
threshold (grayimage, Regions, 23, 255)
connection(Regions,connect)
select_shape (connect, SelectedRegions, 'area', 'and', 5045.87, 87981.6)
dilation_circle(SelectedRegions,regiond,2)
erosion_circle(SelectedRegions,regione,3)
fill_up(regione,regionfull)
difference (regiond, regionfull, RegionDifference)
union1 (RegionDifference, RegionUnion)
reduce_domain (grayimage, RegionUnion, ImageReduced1)
edges_sub_pix (ImageReduced1, Edges, 'canny', 1, 20, 40)
segment_contours_xld (Edges, ContoursSplit, 'lines_circles', 5, 4, 2)
select_contours_xld (ContoursSplit, SelectedContours, 'contour_length', 80, 1000, -0.5, 0.5)
union_adjacent_contours_xld (SelectedContours, UnionContours3, 10, 1, 'attr_keep')
fit_circle_contour_xld (UnionContours3, 'algebraic', -1, 0, 0, 3, 2, Row1, Column1, Radius1, StartPhi, EndPhi, PointOrder)
gen_circle (Circle, Row1, Column1, Radius1)
dev_set_line_width (2)
dev_set_draw ('margin')
dev_display (image)
dev_display (Circle)
dev_disp_text (' radius='+Radius1 , 'image', Row1, Column1, 'black', [], [])

halcon学习二_第1张图片

你可能感兴趣的:(halcon)