1. 程式人生 > >Halcon之計算距離算子

Halcon之計算距離算子

distance_ss distance_lr distance_sr distance_pp distance_pc

*讀取一張圖像 read_image(Image,'Circle.jpg') *畫生成區域 draw_region(Region, 3600) *區域->圖像 reduce_domain(Image, Region, ImageReduced) *閾值分割 threshold(ImageReduced, Region1, 0, 35) *區域連通->將區域分開 connection(Region1, ConnectedRegions) *區域排序 sort_region(ConnectedRegions, SortedRegions, 'first_point', 'true', 'column') *輸出第幾個區域(區域1區域2) select_obj(SortedRegions, ObjectSelected, 1) select_obj(SortedRegions, ObjectSelected1, 2) *區域面積,得到區域面積及中心點坐標 area_center(ObjectSelected,Area, Row, Column) area_center(ObjectSelected1, Area1, Row1, Column1) *區域轉輪廓(gen_region_contour_xld輪廓轉區域) gen_contour_region_xld(ObjectSelected1,Contours, 'border') ***************點到點距離 distance_pp(Row,Column,Row1, Column1, Distance) ***************點到區域距離 distance_pr(ObjectSelected1,Row,Column,DistanceMin, DistanceMax) ***************點到輪廓距離 distance_pc(Contours,Row,Column,DistanceMin1, DistanceMax1) draw_region(Region2, 3600) reduce_domain(Image, Region2, ImageReduced1) *提取亞像素邊緣 edges_sub_pix(ImageReduced1, Edges, 'sobel_fast', 82, 30, 50) count_obj(Edges, Number) *輪廓排序 sort_contours_xld(Edges, SortedContours, 'upper_left', 'true', 'row') *選擇輪廓(直線1直線2) select_obj(SortedContours, ObjectSelected2, 1) select_obj(SortedContours, ObjectSelected3, 2) *輪廓擬合(直線1直線2) fit_line_contour_xld(ObjectSelected2,'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist) fit_line_contour_xld(ObjectSelected3, 'tukey', -1, 0, 5, 2, RowBegin1, ColBegin1, RowEnd1, ColEnd1, Nr1, Nc1, Dist1) *將輸入行存儲為區域 *gen_region_line(RegionLines, RowBegin, ColBegin, RowEnd, ColEnd) *從區域中提取XLD輪廓 *gen_contour_region_xld(RegionLines, Contours1, 'border') *******************點到直線距離 distance_pl(Row,Column,RowBegin,ColBegin,RowEnd,ColEnd,Distance1) *******************線段到線段距離 distance_ss(RowBegin1,ColBegin1,RowEnd1,ColEnd1,RowBegin,ColBegin,RowEnd,ColEnd,DistanceMin2, DistanceMax2) *******************直線到區域距離 distance_lr(ObjectSelected,RowBegin1,ColBegin1,RowEnd1,ColEnd1,DistanceMin3, DistanceMax3) *******************線段到區域距離 distance_sr(ObjectSelected,RowBegin1,ColBegin1,RowEnd1,ColEnd1,DistanceMin4, DistanceMax4)


Halcon之計算距離算子