# Application of Digital Image Processing Technology in Textile and Garment Field

Authors: Jhan-Rong Shih
Journal: Security and Communication Networks
 (2022)

---

## Abstract

In order to study the shortcomings of traditional manual inspection of clothing, improve the quality of clothing. A method of applying digital image processing technology in the field of textile and clothing is proposed. This method combines computer digital image technology to propose an image processing and measurement process technology based on the Labview platform. Through the effective combination of neural networks and support vector machines, methods such as deep learning can better realize the recognition and classification of clothing images. According to a random interview survey of 80 people, 78 people think that the quality of clothing is the most important, and 2 people think that beauty is the most important. The experimental results show that the digital book processing technology platform can further improve the accuracy of clothing detection.


---

## Body

## 1. Introduction

With the continuous development of computer technology, the new technology represented by digital image processing technology can deeply process the image with the help of computers and other digital technologies, so as to better help people identify and extract the required data information [1]. Compared with the traditional manual technology, this technology has good image reproduction performance, higher processing accuracy, better adaptability, and stronger flexibility. Since the late 1980s, digital image processing technology has been gradually applied to the field of textile and garment inspection, and with the development of computer technology, this technology is becoming more and more mature [2]. And this technology has stronger technical advantages in clothing detection, classification, and evaluation compared with traditional manual detection. With the help of digital image processing technology, it can deeply study the defect points, flatness, and style characteristics of clothing, and effectively avoid the problems and disadvantages of traditional manual detection. Therefore, starting with computer digital image technology, the image processing, and measurement process technology based on the Labview platform is proposed. At the same time, combined with neural networks, support vector machines, deep learning, and other methods, it can better realize the recognition and classification of clothing images [3]. The system architecture is shown in Figure 1.Figure 1
Overall structure of the system.


## 2. Literature Review

Jia et al. said that in today’s world, all countries attach great importance to environmental protection and constantly develop green products [4]. Zu et al. believed that colored cotton, as a typical green product, has become one of the hotspots in cotton research [5]. In 2001, the output of colored cotton in China accounted for about one-third of the global output. Noor et al. said that the output of colored cotton in China has accounted for 16% of the world [6]. At present, China has become the largest colored cotton production base in the world. However, Kohan et al. believe that the research on all aspects of Chinese colored cotton is still in the preliminary stage and a lot of work needs to be done [7]. Saad et al. said that since the optical fiber terminal plays an important role in the optical fiber communication system, the quality requirements for the optical fiber terminal are becoming more and more stringent, which requires a better method to detect the optical fiber terminal [8]. At present, the traditional detection method mainly depends on the manual use of magnifying glass and contour and size detection tools. It not only has low detection efficiency and low accuracy but also has high requirements for the professional quality of detection workers. It has great limitations in modern society with the increasing degree of automation. Sharma et al. believe that although there is some improved testing equipment in the market, it has not been well popularized and applied due to high price, bulky equipment, and weak operability [9]. Therefore, we need to develop a new set of optical fiber terminal detection systems with high-cost performance and practicability.Secim Karakaya et al. said that the research of cultural relics digital service platform mainly uses digital means to digitally store, manage and display cultural relics in the museum [10]. Rahman et al. said that the concept of museum resource digitization originated in the United States in the 1990s. It is a new model for the preservation and utilization of cultural heritage formed under the background of the continuous development of information technology [11]. At present, a lot of research work has been carried out on the digitization of museum resources. For example, it studies the application of Internet + thinking in the field of museums, and designs and implements the museum visualization platform; using digital technology, the management information system of cultural relics in a museum is realized, and the unified management of cultural relics information, warehouse information, expert information, and cultural relics flow is realized; the characteristics of the digital museum are studied, and the application of computer technology in the digital museum is studied; taking the digital construction of cultural relics in Liangzhu Museum as an example, this paper introduces the digital construction mode of cultural relics in the museum from three spatial dimensions: digital record, digital display, and digital communication.In the late 1980s, digital image processing technology began to be applied to textile inspection and became more and more mature. With the in-depth research of digital image processing technology, some researchers began to apply it to the field of clothing, such as clothing defect inspection, clothing flatness inspection, clothing style feature recognition and classification, and so on. Using digital image processing technology to detect and classify clothing effectively avoids the problems of low efficiency, high cost and uncertainty of traditional manual detection methods, and makes the results more objective and efficient.


## 3. Method

### 3.1. Image Processing

