8
Fabric defect detection using morphological filters K.L. Mak * , P. Peng, K.F.C. Yiu Department of Industrial and Manufacturing Systems Engineering, The University of Hong Kong, Pokfulam Road, Hong Kong article info Article history: Received 16 June 2007 Received in revised form 29 November 2008 Accepted 2 March 2009 Keywords: Gabor wavelet network Morphological filter Defect detection Quality control Textile fabrics abstract In this paper, a novel defect detection scheme based on morphological filters is proposed to tackle the problem of automated defect detection for woven fabrics. In the proposed scheme, important texture fea- tures of the textile fabric are extracted using a pre-trained Gabor wavelet network. These texture features are then used to facilitate the construction of structuring elements in subsequent morphological process- ing to remove the fabric background and isolate the defects. Since the proposed defect detection scheme requires a few morphological filters only, the amount of computational load involved is not significant. The performance of the proposed scheme is evaluated by using a wide variety of homogeneous textile images with different types of common fabric defects. The test results obtained exhibit accurate defect detection with low false alarms, thus showing the effectiveness and robustness of the proposed detection scheme. In addition, the proposed detection scheme is further evaluated in real time by using a proto- typed automated inspection system. Ó 2009 Elsevier B.V. All rights reserved. 1. Introduction The continually changing fashion of garments has generated a greater product variety and shorter life cycle for production. Tex- tile fabrics constitute a large proportion of the total cost of pro- duction in garment manufacturing. Since a garment with a textile defects usually sells with a massive discount of 45–65% [1], the garment manufacturing industry is faced with increased pressure to become more competitive by increasing yield while reducing costs. Hence, quality control of fabrics before garment manufacturing is essential to ensure the quality of finished prod- ucts and to increase the efficiency of the manufacturing process. Indeed, improved performance in the inspection of fabrics leads to good product quality and, in turn, contributes to increased profitability and customer satisfaction. Above all, the general out- come is a better product image and a competitive market place advantage. Currently, the quality inspection process for textile fabrics is mainly performed manually. However, the reliability of manual inspection is limited by boredom and inattentiveness. Indeed, Sari-Sarraf and Goddard [2] found that only about 70% of fabric de- fects could be detected by the most highly trained inspectors. Therefore, automated detection of fabric defects, which results in the production of high-quality products at a high production speed is definitely desirable. Automated inspection of textile fabrics has attracted a lot of attentions in recent years. Wang et al. [3] reported that 90% of the defects in a plain fabric could be detected simply by thresholding, and other researchers also started to study the auto- mated inspection of more complicated fabrics, such as twill and denim fabrics [4–8]. Numerous approaches were proposed to address the problem of detecting defects in woven fabrics, which can be broadly cate- gorized into three classes: statistical, spectral and model based. Among these approaches, statistical approaches were the earliest approaches used to detect fabric defects. Chetverikov and Han- bury [9] used two fundamental structural properties of a texture, namely, structural regularity and local anisotropy, to detect struc- tural defects in regular and flow-like patterns. Bodnarova et al. [10] compared the performance of several common defect detec- tion methods, such as spatial grey-level co-occurrence, normal- ized cross-correlation, texture blob detection and spectral methods, in terms of detection accuracy and computational effi- ciency, and claimed that the cross-correlation method was the most promising method for textile fabrics. However, they also pointed out that this method would be computationally very demanding if the template size used was large. Muller and Nicko- lay [11] used two morphological filters to detect two types of fab- ric defects, i.e. thread drags and oil spot. Zhang and Bresee [12] also successfully combined morphological operators and autocor- relation functions to inspect two types of fabric defects, i.e. knot and slub. Many other statistical detection methods were also re- ported in the literature, including edge detection [13], cross-corre- lation [14], co-occurrence matrix [15] and neural networks [8].A few model based methods had also been applied successfully to detect defects in textile fabrics. Campbell et al. [16] used the mod- el based clustering method to detect linear pattern production de- fects, and Ozdemir and Ercil [17] used Gauss Markov random 0262-8856/$ - see front matter Ó 2009 Elsevier B.V. All rights reserved. doi:10.1016/j.imavis.2009.03.007 * Corresponding author. Tel.: +852 28592582; fax: +852 28586535. E-mail address: [email protected] (K.L. Mak). Image and Vision Computing 27 (2009) 1585–1592 Contents lists available at ScienceDirect Image and Vision Computing journal homepage: www.elsevier.com/locate/imavis

Fabric defect detection using morphological filters

  • Upload
    vohanh

  • View
    238

  • Download
    9

Embed Size (px)

Citation preview

Page 1: Fabric defect detection using morphological filters

Image and Vision Computing 27 (2009) 1585–1592

Contents lists available at ScienceDirect

Image and Vision Computing

journal homepage: www.elsevier .com/ locate / imavis

Fabric defect detection using morphological filters

K.L. Mak *, P. Peng, K.F.C. YiuDepartment of Industrial and Manufacturing Systems Engineering, The University of Hong Kong, Pokfulam Road, Hong Kong

a r t i c l e i n f o

Article history:Received 16 June 2007Received in revised form 29 November 2008Accepted 2 March 2009

Keywords:Gabor wavelet networkMorphological filterDefect detectionQuality controlTextile fabrics

0262-8856/$ - see front matter � 2009 Elsevier B.V. Adoi:10.1016/j.imavis.2009.03.007

* Corresponding author. Tel.: +852 28592582; fax:E-mail address: [email protected] (K.L. Mak).

