Halcon 边缘提取

 

 

原型
gen_measure_rectangle2( : : Row, Column, Phi, Length1, Length2, Width, Height, Interpolation : MeasureHandle)

功能
准备提取垂直于轮廓线的直边

参数列表
Row (input_control):矩形中心点的行坐标
Column (input_control):矩形中心点的列坐标
Phi (input_control):轮廓线与水平方向的夹角(弧度制)
Length1 (input_control):矩形长轴的一半
Length2 (input_control):矩形短轴的一半
Width (input_control) :待处理图像的宽度
Height (input_control) :待处理图像的高度
Interpolation (input_control) :插值方式(‘bicubic’, ‘bilinear’, ‘nearest_neighbor’)
MeasureHandle (output_control) :测量对象句柄

gen_measure_rectangle2准备提取垂直于矩形长轴的直边。 矩形的中心在(Row,Column),Phi为矩形主轴的角度,Lenth1和Lenth2为两轴的长度,即矩形两边长度的一半。

  在算子measure_pos的文档中描述了边缘提取算法。 如上所述,可以使用不同类型的插值来计算一维灰度值分布。 对于Interpolation = 'nearest_neighbor',测量中的灰度值是从最接近的像素的灰度值,即通过常数插值获得的。 对于Interpolation = 'bilinear',使用双线性插值,而对于Interpolation = 'bicubic',则使用双三次插值。

  要在实际测量中以最佳速度运行,所有可用于多次测量的计算都已在算子gen_measure_rectangle2中执行。 为此,在MeasureHandle中构造并返回一个优化的数据结构,即所谓的measure对象。 要在其中执行测量的图像的大小必须在参数'Width'和'Height'中指定。

  系统参数“int_zooming”(见set_system)会影响用于构建measure对象的计算的准确性和速度。 如果'int_zooming'设置为'true',则内部计算使用定点算术执行,导致执行时间缩短。 但是,这种模式下的几何精度略低。 如果将“int_zooming”设置为“false”,则使用浮点运算执行内部计算,从而导致最大的几何精度,但也会显著增加执行时间。

measure_pos
原型
measure_pos(Image : : MeasureHandle, Sigma, Threshold, Transition, Select : RowEdge, ColumnEdge, Amplitude, Distance)

功能
提取垂直于矩形或者环形弧的直边。

参数列表
Image (input_object) :输入图像
MeasureHandle (input_control) :测量对象句柄
Sigma (input_control) :高斯滤波参数
Threshold (input_control) :边缘强度控制阈值
Transition (input_control) :边界从白到黑还是从黑到白(分别对应’negative’, ‘positive’,也可以选择‘all’)
Select (input_control) :选择寻点的模式( 'all’输出所有点, 'first’输出第一个点, 'last’输出最后一个点)
RowEdge (output_control) :寻到直边的中心点行坐标
ColumnEdge (output_control) :寻到直边的中心点列坐标
Amplitude (output_control) :寻到直边的边缘强度值
Distance (output_control) :连续边之间的距离
 

read_image (Color, 'C:/Users/ADMIN/Desktop/color.png')
dev_close_window ()
get_image_size (Color, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
decompose3 (Color, red, green, blue)

disp_image (Color, WindowHandle)
row:=280
col:=434
len1:=80
len2:=5
* gen_rectangle2 (Rectangle, row, col, rad(90), len1, len2)
gen_measure_rectangle2 (row, col, rad(90), len1, len2, Width, Height, 'bilinear', MeasureHandle)

measure_pos (blue, MeasureHandle, 1, 30, 'all', 'all', RowEdge, ColumnEdge, Amplitude, Distance)
disp_cross (WindowHandle, RowEdge, ColumnEdge, 6, 0)
dev_set_draw ('margin')
gen_empty_region (EmptyRegion)
for i:=0 to |RowEdge|-2 by 2
    gen_rectangle1 (Rectangle1, RowEdge[i+1], ColumnEdge[i+1], RowEdge[i], ColumnEdge[i]+5)
    union2 (Rectangle1, EmptyRegion, EmptyRegion)
endfor
reduce_domain (Color, EmptyRegion, ImageReduced)
dev_clear_window ()
dev_display (ImageReduced)

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值