Processing and identifying the collected sample terminal image is a vital part of this measurement system [12]. In order to obtain the terminal edge contour, which is convenient for size measurement, we need to carry out a series of processing on the sample image before measurement, including image graying, image denoising, image edge detection, and so on. The system image processing process block diagram is shown in Figure 2.Figure 2
Block diagram of image processing process.Because the collected image is a color image, it cannot well reflect the morphological characteristics of the image during processing, so before a series of image processing, it is necessary to carry out gray processing on the sample image to convert it into a gray image convenient for subsequent processing. The process of image graying is a process of converting color images into grayscale images [13]. Because the image measurement mainly depends on the accuracy of image edge structure feature extraction, it requires that the gray information around the image edge cannot be destroyed in the process of graying. However, in real life, there are great differences in the brightness information of images collected from workpieces with different materials, which makes it impossible for us to use a specific grayscale model for grayscale. Therefore, the graying of the image not only needs to take a variety of methods but also needs to select the appropriate graying algorithm according to the image edge type and the actual situation. The same as the gray image, the binary image only needs one data matrix, and only two gray values are taken for each pixel. Binary images can be stored in Unit8 or double type. The functions in the toolbox that use binary images as return results use Unit8 type [14]. In MATLAB, the conversion relationship between various image types is shown in Figure 3.Figure 3
Conversion between image types.At present, in the process of image processing, the commonly used color image formats include RGB, HSV, HLS, and so on. Since they are all composed of three primary colors, we can adopt the following methods for graying:(1)
NTSC TV system zero degree formula is(1)Y=0.2990.5870.144RGBT.(2)
The brightness formula of PAL TV system is(2)Y=0.2220.7070.071RGBT.(3)
CIE three primary color relative brightness equation is(3)Y=14.59070.0601RGBT.(4)
The color components of each channel are averaged:(4)Y=131313RGBT.A color image is represented by one of the three primary colors. Expressed by the maximum of the three primary colors:(5)Y=MaxRGB.In the process of image acquisition and transmission, it is inevitable to encounter noise and interference, resulting in a certain degree of distortion [15]. Therefore, before processing the image, it is often necessary to filter and denoise the noisy image to make it smooth. According to different requirements and the diversity of noise, there are many filtering methods for us to choose from, and each has its own advantages and disadvantages. Therefore, using appropriate filtering methods to denoise noisy images is also an important link that cannot be ignored in this detection system [16]. Firstly, this section introduces two common filtering methods in the spatial domain-mean filtering and median filtering, analyzes their filtering principles and uses two denoising methods to filter the sample image, compare their differences, and choose the best.


#### 3.1.1. Mean Filtering Method

Mean filtering is a local processing algorithm in spatial domain, which is used to smooth the image. Assuming thatf (x, y) is the original image, S is a neighborhood of points (i, j), M is the number of pixels in neighborhood (i, j), and gx,y is the image obtained after filtering, the mean value can be expressed by filtering:(6)gx,y1M∑i,j⊂sfx,yx,y=0,1,2,…,N−1.The mean filtering algorithm is relatively simple, and the calculation speed is very fast [17]. However, the smoothing effect of mean filtering is mainly determined by the neighborhood radius used. Generally, the larger the neighborhood radius is, the more blurred the smooth image is, which will lead to weaker and weaker image information, which is not conducive to the subsequent processing of the image. The commonly used 3 × 3 and 5 × 5 mean filter templates are shown in Figure 4.Figure 4
3 × 3 and 5 × 5 mean filter template.The optical fiber terminal images are filtered by means of templates of 3 × 3 and 5 × 5, respectively [18]. When a 3 × 3 template is used to smooth the image of the optical fiber terminal, the effect is good, while when a 5 × 5 template is used to process, the edge and details of the image appear obvious blur, which is not suitable for subsequent processing.


#### 3.1.2. Median Filtering Method

As a nonlinear filter, the median filter does not need image statistical characteristics in the actual operation process, so it is particularly convenient to use. Compared with linear filtering, it can reduce the image blur caused by filtering to a certain extent. We often use the median filtering method for image noise scanning and pulse interference removal [19]. The principle of median filtering is to use the median value of the gray value of each point in the sliding window (the neighborhood is an odd number of points) to replace the gray value of the pixel at the center of the window. Assuming a one-dimensional sequence with a sliding window length of L (L is an odd number), the median filter is performed on it, which is expressed by a mathematical formula:(7)Yi=Medfi−v⋯fi−1fifi+1⋯fi+v.As shown in formula(8)i∈z,V=m−12.Similarly, the median filtering of two-dimensional data can be expressed as(9)Yi=MedXij.Generally, two-dimensional median filter has a better noise suppression effect than one-dimensional median filter. The two-dimensional median filtering windows have different effects. In practical application, we should select the filtering window according to the specific content of the image to be processed [20]. Similarly, in the process of median filtering, we should also pay attention to the size of the window used, and choose the best according to the specific filtering effect. The commonly used size is 3 × 3, 5 × 5, 7 × 7, etc. The images of optical fiber terminals are processed by median filtering with templates of 3 × 3 and 5 × 5, respectively.


#### 3.1.3. Comparison between Median Filtering Method and Mean Filtering Method

Median filter and mean filter are commonly used filtering algorithms, both of which have a smoothing effect. Among them, median filter is suitable for removing impulse interference, while the mean filter is good at suppressing random noise, which has its own advantages and disadvantages.In contrast, the mean filter is easier to implement, while the median filter needs a long calculation time. The median filter method and the mean filter method are, respectively, 3 × 3, 5 × 5, 7 × 7 templates to filter and measure the average time-consuming as shown in Table1.Table 1
Time-consuming comparison.
Filtering methodTemplate size3 × 35 × 57 × 7Mean filtering19.139.3101.3Median filtering15.4130.1490.4From Table1, we can see that with the increase of the user window, the time consumption of the median filter and mean filter has increased significantly, among which the time consumption of the median filter has increased more. However, when using 3 × 3 templates, the median filter takes slightly less time than the mean filter.


### 3.2. Image Segmentation

We often use the following two methods for image segmentation: one is image segmentation based on threshold selection, and the other is image segmentation based on edge detection. The image segmentation algorithm based on edge detection is vulnerable to noise. Although the image is preprocessed, there will be noise that affects the edge segmentation.


### 3.3. Threshold Segmentation

