處理流程:快速二值化(區域)->獲取區域邊緣->截取邊緣->膨脹邊緣區域(定位)->定位區域進行邊緣檢測->邊緣分割:線和圓->選擇屬性爲圓的弧->擬合圓app
*讀取圖像 read_image (Image, 'double_circle') dev_close_window () get_image_size (Image, Width, Height) dev_open_window (0, 0, Width, Height, 'black', WindowHandle) *快速二值化 fast_threshold (Image, Region, 0, 120, 7) *取region的邊界 boundary (Region, RegionBorder, 'inner') *剪切、膨脹定位弧形區域 clip_region_rel (RegionBorder, RegionClipped, 5, 5, 5, 5) dilation_circle (RegionClipped, RegionDilation, 2.5) reduce_domain (Image, RegionDilation, ImageReduced) *在弧形區域進行邊緣檢測 edges_sub_pix (ImageReduced, Edges, 'lanser2', 0.5, 40, 60) *分割邊緣:線和圓 segment_contours_xld (Edges, ContoursSplit, 'lines_circles', 5, 4, 3) count_obj (ContoursSplit, Number) dev_display (Image) dev_set_draw ('margin') dev_set_color ('white') dev_update_window ('off') for i := 1 to Number by 1 *選擇輪廓並根據特性肯定是否擬合圓:* Attrib = -1 線段 0 橢圓 1圓 select_obj (ContoursSplit, ObjectSelected, i) get_contour_global_attrib_xld (ObjectSelected, 'cont_approx', Attrib) if (Attrib > 0) *逼近結果生成一個圓輪廓 fit_circle_contour_xld (ObjectSelected, 'ahuber', -1, 2, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder) gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, rad(360), 'positive', 1.0) dev_display (ContCircle) endif endfor dev_set_colored (12) dev_set_line_width (3) dev_display (ContoursSplit)