Halcon 学习笔记八:颜色识别

您所在的位置:网站首页 颜色识别训练更新成什么了 Halcon 学习笔记八:颜色识别

Halcon 学习笔记八:颜色识别

2024-07-12 17:48| 来源: 网络整理| 查看: 265

Halcon 学习笔记八:颜色识别 一、图像处理需要的知识二、图像处理的预处理和分割过程二、颜色识别的方法三、例子一四、例子二五、例子三

一、图像处理需要的知识

1.图像处理基础(rgb(hsv),gray) 2.图像灰度变换(scale_img) 3.图像基础(emphasize) 4.图像几何变换(仿射变换,极坐标变换) 5.图像分割(blob分析、边缘检测、reduce_domain) 6.图像的频域(fft_img) 7.图像形态学 8.图像复原 9.运动图像 10.图像配准(模板匹配)

二、图像处理的预处理和分割过程

在这里插入图片描述 在这里插入图片描述

二、颜色识别的方法

颜色识别的方法 1.RGB->HSV (缺点:受光照影响严重) 重点分析H分量和S分量 2.分类器识别颜色

三、例子一

打开颜色识别的例子 在这里插入图片描述 通过对RGB转成HSV,然后因为要选出黄色,从而去限制色度和饱和度的范围,因此可以用thresh去限制饱和度和色度的范围。最后通过blob分析,获得指定颜色的物体。 完整代码

* color_simple.hdev: segment yellow cable in HSV color space dev_close_window () dev_open_window (0, 0, 640, 480, 'black', WindowHandle) for i := 1 to 2 by 1 * 读取图片 read_image (Image, 'cable' + i) * 将RGB图根据通道拆分成三张图 decompose3 (Image, Red, Green, Blue) * 将RGB转为HSV trans_from_rgb (Red, Green, Blue, Hue, Saturation, Intensity, 'hsv') * 对饱和度阈值处理(限制饱和度范围) threshold (Saturation, HighSaturation, 100, 255) reduce_domain (Hue, HighSaturation, HueHighSaturation) * 对色度阈值处理(限制色度范围) threshold (HueHighSaturation, Yellow, 20, 50) * 计算连通域 connection (Yellow, ConnectedRegions) * 选择形状(特征) select_shape_std (ConnectedRegions, SelectedRegions, 'max_area', 0) * 开操作 closing_circle (SelectedRegions, Yellow, 3.5) * 获得目标 reduce_domain (Image, Yellow, ImageReduced) dev_display (HueHighSaturation) dev_display (ImageReduced) stop () endfor 四、例子二

在这里插入图片描述 这个例子,和例子一 同样的方式,只不过这个对 好几个颜色物体进行了检测,并且输出message 完整代码

* color_fuses.hdev: classify fuses by color dev_update_window ('off') * **** * step: set up fuse properties and hue ranges * **** FuseColors := ['Orange','Red','Blue','Yellow','Green'] FuseTypes := [5,10,15,20,30] * HueRanges: Orange 10-30, Red 0-10... HueRanges := [10,30,0,10,125,162,30,64,96,128] Count := 0 dev_close_window () dev_open_window (0, 0, 800, 600, 'black', WH) while (Count


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3