15-Halcon机器视觉实例入门:数学运算-三角函数运算

图像数学运算-三角函数运算

1 正弦计算与反正弦计算

sin_image计算图像的正弦值,如果图像类型是direction或cylic类型,则sin_image将图像灰度值转换为角度值;如果图像类型是real类型,则sin_image则认为图像灰度值为角度值。sin_image的原型如下:

  • sin_image(Image : SinImage : : )

其中,参数Image为输入图像,SinImage为输出图像;

asin_image计算图像的反正弦值。其原型如下:

  • asin_image(Image : ArcsinImage : : )

其中,参数Image为输入图像;ArcsinImage为输出图像;

2 余弦计算与反余弦计算

cos_image计算图像的余弦值,其原型如下:

  • cos_image(Image : CosImage : : )

其中,参数Image为输入图像;CosImage为输出图像;

acos_image计算图像的反余弦值,其原型如下:

  • acos_image(Image : ArccosImage : : )

其中,参数Image为输入图像;ArccosImage为输出图像

* 图像三角函数计算

* 读取图像
read_image(src,'fabrik')


* 缩放图像像素灰度值
get_image_size(src,width,height)
* 生成图像大小的矩形
gen_rectangle1(rectangle,0,0,width,height)
* 获取图像像素灰度值的最大和最小值
min_max_gray(rectangle,src,0,gmin,gmax,range)
* gmax := 179
* gmin := 0
mult := 255 / (gmax - gmin)
add := -mult * gmin
* 图像像素灰度值缩放
scale_image(src,src_scaled,mult,add)
* 转换direction类型
convert_image_type(src_scaled,src_direction,'direction')

sin_image(src_direction,result_direction)

* 使用cyclic类型计算
convert_image_type(src_scaled,src_cyclic,'cyclic')
* 对图像进行正弦计算
sin_image(src_cyclic,result_cyclic)

* 反正弦函数
asin_image(result_direction,result_asin_direction)

* 转换图像类型
convert_image_type(result_asin_direction,result_byte,'byte')
scale_image(result_byte,result_scaled,255,0)

* 反正弦函数
acos_image(result_direction,result_acos_direction)

* 转换图像类型
convert_image_type(result_acos_direction,result_byte,'byte')
scale_image(result_byte,result_scaled,255,0)

3 正切与反正切计算

tan_image计算图像的正切值,其原型如下:

  • tan_image(Image : TanImage : : )

其中,Image为输入图像;TanImage为输出图像

atan_image计算图像反正切值,其原型如下:

  • atan_image(Image : ArctanImage : : )

其中,Image为输入图像;ArctanImage为输出图像

* 图像像素灰度值缩放

convert_image_type(src_scaled,src_direction,'direction')
tan_image(src_direction,result_direction)

* 使用cyclic类型计算
convert_image_type(src_scaled,src_cyclic,'cyclic')
* 对图像进行正弦计算
tan_image(src_cyclic,result_cyclic)

* 反正弦函数
atan_image(result_direction,result_atan_direction)

* 转换图像类型
convert_image_type(result_atan_direction,result_byte,'byte')
scale_image(result_byte,result_scaled,255,0)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

视觉&物联智能

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值