HALCON示例程序count_pellets.hdev分割豆子,基本形态学的使用
生活随笔
收集整理的這篇文章主要介紹了
HALCON示例程序count_pellets.hdev分割豆子,基本形态学的使用
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
HALCON示例程序count_pellets.hdev分割豆子,基本形態(tài)學(xué)的使用
示例程序源碼(加注釋)
- 關(guān)于顯示類函數(shù)解釋
dev_update_off ()
read_image (Image, ‘pellets’)
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, ‘black’, WindowID)
dev_set_part (0, 0, Height - 1, Width - 1)
set_display_font (WindowID, 16, ‘mono’, ‘true’, ‘false’)
dev_set_colored (6)
dev_set_draw (‘margin’)
dev_set_line_width (3)
dev_display (Image)
disp_message (WindowID, ‘Detect each single pellet’, ‘window’, 12, 12, ‘black’, ‘true’)
disp_continue_message (WindowID, ‘black’, ‘true’)
stop () - 之前介紹binary_threshold 算子的文章
binary_threshold (Image, LightRegion, ‘max_separability’, ‘light’, UsedThreshold) - 使用圓形元素進(jìn)行開(kāi)運(yùn)算
opening_circle (LightRegion, Region, 3.5)
dev_display (Region)
disp_message (WindowID, ‘First, segment the pellets’, ‘window’, 12, 12, ‘black’, ‘true’)
disp_continue_message (WindowID, ‘black’, ‘true’)
stop () - 篩選出直接分割連通域的錯(cuò)誤演示,因?yàn)檫@個(gè)時(shí)候還有豆子黏連在一起。
connection (Region, ConnectedRegionsWrong)
dev_display (Image)
dev_display (ConnectedRegionsWrong)
disp_message (WindowID, ‘Simple connection fails’, ‘window’, 12, 12, ‘black’, ‘true’)
disp_continue_message (WindowID, ‘black’, ‘true’)
stop () - 使用圓形元素進(jìn)行腐蝕運(yùn)算
erosion_circle (Region, RegionErosion, 7.5)
dev_display (Image)
dev_display (RegionErosion)
disp_message (WindowID, ‘Erosion of the pellet regions’, ‘window’, 12, 12, ‘black’, ‘true’)
disp_continue_message (WindowID, ‘black’, ‘true’)
stop () - 現(xiàn)在進(jìn)行連通域分割
connection (RegionErosion, ConnectedRegions)
dev_display (Image)
dev_display (ConnectedRegions)
disp_message (WindowID, ‘Perform connection now’, ‘window’, 12, 12, ‘black’, ‘true’)
disp_continue_message (WindowID, ‘black’, ‘true’)
stop () - 恢復(fù)豆子原本區(qū)域,使用圓形元素進(jìn)行膨脹。
dilation_circle (ConnectedRegions, RegionDilation, 7.5) - 對(duì)區(qū)域進(jìn)行計(jì)數(shù)
count_obj (RegionDilation, Number)
dev_display (Image)
dev_display (RegionDilation)
disp_message (WindowID, Number + ’ pellets detected’, ‘window’, 12, 12, ‘black’, ‘true’)
處理思路
這個(gè)例子是主要講解了形態(tài)學(xué)在分割連通域當(dāng)中的應(yīng)用。dilation_circle 、erosion_circle 、opening_circle 。
后記
大家有什么問(wèn)題可以向我提問(wèn)哈,我看到了第一時(shí)間回復(fù),希望在學(xué)習(xí)的路上多多結(jié)交良師益友。
總結(jié)
以上是生活随笔為你收集整理的HALCON示例程序count_pellets.hdev分割豆子,基本形态学的使用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 特征衍生实战
- 下一篇: 年终将至,财务人如何做好数据分析?