a b s t r a c t

In this paper, a novel defect detection scheme based on morphological filters is proposed to tackle theproblem of automated defect detection for woven fabrics. In the proposed scheme, important texture fea-tures of the textile fabric are extracted using a pre-trained Gabor wavelet network. These texture featuresare then used to facilitate the construction of structuring elements in subsequent morphological process-ing to remove the fabric background and isolate the defects. Since the proposed defect detection schemerequires a few morphological filters only, the amount of computational load involved is not significant.The performance of the proposed scheme is evaluated by using a wide variety of homogeneous textileimages with different types of common fabric defects. The test results obtained exhibit accurate defectdetection with low false alarms, thus showing the effectiveness and robustness of the proposed detectionscheme. In addition, the proposed detection scheme is further evaluated in real time by using a proto-typed automated inspection system.

� 2009 Elsevier B.V. All rights reserved.

1. Introduction

The continually changing fashion of garments has generated agreater product variety and shorter life cycle for production. Tex-tile fabrics constitute a large proportion of the total cost of pro-duction in garment manufacturing. Since a garment with atextile defects usually sells with a massive discount of 45–65%[1], the garment manufacturing industry is faced with increasedpressure to become more competitive by increasing yield whilereducing costs. Hence, quality control of fabrics before garmentmanufacturing is essential to ensure the quality of finished prod-ucts and to increase the efficiency of the manufacturing process.Indeed, improved performance in the inspection of fabrics leadsto good product quality and, in turn, contributes to increasedprofitability and customer satisfaction. Above all, the general out-come is a better product image and a competitive market placeadvantage.

Currently, the quality inspection process for textile fabrics ismainly performed manually. However, the reliability of manualinspection is limited by boredom and inattentiveness. Indeed,Sari-Sarraf and Goddard [2] found that only about 70% of fabric de-fects could be detected by the most highly trained inspectors.Therefore, automated detection of fabric defects, which results inthe production of high-quality products at a high production speedis definitely desirable. Automated inspection of textile fabrics hasattracted a lot of attentions in recent years. Wang et al. [3] reportedthat 90% of the defects in a plain fabric could be detected simply by

ll rights reserved.

+852 28586535.

thresholding, and other researchers also started to study the auto-mated inspection of more complicated fabrics, such as twill anddenim fabrics [4–8].

Numerous approaches were proposed to address the problemof detecting defects in woven fabrics, which can be broadly cate-gorized into three classes: statistical, spectral and model based.Among these approaches, statistical approaches were the earliestapproaches used to detect fabric defects. Chetverikov and Han-bury [9] used two fundamental structural properties of a texture,namely, structural regularity and local anisotropy, to detect struc-tural defects in regular and flow-like patterns. Bodnarova et al.[10] compared the performance of several common defect detec-tion methods, such as spatial grey-level co-occurrence, normal-ized cross-correlation, texture blob detection and spectralmethods, in terms of detection accuracy and computational effi-ciency, and claimed that the cross-correlation method was themost promising method for textile fabrics. However, they alsopointed out that this method would be computationally verydemanding if the template size used was large. Muller and Nicko-lay [11] used two morphological filters to detect two types of fab-ric defects, i.e. thread drags and oil spot. Zhang and Bresee [12]also successfully combined morphological operators and autocor-relation functions to inspect two types of fabric defects, i.e. knotand slub. Many other statistical detection methods were also re-ported in the literature, including edge detection [13], cross-corre-lation [14], co-occurrence matrix [15] and neural networks [8]. Afew model based methods had also been applied successfully todetect defects in textile fabrics. Campbell et al. [16] used the mod-el based clustering method to detect linear pattern production de-fects, and Ozdemir and Ercil [17] used Gauss Markov random

Page 2: Fabric defect detection using morphological filters

1586 K.L. Mak et al. / Image and Vision Computing 27 (2009) 1585–1592

fields to detect common defects in textile fabrics. Spectral ap-proaches were the most widely used approaches for detecting fab-ric defects among the three classes of defect detection approaches.The techniques included in this class were Fourier transform,wavelet transform and Gabor analysis. In view of the high degreeof periodicity for textile fabrics, Fourier transform based ap-proaches were adopted for defect detection by some researchers[18,19]. However, since the kernel function of Fourier transformis of infinite length, the contribution from each of the spectralcomponents is difficult to quantify. Therefore, the traditional Fou-rier transform based approaches are not suitable for detecting lo-cal fabric defects, which only cause minor modifications to thefrequency spectrum of a studied fabric image. In order to over-come this problem, one way is to apply the short-term Fouriertransform [20], thereby allowing localization of spectral effects.However, a suitable window function is needed for this approachto work accurately, which may not be an easy task. Another pop-ular approach is to apply the wavelet transform was used instead[2,21]. Being a special type of wavelet which has an optimal local-ization in both the spatial domain and the spatial-frequency do-main, the Gabor wavelet has been widely used in the field offabric defect detection [5,6,22].

