纺织学报 ›› 2024, Vol. 45 ›› Issue (05): 174-182.doi: 10.13475/j.fzxb.20230502901

• 服装工程 • 上一篇    下一篇

基于计算机视觉与Canny算法的服装纸样轮廓提取

庹武1(), 杜聪1, 陈谦1, 吴超2, 魏新桥1, 张欣汝1, 刘思雨1   

  1. 1.中原工学院 服装学院, 河南 郑州 451191
    2.河南工学院 电气工程与自动化学院, 河南 新乡 453003
  • 收稿日期:2023-05-11 修回日期:2024-01-26 出版日期:2024-05-15 发布日期:2024-05-31
  • 作者简介:庹武(1968—),女,教授,硕士。主要研究方向为服装结构技术。E-mail:tuowu@zut.edu.cn
  • 基金资助:
    河南省高等学校重点科研项目(23A540007);教育部产学协同育人项目(220900693082010)

Clothing pattern contour extraction based on computer vision and Canny algorithm

TUO Wu1(), DU Cong1, CHEN Qian1, WU Chao2, WEI Xinqiao1, ZHANG Xinru1, LIU Siyu1   

  1. 1. College of Fashion, Zhongyuan University of Technology, Zhengzhou, Henan 451191, China
    2. College of Electrical Engineering and Automation, Henan Institute of Technology, Xinxiang, Henan 453003, China
  • Received:2023-05-11 Revised:2024-01-26 Published:2024-05-15 Online:2024-05-31

摘要:

为提高服装二维纸样轮廓信息采集转换的准确性及方便性,设计了一种基于计算机视觉的服装纸样轮廓提取方法。将手机相机作为图像采集设备,采用相机标定的方法进行图像畸变矫正,对图像灰度化处理后进行伽马变换。通过改进的Canny算法对纸样图像进行边缘信息的提取,使用自适应双边滤波保边去噪;在原Sobel算子上增加了45°和135°方向的梯度模板计算梯度;采用自适应双阈值确定边缘;融合形态学算法处理轮廓;最后按需进行轮廓骨架提取。结果表明:本文方法适用于二维纸样的轮廓提取,其提取误差在0.15~1.50 cm之间,可实现单独对服装纸样的外轮廓、内轮廓及内外轮廓图的提取,完成轮廓的无差别提取,减少后期人工对轮廓图的编辑,提高二维纸样数字化录入效率。

关键词: 服装纸样提取, 计算机视觉, 相机标定, 图像处理, Canny边缘检测算法, 轮廓后处理, 样板转化

Abstract:

Objective In order to improve the accuracy and convenience in collecting and converting two-dimensional pattern contour information, a method for garment pattern contour extraction based on computer vision was proposed. This research aimed to extract digitally the clothing patterns based on the use of two-dimensional pattern contour obtained from scanners or cameras. It was expected that the original physical template in the form of pattern card would be accurately transformed into a computer pattern contour image.

Method This method involved both hardware and software. The hardware part was composed of a bracket, a smart phone, a quadrupod, a background plate and a calibration plate. The smart phone's camera was used as the image acquisition device. The part of software consists of image processing and contour extraction. The distortion parameters were obtained using the chessboard camera calibration method for image correction, and the corrected image was gray-scale processed and the matrix was simplified. The contrast between the target image and the background was improved by gamma transform ation of the gray image. The improved Canny algorithm was applied to extract the edge information of paper pattern image, and adaptive bilateral filtering was used for better edge-preserving denoising. The gradient templates in the 45°and 135°directions were added to the original Sobel convolution to calculate the gradient so as to improve the accuracy of position weighting coefficient. Non-maximum suppression and adaptive double threshold selection were carried out to refine and determine the edge. Double edge filling, smoothing and reprocessing of contour map were carried out by morphology closing operation. Finally, the skeleton was extracted from the contour map.

