3.1. Image Acquisition and Preprocessing
Image quality is an important factor restricting the detection rate, so image acquisition is an important link in fabric defect detection. At present, the Tilda database [
20] is being used by researchers for research, but due to its high image quality, the algorithm with a high detection rate is generally tested on the Tilda database, and the collected images may not have a high detection rate under actual conditions, which will cause some misunderstanding around the reliability of the scientific research results. Therefore, on the basis of standard image detection, it is of great significance to verify the reliability of the results by collecting fabric defect images in actual production.
The three kinds of standard fabric defect shown in
Figure 3 are (a) knotting, (b) holes, and (c) oil stains. The image is clear and has high resolution, which is the standard image often used by researchers.
Figure 4 shows the plain warp knitted fabric images collected by the laboratory equipment, using the lens with a 6-mm focal length (Ricoh, fl-hc0614-2m) produced by the Ricoh company in Japan, and the linear scan CCD camera produced by the Beijing micro-vision company, which was collected on the hks4 El high-speed warp knitting machine produced by the Fujian Jilong company (Quanzhou, China). (a–c) shown in
Figure 4 are fabric defect images formed by holes, oil stains, and broken yarn, respectively. The image size is 512 × 512, and the resolution of the image is poor compared with the standard fabric.
Figure 5 shows the broken yarn images of some fabrics collected in the factory. Due to the variety of collected images, only parts of the defect images are displayed. The image quality collected by the factory is poor, and some fabrics are difficult to collect.
According to the above image acquisition results, it can be seen that the fabric defect image in the standard state is clear and less affected by external factors, the laboratory environmental conditions are controllable and relatively superior to those of the factory, and the quality of the collected image is acceptable. However, the quality of the collected image in the actual production of the factory is poor, because the environmental factors need to be considered in the acquisition process. For example, when the machine speed is high, the machinery will produce vibration, causing camera jitter, light source vibration, etc. At the same time, if the fabric is light and thin, the reflection of mechanical parts is also an important factor restricting the image quality acquisition. When collecting in the factory, if only the good quality image is selected, it has no reference significance. Therefore, if the various collected defect images can be effectively detected, the subsequent development of fabric defect equipment will have a certain reference value.
For the standard sample, there is less noise, but for the images collected in the experimental process there will be many factors which will cause the loss of image quality. Uneven illumination is a typical factor. In the acquisition process, due to the instability of the light source, mechanical vibration, and reflection, the gray level of the collected image will change, which will lead to the decline of image quality. In order to obtain a higher quality image, we can preprocess it by eliminating uneven illumination and enhancing the details of the image.
In actual production, the image will become blurred and the defect part will be difficult to identify due to the influence of light. Homomorphic filtering can eliminate the influence of uneven illumination by adjusting the gray range of the image and enhancing the texture details of dark areas without losing the details of bright areas. Homomorphic filtering is a special method for image preprocessing in the frequency domain. It mainly reduces the low frequency and increases the high frequency by enhancing and compressing the brightness of the image, and finally reduces the impact of illumination changes on the image and sharpens the edge details [
21].
Take the original image function
as the illumination function, which can be expressed as the product of the illumination component
and the reflection component
, that is, the function of the original image is expressed as [
21]:
The algorithm flow of homomorphic filtering is shown in
Figure 6:
The following operations can be performed according to the above flow chart:
(1) For homomorphic filtering, it is necessary to simplify the multiplication operation of the original image function to the addition operation, that is, to perform a logarithmic operation on the original image function:
(2) In order to convert the image to the frequency domain, Fourier transform is required for the function after the above logarithmic operation:
(3) Then select an appropriate transfer function
, weaken
, enhance the reflection component, enhance
, and enhance the high frequency component by compressing the variation range of the irradiation component
. Suppose a homomorphic filter function
is used to process the Fourier transform of the logarithm of the original image
to obtain:
(4) Inverting to airspace:
(5) Finally, take the index to obtain the final result:
The choice of transfer function is very important to achieve the ideal enhancement effect and the effect of compressing the gray range. Considering that the high-frequency information of the image can be enhanced while retaining part of the low-frequency information, the Butterworth high pass filter is selected. According to the similarity of transfer function, the transfer function of homomorphic filtering can be obtained:
The transfer function of homomorphic filtering should be less than 1 in the low frequency part and greater than 1 in the high frequency part, so there is . is the sharpening function, and is related to the irradiation component and reflection component.
The parameter a can be set according to the principle of the filter. The images before and after homomorphic filtering are shown in
Figure 7 and
Figure 8.
Figure 7 shows the images collected by the factory. It can be seen that the images collected by the factory are seriously polluted by noise such as light sources. Using homomorphic filtering for image preprocessing can more effectively eliminate noise, suppress background, and highlight targets.
Figure 8 shows the standard image, which is less disturbed by noise. The image after homomorphic filtering makes the target defects clearer and clearer, and has a good effect.
According to the above filtering effect, homomorphic filtering can preprocess the image under the interference of noise such as light source, and obtain the ideal preprocessing effect. By comparing the images before and after filtering, homomorphic filtering can make the defect image clearer and clearer, inhibit the background image, and eliminate the influence of light, which has a good processing effect.
3.2. Different Types of Fabric Defect
In order to evaluate the adaptability of this algorithm, plain warp knitted fabric defect images with different types of defect are used for detection. The image acquisition was realized on the hks4 El high-speed warp knitting machine produced by the Fujian Jilong company. The Intel (R) core (TM) I3 was used in the experiment using a 6-mm focal length lens (Ricoh, fl-hc0614-2m, Kanagawa, Japan) produced by Ricoh and a linear scan CCD camera (microview, Beijing, China) produced by the Beijing micro-vision company—
[email protected]. The computer detects three different kinds of defect—holes, oil stains, and broken yarn fabric defects. Considering the sensitivity of the algorithm, it detects the image compressed from 512 × 512 pixels to 32 × 32 pixels. The results are shown in
Figure 9.
In the above figure, (a), (d), and (g), respectively, represent the images of fabric defects with holes, oil stains, and broken warp, (b), (e), and (h) represent three different types of scale image, (c), (f), and (i), respectively, represent the detection results of different types of defect. According to the above experimental results, the scale adaptive comparison method has good detection results for fabric defects, which can not only identify the shape and contour of fabric defects, but also detect different types of fabric defect.
3.3. Comparison of Different Defect Detection Methods
In order to prove the superiority of the scale adaptive local contrast method proposed above, the local binary patterns (LBPs) in the literature [
18] and the local contrast deviation method (LCD) in the literature [
19] are used to compare the experimental results on Tilda datasets with the algorithm proposed in this chapter. The results are shown in
Figure 10.
The above literature, respectively, detects defects on the Tilda dataset based on LCD and LBPs methods. In the figure, (a), (b), and (c), respectively, represent three different types of fabric defect images in the Tilda dataset, (d), (e), and (f), respectively, represent the scale images of three kinds of defect image, (g), (h), and (i), respectively, represent the detection results of the algorithms in this chapter for three kinds of defect, (j), (k), and (l), respectively, represent the detection results of three kinds of defect detected by local contrast deviation (LCD), and (m), (n), and (o), respectively, represent the detection results of three kinds of defect detected by local binary pattern (LBPs).
As shown in
Figure 10 above, the comparison between the proposed algorithm and the experimental results of LCD and LBPs show that the proposed scale adaptive local comparison method has better detection results than the other two methods, and clearer target contour recognition. In the above experimental process, we used homomorphic filtering to preprocess the algorithm, reducing the impact of noise on the detection results, making target recognition more accurate.
The network is trained with this set of parameters, and the training results are shown in
Figure 11. From
Figure 11a, it is found that the accuracy of the validation set of LBPs after the 75th round of training is close to that of the proposed method, and the overall network accuracy is higher than that of LCD. From
Figure 11b, it can be seen that the training loss curve is constantly converging, the loss is close to the method in the 10th round, and the LBPs’ training loss converges significantly earlier than the LCD training loss. The experimental results show that the proposed method is feasible.
The spatial complexity of the model can be reflected by the number of parameters. When a model is deployed on an edge computing platform, in addition to the number of model parameters, the model inference speed is also an important indicator to measure the network model. The time class is usually used to measure model inference time, but there is a warm-up start when the GPU runs, so this approach is not very objective. In this paper, the TILDA dataset is tested by preheating and synchronization, the average time is obtained, and the results are shown in
Table 1. The test accuracy of the model in this paper is 99.89%, the accuracy of the LCD model is 97.06%, and the test accuracy of the LBPs model is very close to that of the model in this paper, namely 97.06%. It can be seen from
Table 1 that the proposed method is less than the current model in terms of the number of parameters and the amount of calculation, which indirectly improves the forward inference time of the model.
3.4. Verification of Images Collected by the Factory
In order to further verify the rationality of the methods in this chapter, factory experiments were carried out. On the cloth inspection machine, a linear CCD camera was used to collect warp knitted fabrics under different tissues (considering the actual production cost of the textile mill). The experimental device is shown in
Figure 12. The CCD camera was a Hikvision MV-CS060-10GM/GC second-generation industrial area scan camera; the light source system selects the LED lamp with the model MV-LLDS-1002-38 as the system light source, the number of lamp beads is 6 rows, the wavelength B: 465 nm, R: 625 nm, the light-emitting surface size is 990 × 32 mm, and the color temperature W: 6500 k; the frame grabber is NIPCIe-1433.
A total of 200 gray-scale images with a resolution of 2568 × 40 pixels were collected, including 115 flawless images and 85 defective images. The collected pictures are used for the offline test. The experimental results are shown in
Figure 13,
Figure 14 and
Figure 15. This experiment uses an experimental window with a central area size of 11 × 39 pixels. The experiments are carried out under the environment of matlab2023a. The pad number of plain weave in
Figure 14 is Gb3: 1-0 | 0-1 | gb4: 1-2 | 1-0 |, the pad number of twill weave in
Figure 13 is Gb3: 1-0 | 1-2 | gb4: 1-2 | 1-0 |, and the pad number of variable warp weave in
Figure 12 is Gb3: 1-0 |1243-4|. Let off volume: 1200 mm/rack, pulling density: 20 rows/cm.
Figure 13,
Figure 14 and
Figure 15 are defect images and detection results of different yarn breaking parts under different tissues. The left broken yarn defect image has a tendency to tilt to the right, the middle broken yarn defect image is a vertical bar, and the right broken yarn is inclined to the left. It can be seen from the yarn breaking diagram on the left that when the yarn breaking starts, the defect image is not very obvious and the image is relatively small, but the detection results show that the algorithm can clearly identify the existence of defects and effectively avoid long defects. As the defect range after yarn breaking is different for different fabrics, it can be seen from the above figure that this method has a good detection effect for different fabrics, which shows that the algorithm used in this paper can adapt to the defect detection of different fabrics and has high robustness.
The image in
Figure 15 is affected by light during acquisition, which shows that this algorithm can adapt to defect detection under the influence of external factors and has certain anti-interference performance.
3.5. Evaluating Indicator
In fabric defect detection, there are two kinds of judgment results for an image containing fabric defects, namely, the normal image and the defect image, which are represented by positive samples and negative samples. For both positive samples and negative samples, there are two judgment methods. Therefore, for the possibility of producing four different results, in order to better reflect the correlation judgment results, it is defined that the case where the positive sample is judged as positive is true positive (TP), the case where the positive sample is judged as negative is false negative (FN), the case where the negative sample is judged as positive is false positive (TP), and the case where the negative sample is judged as negative is true negative (TN).
In order to better reflect the detection rate of defect detection, the following calculation method is defined:
where TP is the number of true positive samples; FP refers to the number of false negative tests; FN the number of false positives detected; TN the number of true negative samples; Accuracy is the detection accuracy.
In the test of this paper, the effect of the improved algorithm can be reflected only by the detection rate. Therefore, the image data collected by the factory were used for the test, 500 positive samples and 80 negative samples were selected, a total of 580 samples were tested, and the results are shown in
Table 2.
As shown in the table, 493 of the 500 positive samples were detected as positive samples, 6 were detected as negative samples, 3 of the 80 negative samples were detected as positive samples, and 77 were detected as negative samples. The test accuracy of samples collected by the factory was 98.45%.