For gray threshold segmentation, we must first determine a threshold to distinguish the object from the background. The pixels within the threshold belong to the target object, and the pixels outside the threshold belong to the background; or on the contrary, the pixels within the threshold belong to the background, and the pixels outside the threshold belong to the target object [21, 22]. Using this method to segment the image with obvious differences between target and background, the effect is very good. When the target and background in the image have completely different gray sets: the target set and background gray set, the two gray sets can be segmented by a gray level threshold t. In this way, the threshold segmentation gray level method can be used to segment the image and segment the target area and background area. This segmentation method is called the gray threshold segmentation method.Set the gray value range of imagef (x, y) as [a, b], and find an appropriate threshold in F (x, y) with certain criteria:(10)ta≤y≤b.Thus,(11)gx,y=1,fx,y≥t,0,fx,y<t.Or(12)gx,y=1,fx,y≤t,0,fx,y>t.Set the threshold gray value range as [t1, t2](13)gx,y=1,t1≤fx,y≤t,0,other.The principle of threshold segmentation can be expressed as(14)gx,y=ZE,fx,y∈Z,ZB,other.Before selecting the threshold, we usually need to draw the gray histogram of the image. If only the histogram corresponding to the two regions of the target and the background is bimodal and has an obvious valley bottom, we can take the gray value corresponding to the valley bottom point as the thresholdT, and then segment the image according to the threshold, so as to segment the target from the image. Of course, we will inevitably encounter the situation that the gray distribution of the target and background is too scattered or their distribution is partially staggered, which makes it difficult to select the threshold with the help of a histogram, and other methods need to be taken to determine the threshold t. The following centralized methods are also based on gray histogram. The difference is that it is not determined manually, but through a certain algorithm, so as to eliminate the influence of thought factors [23]. Figure 5 is a gray histogram of a general image, where i represents the gray value, k is the threshold, h(i) represents the number of occurrences of each pixel in the image, N represents the number of gray values of the image, and n is the total number of pixels in the image.Figure 5
General image gray histogram.The clustering method and minimum measurement method are introduced below.Clustering method: in this method, the thresholdK is determined by the following formula(15)k=μ1+μ22,where μ1 is the average value of pixel values in the range of 0 to K, and μ2 is the average value of pixel values in the range of K + 1 to 255.Minimum measurement method: the thresholdK of the minimum measurement method is the gray value that minimizes the value of the following formula:(16)∑i=0i=khii−μ1+∑i=k+1i=N−1hii−μ2.The edge detection operator is realized in the form of template convolution. The gradient operator needs the combination of two templates to form a complete operator. Common gradient template operators are shown in Figures6–8.Figure 6
Robert operator.Figure 7
Sobel operator.Figure 8
Prewitt operator.


### 3.4. System Function and Technology

The system function and technology are mainly composed of a CCD camera, light source, image acquisition card, Labview image processing software, and computer. Its working process is as follows: firstly, the CCD camera is used to collect the image information of the sample terminal and transfer it to the image acquisition card to convert it into an electrical signal to realize the digitization of image information. Then, Labview image processing software is used on the computer to process the digital image, obtain its contour, size, and other information, and then measure it [24]. Finally, the measurement results are compared with the sample parameters to judge whether they meet the requirements and complete the whole measurement process.Due to the complexity of measuring objects and the diversity of lighting equipment, there is no general machine vision lighting equipment for us to choose. Therefore, we should choose the actual measured object and experimental conditions in order to obtain high-quality images. Therefore, the design of the lighting system should include two aspects: the selection of light source and the design of the lighting scheme.The selection of light source equipment should not only consider the service life and luminous efficiency of the light source but also select the geometric shape, uniformity, luminous spectrum, memory illumination brightness, and other characteristics of the measured object. Light sources are generally divided into visible light sources and invisible light sources. Common visible light sources include a fluorescent lamp, incandescent lamp, sodium lamp, led, mercury lamp, etc.There are four main indicators of lenses, namely, focal length, field of view, working distance, and depth of field. According to the focal length, we often divide the lens into wide-angle lens, standard lens, and long focal length lens. The depth of field is directly affected by the focal length, viewing angle, and minimum working distance. If the focal length is small, the depth of field is large, and if the minimum working distance is far, the depth of field is small [25]. In the visual measurement system, we should try to choose the lens with a short working distance, small lens distortion, and large field of vision. We should try to choose the lens with a short working distance, small lens distortion, and large field of vision. In addition, our commonly used zoom lens can be divided into: “1/3,” “2/3,” “1/2” and “1” in rules. When selecting the zoom lens, we should pay particular attention to that: the specification of the camera must be less than that of the lens.Figure 9
Schematic diagram of lens imaging.


### 3.5. Software Design of Detection System

#### 3.5.1. System Software Design Process

According to the size measurement requirements of optical fiber terminals, the software design flow of the system is shown in Figure10:Figure 10
System software design flow chart.Because the system is designed based on Labview platform, we make full use of its modular design idea to modularize the whole design process. The system program is mainly composed of the main program and function module subroutine. Among them, the function module subroutine includes the image acquisition module program, image processing module program, and size measurement program; The main program is responsible for presenting the whole measurement process to the operator on the front panel for operation [26].


#### 3.5.2. Design of Image Acquisition Module

First, initialize the camera, then cache the collected image into the data buffer, and enter the image processing module for processing after the current cycle.


#### 3.5.3. Image Denoising

In the process of image acquisition and transmission, it is inevitable to produce noise, which will have a certain impact on the image, which requires us to take appropriate methods to denoise the image. The process of denoising is the process of filtering. Labview gives us many filtering algorithms to choose from, including linear filtering and nonlinear filtering, as well as spatial filtering and frequency domain filtering. The system adopts two commonly used filtering methods in spatial domain-mean filtering and median filtering to filter and select the best.


