# Rapid Extraction of Clothing Sample Profile Based on the Improved Canny Algorithm

Authors: Na Liu; Yanyan Ma; Linyi Shao; Hao Wang
Journal: Advances in Multimedia
 (2022)

---

## Abstract

In order to reduce the difficulty of clothing diversity on the edge extraction link, this study proposes an improved Canny algorithm that segments the pattern, styles, and contours of the clothing image after creating a sample library of a women’s image. Extract, improve the accuracy of the edge, and reduce the noise formed by texture and clothing. The results show that in the simulation experiment, the contour extraction of multiple categories of clothing is carried out, and compared with the differential operator algorithm and Canny algorithm, the experimental results show that the improved algorithm can more accurately segment the edge of clothing, extract the style contour, and express the characteristics of clothing.


---

## Body

## 1. Introduction

Image segmentation and target extraction has always been a hot topic in computer vision and multimedia areas involving biomedical, health safety, remote sensing aviation, industrial automation, military, public security, meteorological observations, and other fields. In recent years, the textile and apparel field has gradually carried out garment retrieval, textile detection, and processing of various types of clothing, fabric images, and has made preliminary progress, but the time applied in textile and apparel is not long. The first application was mid-1990s and less studied in the next nearly 10 years. According to statistics, since 2005, the research interest has increased dramatically, indicating that the application of image extraction technology is gradually widely used in the field of clothing, and it also shows that the use of artificial intelligence technology solves the problem in the clothing industry and is increasingly attracting the attention of artificial intelligence research and apparel industry. Pay attention to the Canny edge detection algorithm that first uses Gaussian to convolve each pixel of the image to smooth the image and suppress the noise. The difference quotient of the first partial derivative is used to calculate the amplitude and direction of the gradient, and the lines of the image are extracted according to the obtained amplitude. The gradient amplitude is suppressed by nonmaximum, so that the edge pixels reach the best value. The edge is detected and connected by the double threshold algorithm, the edge is binarized, and the edge contour is formed. Finally, Gaussian smoothing function is used to reduce the noise of contour.Judging from the extraction of clothing contours and pattern, many new costumes are designed every year, but few people have graduated a database to store clothing style. If image extraction technology extracts the desired garment style in the clothing image, build clothing style database, one can realize the secondary use of clothing style, and clothing designers will be able to store garment style electronically and easily retrieve their previous clothing design. In the construction of the pattern database, in addition to the secondary use of the pattern, one can link the pattern database to the virtual platform to realize the self-characterization of consumers. Based on image characteristics and currently used clothing image feature extraction algorithms, summarize the cost of clothing profiles and pattern extraction in order to provide reference for future computer technology in the field of apparel and apparel industry intelligent, automation.


## 2. Literature Review