Results After multiple experiments, the accuracy and effect of contour extraction were verified. In order to verify the accuracy of the contours, the function cv2.findContours() in the python library was adopted to extract the contour information which was then drawn on a white screen using Matplotlib library. The contour image was vectorized and saved as a PDF format, and the contour length was measured by the tool included in the PDF. The measurement results showed that the error was 0.15-1.50 cm compared to the length measured in reality, and the overall error was in line with the clothing error standard. More optical distortions and aberrations may be introduced when the object was placed at the edge of the camera for imaging, resulting in a larger imaging error than the central position. Therefore, it was necessary to place the paper pattern in the center of the camera during the operation to reduce the extraction error. In order to verify the effect of contour extraction, the extracted outer contour map, inner contour map and inner-outer contour map were compared with the contour map extracted by the traditional Canny edge detection algorithm. Both the conventional algorithm and the algorithm in this paper were able to outline roughly the contour map of the paper pattern. For the extraction of the outer outline of the paper pattern, both algorithms could achieve the same extraction effect by changing the sigma value and the parameters of the high and low threshold. However, a big difference existed between the two algorithms in the extraction of inner and inner-outer contours of paper patterns. When extracting the local details of the image, the effect of the conventional algorithm was not ideal, because the extracted internal symbol contour was not smooth enough, causing some small burrs and information lost. The proposed algorithm obtained the extraction of internal symbols without distinction, and the extraction effect of details such as cut, buckle and connector was good. For the whole image extraction, the effect of the conventional algorithm was not satisfactory in causing a large number of breakpoints and a small amount of noise points, especially for the inner contour extraction of paper pattern. Compared with the conventional algorithms, the proposed algorithm was found more prominent in removing noise and preserving edges and in creating clear extraction of the outer contour, inner contour and inner-outer contour of the paper pattern. It was suitable for the contour extraction of two-dimensional paper pattern, offering improved extraction efficiency.

Conclusion The proposed improved pattern extraction algorithm combining the knowledge of camera calibration and image processing, can conveniently and efficiently achieve digital extraction of clothing pattern. Computer vision detection technology and improved Canny edge detection technology were adopted to design a non-contact two-dimensional clothing pattern contour extraction method to extract the outer contour, inner contour and inner-outer contour of paper patterns. The two-dimensional pattern contour extraction was based on the use of scanner or camera, and this technology is applicable to the garment manufacturing industry, advanced customization industry, and individual studios, with high practical application value.

Key words: garment pattern extraction, computer vision, camera calibration, image processing, Canny edge detection algorithm, contour post-processing, template transformation

中图分类号: 

  • TS941.26

图1

图像采集硬件示意图"

表1

4款手机标定结果"

手机型号 反投影误差值
iPhone 13 0.032 8
Redmi K40 0.041 8
Honor V20 0.064 1
Vivo Y76s 0.048 9

图2

γ取不同值的灰度直方图"

图3

整体设计流程图"

图4

算法流程图"

图5

传统算法提取的剪口轮廓示意图"

图6

3×3邻域内边缘方向示意图"

图7

自定义阈值与自适应阈值确定的边缘对比图"

图8

边缘填充图"

图9

八方向结构体元素示意图"

图10

提取轮廓长度与实际轮廓长度对比图"

图11

2种算法整体轮廓对比图"

图12

2种算法局部轮廓对比图"