#### 3.5.4. Image Binarization

Binarization is to convert the gray value of the digital image into 0 or 255 by setting the threshold to become a black-and-white image. Among them, the gray value greater than the threshold is converted to 255, and the gray value less than the threshold is converted to 0.


#### 3.5.5. Edge Detection

After binarization, the gray value of the image is only 0 and 255. Edge detection can make us clearly see the outline of the terminal. The quality of the edge detection algorithm directly affects the complexity and accuracy of the measurement algorithm.


#### 3.5.6. Dimension Measurement

Size measurement is the ultimate goal of the whole system. Its process is as follows: firstly, the processed terminal images are scanned in rows and columns respectively, and the pixels with a gray value not 0 in each row (column) of the digital image are counted and stored in a new array. The obtained statistical array value of pixels is the distance between image edges. Because the sample terminal is not a standard two-dimensional object, we draw the histogram of the new array and sample the data of the smooth segment. Finally, average the collected data to obtain the required terminal length (width) [27], as shown in Figure 11.Figure 11
Flow chart of dimension measurement.


## 3.1. Image Processing

Processing and identifying the collected sample terminal image is a vital part of this measurement system [12]. In order to obtain the terminal edge contour, which is convenient for size measurement, we need to carry out a series of processing on the sample image before measurement, including image graying, image denoising, image edge detection, and so on. The system image processing process block diagram is shown in Figure 2.Figure 2
Block diagram of image processing process.Because the collected image is a color image, it cannot well reflect the morphological characteristics of the image during processing, so before a series of image processing, it is necessary to carry out gray processing on the sample image to convert it into a gray image convenient for subsequent processing. The process of image graying is a process of converting color images into grayscale images [13]. Because the image measurement mainly depends on the accuracy of image edge structure feature extraction, it requires that the gray information around the image edge cannot be destroyed in the process of graying. However, in real life, there are great differences in the brightness information of images collected from workpieces with different materials, which makes it impossible for us to use a specific grayscale model for grayscale. Therefore, the graying of the image not only needs to take a variety of methods but also needs to select the appropriate graying algorithm according to the image edge type and the actual situation. The same as the gray image, the binary image only needs one data matrix, and only two gray values are taken for each pixel. Binary images can be stored in Unit8 or double type. The functions in the toolbox that use binary images as return results use Unit8 type [14]. In MATLAB, the conversion relationship between various image types is shown in Figure 3.Figure 3
Conversion between image types.At present, in the process of image processing, the commonly used color image formats include RGB, HSV, HLS, and so on. Since they are all composed of three primary colors, we can adopt the following methods for graying:(1)
NTSC TV system zero degree formula is(1)Y=0.2990.5870.144RGBT.(2)
The brightness formula of PAL TV system is(2)Y=0.2220.7070.071RGBT.(3)
CIE three primary color relative brightness equation is(3)Y=14.59070.0601RGBT.(4)
The color components of each channel are averaged:(4)Y=131313RGBT.A color image is represented by one of the three primary colors. Expressed by the maximum of the three primary colors:(5)Y=MaxRGB.In the process of image acquisition and transmission, it is inevitable to encounter noise and interference, resulting in a certain degree of distortion [15]. Therefore, before processing the image, it is often necessary to filter and denoise the noisy image to make it smooth. According to different requirements and the diversity of noise, there are many filtering methods for us to choose from, and each has its own advantages and disadvantages. Therefore, using appropriate filtering methods to denoise noisy images is also an important link that cannot be ignored in this detection system [16]. Firstly, this section introduces two common filtering methods in the spatial domain-mean filtering and median filtering, analyzes their filtering principles and uses two denoising methods to filter the sample image, compare their differences, and choose the best.


### 3.1.1. Mean Filtering Method

Mean filtering is a local processing algorithm in spatial domain, which is used to smooth the image. Assuming thatf (x, y) is the original image, S is a neighborhood of points (i, j), M is the number of pixels in neighborhood (i, j), and gx,y is the image obtained after filtering, the mean value can be expressed by filtering:(6)gx,y1M∑i,j⊂sfx,yx,y=0,1,2,…,N−1.The mean filtering algorithm is relatively simple, and the calculation speed is very fast [17]. However, the smoothing effect of mean filtering is mainly determined by the neighborhood radius used. Generally, the larger the neighborhood radius is, the more blurred the smooth image is, which will lead to weaker and weaker image information, which is not conducive to the subsequent processing of the image. The commonly used 3 × 3 and 5 × 5 mean filter templates are shown in Figure 4.Figure 4
3 × 3 and 5 × 5 mean filter template.The optical fiber terminal images are filtered by means of templates of 3 × 3 and 5 × 5, respectively [18]. When a 3 × 3 template is used to smooth the image of the optical fiber terminal, the effect is good, while when a 5 × 5 template is used to process, the edge and details of the image appear obvious blur, which is not suitable for subsequent processing.


### 3.1.2. Median Filtering Method

