halcon-实例:根据颜色提取想要的对象
2022/5/2 6:12:53
本文主要是介绍halcon-实例:根据颜色提取想要的对象,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
实例目的:提取最上面黄色的线
在HDevelop中
dev_close_window () read_image (Image, 'D:/bb/tu/8.png') get_image_size (Image, Width, Height) decompose3 (Image, Red, Green, Blue) *将RGB三通道数据转化为HSV色彩空间的三通道图像数据 *HSV:看https://blog.csdn.net/xiaoyafang123/article/details/113029596 trans_from_rgb (Red, Green, Blue, Hue, Saturation, Intensity, 'hsv') 对HSV图像中的饱和度通道进行阈值操作 threshold (Saturation, HighSaturation, 200, 255) *获取上述阈值操作后区域中的色调通道图像数据 reduce_domain (Hue, HighSaturation, HueHighSaturation) *对上述色调通道图像数据进行阈值处理 threshold (HueHighSaturation, Yellow, 20, 30) *寻找连通域 connection (Yellow, ConnectedRegions) *保留ConnectedRegions里的最大的区域 select_shape_std (ConnectedRegions, SelectedRegions, 'max_area', 0) *对SelectedRegions进行闭运算操作 closing_circle (SelectedRegions, Yellow, 3.5) *将Yellow区域里的图像剪切出来 reduce_domain (Image, Yellow, ImageReduced) dev_open_window(10,10,Width, Height,'black',WindowHandle) dev_display(ImageReduced)
在Qt Creator中
HObject ho_Image, ho_Red, ho_Green, ho_Blue; HObject ho_Hue, ho_Saturation, ho_Intensity, ho_HighSaturation; HObject ho_HueHighSaturation, ho_Yellow, ho_ConnectedRegions; HObject ho_SelectedRegions, ho_ImageReduced; HTuple hv_Width, hv_Height, hv_WindowHandle;
ReadImage(&ho_Image, "D:/bb/tu/8.png"); GetImageSize(ho_Image, &hv_Width, &hv_Height); Decompose3(ho_Image, &ho_Red, &ho_Green, &ho_Blue); //将RGB三通道数据转化为HSV色彩空间的三通道图像数据 //HSV:看https://blog.csdn.net/xiaoyafang123/article/details/113029596 TransFromRgb(ho_Red, ho_Green, ho_Blue, &ho_Hue, &ho_Saturation, &ho_Intensity, "hsv"); //对HSV图像中的饱和度通道进行阈值操作 Threshold(ho_Saturation, &ho_HighSaturation, 200, 255); //获取上述阈值操作后区域中的色调通道图像数据 ReduceDomain(ho_Hue, ho_HighSaturation, &ho_HueHighSaturation); //对上述色调通道图像数据进行阈值处理 Threshold(ho_HueHighSaturation, &ho_Yellow, 20, 30); //寻找连通域 Connection(ho_Yellow, &ho_ConnectedRegions); //保留ConnectedRegions里的最大的区域 SelectShapeStd(ho_ConnectedRegions, &ho_SelectedRegions, "max_area", 0); //对SelectedRegions进行闭运算操作 ClosingCircle(ho_SelectedRegions, &ho_Yellow, 3.5); //将Yellow区域里的图像剪切出来 ReduceDomain(ho_Image, ho_Yellow, &ho_ImageReduced); SetWindowAttr("background_color","black"); OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle); HDevWindowStack::Push(hv_WindowHandle); if (HDevWindowStack::IsOpen()) DispObj(ho_ImageReduced, HDevWindowStack::GetActive());
这篇关于halcon-实例:根据颜色提取想要的对象的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-06-30uniAPP 实现全屏左右滚动滚动的效果-icode9专业技术文章分享
- 2024-06-30如何在本地使用授权或插件-icode9专业技术文章分享
- 2024-06-30伪静态规则配置方法汇总-icode9专业技术文章分享
- 2024-06-29易优CMS安装常见问题汇总-icode9专业技术文章分享
- 2024-06-28易优新手必读安装教程-icode9专业技术文章分享
- 2024-06-28忘记eyoucms后台密码怎么办?-icode9专业技术文章分享
- 2024-06-26终极指南:Scrum中如何设置需求优先级
- 2024-06-26AI大模型企业应用实战(25)-为Langchain Agent添加记忆功能
- 2024-06-26小白家庭 nas 搭建方案-icode9专业技术文章分享
- 2024-06-23AI大模型企业应用实战(14)-langchain的Embedding