real-time defect inspection of textured surfaces

11
Real-time Defect Inspection of Textured Surfaces T exture analysis plays an important role in the automated visual inspection of textured images to detect their defects. For this purpose, model-based and feature-based methods are implemented and tested for textile images in a laboratory environment. The methods are compared in terms of their success rates in determining the defects. The Markov Random Field model is applied on dierent DSP systems for real-time inspection. # 2000 Academic Press Alper Baykut, Alper Atalay, Aytu¨l Erc¸il and Mustafa Gu¨ler Bogazici University, Department of Industrial Engineering, Bebek, Istanbul 80815, Turkey email: [email protected], [email protected] Introduction Quality inspection of textile products is an important problem for fabric manufacturers. Currently, the quality control operation is mostly carried out by human operators. The operator examines the fabric while it passes over a light table with a speed of 8–20 m/min. When the operator notices a defect, he stops the motor that moves the fabric, records the defect and the location of it on the fabric and then starts the motor again. When all of the fabric is inspected the number of defects per meter length of the fabric is calculated and the fabric is classified. During the control, if the operator notices an extraordinary defect rate or repeat- ing defects, he warns the production department so that measures can be taken to decrease the defect rate. For large and obvious defects the control results may be reliable, however, the operator inevitably misses small defects and sometimes large ones also. Generally the width of the fabric is about 160–200 m. It is dicult for a human eye to keep with an object of that width moving at a speed of 10 m/min. Texture analysis plays an important role in automatic visual inspection of surfaces. There have been a limited number of applications of texture processing techniques to automated inspection problems. Conners et al. [1] utilized texture analysis methods to detect defects in lumber wood automatically. Siew et al. [2] proposed a method for the assessment of carpet wear. Chen and Jain [3] used a structural approach to defect detection in textured images. Dewaele et al. [4] used signal processing methods to detect point defects and line defects in texture images. Cohen et al. [5] used Markov Random Field models for defect inspection of textile surfaces while Erc¸il et al. [6] used similar techniques for the inspection of painted metallic surfaces. Atalay [7] has implemented a Markov Random Field model-based method on a TMS320C40 parallel processing system for real-time defect inspection of textile fabrics. For recent surveys of texture analysis see Gool et al. [8], Rao [9] and Tuceryan and Jain [10]. In this paper various texture analysis algorithms are studied for textile quality inspection and a parallel 1077-2014/00/020017+11 $35.00/0 # 2000 Academic Press Real-Time Imaging 6, 17–27 (2000) doi:10.1006/rtim.1998.0153, available online at http://www.idealibrary.com on

Upload: independent

Post on 13-Nov-2023

0 views

Category:

Documents


0 download

TRANSCRIPT

Real-Time Imaging 6, 17±27 (2000)doi:10.1006/rtim.1998.0153, available online at http://www.idealibrary.com on

Real-time Defect Inspection ofTextured Surfaces

Texture analysis plays an important role in the automated visual inspection of texturedimages to detect their defects. For this purpose, model-based and feature-based methodsare implemented and tested for textile images in a laboratory environment. The methods

are compared in terms of their success rates in determining the defects. The Markov RandomField model is applied on di�erent DSP systems for real-time inspection.

# 2000 Academic Press

Alper Baykut, Alper Atalay, AytuÈ l ErcË il and Mustafa GuÈ ler

Bogazici University, Department of Industrial Engineering,

Bebek, Istanbul 80815, Turkey

email: [email protected], [email protected]

Introduction

Quality inspection of textile products is an importantproblem for fabric manufacturers. Currently, the qualitycontrol operation is mostly carried out by humanoperators. The operator examines the fabric while itpasses over a light table with a speed of 8±20 m/min.When the operator notices a defect, he stops the motorthat moves the fabric, records the defect and thelocation of it on the fabric and then starts the motoragain. When all of the fabric is inspected the number ofdefects per meter length of the fabric is calculated andthe fabric is classi®ed. During the control, if theoperator notices an extraordinary defect rate or repeat-ing defects, he warns the production department so thatmeasures can be taken to decrease the defect rate. Forlarge and obvious defects the control results may bereliable, however, the operator inevitably misses smalldefects and sometimes large ones also. Generally thewidth of the fabric is about 1�60±2�00 m. It is di�cult fora human eye to keep with an object of that widthmoving at a speed of 10 m/min.

