Image Matching Algorithm based on Color Image Segmentation
-
摘要: 在零件检测时由于背景复杂、零件表面光照不均匀且存在油污及废屑等问题,导致特征选取与模板制作困难,因此现有图像匹配算法容易出现漏识别与误识别,从而给实际应用带来困难。针对上述问题,提出了一种结合彩色图像分割的图像匹配算法。首先,将HSV颜色空间中各通道的直方图分布曲线方波化;其次,根据方波分布确定阈值,实现自适应阈值分割与目标提取;最后,利用边缘特征进行模板匹配。实验结果表明,该算法能够消除光照和背景噪声的影响,快速准确地分割出目标对象,降低特征选取与模板制作的难度,且算法消除了误识别,耗时短,准确率高,成功应用于工业生产中。Abstract: When the image matching algorithm is applied to inspecting components, there are many factors which can increase the difficulty of extracting features and creating templates, such as complex background, non-uniform illumination, oil and iron filings on the surface of the component. These problems lead to unidentification and misidentification for existing image matching algorithms, which will make image matching algorithms more difficult to be applied in the industries. In order to solve those problems, an image matching algorithm was proposed based on the color image segmentation. Firstly, the different gray curve of each channel in the HSV color space is processed as square wave. Secondly, the threshold used in adaptive image segmentation and extraction is determined with the distribution of square curve. Finally, the edge character information is used for template matching. The experiment results show that the algorithm can eliminate the impact of illumination and background noise, accomplish object segmentation fast and accurate, and reduce the difficulty of feature selection and template creation. The algorithm eliminates the misidentification, and achieves the accuracy with less times consuming. The present algorithm has been applied to industrial production successfully.
-
Key words:
- HSV color space /
- color image segmentation /
- edge character /
- image matching
-
表 1 分割效果及耗时统计
影响因素 因素水平 固定阈值分割算法 Otsu分割算法 本文算法 耗时/ms 分割效果 耗时/ms 分割效果 耗时/ms 分割效果 环境光 弱 27.5 过分割 51.3 过分割 42.4 保存完整 适中 30.8 保存完整 48.9 保存完整 43.8 保存完整 强 28.3 欠分割 50.5 保存完整 43.1 保存完整 背景噪声 高 28.6 保存完整 49.7 过分割 44.3 保存完整 表 2 匹配算法运行结果分析
图像匹配算法 漏识别率/% 误识别率/% 准确率/% 耗时/ms 基于灰度值的NCC模板匹配 1.8 1.2 97 191 基于边缘特征的ESD模板匹配 1.9 3.3 94.8 138 本文算法 0.2 0 99.8 104 -
[1] 余文勇, 石绘.机器视觉自动检测技术[J].中国科技信息, 2013, (24):184 http://www.cnki.com.cn/Article/CJFDTotal-XXJK201324090.htmYu W Y, Shi H. Machine vision automatic detection technology[J]. China Science and Technology Information, 2013, (24):184(in Chinese) http://www.cnki.com.cn/Article/CJFDTotal-XXJK201324090.htm [2] 章毓晋.图像工程(中册):图像分析[M].2版.北京:清华大学出版社, 2005Zhang Y J. Image engineering (Ⅱ) image analysis[M]. 2nd ed. Beijing:Tsinghua University Press, 2005(in Chinese) [3] 王红梅, 张科, 李言俊.图像匹配研究进展[J].计算机工程与应用, 2004, 40(19):42-44, 77 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcyyy200419013Wang H M, Zhang K, Li Y J. Research progress on image matching[J]. Computer Engineering and Applications, 2004, 40(19):42-44, 77(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcyyy200419013 [4] 李强, 张钹.一种基于图像灰度的快速匹配算法[J].软件学报, 2006, 17(2):216-222 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=rjxb200602006Li Q, Zhang B. A fast matching algorithm based on image gray value[J]. Journal of Software, 2006, 17(2):216-222(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=rjxb200602006 [5] 邹晖, 张冰, 王晓萍.一种基于模板匹配的手指静脉识别算法[J].传感技术学报, 2016, 29(10):1529-1534 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=cgjsxb201610011Zhou H, Zhang B, Wang X P. A finger vein recognition algorithm based on template matching[J]. Chinese Journal of Sensors and Actuators, 2016, 29(10):1529-1534(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=cgjsxb201610011 [6] 刘李漫, 张治国, 满征瑞.基于模板匹配及区域信息融合提取的快速目标跟踪算法[J].计算机工程与科学, 2016, 38(3):534-541 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcykx201603021Liu L M, Zhang Z G, Man Z R. A fast object tracking algorithm based on template matching and region information fusion extraction[J]. Computer Engineering & Science, 2016, 38(3):534-541(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcykx201603021 [7] 赖锦祥, 雷亮, 阮杨, 等.基于等积环投影与Zernike矩的快速模板匹配[J].电子学报, 2019, 47(6):1324-1330 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=dianzixb201906020Lai J X, Lei L, Ruan Y, et al. Fast template matching based on equal-area ring projection and Zernike moments[J]. Acta Electronica Sinica, 2019, 47(6):1324-1330(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=dianzixb201906020 [8] 丁小艳, 王婷.基于交叉检验ORB和MCC的图像模板匹配算法[J].电子测量与仪器学报, 2019, (5):39-45 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=dzclyyqxb201905006Ding X Y, Wang T. Image template matching algorithm based on cross-check ORB and MCC[J]. Journal of Electronic Measurement and Instrumentation, 2019, (5):39-45(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=dzclyyqxb201905006 [9] 李志军, 刘松林, 牛照东, 等.基于梯度相位和显著性约束的Hausdorff距离模板匹配方法[J].红外与激光工程, 2015, 44(2):775-780 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=hwyjggc201502068Li Z J, Liu S L, Niu Z D, et al. Hausdorff distance template matching method based on gradient phase and significance constraints[J]. Infrared and Laser Engineering, 2015, 44(2):775-780(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=hwyjggc201502068 [10] 李子印, 许斌, 陈立峰.基于自适应步长选择的NCC图像匹配算法[J].光电工程, 2013, 40(10):77-84, 89 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=gdgc201310013Li Z Y, Xu B, Chen L F. Normalized cross correlation image matching algorithm based on adaptive step size[J]. Opto-Electronic Engineering, 2013, 40(10):77-84, 89(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=gdgc201310013 [11] 陈丽芳, 刘渊, 须文波.改进的归一互相关法的灰度图像模板匹配方法[J].计算机工程与应用, 2011, 47(26):181-183 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcyyy201126050Chen L F, Liu Y, Xu W B. Improved normalized correlation method of gray image template matching method[J]. Computer Engineering and Applications, 2011, 47(26):181-183(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcyyy201126050 [12] 阙昊懿, 黄辉先, 徐建闽.基于双阈值SSDA模板匹配的遥感图像道路边缘检测研究[J].国土资源遥感, 2014, 26(4):29-33 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=gtzyyg201404006Que H Y, Huang H X, Xu J M. Road edge detection based on dual-threshold SSDA template matching[J]. Remote Sensing for Land & Resources, 2014, 26(4):29-33(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=gtzyyg201404006 [13] 谷睿宇, 曾接贤, 符祥, 等.结合轮廓与形状特征的仿射形状匹配[J].中国图象图形学报, 2018, 23(10):1530-1539 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=zgtxtxxb-a201810008Gu R Y, Zeng J X, Fu X, et al. Affine shape matching by using feature combined with contour and shape[J]. Journal of Image and Graphics, 2018, 23(10):1530-1539(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=zgtxtxxb-a201810008 [14] 陶易之, 贺赛先.以多尺度三角形为特征的快速形状匹配[J].计算机辅助设计与图形学学报, 2017, 29(3):469-478 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjfzsjytxxxb201703009Tao Y Z, He S X. Fast shape matching using multiscale triangle features[J]. Journal of Computer-Aided Design & Computer Graphics, 2017, 29(3):469-478(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjfzsjytxxxb201703009 [15] Öktem O, Chen C, Onur DomaniÇ N, et al. Shape-based image reconstruction using linearized deformations[J]. Inverse Problems, 2017, 33(3):035004 doi: 10.1088/1361-6420/aa55af [16] Ali S, Madabhushi A. An integrated region-, boundary-, shape-based active contour for multiple object overlap resolution in histological imagery[J]. IEEE Transactions on Medical Imaging, 2012, 31(7):1448-1460 doi: 10.1109/TMI.2012.2190089 [17] 林开颜, 吴军辉, 徐立鸿.彩色图像分割方法综述[J].中国图象图形学报, 2005, 10(1):1-10 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=zgtxtxxb-a200501001Lin K Y, Wu J H, Xu L H. A survey on color image segmentation techniques[J]. Journal of Image and Graphics, 2005, 10(1):1-10(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=zgtxtxxb-a200501001 [18] 姚学练, 贺福强, 平安, 等.基于HSI颜色空间与灰度波动相结合的复杂桥梁蜂窝麻面的图像分割[J].计算机应用, 2019, 39(3):882-887 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjyy201903043Yao X L, He F Q, Ping A, et al. Image segmentation for complex voids and pits of bridge based on combination of HSI color space and gray fluctuation[J]. Journal of Computer Applications, 2019, 39(3):882-887(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjyy201903043 [19] 邓小亚.基于复合布谷鸟算法的彩色图像多阈值分割[J].计算机与数字工程, 2019, 47(4):944-948 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjyszgc201904042Deng X Y. Multi threshold image segmentation based on hybrid cuckoo algorithm[J]. Computer & Digital Engineering, 2019, 47(4):944-948(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjyszgc201904042 [20] 朱磊, 白瑞林, 吉峰.光照不均匀图像的灰度波动局部阈值分割[J].计算机工程与应用, 2015, 51(12):144-149 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcyyy201512027Zhu L, Bai R L, Ji F. Local threshold segmentation based on grayscale wave for uneven illumination image[J]. Computer Engineering and Applications, 2015, 51(12):144-149(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcyyy201512027 [21] 魏巍, 申铉京, 千庆姬.工业检测图像灰度波动变换自适应阈值分割算法[J].自动化学报, 2011, 37(8):944-953 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=zdhxb201108005Wei W, Sheng X J, Qian Q J. An adaptive thresholding algorithm based on grayscale wave transformation for industrial inspection images[J]. Acta Automatica Sinica, 2011, 37(8):944-953(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=zdhxb201108005 [22] 汪澜, 张慧, 张海涛.结合新颜色空间与Otsu的分水岭彩色图像分割算法[J].计算机应用研究, 2017, 34(12):3873-3879 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjyyyj201712080Wang L, Zhang H, Zhang H T. Watershed image segmentation algorithm combining with Otsu in new color space[J]. Application Research of Computers, 2017, 34(12):3873-3879(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjyyyj201712080 [23] 王祥科, 郑志强.Otsu多阈值快速分割算法及其在彩色图像中的应用[J].计算机应用, 2006, 26(S1):14-15 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjyy2006z1007Wang X K, Zheng Z Q. Otsu multi-threshold fast segmentation algorithm and application in color images[J]. Journal of Computer Applications, 2006, 26(S1):14-15(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjyy2006z1007 [24] Elbayoumi Harb S M, Isa N A M, Salamah S A. Improved image magnification algorithm based on Otsu thresholding[J]. Computers & Electrical Engineering, 2015, 46:338-355 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=a20cf03c50da1dd4cf00edf16874e133 [25] 马天兵, 刘健, 杜菲, 等.基于改进Otsu方法的振动图像分割研究[J].电光与控制, 2019, 26(2):11-15, 31 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=dgykz201902003Ma T B, Liu J, Du F, et al. A vibration image segmentation algorithm based on improved Otsu threshold method[J]. Electronics Optics & Control, 2019, 26(2):11-15, 31(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=dgykz201902003 [26] Bezdek J C. Pattern recognition with fuzzy objective function algorithms[M]. Boston, MA:Springer, 1981 [27] 王鹏宇, 游有鹏, 杨雪峰.基于颜色量化和密度峰聚类的彩色图像分割[J].计算机工程与应用, 2020, 56(2):211-215 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcyyy202002030Wang P Y, You Y P, Yang X F. Color image segmentation based on color quantization and density peak clustering[J]. Computer Engineering and Applications, 2020, 56(2):211-215(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcyyy202002030 [28] 贾瑞玉, 李玉功.类簇数目和初始中心点自确定的K-means算法[J].计算机工程与应用, 2018, 54(7):152-158 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcyyy201807024Jia R Y, Li Y G. K-means algorithm of clustering number and centers self-determination[J]. Computer Engineering and Applications, 2018, 54(7):152-158(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=jsjgcyyy201807024 [29] 任大勇, 贾振红, 杨杰, 等.结合位图切割和区域合并的彩色图像分割[J].计算机工程与应用, 2019, 55(2):162-167 http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=pre_8c77024e-3ced-4031-9d71-74fa115b1868Ren D Y, Jia Z H, Yang J, et al. Color image segmentation based on bitmap cut and region merging[J]. Computer Engineering and Applications, 2019, 55(2):162-167(in Chinese) http://www.wanfangdata.com.cn/details/detail.do?_type=perio&id=pre_8c77024e-3ced-4031-9d71-74fa115b1868