The development of real-time automated visual fabric inspec-tion systems, in general, consists of three processes, namely, imageacquisition, image processing, and image analysis. Typicalexamples include Elbit Vision System’s I-TEX system, BarcoVision’sCyclops and Zellweger Uster’s Fabriscan. These systems inspectfabric in full width either at the batcher for greige fabrics or atthe exit end of a finishing machine [23]. They are designed to findand catalog defects in a wide variety of fabrics including greige fab-rics, sheeting, apparel fabrics, upholstery fabrics, industrial fabrics,tire cord, finished fabrics, piece-dyed fabrics and denim. However,they cannot inspect fabrics with very large and complex patterns.Other examples include a fuzzy wavelet analysis system for pro-cess control in the weaving process [24], a vision system for on-loom fabric inspection [2], a vision system for on-circular knittingmachine [25] and a vision system for fabric detection based on dif-ferent Gabor filters [26,27]. These systems are rather expensivewhich prevent them from being widely adopted by small to med-ium sized factories. Subsequently, Cho et al. [28] proposed a PC-based real-time inspection system to lower the cost. Further re-search and development efforts are definitely needed to establishcost-effective approaches for solving fabric defect detectionproblems.

In this paper, a novel defect detection scheme is proposed tofacilitate automated inspection of woven fabrics. The proposedscheme consists of a Gabor wavelet network (GWN) and severalmorphological filters. Unlike the conventional supervised ap-proach, the design of the proposed scheme only requires anon-defective fabric image and no fabric defect information isneeded. In addition, it can be shown that the GWN which is usedfor extracting typical texture features (the basic yarn informa-tion) from the non-defective fabric image only requires oneimaginary Gabor wavelet in the hidden layer. This reduces signif-icantly the computational load needed in training the GWN.Morphological filters are then designed based on the extractedtexture features for detecting textile fabric defects because previ-ous research has demonstrated that the use of morphological fil-ters can significantly lower the false alarm rate [20]. Theperformance of the proposed scheme is evaluated off-line byusing a set of sample fabric images containing some typical fab-ric defects, and in real time by using a prototype automatedinspection system developed in the laboratory. Results of theexperiments clearly demonstrate that the proposed scheme is in-deed an effective and efficient means for detecting defects in wo-ven fabrics.

2. Fabric defect detection

2.1. Gabor wavelet network for feature extraction

Based on the concept of wavelet transform, Zhang and Benven-iste [29] proposed the notion of wavelet network (WN) as an alter-native to a feed-forward neural network for approximatingarbitrary nonlinear functions. The underlying concept of a WN isto replace the neuron by ‘wavelon’, i.e. computing the units ob-tained by cascading an affine transform and a multi-dimensionalwavelet. Then the affine transform and the ‘synaptic weights’ haveto be identified from possibly noise corrupted input/output data inthe process of network training. Krueger and Sommer [30,31] usedan imaginary part of a Gabor function as the transfer function ofthe hidden layer in a wavelet network, and proposed the conceptof Gabor wavelet network (GWN) for solving 2-D problems in pat-tern recognition [32]. Assuming that a grey-scale image is given byf ðx; yÞ, where the input vector ½x; y� is the position of an image pixeland f is the grey level of the image pixel. The corresponding repre-sentation using a Gabor wavelet network has the following form:

f̂ ðx; yÞ ¼XN

i¼1

wigioðx; yÞ

� �þ f ; ð1Þ

where ½x; y� denotes the network input, f̂ ðx; yÞ denotes the networkoutput, wi refers to a network weight from the ith hidden node tothe output node, gi

oðx; yÞ is the transfer function of the ith hiddennode, f is introduced to normalize the value of any objective func-tions, and N denotes the number of nodes in the hidden layer. Theimaginary part of the Gabor function used in (1), i.e. the transferfunction of the ith hidden node, can thus be expressed as

gioðx; yÞ ¼ exp �1

2ðx� ti

xÞ cos hi � ðy� tiyÞ sin hi

rix

" #28<:

0@þðx� ti

xÞ sin hi þ ðy� tiyÞ cos hi

riy

" #29=;1A

� sin 2pxix ðx� ti

xÞ cos hi � ðy� tiyÞ sin hi

h i� �; ð2Þ

where tix; t

iy

� �; ri

x;riy

� �; hi and xi

x are the translation parameters,

the radial frequency bandwidths, the orientation and the centralfrequency of the transfer function of the ith hidden node, respec-tively. In order to simplify the presentation, the imaginary part ofa Gabor wavelet is represented by the term ‘an imaginary Gaborwavelet’ in the following discussion.

It can be noticed easily that each Gabor wavelet in the GWN in-volves seven parameters, i.e. ti

x; tiy; h

i;rix;ri

y;xix;wi

n o, which should

be determined by using the network training process. The objec-tive function of the network training process (the network optimi-zation) is defined as

E ¼ kf � f̂k22: ð3Þ

Hence, any function f ðf 2 L2ðR2ÞÞ can be numerically reconstructed[29] if sufficient appropriate Gabor wavelets are added into such anetwork.

Since Gabor basis functions are not orthogonal, a direct trans-form-like solution is not possible. Therefore, an optimization tech-nique called the Levenberg–Marquardt algorithm is used toconduct the network training process. In the process of networktraining, Gabor wavelets are added into the network one by one.The training process can be briefly described as follows:

(Step 1) N = 1. Use the LM algorithm to find the optimal values oft1

x ; t1y ; h

1;r1x ;r1

y ;x1x ;w1

n o;

Page 3: Fabric defect detection using morphological filters

K.L. Mak et al. / Image and Vision Computing 27 (2009) 1585–1592 1587

(Step 2) N = 2. Use the LM algorithm to find the optimal values of

t2x ; t

2y ; h

2;r2x ;r2

y ;x2x ;w2

n owith the values of

t1x ; t

1y ; h

1;r1x ;r1

y ;x1x ;w1

n ounchanged;

Fig. 1. (a)image, an

