halcon中将xld轮廓或者region区域绘制在图像上并保存

0、引言

首先是小白现在没有找到xld轮廓直接绘制在图像上面的方法
对于xld轮廓通过转化为region区域之后再绘制在图像上(与直接显示在图像窗口句柄上面的轮廓有一定区别)
-补发——————时隔多日找到新的方法利用:dump_window_image可以将亚像素轮廓绘制在图片上面
如下为:匹配模板获得的xld轮廓绘制在图片上
在这里插入图片描述

1、相关算子

①get_contour_xld(Contour : : : Row, Col)
获得轮廓线的坐标
参数一(Contour ):输入轮廓
参数二(Row) :输出像素值横坐标
参数三(Col) :输出 像素值纵坐标

②gen_region_polygon( : Region : Rows, Columns : )
根据像素点生成区域
参数一(Region ):输出轮廓
参数二(Rows) :输入像素值横坐标
参数三(Columns ) :输入像素值纵坐标

③paint_region(Region, Image : ImageResult : Grayval, Type : )
将region绘制在图像上
参数一(Region ):输入轮廓
参数二(Image ) :输入图像
参数三(ImageResult ) :输出图像(区域绘制在图像)
参数四(Grayval) :设置输入灰度值
参数五(Type ) :设置输入填充方式

2、xld转region

/ContCircle输入的圆轮廓   Region为转化的区域/
get_contour_xld (ContCircle, Row1, Col)
gen_region_polygon (Region, Row1, Col)

xld与region对比如下
在这里插入图片描述

3、region绘制在图像上

1)单通道图像的绘制

单通道图像需要通过compose合成为彩色图像
如果将生成的绿色**[0,255,0]**轮廓绘制在单通道图像上面,如下

draw_circle (WindowHandle, Row, Column, Radius)
gen_circle (Circle, Row, Column, Radius)
paint_region (Circle, Image, ImageR, 0, 'fill')
paint_region (Circle, Image, ImageG, 255, 'fill')
paint_region (Circle, Image, ImageB, 0, 'fill')
compose3 (ImageR, ImageG, ImageB, MultiChannelImage)
*保存图像
write_image (MultiChannelImage1,'bmp' , 0, 'C:/Users/世纪森林/Desktop/picture/region转图像.bmp')

保存之后的图像如下
在这里插入图片描述

2)多通道图像的绘制

draw_circle (WindowHandle, Row, Column, Radius)
gen_circle (Circle, Row, Column, Radius)
paint_region (Circle, MultiChannelImage1, ImageResult, [0,255,0], 'fill')

3、xld绘制在图像上

*ContCircle为输入圆轮廓
gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, 6.28318, 'positive', 1)
*xld转region区域
get_contour_xld (ContCircle, Row1, Col)
gen_region_polygon (Region, Row1, Col)
*region绘制在图像
paint_region (Region, Image, ImageR, 0, 'fill')
paint_region (Region, Image, ImageG, 255, 'fill')
paint_region (Region, Image, ImageB, 0, 'fill')
compose3 (ImageR, ImageG, ImageB, MultiChannelImage1)
write_image (MultiChannelImage1,'bmp' , 0, 'C:/Users/世纪森林/Desktop/picture/xld转图像.bmp')

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值