功能:霍夫变换检测直线。实际是先检测边缘,再用hough拟合直线
THIK:Sobel检测边缘的精度似乎比edge_sub_mix检测边缘低,霍夫变换比普通的直线拟合有优势吗?使用sobel_dir和hough_lines_dir还可以检测直线的方向。

1
2
3
4
5
6
7
8
9
10
11
12
* 读取图像,设置ROI
read_image (Image, 'fabrik')
rectangle1_domain (Image, ImageReduced, 230, 180, 330, 280)
* 使用Sobel算子检测边缘
sobel_amp (ImageReduced, EdgeAmplitude, 'thin_sum_abs', 3)
dev_set_color ('red')
threshold (EdgeAmplitude, Region, 10, 255)
* 霍夫变换,将从Region中检测到的边缘线转化为霍夫空间的直线表示
hough_lines (Region, 4, 50, 5, 5, Angle, Dist)

dev_set_color ('blue')
gen_region_hline (Regions, Angle, Dist)