halcon-edge_segments.hdev

* edge_segments.hdev: extracting connected edges segments
* 
dev_update_off ()
dev_close_window ()
* ****
* step: acquire image
* ****
read_image (Image, 'mreut')
get_image_size (Image, Width, Height)
dev_open_window_fit_image (Image, 0, 0, Width, Height, WindowID)
set_display_font (WindowID, 12, 'Courier', 'true', 'false')
dev_set_draw ('margin')
dev_set_line_width (3)
dev_display (Image)
disp_continue_message (WindowID, 'black', 'true')
stop ()
* ****
* step: filter image
* ****
edges_image (Image, ImaAmp, ImaDir, 'lanser2', 0.5, 'nms', 20, 40)
dev_display (ImaAmp)
disp_continue_message (WindowID, 'black', 'true')
stop ()
* ****
* step: extract edges
* ****
threshold (ImaAmp, Region, 1, 255)

skeleton(Region,aRegion)
connection (Region, ConnectedRegions)
dev_clear_window ()
dev_set_colored (12)
dev_display (ConnectedRegions)
disp_continue_message (WindowID, 'black', 'true')
stop ()
* ****
* step: process edges
* ****
dev_clear_window ()
count_obj (ConnectedRegions, Number)
num := |ConnectedRegions|

gen_empty_obj (XLDContours)
for i := 1 to Number by 1
    select_obj (ConnectedRegions, SingleEdgeObject, i)
    split_skeleton_lines (SingleEdgeObject, 2, BeginRow, BeginCol, EndRow, EndCol)
    for k := 0 to |BeginRow|-1 by 1
        gen_contour_polygon_xld (Contour, [BeginRow[k],EndRow[k]], [BeginCol[k],EndCol[k]])
        concat_obj (XLDContours, Contour, XLDContours)
    endfor
endfor
dev_display (XLDContours)


posted on 2012-09-12 23:33  _song  阅读(565)  评论(0编辑  收藏  举报