dev_update_off ()
dev_close_window ()
dev_open_window (0, 0, 978, 324, 'black', WindowHandle)
dev_set_part (0, 0, 647, 1955)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_color ('yellow')
*检测图中有多少个圈
*dev_set_line_width (3)
read_image (Image, 'C:/Users/Administrator/Desktop/20190727090119176.png')
*因为是随手用画板制的图,需要用到滤波器过滤线条
gauss_filter (Image, ImageGauss, 9)
threshold_sub_pix (ImageGauss, Border, 200)
*根据一种模型拆解轮廓线
segment_contours_xld (Border, ContoursSplit, 'lines', 1, 1, 1)
*使用共线链接,缝合这些满足条件的轮廓线
union_cotangential_contours_xld (ContoursSplit, UnionContours, 4, 30, rad(45), 25, 10, 2, 'attr_forget')
*筛选掉没有缝合到的短的轮廓线
select_contours_xld (UnionContours, SelectedContours, 'contour_length', 100, 99999, -0.5, 0.5)
count_obj (SelectedContours, Num_All)
Num:=Num_All/2
dev_clear_window ()
dev_display (Image)
set_display_font (WindowHandle, 30, 'mono', 'true', 'false')
write_string (WindowHandle, '检测出'+Num+'个圈圈')