HALCON示例程序forest.hdev识别森林中的树
生活随笔
收集整理的這篇文章主要介紹了
HALCON示例程序forest.hdev识别森林中的树
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
HALCON示例程序forest.hdev識(shí)別森林中的樹(shù)
示例程序源碼(加注釋)
- 關(guān)于顯示類(lèi)函數(shù)解釋
dev_close_window ()
dev_update_window (‘off’)
read_image (Forest, ‘forest_air1’)
get_image_size (Forest, Width, Height)
dev_open_window (0, 0, Width, Height, ‘black’, WindowHandle)
decompose3 (Forest, Red, Green, Blue)
dev_display (Red) - 二值化
threshold (Blue, BlueBright, 80, 255) - 分割連通域
connection (BlueBright, BlueBrightConnection) - 通過(guò)面積進(jìn)行區(qū)域篩選
select_shape (BlueBrightConnection, Path, ‘a(chǎn)rea’, ‘a(chǎn)nd’, 100, 100000000)
dev_set_color (‘red’)
dev_set_draw (‘margin’)
dev_display (Path)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop () - 二值化紅色通道圖像
threshold (Red, RedBright, 120, 255) - 分割連通域
connection (RedBright, RedBrightConnection) - 使用面積進(jìn)行區(qū)域篩選
select_shape (RedBrightConnection, RedBrightBig, ‘a(chǎn)rea’, ‘a(chǎn)nd’, 1500, 10000000) - 使用圓形元素進(jìn)行閉運(yùn)算
closing_circle (RedBrightBig, RedBrightClosing, 7.5) - 使用圓形元素進(jìn)行開(kāi)運(yùn)算
opening_circle (RedBrightClosing, RedBrightOpening, 9.5) - 分割連通域
connection (RedBrightOpening, RedBrightOpeningConnection) - 使用面積進(jìn)行區(qū)域篩選
select_shape (RedBrightOpeningConnection, BeechBig, ‘a(chǎn)rea’, ‘a(chǎn)nd’, 1000, 100000000) - 使用區(qū)域的平均灰度進(jìn)行區(qū)域篩選
select_gray (BeechBig, Blue, Beech, ‘mean’, ‘a(chǎn)nd’, 0, 59)
dev_display (Red)
dev_display (Beech)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop () - 聯(lián)合區(qū)域
union1 (Beech, BeechUnion) - 返回區(qū)域的補(bǔ)集
complement (BeechUnion, NotBeech) - 求取兩區(qū)域不相交部分
difference (NotBeech, Path, NotBeechNotPath) - 縮小定義域
reduce_domain (Red, NotBeechNotPath, NotBeechNotPathRed) - 二值化
threshold (NotBeechNotPathRed, BrightRest, 150, 255) - 分割連通域
connection (BrightRest, BrightRestConnection) - 通過(guò)面積篩選區(qū)域
select_shape (BrightRestConnection, Meadow, ‘a(chǎn)rea’, ‘a(chǎn)nd’, 500, 1000000)
dev_display (Red)
dev_display (Meadow)
disp_continue_message (WindowHandle, ‘black’, ‘true’)
stop () - 將兩個(gè)對(duì)象合為一個(gè)對(duì)象
union2 (Path, RedBrightClosing, BeechPath) - smooth_image - 使用各種濾鏡平滑圖像。
- smooth_image(原圖:平滑后的圖像:濾波器,濾波參數(shù):)
smooth_image (Red, RedGauss, ‘gauss’, 4.0) - invert_image - 反轉(zhuǎn)圖像。
invert_image (RedGauss, Invert) - watersheds - 從圖像中提取流域和盆地。
- watersheds (圖片:盆地,流域::)
watersheds (Invert, SpruceRed, Watersheds) - 通過(guò)面積與灰度進(jìn)行區(qū)域篩選
select_shape (SpruceRed, SpruceRedLarge, ‘a(chǎn)rea’, ‘a(chǎn)nd’, 100, 5000)
select_gray (SpruceRedLarge, Red, SpruceRedInitial, ‘max’, ‘a(chǎn)nd’, 100, 200) - 生成一個(gè)空對(duì)象
gen_empty_obj (LocalThresh) - 計(jì)算對(duì)象數(shù)量
count_obj (SpruceRedInitial, NumSpruce)
dev_update_var (‘off’)
dev_update_pc (‘off’)
for i := 1 to NumSpruce by 1- 在組員對(duì)象中選取指定對(duì)象
select_obj (SpruceRedInitial, SingleSpruce, i) - 求取最大最小灰度值,當(dāng)?shù)谌齻€(gè)參數(shù)設(shè)置為50時(shí)返回中值
min_max_gray (SingleSpruce, Red, 50, Min, Max, Range) - 減少定義域
reduce_domain (Red, SingleSpruce, SingleSpruceRed) - 二值化
threshold (SingleSpruceRed, SingleSpruceBright, Min, 255) - 分割連通域
connection (SingleSpruceBright, SingleSpruceBrightCon) - 選取最大面積的區(qū)域
select_shape_std (SingleSpruceBrightCon, MaxAreaSpruce, ‘max_area’, 70) - 將多個(gè)區(qū)域合并到一個(gè)組員下,但不改變對(duì)象個(gè)數(shù)
concat_obj (MaxAreaSpruce, LocalThresh, LocalThresh)
- 在組員對(duì)象中選取指定對(duì)象
endfor
- 開(kāi)運(yùn)算
opening_circle (LocalThresh, FinalSpruce, 1.5)
dev_set_line_width (2)
dev_set_color (‘red’)
dev_display (Red)
dev_display (FinalSpruce)
dev_set_color (‘green’)
dev_display (Beech)
dev_set_color (‘yellow’)
dev_display (Meadow)
處理思路
這個(gè)例子是主要講解了如何通過(guò)無(wú)人機(jī)拍攝的圖像識(shí)別其中的對(duì)象。smooth_image 、watersheds 等算子被應(yīng)用。
后記
大家有什么問(wèn)題可以向我提問(wèn)哈,我看到了第一時(shí)間回復(fù),希望在學(xué)習(xí)的路上多多結(jié)交良師益友。
總結(jié)
以上是生活随笔為你收集整理的HALCON示例程序forest.hdev识别森林中的树的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php运行出现Call to undef
- 下一篇: BZOJ2302 [HAOI2011]P