边缘提取三-亚像素边缘提取实例
1 *一个矩形的轮廓 2 read_image (Pcb, 'E:/学习/Halcon/玩套路之边缘检测/玩套路之边缘检测/PCB/PCB.png') 3 rgb1_to_gray(Pcb, GrayImage) 4 5 *获取ROI 6 dev_set_draw('margin') 7 gen_rectangle1 (ROI_0, 4.475, 290.023, 153.725, 386.392) 8 reduce_domain(GrayImage, ROI_0, ImageReduced) 9 10 threshold (ImageReduced, Regions, 75, 255) 11 12 erosion_circle(Regions, RegionErosion, 3.5) 13 difference(Regions, RegionErosion, RegionDifference) 14 15 reduce_domain(ImageReduced, RegionDifference, ImageReduced1) 16 edges_sub_pix(ImageReduced1, Edges, 'canny', 1, 20, 40) 17 18 segment_contours_xld(Edges, ContoursSplit, 'lines_circles', 5, 4, 2) 19 count_obj(ContoursSplit, Number) 20 length_xld(ContoursSplit, Length) 21 22 dev_display(GrayImage) 23 *Row:=[] 24 *Column:=[] 25 for I:=1 to Number by 1 26 select_obj(ContoursSplit, ObjectSelected, I) 27 dev_set_color('red') 28 dev_display(ObjectSelected) 29 dev_set_color('coral') 30 31 if(Length[I-1]>40) 32 dev_display(ObjectSelected) 33 fit_line_contour_xld(ObjectSelected, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist) 34 dev_set_color('green') 35 disp_line(3600, RowBegin, ColBegin, RowEnd, ColEnd) 36 37 endif 38 endfor