As a nonlinear filter, the median filter does not need image statistical characteristics in the actual operation process, so it is particularly convenient to use. Compared with linear filtering, it can reduce the image blur caused by filtering to a certain extent. We often use the median filtering method for image noise scanning and pulse interference removal [19]. The principle of median filtering is to use the median value of the gray value of each point in the sliding window (the neighborhood is an odd number of points) to replace the gray value of the pixel at the center of the window. Assuming a one-dimensional sequence with a sliding window length of L (L is an odd number), the median filter is performed on it, which is expressed by a mathematical formula:(7)Yi=Medfi−v⋯fi−1fifi+1⋯fi+v.As shown in formula(8)i∈z,V=m−12.Similarly, the median filtering of two-dimensional data can be expressed as(9)Yi=MedXij.Generally, two-dimensional median filter has a better noise suppression effect than one-dimensional median filter. The two-dimensional median filtering windows have different effects. In practical application, we should select the filtering window according to the specific content of the image to be processed [20]. Similarly, in the process of median filtering, we should also pay attention to the size of the window used, and choose the best according to the specific filtering effect. The commonly used size is 3 × 3, 5 × 5, 7 × 7, etc. The images of optical fiber terminals are processed by median filtering with templates of 3 × 3 and 5 × 5, respectively.


### 3.1.3. Comparison between Median Filtering Method and Mean Filtering Method

Median filter and mean filter are commonly used filtering algorithms, both of which have a smoothing effect. Among them, median filter is suitable for removing impulse interference, while the mean filter is good at suppressing random noise, which has its own advantages and disadvantages.In contrast, the mean filter is easier to implement, while the median filter needs a long calculation time. The median filter method and the mean filter method are, respectively, 3 × 3, 5 × 5, 7 × 7 templates to filter and measure the average time-consuming as shown in Table1.Table 1
Time-consuming comparison.
Filtering methodTemplate size3 × 35 × 57 × 7Mean filtering19.139.3101.3Median filtering15.4130.1490.4From Table1, we can see that with the increase of the user window, the time consumption of the median filter and mean filter has increased significantly, among which the time consumption of the median filter has increased more. However, when using 3 × 3 templates, the median filter takes slightly less time than the mean filter.


## 3.1.1. Mean Filtering Method

Mean filtering is a local processing algorithm in spatial domain, which is used to smooth the image. Assuming thatf (x, y) is the original image, S is a neighborhood of points (i, j), M is the number of pixels in neighborhood (i, j), and gx,y is the image obtained after filtering, the mean value can be expressed by filtering:(6)gx,y1M∑i,j⊂sfx,yx,y=0,1,2,…,N−1.The mean filtering algorithm is relatively simple, and the calculation speed is very fast [17]. However, the smoothing effect of mean filtering is mainly determined by the neighborhood radius used. Generally, the larger the neighborhood radius is, the more blurred the smooth image is, which will lead to weaker and weaker image information, which is not conducive to the subsequent processing of the image. The commonly used 3 × 3 and 5 × 5 mean filter templates are shown in Figure 4.Figure 4
3 × 3 and 5 × 5 mean filter template.The optical fiber terminal images are filtered by means of templates of 3 × 3 and 5 × 5, respectively [18]. When a 3 × 3 template is used to smooth the image of the optical fiber terminal, the effect is good, while when a 5 × 5 template is used to process, the edge and details of the image appear obvious blur, which is not suitable for subsequent processing.


## 3.1.2. Median Filtering Method

As a nonlinear filter, the median filter does not need image statistical characteristics in the actual operation process, so it is particularly convenient to use. Compared with linear filtering, it can reduce the image blur caused by filtering to a certain extent. We often use the median filtering method for image noise scanning and pulse interference removal [19]. The principle of median filtering is to use the median value of the gray value of each point in the sliding window (the neighborhood is an odd number of points) to replace the gray value of the pixel at the center of the window. Assuming a one-dimensional sequence with a sliding window length of L (L is an odd number), the median filter is performed on it, which is expressed by a mathematical formula:(7)Yi=Medfi−v⋯fi−1fifi+1⋯fi+v.As shown in formula(8)i∈z,V=m−12.Similarly, the median filtering of two-dimensional data can be expressed as(9)Yi=MedXij.Generally, two-dimensional median filter has a better noise suppression effect than one-dimensional median filter. The two-dimensional median filtering windows have different effects. In practical application, we should select the filtering window according to the specific content of the image to be processed [20]. Similarly, in the process of median filtering, we should also pay attention to the size of the window used, and choose the best according to the specific filtering effect. The commonly used size is 3 × 3, 5 × 5, 7 × 7, etc. The images of optical fiber terminals are processed by median filtering with templates of 3 × 3 and 5 × 5, respectively.


## 3.1.3. Comparison between Median Filtering Method and Mean Filtering Method

Median filter and mean filter are commonly used filtering algorithms, both of which have a smoothing effect. Among them, median filter is suitable for removing impulse interference, while the mean filter is good at suppressing random noise, which has its own advantages and disadvantages.In contrast, the mean filter is easier to implement, while the median filter needs a long calculation time. The median filter method and the mean filter method are, respectively, 3 × 3, 5 × 5, 7 × 7 templates to filter and measure the average time-consuming as shown in Table1.Table 1
Time-consuming comparison.
Filtering methodTemplate size3 × 35 × 57 × 7Mean filtering19.139.3101.3Median filtering15.4130.1490.4From Table1, we can see that with the increase of the user window, the time consumption of the median filter and mean filter has increased significantly, among which the time consumption of the median filter has increased more. However, when using 3 × 3 templates, the median filter takes slightly less time than the mean filter.


## 3.2. Image Segmentation

We often use the following two methods for image segmentation: one is image segmentation based on threshold selection, and the other is image segmentation based on edge detection. The image segmentation algorithm based on edge detection is vulnerable to noise. Although the image is preprocessed, there will be noise that affects the edge segmentation.


## 3.3. Threshold Segmentation

