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());
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
2019-05-02 python-类对象的遍历操作