小哥哥小姐姐覺得有用點個贊唄!
HALCON示例程序resistor.hdev通過不同焦距圖像提取深度信息
示例程序源碼(加注釋)
- 關于顯示類函數解釋
Names := []
dev_close_window ()
for i := 1 to 10 by 1
Names := [Names,‘dff/focus_’ + (i$’.2’)]
endfor
read_image (Image, Names) - 將多通道圖像組成一個多通道圖像
channels_to_image (Image, Image)
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, ‘black’, WindowHandle)
for i := 1 to 10 by 1
訪問多通道圖像的指定通道
access_channel (Image, Image1, i)
endfor - depth_from_focus - 使用多個焦點水平提取深度。
- depth_from_focus(多通道圖像:深度信息,深度圖像:方式,提取清晰像素方式:)
depth_from_focus (Image, Depth, Confidence, ‘highpass’, ‘next_maximum’) - 均值濾波
mean_image (Depth, DepthHighConf, 11, 11) - 將像素值擴大到0-255
scale_image_max (DepthHighConf, ImageScaleMax) - 均值濾波
mean_image (ImageScaleMax, DepthMean, 51, 51) - 二值化
threshold (DepthMean, Resistor, 158, 255) - 分割連通域
connection (Resistor, ConnectedRes) - 選取最大面積區域
select_shape_std (ConnectedRes, FinalRes, ‘max_area’, 0) - 二值化
threshold (DepthMean, Solder, 125, 158) - 分割連通域
connection (Solder, ConnectedSol) - 篩選最大面積區域
select_shape_std (ConnectedSol, SelectedSol, ‘max_area’, 0) - 填充孔洞
fill_up (SelectedSol, FinalSol)
dev_set_line_width (3)
dev_set_draw (‘margin’)
dev_display (Image)
dev_set_color (‘red’)
dev_display (FinalSol)
dev_set_color (‘blue’)
dev_display (FinalRes)
處理思路
這個例子是主要講解了通過不同焦距圖像提取深度信息的應用。
后記
大家有什么問題可以向我提問哈,我看到了第一時間回復,希望在學習的路上多多結交良師益友。