In 2021, Han et al. used the moment invariants and the like using the Fourier descriptors to describe the outline feature clothing and to determine the similarity in shape by several European distance calculation. In 2015, Lixin discrete Fourier transform and wavelet mapping outline coordinate clothing styles FIGS to a high-dimensional feature space and then use LDA (latent Dirichlet allocation) dimension reduction and ELM, finally, as a classifier to classify clothing styles FIG [1]. On the basis of literature, Li et al. 2017, created a clothing sample image database, and extracting from the clothing outline image, Fourier descriptors described clothing garment wheel contour extraction, Fourier identifier described Hu moment invariants, superior to the fusion characteristics (Hu moment invariants and Fourier descriptors), and without Fourier descriptors dimension reduction using principal component analysis, the test results can achieve recognition rate of 95%, in particular of contour style characteristics with significantly better recognition rate. For analysis, Fourier descriptors of the principal component analysis can improve recognition accuracy, and support vector machine classification results as a less extreme learning machine [2]. In 2019, Hu et al. used accurate height function type Fourier descriptor clothes to contour feature extraction and feature descriptors for AFHF2 rapid training and testing using a linear SVM kernel function without the need for adjustment parameter [3]. Self-clothing graphics library is used to verify that the algorithm found is superior to the existing algorithms, wherein AFHF2 than Fourier descriptors descriptor, and a function of height TCDs algorithms, linear kernel SVM radial basis function algorithm, outperforms the SVM algorithm, K Juan nearest neighbor, probabilistic neural networks, and back propagation neural network algorithm; the average recognition rate can reach 97 Yan 91%. Fourier descriptor can describe the outline feature, and only a small amount can be described as a generally representative of the subprofile. Normalized Fourier descriptors having a descriptor can influence translation, rotation, scale-invariant, not the position of the contour in the image, and the outline of the angle scale, and it is a better robustness of the image features. Scholars have identified the above method and the outline of clothing styles Fourier descriptors and SVM combination can efficiently identify many types of clothing styles profile, and robust, but not one correspondence with the contour of clothing.In 2020, Yu et al. combined regional growth and edge detection, according to the image of the image and edge area image detected by the Canny algorithm defined by the Sobel operator, and guided the segmentation of the geometric pattern in the Malaysian Songji woven image [4]. Ding et al., on the basis of image filtering, used an improved Canny algorithm to quickly extract the contour of the clothing model and then extract the skeleton to the skeleton and optimize the contour sample. When the image contour extraction, edge detection algorithms are usually employed, such as the Canny algorithm, which identifies the outline effect than other edge detection algorithms, but the algorithm filter is large, and some details are easily lost, and the two thresholds of the algorithm must be artificial declaration, self-adaptation, and cannot achieve automatic parameters, slower operation; therefore, in the edge positioning accuracy and elimination, noise grade have reverse balance and should appropriately select parameters to the noise level and edge point positioning accuracy according to specific problems [5]. Yu et al. believed that the region-based image segmentation method is to aggregate pixels with small differences in gray values into one category. Regions with similar features are combined to separate out regions with large differences in features. Regions of interest are extracted for further processing and the rest is discarded, so that the subsequent workload can be reduced. This method is only applicable to the case of large difference between target image and background image, and misjudgment may occur in other cases [6]. In 2021, study of Lin et al., the adaptive and fast algorithm of gray-scale image threshold segmentation is studied. The principle of the Otsu method is deeply analyzed, and a threshold segmentation method based on the minimum intraclass exponential variance is proposed, which solves the defect that the Otsu method is prone to produce deviation when the variance difference of classes is relatively large [7].


## 3. Digital Image Pretreatment Based on Total Variation

### 3.1. Image Preprocessing

Since the image is interfered with various environmental noise, the image quality will have a certain degree of degradation. Therefore, it is necessary for noise reduction processing on the image. In the pretreatment of the sample, this study will be preprocessed using a total variation model, and the interference is blanked, which ultimately makes the model image have a clearer visual effect.An image that is disturbed can be broken down into imageu and additive random noise W.Among them, the additive random noise is a Gaussian white noise, with a zero mean, a variance ofσ2, and a full variable division of an image containing noise is significantly increased, and minimizing full variation can eliminate noise.The full variation of imageu is defined as the integral form of gradient amplitude:(1)TVu=∬Ω∇udΩ.In the formula,∇u is a gradient absolute value. Therefore, the texture blanking problem of the image can be converted to the task of the total variant TV (u) minimum, and the constraint items include two categories:(2)∬ΩUdΩ=∬ΩWdΩ,1Ω∬ΩU−W2dΩ=σ2.Therefore, the selection of the constraint item is especially critical.(3)TVu=∫Ω∇udxdy=∫Ω∇xu2+∇yu2dxdy,where ∇xu and ∇yu is the gradient of the image u in X and Y directions; Ω is the definition domain of the image u, and Ω is the defining domain area. Therefore, the problem of image filtering is converted into a value that limits the total variation.The clothing model image as an example is shown in Figure1. Figure 1(a) shows some valuable line information, and after improving the image by the algorithm, it is obtained (Figure 1(b)). The interference line can be eliminated to obtain a clearer clothing sample.Figure 1
Clothing sample (a) and denoising effect diagram (b).
(a)(b)


## 3.1. Image Preprocessing

