A fractal image analysis system for fabric inspection based on a box-counting method Aura Conci 1, Claudia Belmiro Proen‡a2 1Applied Computing and Automation - CAA 2Department of Mechanical Engineering - TEM Federal Fluminense University, Passo da Pßtria 156, 24 210-240, Niteri, RJ - Brazil Abstract Industrial vision systems must operate in real-time, produce a low false alarm rate and be flexible so as to accommodate changes in the manufacturing process easily.. This work presents a system for fabric manufacturing inspection. This environment, like paper and birch wood board industries, has particular characteristics in which morphological feature extraction for Automated Visual Inspection can not be used. The utilization of Fractal Dimension is investigates for discriminating defective areas. The efficiency of this approach is illustrated in textile images for defect recognition (with overall 96% accuracy). While this may sound complex, the method is in fact simple enough to be suitable for PC implementation, as demonstrated in the present work, and utilization across the Word Wide Web. Key Words: textile inspection, quality control, visual inspection, computer vision. 1.Introduction Visual inspection is an important part of quality control in the textile industry. This inspection has traditionally been performed, of course, using human eye. But besides the lack of reliable quantitative measurement data provided that way, visual assessment by humans has been both time consuming and cost-intensive. Moreover, due to the stress of the task, human inspection does not achieve a high degree of accuracy. To increase accuracy, attempts are being made to replace manual inspection by Automated Visual Inspection (AVI) which employs a camera and imaging routines. Process-accompanying image acquisition, automatic evaluation and control could form the basis for a system that will ensure a very high degree of product quality control. The main difficulty is solving the problem of quantifying visual impressions in complex situation like those met in fabric manufacture. Defects which need to be found by the inspections are numerous and complex. The ten most usually found are illustrated in Fig. 1 and 2. These are named: "canaster" (Fig. 1.a and 2.a); "machinery failure" (Fig. 1.b); "basting" (Fig. 1.c); "wrong thread" (Fig. 1.d and Fig. 2.f); "draw back" (Fig. 1.e and Fig. 2.g); "bulky thread" (Fig. 2.b); "gap" (Fig. 2.c); "broken thread" (Fig. 2.d); "weaving strip" (Fig. 2.e) and "slub" (Fig.2.h). It is important to note that the successful outcome of the implementation to a large extent depends upon the specific approach chosen. Traditionally, size and form, (morphological parameters), have been used in image analysis using thresholding or segmentation techniques. The proposed solution, here presented, focuses on detecting defects in textile images by calculating their textural properties. More specifically a methodology is investigated for discriminating defects by applying their fractal dimension. 2. Previous Works The most significant work along the lines of authors is U. M’ssigmann's [9], which makes use of Hausdorff dimension to characterize a multi-fractal set, and introduces a new method for the calculation of a fractal dimension (FD) of textures with the help of the scale space filtering. M’ssigmann goes even beyond by presenting typical applications of texture analysis for the automation of quality inspection tasks in industry in natural surfaces such as leather and stone. It is difficult however to compare objectively M’ssigmann's and the authors's approach, since the paper does not present implementation details nor an efficiency analysis. At first view, it is reasonable to admit that the theoretical superiority of [9] may not be differ very significantly in terms of actual fabric inspection in real time, as compared to the present effort. Moreover, the FD across a region is less important than the fast detection of considerable variations. Many applications of semi-fractal or multi-fractal concepts rely on the ability to estimate the fractal dimension of objects [18]. A wide variety of "fractal dimensions" have been used [2]. These measures can be useful in the analysis and classification of texture [7,9]. A major disadvantage is that in many cases these FD are hard to estimate by computational methods [14]. Pentland [12] noticed that the FD of surfaces could be used to obtain shape information and distinguish between smooth and rough regions. Some other applications involve image segmentation [15] and particle morphology [10]. Mandelbrot [8] stated that one criterion of an object being fractal is its self-similarity. Self-similarity can be explained as follows: if A is a compact set in Euclidean n-space, then this set is said to be self-similar when A is the union of distinct nonoverlapping copies of itself, each one similar to A scaled down by a ratio r. The FD of this set A could be derived from the relation 1 = Nr rFD or FD = log (Nr )/ log(1/r) (1) where Nr is the number of nonoverlapping copies of set A used to form the set by union of itself scaled down by r [8]. For gray level images, consider the Euclidean 3D space where two coordinates (x,y) represent 2D position and the third (z) coordinate represents the image intensity [12]. However, it is difficult to compute FD for images using Eq. 1. directly. An approximate method called the reticular cell counting has been proposed [3], but the FD estimated by this method saturates at about 2.5. The (-blanket idea presented by [11] has been used in many other methods. The box counting method uses the process of estimating the probability that m points lie in the box [17]. Keller et al. proposed a modification of the method due to Voss, which presents satisfactory results up to FD=2.75 [6]. Pentland suggested a method of estimating FD by using Fourier power spectrum of image intensity surface, such method gives satisfactory results (FD ( [2.0,3.0]) but, since Fourier transformation computation is included, it is slower than the others [12]. Sarkar and Chaudhuri described an efficient box-counting approach using the (-blanket idea, named Differential Box-Counting (DBC), that uses differences in computing Nr, and gives satisfactory results in all range of FD [16]. The FD in DBC method is given by FD = limr «0 log(Nr) / log(1/r) (2) where Nr is counted in a different manner from the other box-counting methods. Consider the image of M x M pixels has been partitioned into grids of s x s pixels and scaled down to r = s / M. If G is the total number of gray levels and s' is the number of gray level units in z-direction of each box, then G / s' = M / s. On each grid there is a column of boxes of size s x s x s' (for example see Fig. 3.). Assign number 1, 2, ... n to the boxes as shown. If the minimum gray level of the image in the grid (i,j) falls in box number k, and the maximum gray level of the images (i,j) grid falls in the box number l, then in DBC approach, the thickness of the blanket covering the image surface on the grid (i,j) is: nr (i , j) = l - k + 1, (3) This is the contribution to Nr (number of box needed to cover the whole image) from the grid (i,j). Taking contributions from all grids: Nr =( nr (i , j) (4) Nr is counted for different values of r and s. Then using Eq. 2. FD can be estimate from the least squares linear fit of log(Nr) against log(1/r). 3. Implementation To handle the large amounts of data, the inspection software must to process data in a way that minimizes computational complexity and enhances feature detection capabilities. Although the DBC method gives a very good estimate of FD some simplification in computation and improvement in efficiency is possible with the following changes in the original method. If a set A ( (3 is covered by just-touching boxes of side length (1/2n), Eq. 2. can be rewritten as FD = lim n «( (log Nn) / (log 2n) (5) where Nn denotes the number of boxes of side length (1/2n) which intersect the set A. In implementation, the image division in boxes of different length is processed in a new manner from other box counting variations and the original DBC method. Consider the image of size M x M pixels, we take M to be a power of 2 and take the range of light intensity to be the integers from 0 to 255. All images are enclosed in a big box of size M x M x 256. We consider the image divided into boxes of side length n x n x n' for n = 2, 4, 8, ... 2m (where m is taking from: 2(m-2)=M) and n' = 2, 4, 8...2m' (where m' is taking from 2(m'-2)=256) for each image division, Nn is counted as Nn = (nn (i,j), (6) nn=int(Gmax(i,j)/n')-int(Gmin(i,j)/n') + 1 (7) where int(./.) is the integer part of a division. These changes make the implementation faster and simpler than the DBC original algorithm. It is possible to read the image file only once, in the first image division in boxes, the bitmap of M x M pixels is not saved; when the image is read we save only two matrices of M / 2 x M / 2: Gmax and Gmin. This first calculation of nn, using Eq. 6., corresponds to dividing the image in boxes of 2 x 2 pixels. For boxes of 4 x 4 pixels there will be M / 4 x M / 4 elements in Gmax and Gmin , and each new element (i_new , j_new) is obtained from consulting only the four element (i , j), (i+1 , j), (i , j+1) and (i+1 , j+1) of the Gmax and Gmin matrices. If the algorithm begins with i=j=0 in each new iteration the Gmax and Gmin matrix elements (i_new= i / 2 and j_new= j / 2) for the next division of the image can be saved in the same space. Then using Eq. 5. we estimate FD from mean of log(Nn) / log(2n). It can be easily shown that the computation complexity of others approach, including the original DBC, is much higher than that of this approach. The "training" of this approach, to textile defect detection, proceeds as follows: (1) the user selects a perfect image to be presented to FD analysis; (2) then a defective image with defects to be found; (3) new image material is acquired by the system, in a predefined time interval; and (4) the analysis is done. The analysis decision is based on variation of the FD. If it is larger than the defined defect value, it corresponds to a fail detection and the system promotes an interaction with the user. The task of acquiring an image of sufficient quality and consistency becomes the first major challenge. The field of view (or the area of the object that will be viewed on the monitor) and the resolution of the defect to be recognized (or the smallest resolvable feature of the image) are important aspects to be considered. The relation between the defect surface and the image area must ensure defect representation in a suitable number of pixels. The remaining major parameter involves lighting. Experimentation with lighting is done for consistent acquisition. In general video cameras do not have the ability to view variations in illumination as well as our eyes. The results of improper illumination can be rather severe, yielding poor resolution and contrast. 4. Evaluation and Conclusions The software was written in C++. Its efficiency in automated inspection images, is illustrated on detecting the types of textile defects shown in Fig. 1 and 2. In each analyzed image there is 256x256 pixels and 256 gray levels. The test was carried out using 155 images of fabrics. Each image takes 10 seconds in a Pentium 100 machine. The utilization of the differential box-counting approach turns simple the used of FD to texture classification. The mathematical definition of others FD (such as, for example Hausdorff dimension and Minkowski dimension) require the consideration of various aspects which are hard to perform in practice using algorithms to calculate them. Although, this work have proved that FD concept can be used for automation of quality inspection task in textile industry, it is difficult to consider if the same efficiency will be possible using others FD estimators algorithms. Two categories of image acquisition are used. The first uses 75 images from a desktop CCD scanner. These images represent textiles with or without the types of defects shown on Fig. 1. Table 1. shows the DF representing standard textiles without defect and its deviation considered admissible. These deviations have been estimated by averaging differences between "good" and "defective" samples The number of samples used for each case can be see on Table 2. The accuracy of identification of each image as a good sample or a defective sample is also shown in Table 2. The results show that 80% of the defects in images were correctly located. The approach correctly identifies 76% of samples without defects. Ideal trustworthy systems must detect "100% good" and "100% failed". Table 1 DF parameters for defects in Fig. 1. Defect type Standard DF (DF Fig. 1 - a 2.340 0.015 Fig. 1 - b 2.320 0.015 Fig. 1 - c 2.360 0.015 Fig. 1 - d 2.430 0.015 Fig 1 - e 2.460 0.015 Table 2 Results using DF for defects in Fig.1 Defects Results % type numb. of samples found correct without with good failed a 10 10 30 100 b 5 5 80 100 c 5 5 100 0 d 10 10 100 100 e 10 5 70 100 total 40 35 76 80 The same images were processed by histogram thresholding [4]. The simplest and faster of segmentation methods has been used widely in the field of defect detection [13] and visual inspection [1]. The points at which the thresholding should be placed are often difficult to determine. The number of dark points on a non-defective textile image can be see on column named "Standard" in Table 3. If in an image the number of dark points will fall within a range from "Standard"-(NB to "Standard"+(NB it is considered non-defective image. These analyses take 15 seconds (each) in a Pentium 100 machine. Using this approach 82% of the defects in images was correctly located. The approach correctly identifies 52% of samples without defects. (Table 3). Table 3 Results using Thresholding for defects in Fig.1 Defect type Standard (NB Results %t good failed a 2570 770 30 90 b 73 22 80 60 c 350 150 60 100 d 1800 400 30 60 e 3850 400 60 100 total - - 52 82 The second category of image acquisition employs a camera and a frame grabber. This uses 80 images and directional illumination. These images represent textiles with or without the types of defects shown on Fig. 2. Table 4 shows the DF representing standard textiles without defect and its deviation considered admissible. Five samples are used for each case. The accuracy of identification of each image as a good sample or a bad sample is also shown in this table. The results show that 96% of the defects in these images were correctly located. The approach correctly identifies 72% of samples without defects. The same images were processed by thresholding. The number of dark points and its deviation on a non-defective textile image can be see in Table 5. Using this approach 90% of the defects in images was correctly located. The approach correctly identifies 72% of samples without defects. Table 4 Results using FD for defects in Fig.2 Defect type Stand. DF Admit. Dif. Results % found correct good failed a 2.590 0,044 100 100 b 2.744 0.008 100 100 c 2.644 0.008 60 90 d 2.651 0.007 60 100 e 2.658 0.005 100 80 f 2.634 0.006 60 100 g 2.856 0.002 60 100 h 2.842 0.004 40 100 total - - 72 96 The acquisition categories (equipment and illumination setups) have great influence in the performance of the system. The recommended approach to failure detection is related to the expected type of defects. Both methodologies (Fractal Dimension or Thresholding) showed a classification accuracy of 90% of defective textiles using a camera. Both are very simple and promising for use in the industrial quality control field (which employs cameras and digital boards). The use of Fractal Dimension is 50% faster then Thresholding and presents better results for Fig. 2.c defects, named "bulky thread". The results of the Fractal Dimension methodology in defective textile image recognition has achieved an overall 96%. The automated image system proposed by Karras and Karkanis [5] for textile images classification, based on wavelet (2D Haar) and neural network techniques, achieves a 98% defective area classification [5]. The processing time of their system are not mentioned in the paper. Table 5 Results using Thresholding for defects in Fig.2 Defect type Standard (NB Results % good failed a 1160 160 100 100 b 6460 400 80 100 c 42680 5300 60 80 d 48930 3000 60 100 e 34970 5700 60 100 f 34370 8800 100 80 g 11790 670 60 80 h 1200 600 60 80 total - - 72 90 Lastly, the advantages, efficiency and ease of the use of the system introduced herein, make it particularly attractive and suitable for utilization across networks, particularly WWW applications. Both research and manufacturing tasks will benefit significantly from a Web or shared-environment implementation. Acknowledgements This research was supported by project FINEP/RECOPE SAGE #0626/96, FAPERJ ref. 26/150.817/97 and CNPq ref. 302649/87-5. The authors sincerely thank the kind help from the referees, especially for pointing out relevant references, in particular, the introduction to the work of U. M’ssigmann [9] References [1] R.W. Conners, D.E. Kline, P.A. Araman, T.H. Drayer, Machine vision technology for the forest products industry, IEEE Computer, 7 (1997) 43-48. [2] K. Falconer, Fractal Geometry: Mathematical Foundations and Applications (John Wiley & Sons, Chinchester, 1990). [3] J. Gangepain, C. Roques-Carmes, Fractal approach to two dimensional and three dimensional surface roughness, Wear, 109 (1986) 119-126. [4] R. C. Gonzalez, R. E. Woods, Digital Image Processing, (Addison-Wesley, Massachusetts, 1992). [5] D. A Karras, S. A Karkanis, B.G. Mertzios, Texture Discrimination for Quality Control Using Wavelets and Neural Network Techniques, in: B.G. Mertzios and P. Liatsis ed., Proceedings IWISP'96 (Elsevier Science, Manchester, 1996) 191-194. [6] J. Keller, R. Crownover, S. Chen, Texture description and segmentation through fractal geometry, Computer Vision Graphics and Image Processing, 45 (1989) 150-160. [7] G. Lohmannm, Analysis and Synthesis of Textures: a co-occurrence-based approach, Computer & Graphics, 1 (1995) 29-36. [8] B. B. Mandelbrot, Fractal Geometry of Nature (Freeman & Co., San Francisco, 1982). [9] U. M’ssigmann, Texture Analysis by Fractal Dimension, in: J.L.Encarna‡ƒo, H. O. Peitgen. G. Sakas, G.Englert ed., , Fractal geometry and Computer Graphics, (Springer-Verlag, 1992) 217-230. [10] P J. Orford, W. Whalley, The use of fractal dimension to characterize irregular shaped particle, Sedimentology, 30 (1983) 655-668. [11] S. Peleg, J. Naor, R. Hartley, D. Avnir, Multiple resolution texture analysis and classification, IEEE Trans. Pattern Anal. Machine Intell., 6 (1984) 518-523. [12] A. P. Pentland, Fractal based description of natural scenes, IEEE Trans. Pattern Analysis and Machine Intell., 6 (1984) 661-674. [13] D. T. Pham, R.J. Alcock, Automatic Detection of Defects on Birch Wood Board, Proceedings Inst. Mech. Engrs. , 210 (1996) 45-53. [14] Qian Huang, J. R .Lorch, R. C. Dubes, Can fractal dimension of images be measured?, Pattern Recognition, 3 (1994) 339-350. [15] J. P. Rigaut, Automated image segmentation by mathematical morphology and fractal geometry, J. Microscopy, 150 (1988) 21-30. [16] N. Sarkar, B.B. Chaudhuri, An efficient differential box-counting approach to compute fractal Dimension of Image, IEEE Trans. Sys. Man and Cybernetics, 1 (1994) 115-120. [17] R. Voss, Random fractals: Characterization and measurement, in Scaling Phenomena in R. Pynn and A. Skjeltorp ed., Disordered Systems, (Plenum, 1986). [18] R. Voss, J.C. Wyatt, Multifractals and the Local Connected Fractal Dimension: Classification of Early Chinese Landscape painting, in: A. J. Crilly, R. A. Earnshaw and H. Jones, ed., Applications of Fractals and Chaos, (Springer-Verlag, Berlin, 1993) 171-184. Vitae Aura Conci, Dr.Sc. is titular professor in the Department of Mechanical Engineering and in the post graduate course of Applied Computer and Automation at Federal Fluminense University in Niteri (Brazil). Her research interests include Biomechanics, Applications of Computer Vision to Biomedical Engineering, Color Processing, Content-Based Image Retrieval and Image Compression (http://caa.uff.br/~aconci). Claudia Belmiro Proen‡a is currently researcher at the Federal Fluminense University in Niteri, in the Department of Mechanical Engineering. She received her D.Sc. in Mechanical Engineering, with a thesis with emphasis on Computer Graphics, from Pontificia Universidade Catlica, Rio de Janeiro, Brazil, in 1997. Her research interests include Computer Graphics, Image Processing and Computer-Aided Inspection. ( http://caa.uff.br/~cproenca) 1 Corresponding author. E-mail: aconci@caa.uff.br 2 E-mail: cproenca@caa.uff.br