For gray threshold segmentation, we must first determine a threshold to distinguish the object from the background. The pixels within the threshold belong to the target object, and the pixels outside the threshold belong to the background; or on the contrary, the pixels within the threshold belong to the background, and the pixels outside the threshold belong to the target object [21, 22]. Using this method to segment the image with obvious differences between target and background, the effect is very good. When the target and background in the image have completely different gray sets: the target set and background gray set, the two gray sets can be segmented by a gray level threshold t. In this way, the threshold segmentation gray level method can be used to segment the image and segment the target area and background area. This segmentation method is called the gray threshold segmentation method.Set the gray value range of imagef (x, y) as [a, b], and find an appropriate threshold in F (x, y) with certain criteria:(10)ta≤y≤b.Thus,(11)gx,y=1,fx,y≥t,0,fx,y<t.Or(12)gx,y=1,fx,y≤t,0,fx,y>t.Set the threshold gray value range as [t1, t2](13)gx,y=1,t1≤fx,y≤t,0,other.The principle of threshold segmentation can be expressed as(14)gx,y=ZE,fx,y∈Z,ZB,other.Before selecting the threshold, we usually need to draw the gray histogram of the image. If only the histogram corresponding to the two regions of the target and the background is bimodal and has an obvious valley bottom, we can take the gray value corresponding to the valley bottom point as the thresholdT, and then segment the image according to the threshold, so as to segment the target from the image. Of course, we will inevitably encounter the situation that the gray distribution of the target and background is too scattered or their distribution is partially staggered, which makes it difficult to select the threshold with the help of a histogram, and other methods need to be taken to determine the threshold t. The following centralized methods are also based on gray histogram. The difference is that it is not determined manually, but through a certain algorithm, so as to eliminate the influence of thought factors [23]. Figure 5 is a gray histogram of a general image, where i represents the gray value, k is the threshold, h(i) represents the number of occurrences of each pixel in the image, N represents the number of gray values of the image, and n is the total number of pixels in the image.Figure 5
General image gray histogram.The clustering method and minimum measurement method are introduced below.Clustering method: in this method, the thresholdK is determined by the following formula(15)k=μ1+μ22,where μ1 is the average value of pixel values in the range of 0 to K, and μ2 is the average value of pixel values in the range of K + 1 to 255.Minimum measurement method: the thresholdK of the minimum measurement method is the gray value that minimizes the value of the following formula:(16)∑i=0i=khii−μ1+∑i=k+1i=N−1hii−μ2.The edge detection operator is realized in the form of template convolution. The gradient operator needs the combination of two templates to form a complete operator. Common gradient template operators are shown in Figures6–8.Figure 6
Robert operator.Figure 7
Sobel operator.Figure 8
Prewitt operator.


## 3.4. System Function and Technology

The system function and technology are mainly composed of a CCD camera, light source, image acquisition card, Labview image processing software, and computer. Its working process is as follows: firstly, the CCD camera is used to collect the image information of the sample terminal and transfer it to the image acquisition card to convert it into an electrical signal to realize the digitization of image information. Then, Labview image processing software is used on the computer to process the digital image, obtain its contour, size, and other information, and then measure it [24]. Finally, the measurement results are compared with the sample parameters to judge whether they meet the requirements and complete the whole measurement process.Due to the complexity of measuring objects and the diversity of lighting equipment, there is no general machine vision lighting equipment for us to choose. Therefore, we should choose the actual measured object and experimental conditions in order to obtain high-quality images. Therefore, the design of the lighting system should include two aspects: the selection of light source and the design of the lighting scheme.The selection of light source equipment should not only consider the service life and luminous efficiency of the light source but also select the geometric shape, uniformity, luminous spectrum, memory illumination brightness, and other characteristics of the measured object. Light sources are generally divided into visible light sources and invisible light sources. Common visible light sources include a fluorescent lamp, incandescent lamp, sodium lamp, led, mercury lamp, etc.There are four main indicators of lenses, namely, focal length, field of view, working distance, and depth of field. According to the focal length, we often divide the lens into wide-angle lens, standard lens, and long focal length lens. The depth of field is directly affected by the focal length, viewing angle, and minimum working distance. If the focal length is small, the depth of field is large, and if the minimum working distance is far, the depth of field is small [25]. In the visual measurement system, we should try to choose the lens with a short working distance, small lens distortion, and large field of vision. We should try to choose the lens with a short working distance, small lens distortion, and large field of vision. In addition, our commonly used zoom lens can be divided into: “1/3,” “2/3,” “1/2” and “1” in rules. When selecting the zoom lens, we should pay particular attention to that: the specification of the camera must be less than that of the lens.Figure 9
Schematic diagram of lens imaging.


## 3.5. Software Design of Detection System

### 3.5.1. System Software Design Process

According to the size measurement requirements of optical fiber terminals, the software design flow of the system is shown in Figure10:Figure 10
System software design flow chart.Because the system is designed based on Labview platform, we make full use of its modular design idea to modularize the whole design process. The system program is mainly composed of the main program and function module subroutine. Among them, the function module subroutine includes the image acquisition module program, image processing module program, and size measurement program; The main program is responsible for presenting the whole measurement process to the operator on the front panel for operation [26].


### 3.5.2. Design of Image Acquisition Module

First, initialize the camera, then cache the collected image into the data buffer, and enter the image processing module for processing after the current cycle.


### 3.5.3. Image Denoising

