read_image(Image, 'D:/图片/视觉检测图片/233.jpg')
get_image_size(Image, Width, Height)
dev_close_window()
dev_open_window(0, 0, Width/2, Height/2, 'black', WindowHandle)
dev_display(Image)
binary_threshold(Image, Region, 'max_separability', 'light', UsedThreshold)
connection(Region, ConnectedRegions)
select_shape(ConnectedRegions, SelectedRegions, 'area', 'and', 5000, 99999999)
count_obj(SelectedRegions, Number)
if(Number # 1)
stop()
endif
fill_up(SelectedRegions, RegionFillUp)
boundary(RegionFillUp, RegionBorder, 'inner')
dilation_circle(RegionBorder, RegionDilation, 7.5)
reduce_domain(Image, RegionDilation, ImageReduced)
*10使得线变得光滑,减少断层
edges_sub_pix(ImageReduced, Edges, 'canny', 10, 20, 40)
*使得曲线变得光滑
smooth_contours_xld(Edges, SmoothedContours, 125)
*选择轮廓长度
select_contours_xld(SmoothedContours, SelectedContours, 'contour_length', 200, 2000, -0.5, 0.5)
shape_trans_xld(SelectedContours, XLDTrans, 'convex')
shape_trans_xld(XLDTrans, XLDTrans1, 'rectangle2')
draw_rectangle1(WindowHandle, Row1, Column1, Row2, Column2)
gen_rectangle1(Edges, Row1, Column1, Row2, Column2)
*剪切出线
clip_contours_xld(SelectedContours, ClippedContours, Row1, Column1, Row2, Column2)
*平滑轮廓:smooth_contours_xld(inspect_frame_width.hdev)
*形状变换:shape_trans_xld
*封闭轮廓:close_contours_xld
*对轮廓排序:sort_contours_xld
*修剪出矩形区域的轮廓:clip_contours_xld
*修剪轮廓两端:clip_end_points_contours_xld
*
*
*
*