halcon原理:一维函数function_1d类型【1】
我们知道,元组是一维的,但不是函数。一维函数是用元组专门生成的特殊数据,针对函数,有一组专门的算子进行操作。
一、如何生成
1.1 通过元组产生function_1d函数
- create_funct_1d_array:通过一个一维数组创建一个离散一维函数

- create_funct_1d_pairs:通过一双一维数组创建一个离散一维函数
-

注意点:自变量元组 XValue必须已排序(从小到大)。
1.2 1d函数上逆操作
1)funct_1d_to_pairs获取一维离散函数的x和y值对应元组
funct_1d_to_pairs( flow, XValues1, YValues1)
从输入的函数flow获取两个元组:XValues1, YValues1

2)get_y_value_funct_1d获取一维离散函数的y值(不再详述)
二、1d函数上的一维操作
1)abs_funct_1d 计算一维函数的绝对值
原型:abs_funct_1d( : : Function : FunctionAbsolute)

2)compose_funct_1 将两个离散的一维函数复合成一个函数
这是一个复合函数,比如:
三、综合示例代码
明白以上各种操作,可以看懂下述代码:
* This example program shows how to use compose_funct_1d. It computes
* two functions, atan(x) and cos(x), and composes them, which results in the
* function cos(atan(x)). This function is, of course, identical to 1/sqrt(1+x*x),
* so this function is also calculated. The program displays all four functions.
* By comparing the last two plots, we can check whether compose_funct_1d
* works correctly.
dev_update_off ()
dev_close_window ()
dev_open_window (0, 0, 512, 512, 'white', WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_color ('black')
dev_set_line_width (2)
X := []
for J := -125 to 125 by 1X := [X,J / 40.0]
endfor
stop()
create_funct_1d_pairs (X, cos(X), Cos)
X := []
for J := -100 to 100 by 1X := [X,J / 10.0]
endfor
stop()
create_funct_1d_pairs (X, atan(X), ATan)
create_funct_1d_pairs (X, 1 / sqrt(1 + X * X), InvSqrt1pSqX)
compose_funct_1d (ATan, Cos, 'constant', CosATan)
plot_funct_1d (WindowHandle, ATan, 'x', 'atan(x)', 'red', ['axes_color','origin_x','origin_y'], ['black',0,0])
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
dev_clear_window ()
plot_funct_1d (WindowHandle, Cos, 'x', 'cos(x)', 'red', ['axes_color','origin_x','origin_y'], ['black',0,0])
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
dev_clear_window ()
plot_funct_1d (WindowHandle, CosATan, 'x', 'cos(atan(x))', 'red', ['axes_color','origin_x','origin_y','start_y'], ['black',0,0,0])
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
dev_clear_window ()
plot_funct_1d (WindowHandle, InvSqrt1pSqX, 'x', '1/sqrt(1+x*x)', 'red', ['axes_color','origin_x','origin_y','start_y'], ['black',0,0,0])
*
(未完待续)
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
