Journal of Textile Research ›› 2024, Vol. 45 ›› Issue (05): 174-182.doi: 10.13475/j.fzxb.20230502901

• Apparel Engineering • Previous Articles     Next Articles

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 Online:2024-05-15 Published:2024-05-31

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

CLC Number: 

  • TS941.26

Fig.1

Diagram of image acquisition by hardware"

Tab.1

Calibration results of 4 different mobile phones"

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

Fig.2

Grayscale histogram of different values of γ"

Fig.3

Flow chart of overall design"

Fig.4

Algorithm flow chart"

Fig.5

Diagram of cutting edge contour extracted by conventional algorithm"

Fig.6

Diagram of edge direction in 3×3 area"

Fig.7

Comparison diagram of edge determined by custom threshold (a) and adaptive threshold (b)"

Fig.8

Edge filling diagram"

Fig.9

Diagram of eight-direction structuring elements"

Fig.10

Comparison diagram of extracted contour length and actual contour length. (a) Image of actual edge length and enlarged measurement; (b) Image of extracted edge length and enlarged measurement"

Fig.11

Comparison of overall contour of two algorithms. (a) Original image; (b) External contour image; (c) Internal contour image of conventional algorithm; (d) Internal and external contour image of conventional algorithm; (e) Inner contour image of proposed algorithm; (f) Internal and external contour image of proposed algorithm"

Fig.12

Comparison of local contours of two algorithms. (a) Conventional algorithm; (b) Proposed algorithm"

[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] DAI Ning, LIANG Huijiang, HU Xudong, QI Dongming, XU Yushan, TU Jiajia, SHI Weimin. Empty tube state detection method of intubation robot [J]. Journal of Textile Research, 2023, 44(11): 199-207.
[2] YANG Hongmai, ZHANG Xiaodong, YAN Ning, ZHU Linlin, LI Na'na. Robustness algorithm for online yarn breakage detection in warp knitting machines [J]. Journal of Textile Research, 2023, 44(05): 139-146.
[3] LI Yang, PENG Laihu, LI Jianqiang, LIU Jianting, ZHENG Qiuyang, HU Xudong. Fabric defect detection based on deep-belief network [J]. Journal of Textile Research, 2023, 44(02): 143-150.
[4] AN Yijin, XUE Wenliang, DING Yi, ZHANG Shunlian. Evaluation of textile color rubbing fastness based on image processing [J]. Journal of Textile Research, 2022, 43(12): 131-137.
[5] ZHANG Dongjian, GAN Xuehui, YANG Chongchang, HAN Fuyi, LIU Xiangyu, TAN Yuan, LIAO He, WANG Songlin. Research progress in non-contact fiber tension detection technology in spinning process [J]. Journal of Textile Research, 2022, 43(11): 188-194.
[6] YUAN Yanhong, ZENG Hongming, MAO Muquan. Needle selector detection system based on image processing [J]. Journal of Textile Research, 2022, 43(10): 176-182.
[7] DENG Zhongmin, HU Haodong, YU Dongyang, WANG Wen, KE Wei. Density detection method of weft knitted fabrics making use of combined image frequency domain and spatial domain [J]. Journal of Textile Research, 2022, 43(08): 67-73.
[8] MA Yunjiao, WANG Lei, PAN Ruru, GAO Weidong. Calibration method of three-dimensional yarn evenness based on mirrored image [J]. Journal of Textile Research, 2022, 43(07): 55-59.
[9] ZHOU Qihong, PENG Yi, CEN Junhao, ZHOU Shenhua, LI Shujia. Yarn breakage location for yarn joining robot based on machine vision [J]. Journal of Textile Research, 2022, 43(05): 163-169.
[10] ZHANG Ronggen, FENG Pei, LIU Dashuang, ZHANG Junping, YANG Chongchang. Research on on-line detection system of broken filaments in industrial polyester filament [J]. Journal of Textile Research, 2022, 43(04): 153-159.
[11] XIONG Jingjing, YANG Xue, SU Jing, WANG Hongbo. Testing method for fabric moisture conductivity based on image technology [J]. Journal of Textile Research, 2021, 42(12): 70-75.
[12] LÜ Wentao, LIN Qiqi, ZHONG Jiaying, WANG Chengqun, XU Weiqiang. Research progress of image processing technology for fabric defect detection [J]. Journal of Textile Research, 2021, 42(11): 197-206.
[13] XIA Xuwen, MENG Shuo, PAN Ruru, GAO Weidong. On-line detection of warp collision and reed embedding based on improved inter-frame difference method [J]. Journal of Textile Research, 2021, 42(06): 91-96.
[14] JIANG Yanting, YAN Qingshuai, XIN Binjie, GAO Cong, SHI Meiwu. Comparative study on testing methods for unidirectional water transport in fabrics [J]. Journal of Textile Research, 2021, 42(05): 51-58.
[15] LI Dongjie, GUO Shuai, YANG Liu. Yarn defect detection based on improved image threshold segmentation algorithm [J]. Journal of Textile Research, 2021, 42(03): 82-88.
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!