You are on page 1of 5

Global Congress on Intelligent Systems

Fabric Defect Detection Method Based on Gabor Filter Mask

Runping Han and Lingmin Zhang

Beijing Institute of Fashion Technology
Beijing, China

Abstract—In this paper, a fabric defect detection method extract the basic texture features of defect-free fabric image
based on Gabor filter masks is proposed. In this method, one and whose parameters are determined by the optimization
even symmetric Gabor filter mask and one odd symmetric techniques called the Levenberg-Marquardt algorithm. In the
Gabor filter mask derived from the impulse response of the method proposed in this paper, only one optimal Gabor filter
optimal Gabor filter are used. The optimal Gabor filter is that matches with the texture features of defect-free fabric
designed to match with the texture features of defect-free image is used for fabric defect detection. Parameters of the
fabric image, whose parameters are obtained by using the optimal Gabor filter are obtained by genetic algorithm(GA).
genetic algorithm. The performance of the proposed method is As a result, two filter masks derived from the optimal Gabor
evaluated off-line by using a group of fabric sample images filter are used for defect detection, one of which is even
containing many kinds of fabric defects. The experimental symmetric Gabor filter mask, the other is odd symmetric
results exhibit its accurate defect detection with low false one. The remaining sections of this paper are organized as
alarms. And the effectiveness and robustness of the proposed follows: Section Ⅱ gives a brief description of Gabor filter.
method are confirmed.
Section Ⅲ introduces defect detection scheme. Section Ⅳ
Keywords-fabric defect detection; Gabor filter; convolution describes how to applying GA to acquire parameters of the
mask; GA optimal Gabor filter in detail. Section Ⅴ gives the defect
detection experimental results. Section Ⅵ gives the
I. INTRODUCTION conclusions from this work.
Fabric defect detection has been of great importance to II. GABOR FILTER
the quality control of textile. Researches on fabric defect
Gabor filter used in this fabric defect detection method is
detection have been conducted over the past decades.
a Gaussian that is modulated by a complex sinusoid. Its
Although certain achievements have been obtained, it is still
impulse response is expressed as follows.
a challenging problem to be researched because fabric
defects are various in sort, shape and size. 1 1 ⎛ x2 y 2 ⎞
h( x, y ) = exp[− ⋅ ⎜ 2 + 2 ⎟] ⋅ exp ( 2π ju0 x ) (1)
References [1-6] summarized that Gabor filter is 2πσ xσ y 2 ⎜⎝ σ x σ y ⎟⎠
especially effective for fabric defect detection. Gabor filter is In (1), σ x and σ y define the Gaussian envelope along the
essentially a band-pass filter. In the spatial domain, its
impulse response, Gabor function, is the product of a x and y axes. If σ x = σ y , the Gabor filter is circularly
complex exponential function and a Gaussian function. symmetric; otherwise, it is asymmetric. u0 represents the
Gabor filter has high resolution capability both in spatial Gabor filter’s radial center frequency and determines its
domain and in frequency domain. When using Gabor filter location in the frequency domain. The real part and
bank for defect detection, the problems we meet are that the imaginary part of Gabor filter are expressed respectively as
more filters in filter bank, the longer it needs to realize defect (2) and (3).
segmentation, and some filter in filter bank may be bad for
1 1 ⎛ x2 y2 ⎞
the final defect detection result. Using more Gabor filters for he ( x, y ) = exp[ − ⋅ ⎜ 2 + 2 ⎟⎟] ⋅ cos ( 2π u0 x ) (2)
2πσ xσ y 2 ⎜⎝ σ x σ y ⎠
fabric defect detection can generate extensive data for
processing, which makes it difficult to satisfy the real-time 1 1 ⎛ x2 y2 ⎞
demand of some systems. How to find the most suitable ho ( x, y ) = exp[ − ⋅ ⎜ 2 + 2 ⎟] ⋅ sin ( 2π u0 x ) (3)
2πσ xσ y 2 ⎜⎝ σ x σ y ⎟⎠
Gabor filters on the basis of the defect-free fabric image to
enhance the real-time performance, adaptability and The real part of Gabor filter, he ( x, y ) , is an even
precision of detection method is an increasingly important function, called even symmetric Gabor filter, while the
research issue when using the Gabor filters for fabric defect imaginary part, ho ( x, y ) , is an odd function, called odd
symmetric Gabor filter. The difference of phase between
D.F. Dunn [3] and A.Kumar et al. [4] used several Gabor
them is 90°.
filters to detect fabric defects, which brings that the detection
We can get the Gabor filter (see (4)) with frequency
time increases undoubtedly, and some Gabor filter may be
bad for defect detection. K.L.Mak and P.Peng [5] used one u0 and orientation θ by coordinate rotation.
Gaussian low pass filter and one Gabor filter which can

