HALCON示例程序color_simple.hdev在HSV空間篩選黃色線
示例程序源碼(加注釋)
- 關于顯示類函數解釋
dev_close_window ()
dev_open_window (0, 0, 640, 480, ‘black’, WindowHandle)
for i := 1 to 2 by 1
read_image (Image, ‘cable’ + i)- 將彩色圖片從RGB顏色空間轉換到HSV空間
decompose3 (Image, Red, Green, Blue)
trans_from_rgb (Red, Green, Blue, Hue, Saturation, Intensity, ‘hsv’)
threshold (Saturation, HighSaturation, 100, 255) - 縮小定義域
reduce_domain (Hue, HighSaturation, HueHighSaturation) - 在H空間內進行二值化操作
threshold (HueHighSaturation, Yellow, 20, 50) - 分割連通域
connection (Yellow, ConnectedRegions) - 篩選面積最大區域
select_shape_std (ConnectedRegions, SelectedRegions, ‘max_area’, 0) - 使用圓形元進行閉運算
closing_circle (SelectedRegions, Yellow, 3.5) - 縮小定義域
reduce_domain (Image, Yellow, ImageReduced)
dev_display (HueHighSaturation)
dev_display (ImageReduced)
stop ()
endfor
- 將彩色圖片從RGB顏色空間轉換到HSV空間
處理思路
這個例子是將三通道的RGB圖像轉化到HSV空間進行分割的例子。
后記
大家有什么問題可以向我提問哈,我看到了第一時間回復,希望在學習的路上多多結交良師益友。