Since the image is interfered with various environmental noise, the image quality will have a certain degree of degradation. Therefore, it is necessary for noise reduction processing on the image. In the pretreatment of the sample, this study will be preprocessed using a total variation model, and the interference is blanked, which ultimately makes the model image have a clearer visual effect.An image that is disturbed can be broken down into imageu and additive random noise W.Among them, the additive random noise is a Gaussian white noise, with a zero mean, a variance ofσ2, and a full variable division of an image containing noise is significantly increased, and minimizing full variation can eliminate noise.The full variation of imageu is defined as the integral form of gradient amplitude:(1)TVu=∬Ω∇udΩ.In the formula,∇u is a gradient absolute value. Therefore, the texture blanking problem of the image can be converted to the task of the total variant TV (u) minimum, and the constraint items include two categories:(2)∬ΩUdΩ=∬ΩWdΩ,1Ω∬ΩU−W2dΩ=σ2.Therefore, the selection of the constraint item is especially critical.(3)TVu=∫Ω∇udxdy=∫Ω∇xu2+∇yu2dxdy,where ∇xu and ∇yu is the gradient of the image u in X and Y directions; Ω is the definition domain of the image u, and Ω is the defining domain area. Therefore, the problem of image filtering is converted into a value that limits the total variation.The clothing model image as an example is shown in Figure1. Figure 1(a) shows some valuable line information, and after improving the image by the algorithm, it is obtained (Figure 1(b)). The interference line can be eliminated to obtain a clearer clothing sample.Figure 1
Clothing sample (a) and denoising effect diagram (b).
(a)(b)


## 4. Use the Canny Operator to Detect the Model

The edge extraction problem of the pattern is extracted, that is, the image brightness information is extracted and indicated by a significant change, and finally retains the main structure information of the image. The edge extraction of the clothing model is also a problem. Common edge detection algorithms include Roberts edge detection, Sobel edge detection, and preWitt edge detection, but more or less, there is a problem. If the Roberts operator is simple, it is running fast and convenient, especially for the reaction with steep low noise images, but the result is a pseudoedge, which cannot reflect the true situation of the clothing sample. Although Sobel operator and Prewitt operator detected a wider range, there is also a pseudoedge, and the detected edge line is thicker, and noise is enlarged. Using these algorithms in a relatively complex image, the results will make a more obvious breakpoint, and the clothing samples cannot be fully extracted. The Canny operator is excellent in the above aspects. Therefore, this study passes through a comparative analysis, and finally, the pretreated image is detected by the Canny operator. The main steps are as follows:(1)
Detaplency: any edge detection algorithm is invalid for the original image without processing. Therefore, to perform the initial denoising or impurity blanking treatment of the template image, the original model image is denoised by the previously mentioned total variant image filtering process [8].(2)
Gradient calculation: using the derivative operator to find the image gradation along the derivativesGx, Gy in the two directions, find the magnitude and direction of the gradient, respectively:(4)G=Gx2+Gx2,θ=arctanGxGy.(3)
The gradient direction is determined: first, the edge direction of the image is obtained, and the gradient direction of the edge of the template is roughly divided into several angles, and adjacent pixels in the pixel gradient direction are found according to the angle.(4)
Traverse image: if the gradation value of the pixel is not larger than the gradation value of the two pixels in the gradient direction, the gradation value of the pixel is set to 0, i.e., the pixel point position is not an edge.(5)
Calculate two thresholds with cumulative histogram. Any pixel point position greater than the high threshold must be edge, and the opposite is, if the detection result is between two thresholds, it is determined whether there is an edge pixel that exceeds the high threshold in adjacent pixels of the pixel, and if any, it is the edge, but it is not.


## 5. Model Edge Skeleton Refinement and Data Format Output

The skeleton is an important geometric feature that can effectively reflect the connectivity and topology of the original object shape and consist of a single pixel point. Typically, the process of acquiring the image skeleton is the process of “refining” image. The skeleton of the object used to describe the object is a good way to emphasize the structural features of the object and improve the memory usage and data compression ratio. In this study, the skeletal extraction algorithm of MATLAB will be subjected to skeleton extraction, so that it is refined into a one-dimensional curve, which is convenient for vectorization of the sample data.


### 5.1. Extraction of Edge Skeleton Based on Mathematical Morphology

