基于颜色空间的颜色检测(根据HSV空间中的色度图像来识别不同颜色,因为不同颜色有不同的色度范围)
一、halcon例程1:应用范围—>颜色识别—>segment color image 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)
decompose3 (Image, Red, Green, Blue)
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)
*根据形状选择,‘max_area’为选择面积最大的连通域
select_shape_std (ConnectedRegions, SelectedRegions, &#