In the process of image acquisition and transmission, it is inevitable to produce noise, which will have a certain impact on the image, which requires us to take appropriate methods to denoise the image. The process of denoising is the process of filtering. Labview gives us many filtering algorithms to choose from, including linear filtering and nonlinear filtering, as well as spatial filtering and frequency domain filtering. The system adopts two commonly used filtering methods in spatial domain-mean filtering and median filtering to filter and select the best.


### 3.5.4. Image Binarization

Binarization is to convert the gray value of the digital image into 0 or 255 by setting the threshold to become a black-and-white image. Among them, the gray value greater than the threshold is converted to 255, and the gray value less than the threshold is converted to 0.


### 3.5.5. Edge Detection

After binarization, the gray value of the image is only 0 and 255. Edge detection can make us clearly see the outline of the terminal. The quality of the edge detection algorithm directly affects the complexity and accuracy of the measurement algorithm.


### 3.5.6. Dimension Measurement

Size measurement is the ultimate goal of the whole system. Its process is as follows: firstly, the processed terminal images are scanned in rows and columns respectively, and the pixels with a gray value not 0 in each row (column) of the digital image are counted and stored in a new array. The obtained statistical array value of pixels is the distance between image edges. Because the sample terminal is not a standard two-dimensional object, we draw the histogram of the new array and sample the data of the smooth segment. Finally, average the collected data to obtain the required terminal length (width) [27], as shown in Figure 11.Figure 11
Flow chart of dimension measurement.


## 3.5.1. System Software Design Process

According to the size measurement requirements of optical fiber terminals, the software design flow of the system is shown in Figure10:Figure 10
System software design flow chart.Because the system is designed based on Labview platform, we make full use of its modular design idea to modularize the whole design process. The system program is mainly composed of the main program and function module subroutine. Among them, the function module subroutine includes the image acquisition module program, image processing module program, and size measurement program; The main program is responsible for presenting the whole measurement process to the operator on the front panel for operation [26].


## 3.5.2. Design of Image Acquisition Module

First, initialize the camera, then cache the collected image into the data buffer, and enter the image processing module for processing after the current cycle.


## 3.5.3. Image Denoising

In the process of image acquisition and transmission, it is inevitable to produce noise, which will have a certain impact on the image, which requires us to take appropriate methods to denoise the image. The process of denoising is the process of filtering. Labview gives us many filtering algorithms to choose from, including linear filtering and nonlinear filtering, as well as spatial filtering and frequency domain filtering. The system adopts two commonly used filtering methods in spatial domain-mean filtering and median filtering to filter and select the best.


## 3.5.4. Image Binarization

Binarization is to convert the gray value of the digital image into 0 or 255 by setting the threshold to become a black-and-white image. Among them, the gray value greater than the threshold is converted to 255, and the gray value less than the threshold is converted to 0.


## 3.5.5. Edge Detection

After binarization, the gray value of the image is only 0 and 255. Edge detection can make us clearly see the outline of the terminal. The quality of the edge detection algorithm directly affects the complexity and accuracy of the measurement algorithm.


## 3.5.6. Dimension Measurement

Size measurement is the ultimate goal of the whole system. Its process is as follows: firstly, the processed terminal images are scanned in rows and columns respectively, and the pixels with a gray value not 0 in each row (column) of the digital image are counted and stored in a new array. The obtained statistical array value of pixels is the distance between image edges. Because the sample terminal is not a standard two-dimensional object, we draw the histogram of the new array and sample the data of the smooth segment. Finally, average the collected data to obtain the required terminal length (width) [27], as shown in Figure 11.Figure 11
Flow chart of dimension measurement.


## 4. Results and Analysis