1077-2014/00/020017+11 $35.00/0

Texture analysis plays an important role in automaticvisual inspection of surfaces. There have been a limitednumber of applications of texture processing techniquesto automated inspection problems. Conners et al. [1]utilized texture analysis methods to detect defects inlumber wood automatically. Siew et al. [2] proposed amethod for the assessment of carpet wear. Chen andJain [3] used a structural approach to defect detection intextured images. Dewaele et al. [4] used signal processingmethods to detect point defects and line defects intexture images. Cohen et al. [5] used Markov RandomField models for defect inspection of textile surfaceswhile ErcË il et al. [6] used similar techniques for theinspection of painted metallic surfaces. Atalay [7] hasimplemented a Markov Random Field model-basedmethod on a TMS320C40 parallel processing system forreal-time defect inspection of textile fabrics. For recentsurveys of texture analysis see Gool et al. [8], Rao [9]and Tuceryan and Jain [10].

In this paper various texture analysis algorithms arestudied for textile quality inspection and a parallel

# 2000 Academic Press

Figure 1. Natural hierarchy of MRF models determined byneighborhood con®gurations of increasing order.

18 A. BAYKUTETAL.

implementation design of the Markov Random Fieldmodeling based algorithm using a TMS320C40 basedsystem is given.

Markov Random Field Models

Model-based texture analysis methods try to capture theprocess that generated the texture. They try to model thetexture by determining the parameters of a pre-de®nedmodel. The brightness level at a point in an image is highlydependent on the brightness levels of the neighboringpoints unless the image in simply random noise. MarkovRandom Fields use a precise model of this dependence[5,11]. They are able to capture the local (spatial)contextual information in an image. These models assumethat the intensity at each pixel in the image depends on theintensities of only the neighboring pixels.

Let Y(i, j) denote the brightness level at a point (i, j)on the N6N lattice L. For the sake of simplicity let ustake the labeling of the Y(i, j) to be Y(i),=1,2, . . . , M,where M=N2. A coloring of lattice L (or a coloring of Lwith G levels) denoted by Y is a function from the pointsof L to the set {0,1, . . . , G71}. The point j is saidto be neighbor of the point i if P�Y�i� jY�1�;Y�2�; . . . ;Y�iÿ 1�; . . . ; Y�M�� depends on Y� j�. Notethat this de®nition does not imply that the neighbors ofa point are necessarily close in terms of distance,although this is the usual case. Now we can give thede®nition of a Markov Random Field.

A Markov Random Field is a joint probabilitydensity on the set of all possible colorings Y of thelattice L subject to the following conditions:

Positivity: P(Y(i))40 for all i.

