# Introduction s we entered in digital age, our information has improved better than ever. In the textile industry, fabric defect is one of the most important and the first task of quality control and economy business. So many approaches have made in the field of fabric defect detection. In Bangladesh, textile industries are trying to improve their production with minimum cost. After the waving of a huge roll of fabric, it's then sent for inspection to find if there is any defect on the fabric. An automated fabric defect detection system would be better than human detection which will alert users when any error found [1]. So many researchers have been made to identify fabric defect methods. Some methods are well established. Structural, statistical, spectral, modelbased, learning, hybrid, comparison studies, optical analysis methods and image analysis methods are more common. Some researchers have tried Fourier Transform and Gabor Filters; others use Gabor and HOG in the image analysis method, which is more complex and time-consuming. But we have tried a simple method using edge detection and heuristics. This paper has focused on single colour-based fabric defect detection using image processing. We have experimented with different edge detection algorithms, e.g. Sobel, canny etc. along with noise filter and different threshold. Above those, canny edge detection shows more promising results in fabric defect detection. A simple algorithm is proposed here to detect different kinds of fabric defects. Our goal is to find a more costeffective and fast process to identify fabric defects accurately. Some parameter like zooming, image resolution, colour etc should be considered. Main fabric defects as namely [3,4]Floats, Weft Curling, Slubs, Holes, Oil Stains, Stitching, Knots, Irregular Pick Density, Snag, Tear, Gouts, Snarls, Miss-end, Stripes, Tight/Slack Warp Thread, Double Ends, Smash, Open Reed, Miss-pick, Double Picks, Coarse-pick, Tight/Slack Weft Thread etc. All of these defects are examined with our algorithm and the result comes out very good and promising with some considerations. # II. Objective Different work has been done in previous year for fabric defect detection. And so many methods are being proposed. A direct benchmark among different algorithms for fabric flaw detection was first and last conducted by Bodnarova et al. [5], who compared algorithms based on the ideas of co-occurrence matrices, normalized cross-correlation, blob detection and spectral analysis. All algorithms were manually implemented by the authors. Almost all papers somehow combine a basic method with several other advanced techniques. Some tried to classify the defect and others tried real-time defect detection with accurate position of defect. The objective of this paper is to find different approaches to find a better method to detect fabric defects using image processing. Many tried to classify these defects; others tried to compare existing methods. But my method does not classify the error type. It can only determine if there is any defect that exists in the given fabric image. # III. Proposed Method The objective of the proposed method in this paper is to design an efficient method for fabric defect detection with image. In this section we will discuss fully our method. Matlab software is used for this purpose. We have used a filter-based edge detection method and heuristic to predict if the fabric image contains any errors. If an error is found, then the software shows error found and if not then it shows no error found. This algorithm is designed to perform better in single-color fabrics. Texture and printed fabrics are not suitable. Due to the increasing demand for quality fabrics, high quality requirements are today greater since customers have become more aware of poor quality problems. To avoid rejection of fabric, it is necessary to avoid defects. At first RGB image is taken as an input. This is the test image. It may not contain any errors. Different types of fabric are used for testing. Then the image is converted into a grayscale image. Image is now converted to a n×m matrix. Now take the mean of the image matrix. This value is essential for image pixel equalization. We subtract 100 from this mean value and subtract from every pixel in the gray image. This is done because subtracting from every pixel it will be more efficient for applying thresholds. Now we convert this grayscale image into a binary image. The pixel values are now in 0s and 1s. If the value falls below the threshold value, the pixel value will become 0 and if the value falls above the threshold value, the pixel value will become 1. Then we apply edge detection to the image. A Canny Edge detection algorithm is used here. After that objects are formed in the image. We now remove noise from the image. If any small object contains 2px by 2px or less, we will remove it from the image. As all image pixels do not contain the same rgb or gray value. Noise removal is very important to our method. Without this we cannot find accurate results. If an image does not contain any error, though we can find some small object as noise, that's some value will still remain above threshold. We keep all larger objects and count them. Error can be any size and any length. Finally, we compare the number of remaining objects. If the number is greater than 10 then we can say the image has error otherwise no error. This is the heuristic value. This value can be less than 10 if we want to get a more accurate result , it will then detect some false result. # b) Some Considerations This algorithm is not for patterned fabric or wool. This will work better in single-colored fabrics like cotton or silk. The light intensity should be the same for all over the image and there should not be any stretch. When the picture is taken it should not be so close to the fabric or the image should not be zoomed. # c) RGB image Input Image pixels contain values in RGB. In matlab it forms a three-dimension matrix. The main purpose of the RGB color model is for the sensing, representation and display of images in electronic systems, such as televisions and computers, though it has also been used in conventional photography. Here n1,n2? are the pixel values and N is the total number of pixel. We subtract 100 from this value and finally subtract each pixel value from the gray image. We normalize the image so that the intensity level is distributed all over the pixel value. Now we remove noise from this image by applying a wiener filter. # f) Convert to binary image Computes a threshold for each pixel using the local mean intensity around the neighborhood of the pixel. This is done by the following equation 2*floor (size(I)/16) + 1 # Fig-4: Binary image Binary image is needed for edge detection and separate different size objects. This image contains only 0 and 1 value. # g) Removing and filtering object Remove all objects less than 2px. This is noise removal. Any pixel not associated with object will be removed. We have used a Wiener noise removal filter in this paper. The purpose of the Wiener filter is to filter out noise that has corrupted image. This filter is based on a statistical approach. The goal of the wiener filter is to reduce the mean square error as much as possible. Replacing each pixel value in an image with the mean value of its neighbors, including itself [6]. # h) Decision making We will keep all the larger objects in the image. If the number is below 10, we will assume that the fabric is defect free. And if the number is greater than 10, we will assume there is a defect in the fabric image. The above image does not contain any error. The algorithm found it correctly. 50 different images are given as input. These sample images contain different errors and different colors. Only one image was not identified correctly. Among the 50 images, 49 were identified correctly. So we can tell that the accuracy level is (49/50)*100=98% which is very good. # b) Comparative Analysis of Fabric Defects Detection Methodologies Compared to other fabric defect detection methods [7] we found our algorithm to be better in certain conditions. V. # Conclusion The objective of our project was to find defects in fabric using image processing. The method we used is fast and very accurate. With low false detection, it will help textile industries to save time and money. It only works better with single-colored fabric. With few considerations, our method performs better and detection rate is 98% which is much satisfactory. # VI. Future Work Many methods exist in the field of fabric defect detection. These methods are suitable for fabric only. But as our method is based on edge detection and it can also be used in other fields like vein detection or printed circuit board (PCB) defect detection. Some false detection is present in the experiment. We will try to improve the result in future. # References Références Referencias 1![Fig-1: RGB image with error (source google.com) If we zoom in on this image, we can understand the pixels inside it.](image-2.png "Fig- 1 :") 2![Fig-2: Zoomed image with RGB value d) RGB to Gray Conversion Convert each pixel value to a gray level by the following equation. 0.299 * R + 0.587 * G + 0.114 * B) To convert RGB image into a binary image, this gray level conversion is needed. Grayscale image contains values from 0 to 255. And the image is formed into two dimensional arrays of pixel values.](image-3.png "Fig- 2 :") 3![Fig-3: Gray Scale Image e) Mean and subtracting Calculate the mean of the grayscale image. Take each pixel value and sum them. And divide the sum with total number of pixel. The equation is-Mean = (n1+n2+n3+?..+nN)/N](image-4.png "Fig- 3 :") 5![Fig-5: Test image 1The first test image contains a hole error. The error area is marked red.](image-5.png "Fig- 5 :") 68![Fig-6: Test image 2 Second image contains a error color marking/tag.](image-6.png "Fig- 6 :Fig- 8 :") 9![Fig-9: Test image 5This image contains oil strain. The red marked area is error.](image-7.png "Fig- 9 :") 1011![Fig-10: Test image 6 This image contains a error tight weft thread. The area is marked red.](image-8.png "Fig- 10 :Fig- 11 :") ( ) © 2022 Global Journals © 2022 Global Journals Fabric Defect Detection using Image Processing * Online Fabric Inspection By Image Processing Technology Abdel Salam Malek * Fabric Defect Detection Using Image Processing Techniques 2013 Sava? Ba?kur * Suitability Analysis f Techniques for Flaw Detection in Textiles Using Texture Analysis ABodnarova MBennamoun KKubik Pattern Analysis & Applications 3 3 2000