Scarf Defect Detection Method Based on Periodicity of Braided Texture

The pure color scarf image is a typical periodic texture image. Based on the periodicity of scarf image texture, in order to eliminate the influence of periodical change of gray value of scarf image on scarf defect detection caused by periodic texture change, a defect detection method based on scarf knitting texture periodicity is proposed. Firstly, autocorrelation function is applied to determine the texture period of the averaged image, and the texture period is taken as the parameter to improve the quality of scarf defect detection Row down sampling and bilinear interpolation are used to eliminate the periodic change of gray value caused by texture. After that, the method based on maximum inter class variance is used to cut the image to complete the defect detection of scarf image. Through a large number of experiments, it is proved that this method has good effect on scarf defect detection, and has the characteristics of stable effect and strong practicability.


Introduction
As a textile, scarves have a long history. With the development of technology, the production efficiency of scarves has been continuously improved, but there are still many shortcomings in scarf defect detection. At present, the scarf defect detection mainly depends on manual inspection. Based on the scarf image defect detection method, the main difficulty lies in the existence of scarf texture. The existence of scarf weaving texture causes the change of gray value of scarf image, which is not conducive to the detection and segmentation of scarf defects. In the detection of textile defects, the researchers also proposed different detection methods, which are mainly divided into three types: A statistical method based detection method such as Wen et al. [1][2] proposes a method using a gray level co-occurrence matrix or a gray scale difference matrix; Based on frequency domain analysis, defect detection methods such as Chan et al. [3] proposed Fourier transform method, Sari-Sarraf et al. [4][5][6] adopted wavelet transform method, Kumar et al. [7] proposed Garbor filter method; Model-based detection methods, such as Cohen et al. [8]

Periodicity of Scarf Weave Texture
A particularly distinctive feature of the woven texture of the scarf is the periodicity of the woven texture of the scarf as it is analyzed. Periodicity is a very common property in real life. The following is a mathematical representation of periodicity. Let A and B be periodic in two directions of function f (x, y), then we use mathematical form to express periodicity.
The above equation represents the periodicity in a very ideal situation. In real life, the periodicity in general is an approximate periodicity of a certain thing, not a periodicity in the strict sense. Therefore, a very small value of  can be allowed to make the following formulas hold:

Construction of Image Basic Unit
From the introduction above, we can see that there is periodicity in the woven texture of scarf image. Finding the period of texture is the key step in the pretreatment method of this project. The specific function is to weaken the influence of texture features on defect detection. This section gives a detailed introduction to the method of finding the period of texture. When detecting scarf defects based on the weaving texture cycle of scarf image, the first step is to determine the weaving texture cycle of the image. In order to find the texture period of the image, the auto-correlation function is introduced in this paper as follows equations (3), (4). The auto-correlation function [12] is a common method for solving the texture period. After the auto-correlation function curve is obtained, the periodic variation of the curve can represent the periodic variation of the scarf weave texture. By calculating the period of auto-correlation function curve, the corresponding texture period can be solved. When calculating the auto-correlation function, the number of pixels between two adjacent peaks or valleys of the auto-correlation function curve is the texture period.
In the above formula, M and N represent the size of window selection for the division of basic pixel units, C represent the values of horizontal and vertical auto-correlation functions. When the basic pixel unit is created, the window size is generally N M  . This subject will make N M = . At this time, the value of M and N is the texture period mentioned above. Because the proportion of defective areas in the image to be measured is relatively small, the image can be segmented into the basic pixel units, which will be calculated when the texture background is weakened.

Scarf Defect Detection Method Based on Woven Texture Periodicity
In the detection of scarf defects, this subject requires to weaken the periodic change of gray value of scarf image caused by the texture cycle of the scarf. Only in this way, the follow-up defect detection can have better results. In the following section, I will improve the pretreatment method, introduce in detail the defect detection method based on the periodicity of scarf weaving texture, and introduce the segmentation method of defect image.

Calculating Method of Scarf Weaving
Texture Period. The observation shows that the gray value of the scarf image is generally in a relatively small range. In order to calculate the texture period better, it is necessary to stretch the gray value range of the scarf image and equalize the image so that the gray value is distributed between 0 and 255. The processing structure is shown in figures 1 and 2 below.

