orientation_region算子
* clip.hdev: Orientation of clips
*
dev_update_window ('off')
*读取图片
read_image (Clip, 'clip')
*获取图片大小
get_image_size (Clip, Width, Height)
dev_close_window ()
dev_open_window (0, 0, Width / 2, Height / 2, 'black', WindowID)
dev_display (Clip)
set_display_font (WindowID, 14, 'mono', 'true', 'false')
disp_continue_message (WindowID, 'black', 'true')
stop ()
*自动二值化图片,取出暗的部分
binary_threshold (Clip, Dark, 'max_separability', 'dark', UsedThreshold)
*区域连通操作,一整块区域根据连通性分割成小区域数组
connection (Dark, Single)
*获取区域数组中的满足条件的区域,这里是根据区域面积筛选
select_shape (Single, Selected, 'area', 'and', 5000, 10000)
dev_set_draw ('fill')
dev_set_colored (12)
dev_display (Selected)
disp_continue_message (WindowID, 'black', 'true')
stop ()
dev_display (Clip)
dev_set_color ('green')
dev_display (Selected)
*获取每个小区域的方向
orientation_region (Selected, Phi)
*获取每个小区域的中心点
area_center (Selected, Area, Row, Column)
dev_set_line_width (3)
dev_set_draw ('margin')
*箭头长度
Length := 80
dev_set_color ('blue')
*根据区域的方向绘制相应的箭头
disp_arrow (WindowID, Row, Column, Row - Length * sin(Phi), Column + Length * cos(Phi), 4)
disp_message (WindowID, deg(Phi)$'3.1f' + ' deg', 'image', Row, Column - 100, 'black', 'false')
dev_update_window ('on')
=============================================================
主要算子 可以看英文的帮助或者复制到翻译工具翻译
binary_threshold(Image : Region : Method, LightDark : UsedThreshold)
参数:
Image:需要进行阈值的图像
Region:处理后的区域
Method:分割方法('max_separability':最大限度的可分性, 'smooth_histo':直方图平滑)
LightDark:提取的是黑色部分还是白色部分
UsedThreshold:自动阈值使用的阈值值
orientation_region(Regions:::Phi)
功能:
该算子基于算子elliptic_axis,测试区域的方位,包括轮廓中的点(以最大距离到区域重心)。如果该点的列坐标小于重心的列坐标,角度将使用Pi表示。如果多个区域进行计算,输出结果也是一一对应输入区域。
参数列表:
第1个参数Regions是输入对象,被测区域
第2个参数Phi是输出变量,被测区域的方位
浙公网安备 33010602011771号