# Detection of Defects in Warp Knitted Fabrics Based on Local Feature Scale Adaptive Comparison
###### Abstract  
In order to improve the accuracy and detection effect of fabric defect detection, a fabric defect detection method based on local similarity comparison is proposed in this paper. This method first takes each pixel in the image as the central pixel, selects a specific window as the region size, and then uses the similarity between the central region and the surrounding neighborhood to find the neighborhood most similar to the central region to complete the estimation of the central pixel. Finally, the target image is obtained by the principle of background difference, so as to detect fabric defects. The results show that this method is superior to the traditional detection method, which can not only detect the defect image under the complex background, but also have good detection results for the fabric defect image under the influence of different organization and lighting factors. The detection accuracy rate under factory conditions can reach 98.45%, which has a high applicability and detection rate, and also demonstrates certain anti-interference performance. local similarity; fabric defects; detection; center pixel; background difference 0  
However, there are still some problems, such as high calculation complexity, limited detection effects for specific types of defect, a large amount of annotation data, and insufficient generalization ability for irregular defects. In terms of target detection, [PERSON] et al. [8] optimized a pooling operation in a YOLOv4 SPP structure to effectively improve the mAP while improving FPS. [PERSON] et al. [9] introduced a Swin Transformer module into the trunk network of YOLOv5 and added a small target detection layer to strengthen the detection capability for small targets. [PERSON] et al. [10] added five anti-convolution layers as decoders, and generated a segmentation mask by adjusting the size of the bilinear. The proposed model achieved good detection results on the fabric defect dataset. [PERSON] et al. [11] divided the segmentation network into two parts: segmentation and decision making. Only a small number of defect samples are combined with standard samples to obtain high-precision defect positions, and the detection speed of 25 frames per second can be achieved. Although the above methods are effective, they are limited in adaptability and multi-scale information processing, which results in unstable performance when dealing with complex fabric texture or different lighting conditions. Learning-based methods play an important role in the field of image processing by training the model by extracting fabric image features, and then detecting the image using the trained model. [PERSON] et al. [12] proposed a visual significance detection method based on a collaborative teaching model, which controls the propagation order of hyperpixels by means of teaching interaction, optimizes the propagation path, and improves the detection accuracy. [PERSON] et al. [13] used a PSO-BP neural network to detect fabric defects, extracted fabric texture features by orthogonal wavelet transform, and optimized the BP neural network through a particle swarm optimization algorithm to determine the threshold and weight of the neural network. Compared with the BP network, the PSO-BP neural network algorithm achieved good results. When dealing with fabric defects, the above method has high computing complexity and insufficient multi-scale information fusion. The image recognition method based on similarity mainly uses the feature structure of the image to match and estimate the similarity between different samples. The commonly used methods include Euclidean distance, Marov's distance, correlation coefficient, and information entropy [14]. [PERSON] et al. [15] proposed a fabric defect detection method based on local entropy, which converts the original gray image space into entropy space and extracts the texture region of the defect.