It is complex and costly to use the method of thread removal or digitizer to analyze the clothing style. The use of digital image processing technology cannot only quickly identify and classify the style information of clothing images but also realize the conversion between style maps and structure maps. Among them, the commonly used clothing pictures are clothing style drawings and clothing object drawings.For the extraction of clothing contour, a fuzzy clustering algorithm is proposed to recognize and classify clothing styles, but this method is only suitable for the recognition of local contour segments. The combination of Fourier descriptor and support vector machine is used to identify clothing styles, which cannot only identify many kinds of clothing styles quickly and effectively, but also has good robustness, but it cannot correspond to the clothing contour one by one; By extracting the curvature extreme points from the clothing contour curve to represent the clothing contour shape, a clothing style recognition method based on the contour curvature feature points is proposed. The algorithm is simple to operate, and can more intuitively show the characteristic information of clothing contour.The most commonly used method in texture feature extraction is the gray level co-occurrence matrix, which can better reflect the texture information of the image, and the principle is simple and easy to understand [28]. Based on this, a texture feature extraction method combining a local two-mode algorithm and gray level co-occurrence matrix is proposed in the literature. This method has good anti-rotation. When the clothing image rotates, this method has higher detection efficiency and accuracy than the traditional texture feature extraction method. In order to improve the accuracy of image recognition, a parallel fusion method based on contour and texture features is proposed in the literature to extract the structural and statistical features of clothing images. This method can recognize and describe clothing style images more comprehensively [29].The traditional methods to identify the types of clothing fabrics include the hand touch method, combustion method, microscope observation method. These methods need the help of clothing objects, and are vulnerable to environmental factors. Garment fabric recognition based on image processing technology mainly extracts fabric attributes from garment fabric images for simulation, so as to achieve the purpose of fabric recognition. Fabric simulation is carried out by using the garment fold information extracted from the fabric images of different materials and different yarn counts. The effect of the simulation image and the physical image is compared to realize the garment fabric recognition. This method has high accuracy, but it needs repeated simulation experiments to achieve the ideal effect, and the recognition efficiency is low.With the development of information technology, many designers begin to design fabric patterns and clothing with the help of design software. With the help of image processing technology, emotional semantic recognition of clothing fabric images cannot only provide emotional judgment for designers but also provide a reference for consumers. The fabric color and texture features are used to represent the fabric’s emotional semantics, the expression of features and semantics is constructed, and the recognition and classification of fabric image emotional semantics are realized by a support vector machine. On this basis, combined with image feature extraction and classification algorithm and dynamic link technology, a web-based fabric image emotional semantic recognition module is developed. This method provides a simple and easy retrieval method for customers and meets the emotional needs of consumers when selecting goods.Clothing modeling evaluation usually adopts a subjective evaluation method, and the evaluation results cannot be quantified. In addition, the individual aesthetic differences lead to the poor consistency of the evaluation results. The common method of image-based garment modeling evaluation is to use image processing software to extract the evaluation indexes reflecting garment modeling from garment images from different angles, such as fold, angle, curvature, and so on. Combined with the correlation between subjective evaluation index and evaluation grade, an evaluation system is established.In view of the disadvantages of subjective evaluation, the literature attempts to quantitatively evaluate the influence of different fabric properties on skirt modeling such as A-line skirts, pleated skirts, and ultra-short skirts by using image processing technology. Photoshop, MATLAB, and other software are used to process and analyze the appearance images of skirts in different directions, extract the indicators reflecting skirt modelings such as area, length, angle, and fold, and construct the evaluation system by combining the methods of principal component analysis and factor analysis. Through the above methods, curvature analysis is proposed to objectively evaluate the roundness of the lapel collar. The fold line of the back neckline is extracted from the gray image by Photoshop software, and four characteristic indexes in the target curve are extracted by ugnx10.0 software, including the number of turns, the maximum value of curvature range, the sum of curvature range and the coefficient of variation of curvature range, so as to characterize the roundness of the lapel.With the development of image processing technology, some researchers also try to use images to analyze the relationship between human body and clothing contour. The definition of human body section width feature is proposed to identify clothing profile. AdaBoost algorithm is used for face recognition to obtain face size information, and then threshold segmentation, denoising, and human body proportion division are carried out. The width of each section is extracted by line-by-line scanning, and the clothing profile is represented by each width proportion. This method uses shape proportion to quantify clothing contour and has high recognition degree. The pixel statistics of terminal width obtained by scanning are shown in Figure12:Figure 12
Terminal width pixel statistics.In order to solve the difficulty of fitting online shopping, virtual fitting technology has attracted more and more attention. At present, the common virtual fitting systems are mainly divided into three categories: virtual fitting mirror, which uses the user’s Avatar to directly replace the fitting model’s Avatar and shows the fitting effect through simple local body shape adjustment; Somatosensory fitting mirror, matching the segmented clothing image on the collected user image; the three-dimensional digital fitting system obtains the user’s three-dimensional information through the three-dimensional data acquisition device and matches the three-dimensional clothing model to the constructed human model. Virtual fitting mirrors and somatosensory fitting mirrors can realize the virtual fitting display effect only through simple image preprocessing, image segmentation, image matching, and other methods, but users can only see the two-dimensional dressing effect. At the same time, due to individual differences, the matching effect has great defects. According to a random interview survey of 80 people, 78 people think that the quality of clothing is the most important, and 2 people think that beauty is the most important. The experimental results show that the digital book processing technology platform can further improve the accuracy of clothing detection. It proves that the application of digital image processing technology in the field of textile and clothing is feasible, effectively solves the quality problem of clothing inspection, can meet the needs of merchants for high and accurate clothing quality inspection, and can make up for the low detection ability of traditional artificial clothing, and improve the factory’s quality. Work efficiency. The human body and clothing information in the three-dimensional digital fitting system comes from the three-dimensional point cloud image, which can show the three-dimensional dressing effect. The matching effect is good, but it is time-consuming and poor in real-time.


## 5. Conclusion

It proves that the application of digital image processing technology in the field of textile and garment is feasible, effectively solves the quality problem of garment detection, meets the needs of merchants for high and accurate garment quality inspection, makes up for the low detection ability of traditional artificial clothing, and improves the work efficiency of the factory. Combined with the current application research of image processing technology in the field of clothing, it is found that the simulation of clothing fabric material and touch is the key problem in the current virtual fitting. Due to the unique texture structure of clothing fabrics, fabrics with different materials and attributes have their own unique texture characteristics. For material simulation, the image processing algorithm is proposed to obtain the spectrum distribution image of clothing fabric, extract the texture feature parameters according to the change of spectrum information, and reconstruct the image combined with reverse engineering technology to realize the virtual simulation of clothing fabric material. In addition, the tactile simulation of fabrics is still a major difficulty and focus in future research. Nowadays, intellectualization is the focus of research in the field of clothing. Consumers are more and more inclined to intelligently recommend clothing matching in line with their own style. Therefore, combined with image automatic acquisition technology, image processing technology, virtual fitting, neural network, and expert system, it is the trend of future research to build an integrated clothing style recognition and matching recommendation system. Based on the current research situation of digital image processing technology in the clothing field, realizing the virtual simulation of clothing fabric touch and building an intelligent clothing matching recommendation system is the research focus of realizing intelligence and integration in the clothing field. Therefore, we should combine the existing research with new theories and technologies to make the garment field develop in a more intelligent and integrated direction.



---

*Source: 7971811-2022-08-17.xml*