[1] 雷鸽, 李小辉. 数字化服装结构设计技术的研究进展[J]. 纺织学报, 2022, 43(4): 203-209.
LEI Ge, LI Xiaohui. Review of digital pattern-making technology in garment production[J]. Journal of Textile Research, 2022, 43(4): 203-209.
[2] NA L, YANYAN M, LINYI S, et al. Rapid extraction of clothing sample profile based on the improved Canny algorithm[J]. Advances in Multimedia, 2022. DOI:10.1155/2022/7554652.
[3] 李涛, 杜磊, 黄振华, 等. 服装款式图识别与样板转换技术研究进展[J]. 纺织学报, 2020, 41(8): 145-151.
LI Tao, DU Lei, HUANG Zhenghua, et al. Review on pattern conversion technology based on garment flat recognition[J]. Journal of Textile Research, 2020, 41(8): 145-151.
[4] 高鹏, 王永强, 周聪玲, 等. 基于机器视觉的服装样片轮廓特征数据采集系统[J]. 天津科技大学学报, 2020, 35(6): 60-65.
GAO Peng, WANG Yongqiang, ZHOU Chongling, et al. Data acquisition system of garment sample contour based on machine vision[J]. Journal of Tianjin University of Science & Technology, 2020, 35(6): 60-65.
[5] 周佳, 宗雅倩, 刘其思, 等. 基于图像处理的服装样板轮廓提取[J]. 纺织科学与工程学报, 2018, 35(4):133-136.
ZHOU Jia, ZONG Yaqian, LIU Qisi, et al. Garment template outline extraction based on image processing[J]. Journal of Textile Science and Engineering, 2018, 35(4): 133-136.
[6] 管昉立, 徐爱俊. 基于智能手机与机器视觉技术的立木胸径测量方法[J]. 浙江农林大学学报, 2018, 35(5): 892-899.
GUAN Fangli, XU Aijun. Tree DBH measurement method based on smartphone and machine vision technology[J]. Journal of Zhejiang A & F University, 2018, 35(5): 892-899.
[7] ZHANG Y J. 3-D computer vision: principles, algorithms and applications[M]. Singapore: Springer, 2023: 37-65.
[8] ZHAO L, ZHU R. Research on image contour edge analysis based on Canny edge detector[J]. Academic Journal of Computing & Information Science, 2022, 5(1): 70-75.
[9] 刘雨琪, 李治江. 基于单应性矩阵组的手机多镜头相机标定方法[J]. 数字印刷, 2021(1): 29-36.
LIU Yuqi, LI Zhijiang. Calibration method of multi-lenscelltphone camera based on homography matrix group[J]. Digital Printing, 2021(1): 29-36.
[10] 庹武, 王哓玉, 高雅昆, 等. 基于改进边缘检测算法的服装款式识别[J]. 纺织学报, 2021, 42(10): 157-162.
doi: 10.13475/j.fzxb.20201205006
TUO Wu, WANG Xiaoyu, GAO Yakun, et al. Clothing style identification based on improved edge detection algorithm[J]. Journal of Textile Research, 2021, 42(10): 157-162.
doi: 10.13475/j.fzxb.20201205006
[11] 李东洁, 郭帅, 杨柳. 基于改进图像阈值分割算法的纱线疵点检测[J]. 纺织学报, 2021, 42(3): 82-88.
LI Dongjie, GUO Shuai, YANG Liu. Yarn defect detection based on improved image threshold segmentation algorithm[J]. Journal of Textile Research, 2021, 42(3): 82-88.
[12] 胡易, 邹立, 昝世良, 等. 基于暗通道和伽马变换的水下图像增强[J]. 电光与控制, 2021, 28(3): 81-85.
HU Yi, ZOU Li, ZAN Shiliang, et al. Underwater image enhancement based on dark channel and gamma transform[J]. Electronics Optics & Control, 2021, 28(3): 81-85.
[13] CHEN D, CHENG J J, HE H Y, et al. Computed tomography reconstruction based on Canny edge detection algorithm for acute expansion of epidural hematoma[J]. Journal of Radiation Research and Applied Sciences, 2022, 15(3): 279-284.
[14] 杜绪伟, 陈东, 马兆昆, 等. 基于Canny算子的改进图像边缘检测算法[J]. 计算机与数字工程, 2022, 50(2): 410-413.
DU Xuwei, CHEN Dong, MA Zhaokun, et al. Improved image edge detection algorithm based on Canny operator[J]. Computer & Digital Engineering, 2022, 50(2):410-413.
[15] ZHANG W. Image denoising algorithm of refuge chamber by combining wavelet transform and bilateral filtering[J]. International Journal of Mining Science and Technology, 2013, 23(2): 228-232.
[16] 尤波, 张宸枫. 结合小波自适应阈值与双边滤波的图像降噪[J]. 计算机工程与设计, 2019, 40(8): 2278-2282.
YOU Bo, ZHANG Chengfeng. Image noiser reduction combining wavelet adaptive threshold and bilateral filtering[J]. Computer Engineering and Design, 2019, 40(8): 2278-2282.
[17] 王军, 林宇航, 贾玉彤, 等. 一种改进Canny算子的图像边缘检测算法[J]. 小型微型计算机系统, 2023, 10(13): 1-6.
WANG Jun, LIN Yuhang, JIA Yutong, et al. An image edge detection algorithm based on improved Canny operator[J]. Journal of Chinese Computer Systems, 2023, 10(13): 1-6.
[18] XIAOKANG Y, ZHIWEN W, YUHANG W, et al. Edge detection of agricultural products based on morphologically improved Canny algorithm[J]. Mathematical Problems in Engineering, 2021. DOI:10.1155/2021/6664970.
[1] 杨金鹏, 景军锋, 李吉国, 王渊博. 基于机器视觉的玻璃纤维合股纱缺陷检测系统设计[J]. 纺织学报, 2024, 45(05): 193-201.
[2] 戴宁, 梁汇江, 胡旭东, 戚栋明, 徐郁山, 屠佳佳, 史伟民. 插管式机器人空管状态检测方法[J]. 纺织学报, 2023, 44(11): 199-207.
[3] 王小虎, 潘如如, 高卫东, 周建. 基于稀疏字典优选的织物疵点检测方法[J]. 纺织学报, 2023, 44(08): 81-87.
[4] 杨宏脉, 张效栋, 闫宁, 朱琳琳, 李娜娜. 一种高鲁棒性经编机上断纱在线检测算法[J]. 纺织学报, 2023, 44(05): 139-146.
[5] 李杨, 彭来湖, 李建强, 刘建廷, 郑秋扬, 胡旭东. 基于深度信念网络的织物疵点检测[J]. 纺织学报, 2023, 44(02): 143-150.
[6] 安亦锦, 薛文良, 丁亦, 张顺连. 基于图像处理的纺织品耐摩擦色牢度评级[J]. 纺织学报, 2022, 43(12): 131-137.
[7] 张东剑, 甘学辉, 杨崇倡, 韩阜益, 刘香玉, 谈渊, 廖壑, 王松林. 纺丝过程中非接触式纤维张力检测技术研究进展[J]. 纺织学报, 2022, 43(11): 188-194.
[8] 袁嫣红, 曾洪铭, 茅木泉. 基于图像处理的选针器检测系统[J]. 纺织学报, 2022, 43(10): 176-182.
[9] 邓中民, 胡灏东, 于东洋, 王文, 柯薇. 结合图像频域和空间域的纬编针织物密度检测方法[J]. 纺织学报, 2022, 43(08): 67-73.
[10] 马运娇, 王蕾, 潘如如, 高卫东. 基于平面镜成像的纱线条干三维合成校准方法[J]. 纺织学报, 2022, 43(07): 55-59.
[11] 周其洪, 彭轶, 岑均豪, 周申华, 李姝佳. 基于机器视觉的细纱接头机器人纱线断头定位方法[J]. 纺织学报, 2022, 43(05): 163-169.
[12] 张荣根, 冯培, 刘大双, 张俊平, 杨崇倡. 涤纶工业长丝毛丝在线检测系统的研究[J]. 纺织学报, 2022, 43(04): 153-159.
[13] 熊晶晶, 杨雪, 苏静, 王鸿博. 基于图像技术的织物导湿性能测试方法[J]. 纺织学报, 2021, 42(12): 70-75.
[14] 吕文涛, 林琪琪, 钟佳莹, 王成群, 徐伟强. 面向织物疵点检测的图像处理技术研究进展[J]. 纺织学报, 2021, 42(11): 197-206.
[15] 夏旭文, 孟朔, 潘如如, 高卫东. 基于改进帧间差分法的经纱撞筘拥纱在线检测[J]. 纺织学报, 2021, 42(06): 91-96.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!