978-0-7695-3571-5/09 $25.00 © 2009 IEEE 184

DOI 10.1109/GCIS.2009.356
1 ⎧⎪ 1 ⎡ ( x ' )2 ( y ' )2 ⎤ ⎫⎪ imaginary part of impulse response of the optimal Gabor
h′( x, y) = exp ⎨− ⋅ ⎢ 2 + 2 ⎥ ⎬ ⋅ exp(2π u0 x ') (4) filter.
2πσ xσ y ⎪⎩ 2 ⎢⎣ σ x σ y ⎥⎦ ⎪
⎭ A fabric sample image which may contain defects and its
Where x′ = x ⋅ cos θ + y ⋅ sin θ , y′ = − x ⋅ sin θ + y ⋅ cos θ , θ corresponding defect-free fabric image are filtered by using
represents rotation angle. x and y represent initial this two filter masks respectively in order to obtain two
ordinates, while x′ and y ′ represent ordinates after rotation. filtered sample images and two filtered defect-free fabric
images, and then we can get two binary images by
In this method, we use Gabor filter with σ x = σ y = σ , conducting binarization operation on two filtered sample
therefore, odd symmetric Gabor filter with frequency u0 and images respectively, in which the threshold values are
orientation θ is expressed as follows. obtained on the basis of the filtered defect-free fabric image.
The final segmentation result, binary output image, can be
1 1 ⎛ x2 + y 2 ⎞
ho′ ( x, y ) = exp[− ⋅ ⎜ ⎟] ⋅ sin(2π u0 x ') (5) acquired by fusing the two binary images. The flow chart of
2πσ 2
2 ⎝ σ2 ⎠ the defect detection scheme proposed in this paper is shown
as Fig.1.
A.Selection of Optimal Gabor Filters
Many researchers applied Gabor filter to fabric defect
detection because it has good performances both in spatial A.Kumar and G.Pang [6] pointed out that the odd
domain and in frequency domain. In general, an even symmetric Gabor can be tuned to extract the texture features
symmetric Gabor filter is good at detecting blob-shaped of defect-free fabric image. In the method proposed in this
fabric defects including knot, burl, et al., while an odd paper, the imaginary part of the optimal Gabor filter is tuned
symmetric one performs well in detecting edge-shaped fabric to roughly describe the texture features of defect-free fabric
defects including mispick, overshot, et al.. In this method, image by minimizing the objective function that is given by
even symmetric and odd symmetric Gabor filter masks are (8).
used for better defect detection. Assume that g ( x, y ) represents the defect-free fabric
As shown in Fig.1, a defect-free fabric image is used to
design the optimal Gabor filter whose parameters image. The difference between h0′ ( x, y ) (see (5)) and g ( x, y )
optimization process is conducted by GA. After parameters at pixel point ( x, y ) is large. In order to make parameters
optimization process, the optimal Gabor filter that can match optimization process more efficient, the value of h0′ ( x, y ) is
with the texture features of defect-free fabric image is
determined. Then, even symmetric and odd symmetric Gabor transformed to (-1,1) by multiplying it with the coefficient
filter masks are derived respectively from the real and 2πσ 2 , that is, h0′ ( x, y ) is transformed to h0′′ ( x, y ) which is
defined by (6). Obviously, the coefficient 1 / ( 2πσ 2 ) does
not influence the shape of odd symmetric Gabor filter, and it
only adjusts amplitude, therefore, the transformation does
not alter the basic characteristics of Gabor filter.
1 ⎛ x2 + y2 ⎞
ho′′( x, y) = exp[− ⋅ ⎜ ⎟] ⋅ sin(2π u0 x ') (6)
2 ⎝ σ2 ⎠
Accordingly, the value of g ( x, y ) is transformed to (-1,1)
based on (7), and f ( x, y ) is formed.
2 ⋅ g ( x, y ) − max g ( x, y ) − min g ( x, y )
f ( x, y ) = (7)
max g ( x, y ) − min g ( x, y )
The optimal Gabor filter can be determined based on (8).
E = min f ( x, y ) − ho′′ ( x, y ) (8)
In this method, the key point is to find out a group of
parameters {θ , σ ,u0 } of the optimal Gabor filter by
minimizing the objective function given in (8).
B.Gabor Filter’s Parameters Optimization
In the research, two methods are selected for obtaining
optimal Gabor filter’s parameters {θ , σ ,u0 } . One is to use
fmincon function in MATLAB toolbox, the other is to use
GA. Both of them use the same objective function given by
Fig.1 Flow chart of the defect detection scheme (8) for parameters optimization. When using fmincon
function to optimize parameters, the defect detection results

are unsatisfactory if we select improper initial values of ⎪⎧ 1, g d ( x , y ) ≥ t max or g d ( x , y ) ≤ t min
Gabor filter’s parameters. This method is sensitive to the Ga ( x, y ) = ⎨ (11)
⎪⎩ 0, t min < g d ( x , y ) < t max
initial values of parameters, and it is proved to be time-
consuming. Therefore we use GA instead. GA hardly E.Image Fusion
demands auxiliary information or knowledge. It can get Considering that for a sample image, defect detection
exact or approximate solutions to optimization or searching result obtained by using odd symmetric Gabor filter mask is
problems by objective function which influences the not identical with the one obtained by using even symmetric
direction of searching. Its advantage lies in its robustness, Gabor filter mask, in order to maintain the high probability
global optimality and extensive applicability. Section Ⅳ of detection of defects, two binary images from two masks
will summarily discuss the genetic algorithm used for need to be fused. As shown in (12), the final detection result,
optimizing Gabor filter’s parameters. also called defects segmented or binary output image shown
C.Filtering with Convolution Masks in Fig.1 is obtained by fusing two binary images.
G ( x , y ) = GR ( x , y ) + GI ( x , y ) (12)
The real part mask and the imaginary part mask of the
optimal Gabor filter, that is, even symmetric Gabor filter IV. OPTIMIZING GABOR FILTER PARAMETERS USING GA
mask and odd symmetric Gabor filter mask (the size of
mask is 7 × 7 in this method) can be easily obtained by A genetic algorithm is a searching technique used in
sampling the real part and the imaginary part of impulse computing to find exact or approximate solutions to
response of the optimal Gabor filter in spatial domain. optimization and searching problems. Genetic algorithms
Filtering a sample image and its corresponding defect-free are a particular class of evolutionary algorithms that use
fabric image can be implemented by using (9). techniques inspired by evolutionary biology such as
inheritance, selection, crossover and mutation.
⎧ g s = g so ⋅ a _ M
⎨ a is R or I (9) The purpose of optimizing Gabor filter’s parameters
⎩ g d = g do ⋅ a _ M using GA on the basis of defect-free fabric image is to
In (9), R_M and I_M represent an even symmetric Gabor determine optimal Gabor filter’s parameters. In order to
filter mask and an odd symmetric Gabor filter mask solve this parameters optimization problem, a genetic
respectively. gdo represents a sample image, while gso algorithm is developed. In this genetic algorithm, binary
represents its corresponding defect-free fabric image. When encoding is used. The length of binary string is determined
a is R or I in (9), filtering mask is an even symmetric Gabor by the precision of parameters for solving problems.
filter mask or an odd symmetric Gabor filter mask. gs and gd Parameters involved in this algorithm are accurate to the
are obtained by filtering the defect-free fabric image and the fourth decimal place. Based on binary encoding, the genetic
sample image respectively. operation is composed of roulette wheel selection operator,
single-point crossover operator, improved mutation operator.
D.Binarization Reinsertion operation is used for keeping population size.
In view of (10), the threshold value tmax and tmin of the The operational parameters of this genetic algorithm are
binarization step can be determined from the image gs selected as follows: the size of population is 40, the
obtained by filtering a defect-free fabric image using Gabor maximum evolutional generation is 500, the objective
filter mask. W is sub-window centered at the image gs, the function is given by (8), generation gap is 0.9, and crossover
size of which should be suitably chosen to contain rate is 0.6. In this genetic algorithm, an improved mutation
information of pixel gray value as much as possible and operator [7] is used to prevent premature convergence,
avoid distortion caused by the edges of the image, tmax and which is mentioned in the following paragraph.
tmin are the maximum value and minimum value of the gray Mutation operation changes randomly the encoding
value of the image pixel in the sub-window. string of the new offspring. It is an auxiliary method to
⎧tmax = max g s ( x, y ) produce new individuals. There are two reasons for applying
⎪ x , y∈W
mutation operator to GA. One is to improve local searching
⎨ (10)
⎪⎩ tmin = xmin g s ( x, y ) capability, and the other is to prevent all solutions in
, y∈W
population falling into a local optimum by increasing the
Hence, the operation of the binarization step is shown as
diversity of population [8]. In this genetic algorithm, we
(11). As for a defect-free fabric image, its pixel’s gray value
adopt the improved mutation operator to increase the
varies in a certain range, if the gray value of a pixel in
diversity of population.
sample image exceeds the range, this pixel is determined as
Assume that current population is X, which contains N
a defect pixel. When a is R, GR is the binary image obtained
individuals, the length of chromosome is M. X is expressed
by using even symmetric Gabor filter mask. Similarly, GI is
by (13).
the binary image obtained by using odd symmetric Gabor
filter mask.

⎡ x11 x12 " x1k " x1M ⎤
⎢ ⎥
x x " x2 k " x2 M ⎥
X = [ X 1 , X 2 ," , X N ] = ⎢ 21 22
⎢""""""" ⎥
⎢ ⎥
⎣ xN 1 xN 2 " xNk " xNM ⎦
For the kth gene bit, if the number of 1 is n, p=n/N , and
Fig.2 Defect detection results
p is called gene frequency. The diversity of gene in the kth
gene bit is expressed as (14).
1 1
D ( p) = exp[− ( p − 0.5 ) ] ( 0 ≤ p ≤ 1)
2π 2
The diversity D(p) obeys a normal distribution. When p
is equal to 0.5, gene diversity becomes maximum, and small
mutation rate is needed, while p is equal to 0 or 1, all of Fig.3 Knot defect detection results
genes in the kth gene bit are 0 or 1, in this case, GA should
increase the diversity of population by increasing mutation
rate to restore omitted and useful genes. The diversity is in
inverse proportion to mutation rate, so the mutation rate pm
can be obtained by normalizing the reciprocal of D(p),
which is expressed as (15).
1 1

D ( p ) D ( 0.5 ) ⎧ ⎡1 2⎤ ⎫
pm ( p ) = = 7.51 ⋅ ⎨exp ⎢ ⋅ ( p − 0.5 ) ⎥ − 1⎬ (15)
1 1 ⎩ ⎣ 2 ⎦ ⎭

D (1) D ( 0.5 )
Mutation operation is local random searching. It can
improve local searching capability of GA and increase
diversity of population. However, when mutation rate is too
large, GA will degenerate into random searching. From (15),
mutation operation can not be performed when p =0.5, so pm
needs to be revised. In this genetic algorithm used for Gabor
filter’s parameters optimization, the mutation rate for
mutation operation is given by (16).
⎧ ⎡1 2⎤ ⎫
pm′ ( p ) = 0.0001 + 0.1× 7.51 ⋅ ⎨exp ⎢ ⋅ ( p − 0.5 ) ⎥ − 1⎬ (16)
⎩ ⎣2 ⎦ ⎭


Fig.2 gives defect detection results using the method
proposed in this paper. A sample image is shown in Fig.2(a), Fig.4 Defect detection results of some sample images
detection results (binary images) from even symmetric
Gabor filter mask and odd symmetric Gabor filter mask are TABLEⅠ EVEN SYMMETRIC GABOR FILTER MASK
shown in Fig.2(b) and Fig.2(c) respectively. Defect
0.914 0.915 0.915 0.916 0.915 0.915 0.914
detection results given in Fig.2 demonstrate that even 0.960 0.961 0.961 0.962 0.961 0.961 0.960
symmetric Gabor filter is good at detecting blob-shaped 0.988 0.990 0.990 0.990 0.990 0.989 0.988
fabric defects and odd symmetric Gabor filter performs well 0.998 0.999 0.999 1 0.999 0.999 0.998
in detecting edge-shaped fabric defects. Fig.2(d) shows the 0.988 0.989 0.990 0.990 0.990 0.989 0.988
final segmented defect in the binary output image. 0.960 0.961 0.961 0.962 0.961 0.961 0.960
0.914 0.915 0.915 0.916 0.915 0.915 0.914
Fig.3 shows the detection results of the sample image
containing a knot defect. Parameters of the optimal Gabor TABLE Ⅱ ODD SYMMETRIC GABOR FILTER MASK
obtained by GA are u0 = 0.0010, σ = 10.0000,θ = 2.9944.
0.020 0.019 0.018 0.017 0.016 0.015 0.015
Table 1 and Table 2 give its corresponding even symmetric 0.015 0.014 0.013 0.012 0.011 0.010 0.009
Gabor filter mask (multiplied by 2πσ 2 ) and odd symmetric 0.009 0.008 0.007 0.006 0.005 0.004 0.003
Gabor filter mask (multiplied by 2πσ 2 ). Defect detection 0.003 0.002 0.001 0 -0.001 -0.002 -0.003
-0.003 -0.004 -0.005 -0.006 -0.007 -0.008 -0.009
results of some other sample images are shown in Fig.4. -0.009 -0.010 -0.011 -0.012 -0.013 -0.014 -0.015
-0.015 -0.015 -0.016 -0.017 -0.018 -0.019 -0.020

The performance evaluations of this detection method are The performance of the detection method has been
made by visually comparing defects appearing in sample evaluated by the detection results obtained from a set of 42
images with their segmented results. We use several sample images that have different background texture and
statistical criteria such as true detection(TD), false contain different types, sizes, and shapes of defects. The
alarm(FA), misdetection(MD), overall detection(OD) for statistical data on the performance evaluations of this
performance evaluations. TD is recorded when (1) the white proposed method show that the method performs well in
areas of the binary output image only overlap the areas of the detecting fabric defects. The detection results obtained
corresponding defects in the sample image, and (2) no white confirm the effectiveness, efficiency and adaptability of the
area appears in the binary output image if the sample image method. In addition, further research on Gabor filter’s
contains no defect. FA is recorded when the white areas of parameters optimization should be conducted in order to
the binary output image do not only overlap the areas of the acquire the most suitable Gabor filter.
corresponding defects in the sample image, but also appear
in some other areas significantly distant from the defective ACKNOWLEDGMENT
areas, or when white areas appear in the binary output image This research has been supported by the Hubei Digital
even though the sample image contains no defect. OD is the Textile Equipment Key Laboratory Open Subject (No.
sum of TD and FA. MD means that no white area appears in DTL200707).
the binary output image even though the sample image
contains a defect. REFERENCES
In this research, we use a set of 42 sample images of
different background texture for the performance evaluations [1] J.Escofet, R.Navarro, MS.Millan, and J.Pladelloreans,
of this proposed method, which contain common defects “Detection of local defects in textile webs using Gabor
appearing in textile industry. Table 3 shows statistical data of filters,” Opt. Eng.,Vol.37,1998,pp.2297-2307.
the test results obtained by the proposed method in this [2] D.Dumn,W.E.Higgins, and J.Wakeley, “Texture segmentation
paper. using 2-D Gabor elementary functions,” IEEE Transactions
on Pattern Analysis and Machine Intelligence, Vol.16, Issue
2, 1994,pp 130-149.
[3] D.F.Dunn, “Designing Gabor filters for texture
OD TD FA MD segmentation,” Ph.D. thesis, Pennsylvania State
Number of image 40 39 1 2 University,USA, 1992.
Detection rate 95.24% 92.86% 2.38% 4.76% [4] A.Kumar and G.Pang, “Fabric defect segmentation using
multichannel blob defectors,” Opt. Eng., Vol.39, No.12, 2000,
VI. CONCLUSIONS pp.3176-3190.
[5] K.L.Mak and P.Peng, “An automated inspection system for
In general, defect detection approaches can be classified textile fabrics based on Gabor filters,” Robotics and
into two categories, one of which is supervised detection Computer-Integrated Manufacturing, Vol.24, Issue 3, 2008,
approach, the other is unsupervised detection approach. A pp.359-369.
conventional supervised approach developed based on the [6] A.Kumar and G.Pang, “Defect detection in textured materials
knowledge of some particular defect types may not be using Gabor filters,” IEEE Transaction on Industry
suitable in practice and an unsupervised approach is more Application,Vol.38,No.2,2002, pp.425-440.
practical. However, the design of unsupervised approach is [7] Qiuling Wu and Qiwen Yang, “The modified adaptive
rather complicated. In this paper, an unsupervised defect mutation operator,” Journal of HOHAI University, Vol.19,
detection method has been proposed, which consists of only
[8] Wenjie Huo,Shanwen Zhang, xuwu Li, and chuangming
one optimal Gabor filter, that is, two real-valued Gabor Zhou, “Genetic algorithm toolbox in MATLAB and its
filters. A genetic algorithm is developed to determine the application,” Publishing House of Electronics Industry,
optimal Gabor filter’s parameters on the basis of the defect- China, 2005, pp.17.
free fabric image.