. . .. . .. . ..

Fig. 2. (a) The fabric image and (b) the reconstructed image obtained by using thetrained GWN with only one imaginary Gabor wavelet.

(Step i) N = i. Use the LM algorithm to find the optimal values of

tix; t

iy; h

i;rix;ri

y;xix;wi

n owithout changing the values of

ti�1x ; ti�1

y ; hi�1;ri�1x ;ri�1

y ;xi�1x ;wi�1

n o, . . . , and

t1x ; t

1y ; h

1;r1x ;r1

y ;x1x ;w1

n o.

A typical application of this procedure to study textile fabricimages is depicted in Fig. 1. Fig. 1(a) shows a fabric image capturedfrom a twill weaving fabric, which is used as a template image fortraining the GWN, Fig. 1(b) shows the reconstructed template im-age obtained by using the trained GWN with N ¼ 100 and Fig. 1(c)shows that the difference between the original template image andthe reconstructed template image is not significant. Obviously, thereconstruction of the complete image requires a fairly large N.However, it is interesting to discover that if the fabric image con-sists of some repetitive patterns, texture features can be extractedeasily from the template image for morphological operations with-out using the full image representation. In this research, the yarnwidth and the yarn orientation (Fig. 1(d)) have been identified asthe two important features for the textile fabric. These featurescan be extracted by using some of the parameters of the imaginaryGabor wavelets in the trained network. Fig. 2 shows the extractedbasic yarn features by using only one imaginary Gabor function inthe hidden layer of the trained GWN. In view of the form of thetransfer function given by Eq. (2), the yarn information is ex-pressed approximately by using the parameters rx and h of a singleimaginary Gabor wavelet in the hidden layer of the network asfollows:

wy ¼ 4rx

hy ¼ hþ p2

