工业生产中颜色测量应用比较多的有印刷品的颜色检测、纺织品颜色的检测等。对于颜色检测中比较简单的有指定区域的灰度值大小的比较,比较复杂的有区域内灰度分布。以下是相关的一些常用的算子:
rgb1_to_gray 把RGB图像转换为灰度图像;
trans_from_rgb 把图像转换为XXX 颜色空间的图像;
cfa_to_rgb 把一个单通道颜色滤波阵列图像转换成RGB图像;
gray_histo 获取Image图像Region区域的灰度相对直方图RelativeHisto和绝对直方图AbsoluteHisto;
* 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)
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)
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