Markovianity: P(Y(i)| all point in the lattice except(i)=P(Y(i)| neighbors of (i).

Homogeneity: P(Y(i)| neighbors of (i) depends onlyon the con®guration of neighbors and is translationinvariant (with respect to translates with the sameneighborhood con®guration).

Let Np(i, j) denote the neighborhood of the point (i, j).The neighborhood Np(i, j) is shown in Figure 1 for p=5.If we assume a unit distance between adjacent graphvertices then the ®rst order MRF corresponds to aneighborhood con®guration of radius 1 that consists ofthe four nearest neighbors labeled by 1's, the second

order MRF corresponds to a neighborhood con®gura-tion of radius 2, that further includes the diagonalneighbors labeled by 2's, and so on.

As one would guess, the higher the order of the modelis, the more powerful the model will be. For example, amodel of 0th order deals with only the pixel values,while a ®rst-order model also encounters the relationbetween a pixel and its ®rst-order neighbors. Hence theGMRF is a noncausal two-dimensional process de-scribed in Eqn (1).

Y�r� �X

v2Nr�r��rÿvY�v� � "�r� �1�

where "�r� is a Gaussian noise sequence with zero meanand the autocorrelation function given in Eqn (2):

�2 if v � r�2=�rÿv if v 2 Np.

��2�

�1's are the parameters of the model to be estimated.However, estimating those parameters brings computa-tional cost. Instead, su�cient statistics that de®ne aparameter set may be estimated. Su�cient statistics arevalues that can describe a known model completely.Su�cient statistics for a second order MRF can bedescribed as in Figure 2.

Using the su�cient statistics the inspection processconsists of essentially two steps: the ®rst stage is thetraining stage where the system is trained on surfaceimages or image regions which are void of defects. Atraining image of the nondefective surface to beinspected is obtained under a given camera/illuminationsetting. The image is partitioned into windows and foreach window of the image a GMRF model is ®tted, andthe su�cient statistics are obtained. These statistics arestored and are subsequently used by the classi®er toinspect a given texture sample. As the order increases,the number of su�cient statistics and the number of

Figure 2. Su�cient statistics for a second order MRF.

REALTIMEDEFECT INSPECTIONOF TEXTUREDSURFACES 19

elements used to calculate these statistics also increase. Inthe inspection process, under the same camera/illumina-tion settings, an image of a given surface is analysed fordetecting the presence of any defects, as well fordetecting their locations in the image. After the su�cientstatistics of an unknown texture are calculated, they canbe used to make a hypothesis test to determine if thetexture is of the type of the training texture. Thus, defectinspection is possible by partitioning a test image intoW6W windows and calculating the su�cient statisticsof each window. If the su�cient statistic set of a windowdoes not agree with that of the original training texturethen it can be concluded that there is a defective regionwithin that particular window. The likelihood ratio testfor testing the equivalence of two textures is equivalentto using a distance measure [5,6], Eqn (3):

d 2 � �Tt�Y� ÿ E�T�Y��tXÿ1r

�Tt�Y� ÿ E�T�Y�� �3�

where T�Y� is the su�cient statistics of the training(nondefective) texture, E�T�Y�� is the mean of T�Y�; �ST�is the covariance matrix of T�Y� and Tt�Y� is thesu�cient statistic set calculated for the texture windowbeing tested. If the value d 2 is smaller than some certainthreshold then the texture may be considered as non-defective, as can be seen in Figure 3. Otherwise it may beconsidered as a region containing a defect.

Experimental Results

Baykut et al. [12] have studied various texture analysismethods for defect inspection of textile fabrics. Themethods have been applied to images taken fromdefective fabrics from Altõnyõldõz A.S., a Turkish textilefabric manufacturer. For each method the e�ects ofvarious parameters have been examined, as seen inTable 1. The methods compared in this study wereMarkov Random Fields, Karhunen-LoeÁ ve Transform,2D Lattice Filters, Laws Filters, Cooccurance and FFTbased Methods.

The experiments were carried out on 2566256 graylevel images taken by a Sony CCD Iris SSC-M370CEcamera in a laboratory environment. The images thatwere dealt with correspond to 8�5368�53 cm fabric.Thus, the resolution was 3�33 pixels/mm which is thesame resolution that is required in the factory environ-ment. Ninety-two fabric images were used in theexperiments. E�ort was made to include various texturesand di�erent types of defects. The procedure that wascarried out in the laboratory was as follows. Theoriginal 2566256 images were subdivided into non-overlapping 32632 subwindows. For each subwindow,the appropriate feature vectors were found and then theMahalanobis distances for the feature vectors werecomputed. A subwindow was declared to be defective ifits Mahalanobis distance lies outside the admissiblerange. The admissible range is de®ned to be the regionwhich is n quartiles from the median, where n will be anexperimental parameter. Some of the results are given inTable 1 for comparison reasons, and together with thefabric images and the comparison results of all thefabrics are given in Table 2.

Each subsection of the table corresponds to thedefective image given on the right-hand side of thesubsection. The true number of defective subwindowsare noted at the bottom of the image. Rows 2, 5 and 8 ofthe table give the number of defective subwindowsfound by the corresponding methods for the speci®edvalue of n. Rows 3, 6 and 9 give the number ofsubwindows with false alarms. Rows 4, 7 and 10 give thepercentage of the subwindows that are correctlyclassi®ed. The texture analysis techniques used in thecomparisons are listed below. Details about thesetechniques can be found in Baykut et al. [12].

. co-occur: The angular second moment, contrast,correlation and entropy for d=1 and 08,458, 908, 1358

. lawsa: The absolute values of the nine ®lteredimages using Laws ®lters

. lawss: The sum of the squares of the nine ®lteredusing Laws ®lters

Figure 3. Some defective images and their corresponding d2 values.

20 A. BAYKUTETAL.

. mrf 5: 5th order MRF model with 13 features

. mrf 9: 9th order MRF model with 25 features

. mrf14: 14th order MRF model with 41 features

. eigenval5: The largest ®ve eigenvalues of the covar-iance matrix

. eigenval7: The largest seven eigenvalues of thecovariance matrix

. eigenval9: The largest nine eigenvalues of the covar-iance matrix

. evalue3su: The sum of the three largest eigenvalues ofthe covariance matrix

. evalue5su: The sum of the ®ve largest eigenvalues ofthe covariance matrix

. lattice: The re¯ection coe�cients of the ®rst stage

. �t-based: The energies of the 464 blocks

Although many of the methods gave promisingresults, texture modeling using the 9th order MarkovRandom Field model gave the best results. Consideringthe results obtained with respect to speed and thereliability, this approach seems feasible for a real-timefactory implementation.

The MRF model is ®rst applied on a single DSPprocessor, later it is applied on a DSP system with twoTMS320C40 parallel processors, and based on theseresults a DSP system with 13 TMS320C40 processors,which is speci®cally designed for real-time implementa-tion, has been built and the software developed has beenported to this environment.

Table 1. Performance characteristics of various texture analysis techniques on some images from defective fabrics

REALTIMEDEFECT INSPECTIONOF TEXTUREDSURFACES 21

Table 2. Comparison of overall correct classi®cation rates for various texture analysis techniques (n=3, number of samples=92)

co-occur lawsa lawss mrf5 mrf9 mrf14 eigen

val5

eigen

val7

eigen

val9

evalue

3su

evalue

5su

lattice FFT-

based

Mean 89.83 91.10 92.24 94.29 96.63 95.52 89.43 89.87 90.73 90.11 89.56 86.49 92.11Standard deviation 5.13 4.22 4.13 4.06 3.98 4.56 4.09 5.19 4.76 3.40 3.48 5.32 4.11

22 A. BAYKUTETAL.

Real-Time Implementation of the MRF Algorithm

Implementation on a TMS320C30-based DSP system

PCs are designed for general purposes. However, criticaltime applications require specialized hardware. Proces-sors designed for digital signal processing applicationswould be a much more suitable choice for imageprocessing applications. In this work the implementa-tions were carried out on DSP systems using TexasInstruments TMS320C3X and TMS320C4X processors.

The ®rst implementation of the algorithm was on aTMS320C30 processor-based system, which can beconnected up to four CCD cameras. The four CCDsare used to cover a region of 1�60m, so a 33�3 pixel/mmresolution can be achieved. The speed of inspection forone camera system is 17 ms; if four CCDs are used, theinspection time is four times longer since each cameraimage is processed sequentially. Since the acquisitiontakes negligible time, the times quoted are for processingthe images or image subwindows.

Implementation on a TMS320C40-basedDSP system

Even though the use of multiple cameras in anapplicable solution, since the syncronization of thecameras might present a problem in the factoryenvironment and the algorithm used is very appropriatefor parallel processing, the use of parallel DSParchitecture is a preferred solution for a real-timeimplementation.

There are many types of parallel architectures thathave been proposed for use at speci®c levels of visionprocessing. An important concept in present computersis pipelining. A pipelined computer overlaps computa-tions in order to exploit temporal parallelism. In ourproblem, however, spatial parallelism is more appro-priate since the same operation is done to variouswindows of the image.

The basic idea is to divide the acquired image intosubwindows, carry out the inspection task for eachsubwindow using di�erent processors, and collect theoutcomes and report as the ®nal inspection result. Thetype of parallel processing is ®rst implemented on asystem with two TMS320C40 processors, one being themaster and the other the slave to decide on theappropriate number of processors for real-time inspec-tion.

Before discussing how the algorithm is modi®ed foruse on a TMS320C40 ¯oating point DSP system, it isbetter to have some information about the C40 and theimage processing modules that depend on it. Theinstruction set of the C40 contains single-cycle ¯oatingpoint operations. Moreover one can take advantage ofthe parallel instructions which are again single-cycle butcan do two operations instead of one. Furthermorewhile the CPU is busy with executing this instruction,the DMA coprocessor may deal with data transfersfrom one portion of the memory to another portion orto and from any of the communication channels withoutslowing the CPU down.

MDC40IM1 and MDC40HB1 modules installed on acarrier board called QPC/C40B which is designed tocarry four small or two large TIM-40 modules wereselected as the implementation environment. The carrierboard is inserted in a slot of the host PC and supplies thecommunication between the host and the modules. Infact only one module can communicate with the PCdirectly. The other modules communicate with the hostvia the ®rst module in an indirect fashion. Therefore wemay regard this module as the master and the others asthe slaves. The master gets data from the outer worldand distributes tasks among the slaves. After the work is®nished, the master gives out the results and this processcontinues. In Figure 4, a simple schematic diagram ofthe carrier module is shown.

Instead of writing all of the program in assemblylanguage, only the signi®cant time-consuming partswere written in assembly language. The most time-consuming part of the program is the function that

Figure 4. The schematic diagram of the carrier module QPC/C40B.

REALTIMEDEFECT INSPECTIONOF TEXTUREDSURFACES 23

calculates the su�cient statistics of the 32632 blocks.Therefore an assembly function to calculate the statisticswas written in TMS320C40 assembly language. Parallelinstructions which make one ¯oating-point multiplica-tion and one ¯oating-point addition at the same timewere employed. RPTS (repeat single) instruction wasused whenever possible. Using the RPTS instructionresults in much faster executions if the block to berepeated consists of a single instruction or a parallelinstruction, as in our case. Since on-chip RAM is thefastest RAM in the system, the 32632 blocks weremoved to the on-chip memory before processing them.The assumption was that the time lost by this movementcould be compensated by the time gained by usingmemory. The on-chip memory is dual access, zero-waitstate memory.

In the nondefective part, after reading the image fromthe ®le and calling the averageout routine, the ®rstprocessor sends half of the image to the secondprocessor, which is on the second module. Then bothprocessors start to evaluate the statistics. The secondprocessor returns the statistics of the windows that itprocessed. These statistics, combined with those eval-uated by the ®rst processor, are used to evaluate thecovariance matrix and its inverse by the ®rst processor.Then, in the defective part, both the inverse covariancematrices and one half of the image are sent to the®rst processor for it to evaluate the d 2 values for theblocks that are sent to it and return them back.Meanwhile, the ®rst processor evaluates the d 2 valuesfor the blocks that have not been sent. The executiontime has improved from 114 ms, in the single processor

case to 80 ms, which is an improvement of about 30%.It is not 50% since time is lost during the transfer of thehalf image.

Based on these timings, a DSP system with 13processors (1 master, 12 slaves) was developed to carryout real-time inspection for a 2m wide fabric.

Thirteen processor-based DSP systemimplementation

The architecture of the system

Ninth-order MRF model with 25 su�cient statistics [7]was implemented on a line scan camera-based specialimage processing system based on 13 processors(TMS320C40@10±5MHz). As shown in Figure 5, thearchitecture of the system consists of a master processor(MP) and six slave processors, denoted as slave mainprocessor (SMP), each having a slave_slave processor(SSP) as co-processor [13].

The MP is the coordinator of the system and resideson a common bus with the SMPs and is used for thedistribution of raw camera data. SSPs are not connectedto this common bus as they have a dedicated link totheir associated SMPs. The speci®cations of theprocessors are as follows:

. Master processorProcessor TMS320C40 @ 10±50 MHzSRAM 512K632 bits

Figure 5. Parallel DSP architecture.

Figure 6. Black diagram of MP.

24 A. BAYKUTETAL.

nvSRAM 8K632 bitsSerial port Two ports, programmable,

1200 baud to 56K baudParallel port Communications with PCDigital input/output Four-bit input port, Four-bit

output portCommunication port Six ports for communication

with SMPs

. Slave main processorProcessor TMS320C40 @ 10±50 MHzSRAM 32K632 bitsnvSRAM 8K632 bitsDual-Port RAM 64K68 bitsCommuniction port One port for communication

with MP, port for communica-tion with SSP

. Slave_slave processorProcessor TMS320C40 @ 10±50 MHzSRAM 32K632 bits

nvSRAM 8K632 bitsCommunication port One port for communication

with SMP

The MP contains the following interfaces (Figure 6):1. a line scan camera,2. parallel port (for a PC compatible),3. two serial ports4. general purpose digital input/output port,5. six high speed communication ports (dedicated for

SMPs),

The line scan camera requires a number of timingsignals to operate. All of these signals are generated by aspecial purpose gate array chip.

A parallel port on the MP directly interfaces to a PCcompatible parallel printer port. This is the primarymeans of communication between the parallel systemand the external master computer. Software drivers

REALTIMEDEFECT INSPECTIONOF TEXTUREDSURFACES 25

provided with the system facilitate program and data¯ow between the system and the master computer.

Two general purpose RS-232 serial ports are providedfor communication with external devices including themaster computer. Software drivers enable these ports tooperate at various communication speeds.

A general purpose digital input/output port isprovided for process control. This port can receive datafrom or transmit data to external devices. Usually, thisport is used for monitoring the status of certain externalevents such as switches, and/or activate externaltransducers such as relays.

Six communication ports are used for data andprogram exchange between the MP and the SMPs.Each SMP has a dedicated high speed communicationport. Any number of these ports can be active at anygiven time. These ports are normally used for down-loading programs into the SMP and also to SSP (via itscorresponding SMP), and to receive the processed datafrom the SMPs.

An emulation port is used during system develop-ment, debugging of system software, and for perma-nently storing system routines into the nonvolatilesystem memory. The application user cannot utilize thisport, jumpers associated with this port should not bemodi®ed, and the connector should be left open. Theinterfaces of SMP and SSP are designed as in Figure 7.

An MP board contains the logic for controlling theline scan camera. When the system is turned on, theinitialization routines activate the camera, and this datais continuously fed into the MP board. The MP boardgenerates control signals for individual SMPs to

Figure 7. Block Diagram of the SMP and SSP.

distribute the camera data. The largest camera dataentity is a frame and there is storage for two completeframes in the overall system. Each frame consists of 32lines, each like being 6000 pixels, and the frame data isdistributed among six di�erent processors, as shown inFigure 8. For each scan line, pixels 0 through 1023 arestored in SMP#0 memory, 1024 through 2047 in SMP#1memory, etc. Only the last processor, SMP 5 memory,contains a less amount of data, pixels 5120 through5999, because of the number of pixels in the line scancamera. The system automatically ®lls the frames in analternate manner, that is, once frame 0 is ®lled, then itcontinues ®lling frame 1, then frame 2 etc. At thecompletion of each frame data, an interrupt is gener-ated, called FINT0* and FINT1* for frames 0 and 1,respectively. The line scan camera scans sequentially;however, the sequence of data is altered as it is stored inthe memory to facilitate more convenient processing. Inother words, the purpose of this alternate storagetechnique is to generate a double bu�er, and overlapdata acquisition and processing. While a given frame isacquired, the other is processed, and vice versa. Thecamera storage medium is dual-port static RAM, thusdata can be accessed while being acquired. However, theapplication program should ®nish the processing on thedata before the new one is acquired.

The data in each processor memory is furtherarranged for ease of computation. The data is arrangedin 32 by 32 windows, each one designated as a kernel.There are 32 kernels in each processor's memory. Theorganization of data for a given processor is shown inFigure 9.

The frame bu�ers are physically linear arrays, thedata representation is two dimensional. As the cameradata is stored into the frame bu�er through the camera

Figure 8. Distribution of camera data among six processors.

Figure 9. Arrangement of data in a processor memory.

26 A. BAYKUTETAL.

data port, the write address generated by the gate arraychip is not linear, but scrambled such that the ®nal datain the frame bu�er is properly organized for processing.The lowest memory location starts with pixel 0 of line 0of kernel 0, and continues until pixel 31 of line 0 ofkernel 0. Then the next location contains pixel 0 of line 1of kernel 0, and continues in the same manner until theend of kernel 0 data. The next location contains pixel 0of line 0 of kernel 1, which is pixel 32 of line 0 from thecamera. All the data of kernel 1 is stored in contiguouslocations, similar to kernel 0. This process continuesuntil all the kernel, 0 through 31, are stored in thememory for all the processors. Note that few last kernelsof processor 5 contain invalid data since there are 6000pixels per camera scan line. This constitutes the data forone of the frames. Upon completion of this process,when the last pixel of the last processor is stored, thesystem generates a unique interrupt associated with thecurrent frame to all the slave modules. The data startingwith the next camera scan line is stored in the alternateframe and another unique interrupt signal is generatedto the slave modules at the completion of this frame.

There are three types of software interrupts on thesystem: frame, parallel communications and DSP-to-DSP comm port interrupts. For frame interrupts to beactive, the camera must be on. By default, the camera iso� until an application turns it on. Since there are twoframe bu�ers, frame interrupts alternate between frame#0 and frame 1 when the camera is on. The frame #0interrupt occurs when frame #0 has been ®lled and isready for processing; likewise, for frame #1. The parallelcommunications interrupt, available only on the masterprocessor board, occurs when an external device(typically a PC) sends a message over the parallel port.The interrupt occurs only on the ®rst byte (thecommand byte). The system service routine then

continues to read until the requested command iscomplete. DSP-to-DSP comm port interrupts, likewise,occur only on the ®rst word received. Subsequent wordsare read by the service routine. These service routinesdi�er between SMPs and SSPs. The interrupt for SMPoccurs only when it receives communications from MP,and then only when the camera is o�. This is so becausesystem commands are propagated downward from MPto SMP to SSP only when frame processing is disabled.This allows frame interrupts to perform arbitrary commport transfers. When frame processing is completed thecomm ports are returned (by the system) to a knownstate to facilitate system commands. The interrupt forSSP is always enabled and occurs whenever it receivescommunications from SMP. This occurs regardless ofcamera state since SSP has no frame interrupt serviceroutines.

Implementation of MRF on the system

The width of the fabrics to be inspected are 200 cm anda line-scan camera with 6000 elements is sued in theinspection process, giving a 3�0 pixel/mm resolution.The system is con®gured to inspect at 10 m/min speed,so it is acquiring nonoverlapping 32 lines of the movingfabric in 0�6 s. Each SMP and SSP has to process 32windows and transfer the results to MP. The most time-consuming part of the program is the function thatcalculates the su�cient statistics of the 32632 windows,which should be performed in approximately 15 ms.Therefore as assembly function to calculate the statisticswas written in TMS320C40 assembly language. Parallelinstructions which make one ¯oating-point multiplica-tion and one ¯oating-point addition at the same timewere employed. RPTS (repeat single) instruction wasused whenever possible. As an example, calculation ofsu�cient statistic #0 can be considered, which is the sum

REALTIMEDEFECT INSPECTIONOF TEXTUREDSURFACES 27

of all gray scale values multiplied by themselves in a32632 window: Stat0 �P32�32ÿ1

i�0 Y�i� � Y�i�

Stat0: Ida ar0, arl ;get begin address of thewindow

Idi 0, r3 ;result of the sumIdi 0, r1 ;result of the multiplicationrpts 32*3271 ;repeat for all pixels in the

32632 windowmpyf3 *ar1,

*ar1��. r1;add and multiply in onecycle

k addf3 r1, r3, r3addf r1, r3

pushf r3 ;store the resultspop r3sti r3, *ar2��

The inspection of a 3266000 block is carried out in60 ms, which is su�cient to satisfy the factoryrequirements.

Summary and Conclusions

The problem of real-time automated inspection of textilefabrics is studied. For this purpose, model-based andfeature-based methods are implemented and tested fortextile images in a laboratory environment. The methodsare compared in terms of their success rates indetermining the defects. The Markov Random Fieldmodel is implemented on di�erent DSP systems to beable to apply the system for real-time inspection. Theresults indicate that automation of the process is feasiblein product line.

Acknowledgements

We would like to thank Altõnyõldõz A.S, for providingfabrics. This work is partially supported by DPT95K120320 project and TTGV 169 project.

References

1. Conners, R. et al. (1983) Identifying and locating surfacedefects in wood. IEEE PAMI, 5, No. 6, November 1993.

2. Siew, L., Hodgson, R.M., & Wood, E.J. (1988) Texturemeasures for carpet wear assessment. IEEE Transactionson PAMI, 10: 92±105.

3. Chen, J. & Jain, A.K. (1988) A structural approach toidentify defects in textural images. Proceedings of IEEEInternational Conference on Systems,Man and Cybernetics,pp. 29±32.

4. Dewaele, P., Van Gook, P. & Oosterlinchk, A. (1988)Texture inspection with self-adaptive convolution ®lters.Proceedings of the 9th International Conference on PatternRecognition, Rome, Italy, 14±17 November, pp. 56±60.

5. Cohen, F., Fan, Z. & Attali, S. (1991) Automatedinspection of textile fabrics using textural models. IEEEPAMI, 13, No. 8, August 1991.

6. ErcË il, A. & OÈ zuÈ yõlmaz, B. (1994) Automated visualinspection of metalic surfaces. Proceedings of the ThirdInternational Conference on Automation, Robotics andComputer Vision (ICARCV'94), pp. 1950±1954.

7. Atalay, A. (1995) Automated Defect Inspection of TextileFabrics Using Machine Vision Techniques. MS. Thesis,BogazicË i University.

8. Van Gool, L., Dewaele, P. & Oosterlinck, A. (1985)Survey: texture analysis anno 1983. Computer Vision,Graphics and Image Processing, 29: 336±357.

9. Rao, T.R. (1990) A taxonomy for Texture Description andIdenti®cation. New York. Springer-Verlag.

10. Tuceryan, M. & Jain, A. (1993) Texture analysis. In: Chen,C.H., Pau, L.F., Wang, P.S.P. (eds), The Handbook ofPattern Recognition and Computer vision. World Scienti®cPublishing Co.

11. Cross, G. & Jain, A. (1983) Markov Random FieldTexture models. IEEE-PAMI, 5, No. 1, January 1983.

12. Baykut, A., OÈ zdemir, S., Meylani, R., ErcË il, A. & ErtuÈ zuÈ n,A. (1997) Comparative evaluation of texture analysisalgorithms for defect inspection of textile products.BogazicË i University Research Report, FBE-IE-08/97±12.

13. TexInspect Users Guide (1997) Visionex Inc.14. Atalay, A., FõcË õcõ, R., ErcË il, A. (1996) Defect classi®cation

of textured surfaces using GMRF models and neuralnetworks. Proceedings of IEEE ICRAM. pp. 206±211.

15. Cohen, F. & Cooper, D. (1983) Real time textured imagesegmentation based on noncausal Markovian random ®eldmodels. Brown University Technical Report #LEMS-3,September.

16. Fukunaga, K. (1990) Introduction to Statistical PatternRecognition. Academic Press.

17. GuÈ l, E., Sitti, M., ErcË il, A. & OÈ zuÈ yõlmaz, B. (1995) Parallelsystem design for quality inspection of painted metallicsurfaces. Proceedings of IEEE SIU, Vol. A, pp. 141±146,(in Turkish).

18. Reed, T.R. & Hans Du Buf, J.M. (1993) A review of recenttexture segmentation and feature extraction techniques.CVGIP: Image Understanding, 57: 359±372.

19. Strand, J. & Taxt, T. (1994) Local frequency features fortexture classi®cation. Pattern Recognition, 27: 1397±1406.

20. TMS320 Floating-Point DSP Assembly Language ToolsUser's Guide (1991) Texas Instruments Inc.

21. TMS320C4x User's Guide (1993) Texas Instruments Inc.