Halcon轮廓
halcon吧
全部回复
仅看楼主
level 1
如图,这个可以实现吗?求大神
2016年04月20日 09点04分 1
level 1
???
2016年04月21日 01点04分 2
level 4
这个应该可以,重点是想办法把感兴趣的区域封闭起来
2016年06月04日 02点06分 3
level 2
参考解答
dev_update_window ('off')
dev_close_window ()
read_image (ColorImage, 'D:/Tooth/test.png')
get_image_size(ColorImage,width,height)
decompose3 (ColorImage, Image, Image2, Image3)
factor := 1
dev_open_window (0, 0, width/factor, height/factor, 'gray', hWindow)
dev_set_part (0, 0, height, width)
dev_display (Image)
stop()
* draw_point (hWindow, row1, col1)
row1 := 67
col1 := 53
gen_region_line (RegionLine1, row1, col1, row1, 0)
* draw_point (hWindow, row2, col2)
row2 := 56
col2 := 285
gen_region_line (RegionLine2, row2, col2, row2, width-1)
threshold(Image,RegionContour,0,0)
gen_rectangle1(RegionFrame,0,0,height-1,width-1)
union2(RegionLine1,RegionContour,RegionUnion)
union2(RegionUnion,RegionLine2,RegionUnion)
difference(RegionFrame,RegionUnion,RegionDiff)
connection(RegionDiff,ConnRegion)
select_obj(ConnRegion,LowerPart, 2)
shape_trans (LowerPart, LowerConvex1, 'convex')
difference(LowerConvex1,LowerPart,RegionDiff1)
shape_trans (RegionDiff1, LowerConvex2, 'convex')
difference(LowerConvex2,RegionDiff1,RegionDiff2)
connection(RegionDiff2,ConnRegion)
smallest_rectangle1 (ConnRegion, row1, col1, row2, col2)
leftCol := min(col1)
rightCol := max(col2)
select_shape (ConnRegion, LeftRegion, 'column1', 'and', leftCol-1, leftCol+1)
select_shape (ConnRegion, RightRegion, 'column2', 'and', rightCol-1, rightCol+1)
difference(RegionDiff2,LeftRegion,RegionDiff3)
difference(RegionDiff3,RightRegion,RegionDiff3)
connection(RegionDiff3,ConnRegion)
area_center(ConnRegion,area,_row,_col)
maxArea := max(area)
select_shape (ConnRegion, ResultRegion, 'area', 'and', maxArea, maxArea+1)
dev_set_draw('margin')
dev_set_line_width(3)
dev_display (ResultRegion)
disp_message (hWindow, 'Area='+maxArea, 'image', 10, 10, 'black', 'true')
原图
结果
2016年06月12日 13点06分 4
1