Halcon之hough變換檢測直線

 今天開始因爲項目需要學習halcon軟件下面是一段利用halcon做直線檢測的代碼:

read_image (Image, 'fabrik') 
*讀取圖像
rectangle1_domain (Image, ImageReduced, 230, 180, 330, 280)
*在Image的圖像定義一個座標爲(230,180,330,280)的有效區域
* Detect edges (amplitude) using the Sobel operator
sobel_amp (ImageReduced, EdgeAmplitude, 'thin_sum_abs', 3)
**利用sobel算法在有效的圖像區域內提取邊緣
dev_set_color ('red')
*設置顯示顏色爲紅色
threshold (EdgeAmplitude, Region, 10, 255)
*對提取邊緣後的圖像進行二值化分割圖像,圖像的閾值範圍10<pixel<255;
hough_lines (Region, 4, 50, 5, 5, Angle, Dist)
*對於二值化的圖像提取直線
dev_set_color ('blue')
*設置顯示的顏色爲藍色
* Store input lines described in HNF
gen_region_hline (Regions, Angle, Dist)
*保存並畫出保存的直線


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章