小哥哥小姐姐觉得有用点个赞呗!
HALCON示例程序stamp_catalogue.hdev分割图片与文字
示例程序源码(加注释)
- 关于显示类函数解释
gen_rectangle1 (Rect, 0, 0, 5, 5)
dev_update_var (‘off’)
dev_update_window (‘off’)
dev_close_window ()
read_image (Image, ‘stamps/swiss1’)
get_image_size (Image, Width, Height)
dev_open_window (0, 0, round(Width / 1.5), round(Height / 1.5), ‘black’, WindowID)
set_display_font (WindowID, 14, ‘mono’, ‘true’, ‘false’)
for i := 1 to 9 by 1read_image (Image, 'stamps/swiss' + i)get_image_size (Image, Width, Height)dev_set_part (0, 0, Height - 1, Width - 1)dev_display (Image)dev_set_draw ('fill')* 二值化threshold (Image, Dark, 0, 110)fill_up (Dark, DarkFilled)connection (DarkFilled, ConnectedRegions)* 面积筛选区域select_shape (ConnectedRegions, PotStamps, 'area', 'and', 10000, 100000000)* 开运算opening_rectangle1 (PotStamps, Stamps, 10, 10)select_shape (ConnectedRegions, Lines, 'convexity', 'and', 0, 0.3)select_shape (ConnectedRegions, Character, 'area', 'and', 10, 500)* 使用大礼帽算法top_hat (Lines, Rect, RegionTopHat)connection (RegionTopHat, ConnTopHat)select_shape (ConnTopHat, AllLines, 'area', 'and', 150, 1000000)union1 (Character, CharacterUnion)dilation_rectangle1 (CharacterUnion, Words, 8, 2)connection (Words, SingleWords)shape_trans (SingleWords, RectWords, 'rectangle1')dev_set_draw ('margin')dev_display (Image)dev_set_color ('red')dev_display (AllLines)dev_set_color ('green')dev_display (Stamps)dev_set_color ('yellow')dev_display (Character)dev_set_color ('blue')dev_display (RectWords)if (i < 9)disp_continue_message (WindowID, 'black', 'true')endifstop ()
endfor
dev_display (Image)
处理思路
这个例子是主要讲解了blob用于区域分割。
后记
大家有什么问题可以向我提问哈,我看到了第一时间回复,希望在学习的路上多多结交良师益友。