小哥哥小姐姐覺得有用點個贊唄!
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用于區域分割。
后記
大家有什么問題可以向我提問哈,我看到了第一時間回復,希望在學習的路上多多結交良師益友。