After extracting the edges of the sample with an improved Canny algorithm, the edge skeleton is extracted based on mathematical morphology. The skeleton method of mathematical morphology is based on the discipline of mathematics. The main idea used for image analysis and recognition is to measure and extract the corresponding shape in the image through certain forms of structural elements. The image passes through mathematical morphology, not only simply causes the original image data information but also removes the unrelated information, retains the fundamental shape properties, and has the structural advantages of native parallel implementation, and finally, the continuous, accurate skeleton is obtained.According to the definition of the largest disc algorithm, the two sets of structural elements are(5)A=A1,A2,A+3,A+4,B=B1,B2,B3,B4.


### 5.2. Skeleton Refinement Treatment

The refinement of the structural elementB on the collection A can be represented as A⊗B, which can be defined depending on hit or missed [9, 10].(6)A⊗B=A−A⊗B=A∩A⊗BC.Refine the image by applying a mathematical morphological analysis algorithm, and the main steps are as follows:(1)
Target imageA, refine y, and use A ⟶ Y;(2)
Makea = a ⊗ bi, where i takes from 1 to 8;(3)
IfA = Y, iteration ends; otherwise, the step (4) is performed;(4)
a ← Y; then, execute (2) step.The sample skeleton after mathematical morphology is shown in Figure2, and the sample skeleton of the single pixel connection is obtained, which greatly reduces the storage amount of the sample.Figure 2
Skeleton.


### 5.3. Oil Edge Optimization

The integrity of the edge plays a key role in the processing of the postimage. Therefore, it is very important to repair the segmented image. This study uses morphological operation to repair edge images. Morphological operations mainly include opening hours and closed [11, 12].The process of advanced corrosion and postexpansion is called opening. The structural elementB is operated on the set A, which is expressed as A∘B, defined as follows:(7)A∘B=AΘB.The process of expanding advanced rises is called closed operation. The structural elementB is closed on the collection A. The representation is A∙B. The definition is as follows:(8)A⋅B=A⊕BΘB.Specifically, in Figure3, a picture after pretreatment, edge extraction, and skeletal refinement of the sample, resulting in a connection phenomenon due to the difference in the edge of the sample, resulting in a connection, and raised in the edge of the model, not flat, is shown. With the morphological operation, the problems shown in Figure 3(a) have been well repaired; as shown in Figure 3(b), ultimately, the smooth continuous curve can be the output, which provides a solid foundation for subsequent operations, which is of important significance [13].Figure 3
Model silhouette (b) after the model skeleton (a) and smooth treatment.
(a)(b)


### 5.4. Vectorized Data Format Output

Since the sample profile will be used in the industrial plate, it is necessary to save the resulting sample contour to the format DxF that can be identified as AutoCAD by graphic exchange files for subsequent processing. DXF is the CAD data file format developed by Autodesk to exchange CAD data between AutoCAD and other softwares.During the plate, most of them use AutoCAD to plate, and the code itself in the DXF format file is good readability, which is convenient for users to modify. Therefore, this study stores the resulting sample contour as a DXF format and finally uses the VisualC++ programming, saving the vectorized data of the saved DXF format to the CAD plate [14].


## 5.1. Extraction of Edge Skeleton Based on Mathematical Morphology

After extracting the edges of the sample with an improved Canny algorithm, the edge skeleton is extracted based on mathematical morphology. The skeleton method of mathematical morphology is based on the discipline of mathematics. The main idea used for image analysis and recognition is to measure and extract the corresponding shape in the image through certain forms of structural elements. The image passes through mathematical morphology, not only simply causes the original image data information but also removes the unrelated information, retains the fundamental shape properties, and has the structural advantages of native parallel implementation, and finally, the continuous, accurate skeleton is obtained.According to the definition of the largest disc algorithm, the two sets of structural elements are(5)A=A1,A2,A+3,A+4,B=B1,B2,B3,B4.


## 5.2. Skeleton Refinement Treatment

The refinement of the structural elementB on the collection A can be represented as A⊗B, which can be defined depending on hit or missed [9, 10].(6)A⊗B=A−A⊗B=A∩A⊗BC.Refine the image by applying a mathematical morphological analysis algorithm, and the main steps are as follows:(1)
Target imageA, refine y, and use A ⟶ Y;(2)
Makea = a ⊗ bi, where i takes from 1 to 8;(3)
IfA = Y, iteration ends; otherwise, the step (4) is performed;(4)
a ← Y; then, execute (2) step.The sample skeleton after mathematical morphology is shown in Figure2, and the sample skeleton of the single pixel connection is obtained, which greatly reduces the storage amount of the sample.Figure 2
Skeleton.