Improved Method of Mean Down-Sampling Based in Auto-correlation Function.
In order to eliminate the texture period, this paper proposes a bi-linear interpolation method after the mean downsampling of the scarf image to eliminate the gray value changes caused by texture changes. Downsampling is to sample a sequence at a certain interval. Under this condition, the new sequence is the down-sampling sequence of the original sequence. When sampling sequence, Shannon sampling theorem should be followed, so that the sampled sequence will not lose signal and signal aliasing. For a sampling sequence, this subject assumes that its sampling interval is N. The practical significance of down-sampling is to collect a sample value for each interval of N-1 sample value of the target sequence. In this way, a new sampled sequence can be obtained. Mean down-sampling is to average the gray value in the sampling window before down-sampling. After gray value averaging, the texture of scarf image will become smooth. In the selection of window for sampling scarf image, the selection criteria are as follows: First, the size of window selection should not be too large, if it is too large, it will easily cause the loss of defects, so we require that the smaller the window size, the better. Secondly, in order to minimize the texture background in window selection, we need to select a larger window. Traditional down-sampling attempts all window sizes, and ultimately chooses the most suitable window sizes. In this paper, we choose the weaving period of texture as the window size of down-sampling, and then sample the scarf image by means of down-sampling. The gray values of the pixels in each window are approximately the same. Then we interpolate the sampled image by bilinear interpolation, so that the texture features are weakened to the greatest extent. Figure 4 are the results of image segmentation after bi-linear interpolation when different windows are selected.

Bi-linear Interpolation Principle.
After the image is down-sampled, bi-linear interpolation is needed to restore the original size of the image. In this paper, we set the height of the output image as Out-height, the width of the output as Out-width, the height of the input image as Height and the width of the input image as Width. If we want to enlarge or reduce the output image on the basis of the input image, we need to use four adjacent points with known gray levels to calculate. Assuming that the coordinates of four known points are (a, b), (a + 1, b), (a, b + 1) and (a + 1, b + 1), the gray values are determined. The calculation process is shown in figure 5. below. In the graph, the height represents the gray value.   figure 5, the values of a and b are determined as follows equations (5) and (6). In the following expression, [y] denotes an integer not larger than y.
Assume that the input value of the gray point value of the pixel point (x, y) is g(x, y), and the output value of the gray value is f(x, y), then; Among them: In order to ensure the continuity of the pixels in the picture, the gray value of the pixels of the edge remains unchanged, as shown in the following equation (11).

Scarf Defect Image Segmentation
In image defective region segmentation, Otsu method is used in this paper. When choosing the best threshold of segmentation, we can choose to traverse the gray value of all the pixels in the image. When the threshold is assumed, the variance between classes can be calculated. When the defective region is segmented to the area without defect or the flawless region is segmented into the flawed region, the difference between the two regions will decrease, and the variance between classes will decrease. So we only need to find the gray value threshold corresponding to the maximum variance between classes, and then we can successfully find the optimal threshold. The specific method is as follows (12). Next, the image can be segmented according to the optimal threshold.

Result
The flow chart of the defect detection method based on the periodicity of scarf weaving texture is shown in figure 6 below.  Figure 6. Flow of scarf detection method.
In order to verify whether the defect detection method based on the periodicity of scarf weaving texture can be realized, this experiment chooses the holes and oil stains in the common defects of scarf to carry out experiments. The experimental results are shown in figures 7-9, the periodic defect detection method based on scarf weaving texture can play a better role in scarf defect detection. For two kinds of defects, oil stain and holes in scarf, the experimental results achieve the expected goal.

Summary
Based on the periodicity of the woven texture of scarf image, the defect of scarf image is segmented. Firstly, the period of woven texture of scarf image is searched by auto-correlation function. Then, the period is taken as window size, and the image is sampled based on auto-correlation function. After the down-sampling process, in order to restore the original size of the image, the image is subjected to bilinear interpolation processing. After image down-sampling based on auto-correlation function and bilinear interpolation, the texture of scarf image will be greatly weakened. After image segmentation based on Otsu method, the defective region of image can be segmented completely. Through a large number of experiments, it is proved that the scarf image defect detection method based on the periodicity of scarf image texture has high accuracy for scarf image defect segmentation and detection. At the same time, the method is suitable for many kinds of defects and has better adaptability.