(ð4Þ

where wy and hy denote the yarn width and the yarn orientation ofthe template image, respectively. Such a GWN can also be used toextract local features for denim weaving fabrics since denim weav-ing fabrics usually have a similar pattern as that of twill weavingfabrics.

2.2. Morphological filters design

After the texture features have been extracted from the non-defective fabric image, morphological filters can be designed to de-tect defects, if any, from fabrics which have the same texture back-ground as the non-defective fabric image by using sample fabricimages captured from such fabrics. Mathematical morphology orsimply morphology has been recognized as a technique for theanalysis of spatial structures [33], which aims at analyzing theshapes and the forms of objects. The technique was first reported

The twill weaving fabric image, (b) the reconstructed image obtained by usingd (d) the yarn information in the fabric image.

as an image analysis tool in a study about porous materials [34].An introduction to morphological image processing, both binaryand grey level, and containing pictorial examples, is contained in[35]. The following discussions highlight briefly its important as-pects which are relevant to this research. Morphological operationsare conducted by comparing the object being studied with anotherobject called a structuring element which is chosen with a knownshape and size (e.g. a line, a square or a hexagon) for the purpose ofobject identification, noise elimination, etc. The shape and the sizeof the structuring element are usually chosen according to somepriori knowledge about the geometry of the image structure ofthe object being studied. Complex operations can usually beachieved by combining some simpler operations. Therefore, mor-phological filters can usually become a chain of operations.

2.2.1. Morphological operationsThe language of mathematical morphology is set theory. Sets in

mathematical morphology represent objects in an image. In binaryimages, the sets in question are members of the 2-D integer spaceZ2 where each element of a set is a 2-D vector whose coordinatesare the ðx; yÞ coordinates of a black or white pixel in the image.Let A and B be sets in Z2. For binary images, defining the reflectionof set B, denoted by bB, as bB ¼ fwjw ¼ �b; for b 2 Bg and the trans-lation of set A by point z ¼ ðz1; z2Þ, denoted by ðAÞz, asðAÞz ¼ fcjc ¼ aþ z; for a 2 Ag, the four fundamental morphologicaloperations are as follows:

(a) The dilation of A by B: A� B ¼ fzjðbBÞz \ A–;g.(b) The erosion of A by B: A� B ¼ fzjðbBÞz # Ag.(c) The opening of set A by structuring element B:

A � B ¼ ðA� BÞ � B.(d) The closing of set A by structuring element B:

A � B ¼ ðA� BÞ � B.

Note that dilation and erosion on binary images can be viewedas a form of convolution over a Boolean algebra of operations (NOT,AND, OR, XOR), which are defined between pixels of correspondinglocations in two images of equal dimensions [36]. Furthermore,

a trained GWN, (c) the difference between the fabric image and the reconstructed

Page 4: Fabric defect detection using morphological filters

1588 K.L. Mak et al. / Image and Vision Computing 27 (2009) 1585–1592

opening and closing are two higher order operations built on dila-tion and erosion. Due to the connection with Boolean operations,the erosion and dilation can turn black pixels white and white pix-els black when certain conditions are met. This explains why theopening and closing operations can clean up the detections yieldedby the Gabor procedure.

These operations can be extended for grey-scale images. In par-ticular, we are dealing with digital image functions of the formsf ðx; yÞ and bðx; yÞ, where f ðx; yÞ is the input image and bðx; yÞ is astructuring element. If Z denotes the set of real integers, theassumption is that ðx; yÞ are integers from Z � Z and that f ðx; yÞand bðx; yÞ are functions that assigned a grey-level value to eachdistinct pair of coordinates. Denote Df and Db as the domains of fand b, respectively, the four fundamental morphological opera-tions become:

(a) Grey-scale dilation of f by b:

ðf � bÞðs; tÞ ¼maxff ðs� x; t � yÞ þ bðx; yÞjðs� xÞ;ðt � yÞ 2 Df ; ðx; yÞ 2 Dbg:

(b) Grey-scale erosion of f by b:

ðf � bÞðs; tÞ ¼minff ðsþ x; t þ yÞ � bðx; yÞjðsþ xÞ;ðt þ yÞ 2 Df ; ðx; yÞ 2 Dbg:

(c) The opening of image f by structuring element b:

f � b ¼ ðf � bÞ � b:

(d) The closing of image f by structuring element b:

f � b ¼ ðf � bÞ � b:

It is well-known that the opening operation will smooth con-tours, breaks narrow isthmuses, and eliminates small islands andsharp peaks, while the closing operation will smooth contours,fuses narrow breaks and long thin gulfs, and eliminates smallholes. The results are that if the structuring elements are definedproperly, texture background can be removed easily by the open-ing and closing operations. Also, the defect images left behind willbe sharpened by the operations. Hence, alternating sequential fil-ters can be constructed by combining a number of openings andclosings, which is one of the most important filters in mathemati-cal morphology.

2.2.2. Design of filtersUnlike the conventional supervised approach, the GWN with

one imaginary Gabor wavelet in the hidden layer is used in this pa-per as a means to extract local texture features from a non-defec-tive fabric image. Feature extraction is conducted in the networkoptimization process (the network training process) by using anon-defective template image. After the network has been trained,the parameters of the resulting imaginary Gabor wavelet are di-rectly related to the basic yarn information contained in the tem-plate image. Based on the yarn information obtained, astructuring element can be constructed for developing morpholog-ical filters which are the key components of the defect detectionscheme proposed in this paper.

For 2-D discrete images, a structuring element is usually repre-sented by a set of points ði; jÞ in the 2-D space indicating its geom-etry, i.e. i; j 2 Z. For example, if the structuring element is a line,the set of points ði; jÞ are uniformly distributed along the line. Inthis case, two parameters, the length and the orientation, have tobe determined in order to construct an appropriate linear structur-ing element, so that the texture background can be eliminated asmuch as possible in the filtered fabric image. Indeed, the length

of the linear structuring element is set equal to the yarn width ofthe fabric image being studied, because the image of a piece of fab-ric containing defects consists of the images of defects and the tex-ture background formed by the images of yarns, and the size of theimage of a defect is usually larger than the width of the image of ayarn. Hence, the linear structuring element with a length of oneyarn width can effectively eliminate as much as possible the tex-ture background and prevent losing too much information aboutthe defect. In view of Eq. (4), the length of the linear structuringelement is set equal to 4rx, where rx is the bandwidth in the x-axisof the imaginary Gabor wavelet in the trained GWN. The orienta-tion of the linear structuring element depends on the type of fabricunder consideration. This paper only considers detecting defects incommonly used fabrics, i.e. plain, twill and denim fabrics. Sari-Sar-raf and Goddard [2] reported that in the textile industry, most fab-ric defects simply appear in some specific orientations (either inthe direction of motion (i.e. warp direction) or perpendicular to it(i.e. weft direction)), because of the nature of the weaving process.Therefore, the orientation of the linear structuring element is set top=4 for fabrics without obvious yarn orientation information likeplain fabrics, and is set perpendicular to the yarn orientation h ob-tained by using the trained Gabor wavelet network for the otherfabrics like twill and denim fabrics.

Fig. 3 depicts the proposed scheme for detecting defects in wo-ven fabrics. The scheme firstly employs a pair of opening and clos-ing to eliminate as much as possible the texture background in thefabric image. The linear structuring element obtained previously isused in both of the operations. Fig. 4 shows the effect of using thesetwo operations to filter a sample fabric image with a defect.Fig. 4(b) shows that the filtering process has effectively eliminatedmost of the texture background of the sample fabric image andkept the image which indicates the defect area. This results in asharp contrast between the resulting texture background and thedefect area in the filtered fabric image, which is an essential fea-ture of a good defect detection scheme.

2.3. Post-processing

Fig. 4 also depicts that, in the proposed detection scheme, a3� 3 median filter is applied to smooth the filtered fabric imagein order to reduce the amount of noise in the image. Thesmoothed fabric image is then closed again by using a 3� 3square structuring element. The last step of the proposed detec-tion scheme is a thresholding step for producing a binary detec-tion result. The thresholding limits kmax and kmin in this stepsatisfy the equation

kmax ¼maxx;y2W

jCðx; yÞj

kmin ¼ minx;y2W

jCðx; yÞj

8<: ; ð5Þ

where C is the resulting fabric image obtained by applying a pair ofopening and closing operations with the linear structuring elementdesigned in Section 2.2.2, the median filter and the closing opera-tion to a defect-free fabric image (a template image), W is a sub-window of the image C, the size of which should be suitably chosento avoid the distortion effect caused by the edges of the image, andCðx; yÞ is the grey level of the image pixel in position ðx; yÞ of the im-age C. kmax and kmin are the maximum value and minimum value ofthe grey levels of the image pixels in the sub-window. Hence, theoutput of the binarization step is a binary image B governed bythe equation

Bðx; yÞ ¼1; Cðx; yÞ > kmax or Cðx; yÞ < kmin

0; kmin 6 Cðx; yÞ 6 kmax

�ð6Þ

Page 5: Fabric defect detection using morphological filters

Minimization

Constructing optimal structuring element

Yarn features2

2

ˆE f f= −b( , )f x y

Template image

f b

( , )f x y

b

Sample image Linear

opening

f b••

Linear closing

Median Filter 3 3f b ו

Closing(3×3)

Thresholding

Detected defects

Detection

Training

Fig. 3. The proposed defect detection scheme based on morphological filters.

Fig. 4. (a) The sample fabric image with a big knot and (b) the resulting imageobtained by using a pair of linear opening and closing.

Table 1The overall performance of the proposed detection scheme.

The detection scheme Performance (No. of cases)

True detection (TD) 74False alarm (FA) 2Missed detection (MD) 2Total no. of cases 78

K.L. Mak et al. / Image and Vision Computing 27 (2009) 1585–1592 1589

where Bðx; yÞ is the value of the image pixel in position ðx; yÞ of theimage B. The determination of the thresholding limits kmax and kmin

is an important part of the calibration process before the actualinspection is conducted.

3. Experiments and results

3.1. Off-line performance analysis

The performance of the proposed defect detection scheme is eval-uated off-line by applying the scheme to detect defects in 78 fabricimages selected from the Manual of Standard Fabric Defects in theTextile Industry [37]. These images are captured by using a digitalflat-bed scanner. There are 39 defect-free images in the database.The other images contain different types of fabric defects including32 defects commonly appearing in the textile industry. The fabricsin the database are mainly plain, twill, denim weaving fabrics,although other types of fabrics are also included. In the paper, theimages have a size of 256� 256 pixels and an 8-bit grey level.

The performance of the scheme is determined by visuallyassessing the quality of the binary output images. True detections(TD) are recorded when (1) the white areas of the binary outputimage only overlap the areas of the corresponding defects in thefabric image, and (2) no white area appears in the binary outputimage if the fabric image contains no defect. False alarms (FA)are recorded when the white areas appearing in the binary outputimage do not only overlap the areas of the corresponding defects inthe fabric image, but also appear in some other areas significantlydistant from the defect areas, or when white areas appear in thebinary output image when the fabric image contains no defect.Overall detection (OD) is the sum of TD and FA. Missed detection(MD) means that no white area appears in the binary output imageeven if the fabric image contains a defect.

Table 1 summarizes the test results. In the off-line tests, theproposed scheme achieves a 97.4% overall detection (OD) rate with

a 2.6% false alarm rate, and only two defective images are missed.Fig. 5 shows some of the detection results. Fabric samples with dif-ferent fabric defects are displayed in Fig. 5(a), (c), (e), (g), (i), (k),(m), (o), (q),(s), (u), (w), and (y). The pairs of opening and closingoperations with the linear structuring elements obtained previ-ously, the median filter and the closing operation are used to pro-cess the fabric images and the final binary detection resultsobtained are displayed in Fig. 5(b), (d), (f), (h), (j), (l), (n), (p), (r),(t), (v), (x), and (z). It can be seen that the proposed scheme cansuccessfully segment the defects with different shapes, differentpositions and different texture backgrounds.

It can also be seen that the proposed scheme can performequally well in the case of bright defects with dark texture back-grounds, and in the case of dark defects with bright texture back-grounds. Even when the defect only alters the spatial arrangementof neighboring image pixels and not the mean grey level, the alter-ation can also be enhanced by the proposed scheme and the defecthas been successfully segmented.

The computational complexity of the proposed defect detectionscheme is analyzed in order to further evaluate its performance.Assume that the mask size of the structuring elements used inthe opening operation and the first closing operation is 1�m1, thatthe mask size of the median filter is m2 �m2, that the mask size ofthe structuring element in the second closing operation is m3 �m3,and that the size of the image is n� n pixels. The first two steps ofthe proposed scheme require ðm1 � 1Þ comparisons to erode or di-late each image pixel of the image. Thus, ðm1 � 1Þn½n� ðm1 � 1Þ�comparisons are required to erode or dilate the complete image.In this way, it requires 2ðm1 � 1Þn½n� ðm1 � 1Þ� comparisons toopen or close the image. Similarly, ðm2

2 � 1Þ! comparisons areneeded to conduct the median filtering for each image pixel, andtherefore ðm2

2 � 1Þ!� ½n� ðm2 � 1Þ�2 comparisons are required tofilter the entire image. The fourth step requires2 m2

3 � 1� �

½n� ðm3 � 1Þ�2 comparisons. Finally, the thresholdingstep requires 2n2 comparisons. If the proposed defect detectionscheme is applied to process the complete image, the number ofcomparisons needed is

4ðm1 � 1Þn½n� ðm1 � 1Þ� þ m22 � 1

� �! � ½n� ðm2 � 1Þ�2

þ 2 m23 � 1

� �½n� ðm3 � 1Þ�2 þ 2n2:

Page 6: Fabric defect detection using morphological filters

Fig. 5. Images of fabrics with different types of defects and the corresponding binary detection results.

1590 K.L. Mak et al. / Image and Vision Computing 27 (2009) 1585–1592

Hence, when m1 ¼ 7; m2 ¼ 3; m3 ¼ 3, and n ¼ 256; 2604 millionscomparisons have to be performed in processing each inspected im-age. If the camera employed can capture four frames per second, the

proposed scheme will need to perform approximately 10.4 billionscomparisons per second which indeed is not very computationallydemanding with a modern computer.

Page 7: Fabric defect detection using morphological filters

K.L. Mak et al. / Image and Vision Computing 27 (2009) 1585–1592 1591

3.2. Real-time performance analysis

In order to evaluate the proposed defect detection scheme for real-time implementation, a low-cost prototyped defect detection systemhas been developed in the laboratory. Fig. 6 shows the architecture ofthe developed automated defect detection system. The system con-sists of a fabric conveying module, a lighting module, an image acqui-sition module, a supporting frame and the proposed detectionscheme. Sari-Sarraf and Goddard [2] indicated that the followingissues had to be considered when designing an automated systemfor fabric inspection: (1) the vibration generated by the moving parts;(2) the irregular motion of the fabric; and (3) the system cost. All theseissues have been considered in developing the prototype system.

The image acquisition module mainly consists of a line scan cam-era (Model L103k-2k made by Basler (Germany)) and a frame grab-ber (Model Matrox Odyssey XCL made by Matrox (US)), and a cameralink connects these two components. Thus, an image can be capturedby the frame grabber interfaced to the camera by the camera link.Both the frame grabber and the control board are installed in apersonal computer with a Pentium IV 2.8 GHz CPU and 1.0 G RAM.

The performance of the proposed detection scheme is evaluatedin real time by using the prototyped automatic defect detectionsystem developed in the laboratory. The system is adjusted to cap-ture frames of images having a size of 768� 256 pixels and an 8-bit grey level, and with an image resolution of about 7.8 pixels

Fig. 6. Architecture of the prototype

per mm in both directions. The fabric conveying speed is about12 m/min. Comparing to plain weaving fabrics, twill weaving fab-rics are more difficult to inspect automatically because they havemore complicated texture background. In the experiments, a longpiece of twill weaving fabric is used which contains defects, suchas oil spot, burl, knot with halos. Two hundred and seventy-sixframes of images are captured and analyzed, in which 17 imagescontains different defects and 259 images are defect-free. Since itis difficult to obtain a long piece of fabric with a variety of fabricdefects, most of the defects are deliberately made by hand. Theexperimental results show that two fabric defects are missed(MD), and that a 3.3% false alarm rate is achieved. Fig. 7 displaysa real-time test example, in which a fabric defect is successfully de-tected by the proposed detection scheme. Indeed, the good detec-tion results achieved clearly demonstrate the efficiency,effectiveness and robustness of the proposed detection scheme.The prototype system developed also has the ability to recordinformation related to the defects appeared, in order to facilitatestatistical analyses conducted off-line.

4. Conclusions

When a piece of textile fabric with defects leaves the productionline, the locations, the shapes and the sizes of the defects normallycannot be predetermined. A conventional supervised defect detec-

d automated inspection system.

Page 8: Fabric defect detection using morphological filters

Fig. 7. (a) The fabric image and (b) the final binary detection result of the real-timetest.

1592 K.L. Mak et al. / Image and Vision Computing 27 (2009) 1585–1592

tion approach developed on the basis of some particular defect typestherefore may not be very suitable in practice and an unsupervisedapproach is usually preferred. However, the design of an unsuper-vised approach is rather complicated and the approach usually re-quires excessive computational efforts because of the largenumber of filters used. In this paper, a novel supervised defect detec-tion scheme for automated inspection of textile fabrics has been pro-posed. The proposed defect detection scheme consists of a Gaborwavelet network with only one imaginary Gabor wavelet in the hid-den layer and several simple morphological filters with a suitablydesigned linear structuring element. The Gabor wavelet networkhas been utilized to extract from the fabric image under consider-ation the basic texture features which serve as the priori knowledgefor the design of the linear structuring element. The performance ofthe proposed defect detection scheme has been extensively evalu-ated by using an off-line test database, which consists of a varietyof fabric defects including (1) different types, sizes, and shapes of de-fects, and (2) different texture backgrounds. The test results ob-tained have shown that the scheme is a simple and effective defectdetection method. The proposed scheme has also been further eval-uated in real time by conducting experiments with a prototypedautomated defect detection system developed in the laboratory. Fur-ther research can be conducted to apply the proposed scheme to de-tect defects in other products, such as non-woven fabrics, wood ormetal castings. In addition, the possibility of developing faster meth-ods of morphological filtering for implementation in the proposedscheme should also be investigated.

Acknowledgements

The work described in this paper was supported by a grant fromthe research Grants Council of the Hong Kong Special Administra-tive Region, China (Project No. HKU7382/02E). The authors wouldalso like to thank the reviewers for their helpful suggestions andconstructive comments on the earlier versions of the paper.

References

[1] K. Srinivasan, P.H. Dastoor, P. Radhakrishnaiah, S. Jayaraman, FDAS: aknowledge-based framework for analysis of defects in woven textilestructures. Part 1, J. Text. Inst. 83 (3) (1992) 431–448.

[2] H. Sari-Sarraf, J.S. Goddard, Vision systems for on-loom fabric inspection, IEEETrans. Ind. Appl. 35 (1999) 1252–1259.

[3] J. Wang, R.A. Campbell, R.J. Harwood, Automated inspection of carpets, Proc.SPIE 2345 (1995) 180–191.

[4] J.G. Campbell, C. Fraley, D. Stanford, F. Murtagh, A.E. Raftery, Model-basedmethods for textile fault detection, Int. J. Imaging Sci. Technol. 10 (1999) 339–346.

[5] J. Escofet, R. Navarro, M.S. Millan, J. Pladelloreans, Detection of local defects intextiles webs using Gabor filters, Opt. Eng. 37 (8) (1998) 2297–2307.

[6] A. Kumar, G.K.H. Pang, Fabric defect segmentation using multichannel blobdefectors, Opt. Eng. 39 (12) (2000) 3176–3190.

[7] A. Kumar, G.K.H. Pang, Defect detection in textured materials using optimizedfilters, IEEE Trans. Syst. Man Cybern. B: Cybern. 32 (5) (2002) 553–570.

[8] A. Kumar, Neural network based detection of local textile defects, PatternRecogn. 36 (2003) 1645–1659.

[9] D. Chetverikov, A. Hanbury, Finding defects in texture using regularity andlocal orientation, Pattern Recogn. 35 (2002) 2165–2180.

[10] A. Bodnarova, M. Bennamoun, K.K. Kubik, Suitability analysis of techniques forflaw detection in textiles using texture analysis, Pattern Anal. Appl. 3 (2000)254–266.

[11] S. Muller, B. Nickolay, Morphological image processing for the recognition ofsurface defects, Proc. SPIE 2249 (1994) 298–307.

[12] Y.F. Zhang, R.R. Bresee, Fabric defect detection and classification using imageanalysis, Text. Res. J. 65 (1995) 1–9.

[13] J.S. Lane, Textile fabric inspection system, U.S. Patent 5774177, 1998.[14] A. Bodnarova, M. Bennamoun, K.K. Kubik, Defect detection in textile materials

based on aspects of HVS, in: Proceedings of the IEEE SMC’98 Conference, SanDiego, CA, October 1998, pp. 4423–4428.

[15] A. Bodnarova, J.A. Williams, M. Bennamoun, K.K. Kubik, Optimal texturalfeatures for flaw detection in textile materials, in: Proceedings of the IEEETENCON’97 Conference, Brisbane, Australia, December 1997, pp.307–310.

[16] J.G. Campbell, C. Fraley, F. Murtagh, A.E. Raftery, Linear flaw detection inwoven textiles using model-based clustering, Pattern Recogn. Lett. 18 (1997)1539–1548.

[17] S. Ozdemir, A. Ercil, Markov random fields and Karhumen–Loeve transformsfor defect inspection of textile products, in: Proceedings of the IEEE Conferenceon Emerging Technologies and Factory Automation, vol. 2, November 1996, pp.697–703.

[18] D.M. Tsai, C.Y. Heish, Automated surface inspection for directional textures,Image Vis. Comput. 18 (1999) 49–62.

[19] C.H. Chan, G. Pang, Fabric defect detection by Fourier analysis, IEEE Trans. Ind.Appl. 36 (2000) 1267–1276.

[20] J.G. Campbell, F. Murtagh, Automatic visual inspection of woven textiles usinga two-stage defect detector, Opt. Eng. 37 (9) (1998) 2536–2542.

[21] W.J. Jasper, S.J. Garnier, H. Potapalli, Texture characterization and defectdetection using adaptive wavelets, Opt. Eng. 35 (1996) 3140–3149.

[22] A. Bodnarova, M. Bennamoun, S. Latham, Optimal Gabor filters for textile flawdetection, Pattern Recogn. 35 (2002) 2973–2991.

[23] A. Dockery, Automated fabric inspection: assessing the current state of the art,techexchange.com, 2001.

[24] J.L. Dorrity, G. Cachtsevanos, In process fabric defect detection andidentification, Mechatronics’98, Skovde, Sweden, September 1998.

[25] R.G. Saeidi, M. Latifi, S.S. Najar, A.G. Saeidi, Computer vision-aided fabricinspection system for on-circular knitting machine, Text. Res. J. 75 (6) (2005)492–497.

[26] K.L. Mak, P. Peng, Detecting defects in textile fabrics with optimal Gabor filters,Int. J. Comput. Sci. 1 (2006) 1306–4428.

[27] K.L. Mak, P. Peng, An automated inspection system for textile fabricsbased on Gabor filters, Robot. Comput.-Int. Manuf. Arch. 24 (3) (2008)359–369.

[28] C.S. Cho, B.M. Chung, M.J. Park, Development of real-time vision-basedfabric inspection system, IEEE Trans. Ind. Electron. 52 (4) (2005) 1073–1079.

[29] Q. Zhang, A. Benveniste, Wavelet networks, IEEE Trans. Neural Netw. 3 (6)(1992) 889–898.

[30] V. Krueger, G. Sommer, Gabor wavelet networks for object representation, in:DAGM Symposium, Germany, September 2000, pp. 13–15.

[31] V. Krueger, G. Sommer, Gabor wavelet networks for efficient heard poseestimation, Image Vis. Comput. 20 (2002) 665–672.

[32] V. Krueger, Gabor wavelet networks for object representation, Ph.D. thesis,Christian Albrecht University, Germany, 2001.

[33] P. Soille, Morphological Image Analysis, second ed., Springer, 2003.[34] G. Matheron, Elements Pour Une Theorie Des Milieux Poreux, Masson, Paris,

1967.[35] R.C. Gonzalez, R.E. Woods, Digital Image Processing, second ed., Prentice-Hall,

2002.[36] I.T. Young, J.J. Gerbrands, L.J. vanVliet, Fundamentals of image processing, in:

V.K. Madisetti, D.B. Williams (Eds.), The Digital Signal Processing Handbook,CRC Press, Boca Raton, FL, 1998, pp. 51.01–51.81.

[37] Graniteville Company, Manual of Standard Fabric Defects in the TextileIndustry, Grantiteville Company, South Carolina, 1975.