## 5.3. Oil Edge Optimization

The integrity of the edge plays a key role in the processing of the postimage. Therefore, it is very important to repair the segmented image. This study uses morphological operation to repair edge images. Morphological operations mainly include opening hours and closed [11, 12].The process of advanced corrosion and postexpansion is called opening. The structural elementB is operated on the set A, which is expressed as A∘B, defined as follows:(7)A∘B=AΘB.The process of expanding advanced rises is called closed operation. The structural elementB is closed on the collection A. The representation is A∙B. The definition is as follows:(8)A⋅B=A⊕BΘB.Specifically, in Figure3, a picture after pretreatment, edge extraction, and skeletal refinement of the sample, resulting in a connection phenomenon due to the difference in the edge of the sample, resulting in a connection, and raised in the edge of the model, not flat, is shown. With the morphological operation, the problems shown in Figure 3(a) have been well repaired; as shown in Figure 3(b), ultimately, the smooth continuous curve can be the output, which provides a solid foundation for subsequent operations, which is of important significance [13].Figure 3
Model silhouette (b) after the model skeleton (a) and smooth treatment.
(a)(b)


## 5.4. Vectorized Data Format Output

Since the sample profile will be used in the industrial plate, it is necessary to save the resulting sample contour to the format DxF that can be identified as AutoCAD by graphic exchange files for subsequent processing. DXF is the CAD data file format developed by Autodesk to exchange CAD data between AutoCAD and other softwares.During the plate, most of them use AutoCAD to plate, and the code itself in the DXF format file is good readability, which is convenient for users to modify. Therefore, this study stores the resulting sample contour as a DXF format and finally uses the VisualC++ programming, saving the vectorized data of the saved DXF format to the CAD plate [14].


## 6. Experimental Results and Analysis

According to the target segmentation results in the table above, the segmentation accuracy of the method with manual interaction is higher, but the processing of each image requires manual labeling, resulting in a high time cost. The automatic segmentation method realizes the automatic segmentation of the target image, greatly saving the extraction time, and the accuracy of the traditional method is not much different from the automatic segmentation accuracy. This study uses MATLAB programming, using ordinary clothing samples as testing, and use the above method to extract and optimize [15]. From the experimental results, it can be seen that the improved Canny algorithm can be more accurately divided into the edge of the model, and when extracting the skeleton of the edge profile, it can be seen from the results to see the extracted skeleton has certain coherence. However, there is still a specific set of points and projections in each part of the skeleton. Therefore, in the contour optimization, this problem is well solved, so as to build a single pixel sample contour [16].


## 7. Conclusions

In order to effectively divide the style profile of the women’s image and ensure the effect of subsequent clothing image processing links, this study proposes a clothing image segmentation algorithm for the Canny algorithm. Reproduce and eliminate the edge of the garment, thereby extracting the sharp contiguous clothing profile, and in the simulation experiment, the contour extraction of the multicategory clothing images. After compared analysis, the improved Canny algorithm can more accurately divide the edge of the clothing and extract the contour of the clothing.In this study, we proposed a differentiated visual information method to enhance the contour and weaken the irrelevant texture and design a fusion model of complex cells in the primary visual cortex of biological vision. After verification, this study obtained good extraction results, with the two-dimensional Gaussian derivative function model. However, there are still shortcomings in this study, which can be summarized as follows: in contour extraction, although it can be used to a certain extent, upper weaken texture, there are still some false edges that cannot fully meet the standard of manual extraction contour to be applied in practice that still needs further in-depth research.In future study, there is need to improve the performance of the object contour extraction technology, rather than extraction of single items, making the technology achieve popularization; to extend to the need of the technology fields, such as medicine, agriculture, and environmental protection; to realize the recognition part in clothing styles figure extraction, such as cuff size, neck line, line position, provincial roads, weight, and length of sleeve; and to design the clothing style automatic identification system using the computer to automatically identify the style map.



---

*Source: 7554652-2022-04-11.xml*