12
Real-time Aspects of SOM-based Visual Surface Inspection Matti Niskanen, Hannu Kauppinen, and Olli Silvén Machine Vision and Intelligent Systems Group, Infotech Oulu, Univ. of Oulu, Finland ABSTRACT We have developed a self-organizing map (SOM) -based approach for training and classification in visual surface inspection applications. The approach combines the advantages of non-supervised and supervised training and offers an intuitive visual user interface. The training is less sensitive to human errors, since labeling of large amounts of individual training samples is not necessary. In the classification, the user interface allows on-line control of class boundaries. Earlier experiments show that our approach gives good results in wood inspection. In this paper, we evaluate its real time capability. When quite simple features are used, the bottleneck in real time inspection is the nearest SOM code vector search during the classification phase. In experiments, we compare acceleration techniques that are suitable for high dimensional nearest neighbor search typical for the method. We show that even simple acceleration techniques can improve the speed considerably, and the SOM approach can be used in real time with a standard PC. Keywords: code vector, fast search speed, vector quantization, nearest neighbor search, lumber inspection 1. INTRODUCTION Visual inspection of natural materials, like wood surfaces, is a challenging problem due to the huge variation of the surface properties. The appearance of a good surface as well as the defects within classes varies remarkably, and it is often impossible to define a clear boundary between classes. This makes collecting and labeling of training samples very laborious and error prone even for an experienced user. Furthermore, the state-of-the-art inspection system classifiers often require parameter tuning expertise which may be slow to acquire. We have proposed 1,2,3 a self-organizing map (SOM) -based approach for visual surface inspection. The solution does not require labeling of individual samples or parameter tuning, but discovers whether the samples fall into a finite set of categories based on the similarity of their features. Thus, it is not affected by human errors in training. The approach also provides an intuitive visual user interface. Earlier experiments show that our approach gives good results in wood inspection. In this paper, we evaluate its real time capability. The next chapter introduces the inspection method and gives background information to understand the properties of time critical aspects. It turns out that the nearest code vector search is perhaps the most critical part when computation time is considered. In experiments, we concentrate on fast nearest code vector search methods. We also propose two method of our own suitable for a nearest code vector search from a trained SOM. 2. SOM-BASED SURFACE INSPECTION METHOD 2.1 Self-organizing maps The Self-Organizing Map (SOM) 4 is an algorithm used to visualize and interpret high-dimensional data sets by projecting them to a low-dimensional space. Typically a SOM consists of a two dimensional regular grid of nodes, also known as neurons. A model of a multidimensional observation, eventually a vector consisting of features, is associated with each node. During the training phase, the training data is looped one by one, and for each data vector in the training set, the closest node from the map is chosen. The choice of this node, also called the best matching unit (BMU), is based on the nearest

Real-time Aspects of SOM-based Visual Surface … Aspects of SOM-based Visual Surface Inspection Matti Niskanen, Hannu Kauppinen, and Olli Silvén Machine Vision and Intelligent Systems

Embed Size (px)

Citation preview

Real-time Aspects of SOM-based Visual Surface InspectionMatti Niskanen, Hannu Kauppinen, and Olli Silvén

Machine Vision and Intelligent Systems Group, Infotech Oulu, Univ. of Oulu, Finland

ABSTRACT

We have developed a self-organizing map (SOM) -based approach for training and classification in visual surfaceinspection applications. The approach combines the advantages of non-supervised and supervised training and offers anintuitive visual user interface. The training is less sensitive to human errors, since labeling of large amounts ofindividual training samples is not necessary. In the classification, the user interface allows on-line control of classboundaries.

Earlier experiments show that our approach gives good results in wood inspection. In this paper, we evaluate its realtime capability. When quite simple features are used, the bottleneck in real time inspection is the nearest SOM codevector search during the classification phase. In experiments, we compare acceleration techniques that are suitable forhigh dimensional nearest neighbor search typical for the method. We show that even simple acceleration techniques canimprove the speed considerably, and the SOM approach can be used in real time with a standard PC.

Keywords: code vector, fast search speed, vector quantization, nearest neighbor search, lumber inspection

1. INTRODUCTION

Visual inspection of natural materials, like wood surfaces, is a challenging problem due to the huge variation of thesurface properties. The appearance of a good surface as well as the defects within classes varies remarkably, and it isoften impossible to define a clear boundary between classes. This makes collecting and labeling of training samplesvery laborious and error prone even for an experienced user. Furthermore, the state-of-the-art inspection systemclassifiers often require parameter tuning expertise which may be slow to acquire.

We have proposed1,2,3 a self-organizing map (SOM) -based approach for visual surface inspection. The solution doesnot require labeling of individual samples or parameter tuning, but discovers whether the samples fall into a finite set ofcategories based on the similarity of their features. Thus, it is not affected by human errors in training. The approachalso provides an intuitive visual user interface.

Earlier experiments show that our approach gives good results in wood inspection. In this paper, we evaluate its realtime capability. The next chapter introduces the inspection method and gives background information to understand theproperties of time critical aspects. It turns out that the nearest code vector search is perhaps the most critical part whencomputation time is considered. In experiments, we concentrate on fast nearest code vector search methods. We alsopropose two method of our own suitable for a nearest code vector search from a trained SOM.

2. SOM-BASED SURFACE INSPECTION METHOD

2.1 Self-organizing maps

The Self-Organizing Map (SOM)4 is an algorithm used to visualize and interpret high-dimensional data sets byprojecting them to a low-dimensional space. Typically a SOM consists of a two dimensional regular grid of nodes, alsoknown as neurons. A model of a multidimensional observation, eventually a vector consisting of features, is associatedwith each node.

During the training phase, the training data is looped one by one, and for each data vector in the training set, the closestnode from the map is chosen. The choice of this node, also called the best matching unit (BMU), is based on the nearest

neighbor principle for feature vectors associated with each node. BMU and its neighborhood kernel, that is, a fewsurrounding nodes in the map, are then tuned to the direction of the training vector.

As a result of the training, high-dimensional vectors for all nodes in the map will be tuned to represent the training data.In addition, data vectors of nearby nodes are located nearby also in high-dimensional feature space. Thus, similar data isprojected to the same or nearby nodes in the SOM, while dissimilar will be mapped to nodes located further from eachother.

The SOM can be used as a classifier. In classification, for a feature vector to be classified, the node from the SOMwhose code vector is most similar to it is chosen. We have measured the similarity using the Euclidean metric, althoughSOM and most speed-up methods presented work also with other metrics. BMU determines the class for the classifiedfeature vector. Classes can be assigned to nodes beforehand, for instance after the training phase, or for examplemanually after clustering, based on an overview of the map.

2.2 Using SOM in surface inspection

In surface inspection, it is often required to detect and recognize the defects from a non-defective background. In manycases, it is also meaningful to separate these two phases, as is done in the following inspection example. Even thoughoften used, simple thresholding based methods do not perform well enough on difficult material, like wood surface. Weuse the so-called non-segmenting method instead. In it, the surface is divided into non-overlapping regions (e.g. 32*32pixel blocks), as illustrated in Fig. 1 a) for lumber images. For each of these, a set of characterizing features iscalculated. With a SOM-based approach, regions are then mapped on the two dimensional SOM. Fig. 1 b) illustrates theSOM trained for wood inspection. For each node, an image of one randomly selected region associated to it is shownand similarity of nearby nodes is clearly perceptible. So far, no labeling of training material has been done. By usingSOM, this labor and error prone process at early stages was avoided.

The dashed line in the SOM in Fig. 1 b) is the boundary between sound wood and suspected defects. This boundary isset manually after the basic training stage of the algorithm. During the classification stage, it is possible to modify classboundaries, e.g. to adapt to changes in the environment. Fig. 2 a) shows a piece of board where regions clustered to thedefects’ side of the border are highlighted. These latter regions are the suspected defects, and the defect detection phaseof inspection is done.

For each individual detection, another set of features is calculated and the feature vectors are used to cluster thesuspected defects to another SOM. An example of such a SOM is shown in Fig. 2 b), which is produced from detectionsobtained from a number of boards. Again, similar defects are clustered close to each other. The human’s task in trainingis to define class boundaries and assign labels for each cluster. In recognition, labels for detections are the ones assignedto nodes with the most similar code vectors.

Fig. 1: Detection SOM built from images of wooden boards. Border between sound and defective material is drawn aftertraining stage.

a) b)

sound knot

split

pitch pocketdry knot

sound wood

2.3 Real time aspects

The real time requirements are usually quite hard in wood inspection. The inspection speed varies typically from half ameter to tens of meters per second. For example, at a lumber mill, the requirement is to inspect several boards persecond from all four sides. This usually requires several parallel cameras and processing units, as imaging resolution isfor example 0.5 mm.

An example of time consumption with a 550MHz PC using the software implementation of our method is shown onTable 1 for a typical image consisting of about 7 million pixels in RGB with 6000 blocks to classify. Color channelcentiles (28 features) are calculated for the red, green, and blue color channels and LBPs (32 features) for the redchannel. An exhaustive search is used to find the BMU on 18*12 nodes map. The time used in the recognition phase(for e.g. CCA, feature calculation, and node search) is negligibly small. White calibration, which eliminates the effect ofan inhomogeneous lighting profile, is an essential part of inspection system. Using software, it is very time consuming.Fortunately, it can be done on hardware for instance by camera or by adjustable LED lightning. Then, the CPU timespent in this phase would be reduced from 7.61 s to 0.20 s required by memory copies. In this case, time is wastedmainly on two things: feature calculation for blocks (in the detection phase) and finding the nearest nodes for them.

Table 1 Example of time spent on wood inspection on test system.

Preprocessing Detection Recognition

Phase WhitecalibrationHW (SW)

Centilecalculation, 28for 3 channels.

LBPcalculation,32 for 1 channel

Exhaustive nearestnode search from18*12 nodes map

CCA, featurecalculation, andnode search

Total

Time(s/board)

0.20 (7.61) 0.39 0.30 1.09 0.01 1.98

In the detection, the total time used for feature calculation depends on the type and number of features, and the numberof regions to be processed. The total number of regions comes from region size and imaging resolution. Features used inour experiments, color centiles and Local Binary Pattern (LBP)5 texture values, are both very fast to calculate. They aredescribed in paper 1 for example, where also the effects of different feature sets are evaluated. Centiles are cumulatedfrom color channel histograms. It is necessary to access each image pixel only once to collect histograms. To obtain aset of centile features for a region, also the histograms need to be scanned only once. If centile calculation was limitedto cover only one color channel, time would be reduced to one third compared to RGB centiles used in our experiments.

Time in an exhaustive SOM node search is almost linearly dependent on the map size and the number of features, andeasily becomes a bottleneck in the real time inspection system. Since parameters like map size, feature vector length,and the number of regions also affect the accuracy of the system, other means of reducing nearest code vector search

Fig. 2: Detections shown highlighted in a) are regions clustered into defects side of SOM in Fig.1. Labels for detections areobtained from recognition SOM illustrated in b).

a) b)

time is required. A large number of such methods has been presented in the literature, and a number of these isevaluated in our experiments. Their principles are explained on the next chapter, and their speed are compared as afunction of map size, as well as a function of feature vector dimensionality on the test section.

3. TECHNIQUES FOR A QUICK SOM SEARCH

As described earlier, SOM classification is in principle a nearest code vector search. The search problem is similar tovector quantization, but is done on the topologically ordered codebook. A comparison of search algorithm for smalldimensional data (2-16) can be found in the paper by Cheung et al6. A fast SOM search algorithm for textualdocuments, using inner product distance measures in very high dimensions (>5000), has been presented by Kaski7.

Many code vector search algorithms for the SOM are designed to speed up the training phase. During training, thetraining set is reused many times, and the position of the BMU for each training vector does not change very muchbetween sequential rounds. This information is for example often used to limit the search close to the position of aprevious BMU8. Another approach is to use heuristics to quickly form a preliminary map, which is then tuned by usingthe SOM algorithm9.

We need a quick BMU search method for the classification using SOM, and thus we are not interested in speeding upthe training phase. The training can be done off-line as well as the preprocessing task required by most quick searchmethods. Furthermore, to improve the search speed at classification phase, the topology preserving property of SOMcan be utilized. Similarity of neighbors in SOM mapping is preserved. As an example, the distances from a 60dimensional test vector to all code vectors of a 45*30 nodes SOM are shown in Fig. 3. In the figure, shading togetherwith the z- axis (i.e. surface height) denote the distance of each code vector to this particular test vector.

Acceleration techniques for vector quantization consist roughly of two kinds of methods. Most algorithms exclude someof the code vectors from a further search by some means, e.g. by using simple geometry to note that they cannot becloser than the closest code vector found so far. The other approach is to construct a search structure. We tested themost common and promising methods suitable to our needs. From the first category, methods included in ourexperiments are partial distance search (PDS)10, annulus testing (AT)11, sum of components (SOC)12, and dynamicalhyperplanes shrinking search (DHSS)13. In second category Tree Structure SOM (TS-SOM)14 is tested. Also twomethods of our own are tested. The first, called mean tree (MT) belongs to the second category. The second, called

Fig. 3: Distance of one high dimensional test vector to all nodes on 45*30 map.

focused sparse search (FSS), does actually belong to neither of these categories, but uses the topological preservingnature of the SOM to find good candidates.

All methods tested from the first category are optimal. That is, they find the real BMU even though they do notnecessarily test every node. The last tree methods are sub-optimal. They do not necessarily find the node which is theclosest one, but can end up with some other good candidate slightly farther apart.

3.1 Methods based on excluding code vectors

The partial distance search (PDS)10 is a simple way of reducing the number of calculations needed. If the squaredpartial distance between the test vector and the code vector exceeds the full squared distance to the nearest neighborfound so far, the distance calculation for this particular code vector can be aborted. The time used in additionalcomparisons after each component’s squared distance is added to the sum is on average much smaller than the timesaved by a early abort. Being a very basic method, PDS is also included in other methods in our experiments, except infull exhaustive search.

The idea of annulus testing (AT)11, like for most methods of this group, is best clarified with a graphical example. InFig. 4 a), the vector quantization situation is illustrated in two dimensions, but the same principles apply in anydimensions. In Fig. 4, X denotes the test vector and dots denote code vectors of nodes. If minm� is the closest code vectorfound so far, it is clear, that the closest vector of all nodes must lie inside a spherical region (darker gray in the figure)with a radius of the smallest distance mind� so far. While this information cannot efficiently be used to exclude codevectors, limitation can be loosened. Closer code vectors must also lie inside the annular region marked with lighter grayin the figure. This region is bounded by shells of hyperspheres with radii of d(x,p) - mind� and d(x,p) + mind� centered inany arbitrary point p (e.g. origin). The best node minm must be inside this region, and thus for the closest node minm itmust hold,

min min mind(x, p) - d d(m ,p) d(x, p) + d≤ ≤� � . (1)

Distances d(m,p) can be calculated beforehand, when the map is generated. Furthermore, the distance d(x,p) needs to becalculated only once for each vector to be classified, and most code vectors can be excluded since they do not satisfy (1)if a small mind� is found.

The sum of components test (SOC)12 makes use of the inequality

n

j ij i

j 1

(x m ) nd(m , x)=

− ≤� , (2)

where n is the number of components in the vector (i.e. dimensionality).

Fig. 4: Methods excluding code vectors ( a) AT, b) SOC, c) TIE, and d) DHSS) limit the search on shaded regions. X denotesthe test vector, spots code vectors of which minm� is best found so far with distance mind� .

c) TIE

x2

x1

mind~minm~

mind~

2

b) SOC

mind~minm~

x1

x2

x’1

x’2

mind~minm~

x1

x2

d) DHSSa) AT

mind~minm~

x1

x2

p

Thus for the best match minm ,

2n n

2j (min) j min

j 1 j 1

x m nd= =

� �− ≤� �

� �� �� � � (3)

must also hold. Sums of components nj 1 ijm=� for nodes can be calculated for pre structure and sums n

j 1 jx=� areefficiently calculated once for each vector. Geometrically interpreted, SOC limits the search by two hyperplanesorthogonal to the vector (1,...,1), as shown in Fig. 4 b).

One popular method in this category is triangular inequality elimination (TIE)15. It limits the search inside ahypersphere with a radius 2* mind� centered on minm� . Distances between all nodes are calculated and stored as a pre-structure whose size thus grows exponentially with the map size. Graphically this method is illustrated in Fig. 4 c), butit is not included in experiments due to its unsuitability for large maps.

A dynamical hyperplanes shrinking search (DHSS)13 does component testing (CT)16 on transformed coordinates. CTcalculates the absolute difference j ijx - m for an arbitrary dimension (=component) j, and rejects the code vector mi ifthis difference is larger than mind� . Often in the real world, and this is the case here too, the data components arecorrelated. Rather than taking the distances in an arbitrary direction j, the distance in the direction of the principal vectorcorresponding the largest eigenvalue is more likely to reduce the number of candidates. In addition, a few of the mostinformative orthonormal principal vectors can be used to reduce the candidates even further. In addition to PrincipalComponent Analysis (PCA), Discrete Cosine Transform (DCT) and Walsh-Hadamard Transform (WHT) coordinatetransformations could be used to avoid the overhead in coordinate transformation. In our experiments, only PCA wasused.

As preprocessing for DHSS, we calculate the principal components c for code vectors in nodes. All nodes are projectedonto these components, and these projections m’i together with the principal vectors are stored. In classification, thevector to be classified is first projected on a few principal components by

(n) (n)x ' x c= ⋅T (4)

where n = number of dimension, and (n)c = n:th principal vector.

Candidate mi can be closer than the minm� so far found only if

i(n) (n) minm ' x ' d .− < � (5)

If (5) is not true, node mi is excluded. The method is illustrated in Fig. 4 d), where the search is again restricted to thelight gray area. The dotted line illustrates the effect of the second principal component, which limits the search evenfurther.

A suitable number of vectors is of course dependent on the structure of data and the cost of distance measurement. Eventhough additional principal vectors would limit the number of searches, in our case using only one vector is favored dueto the overhead caused by additional projections and comparisons with more vectors. When only one vector is used, it isalso possible to use a sorted list for nodes. This speeds up the calculation by preventing unnecessary comparisons andby providing better results earlier. A sorted list is also useful in speeding up the AT, SOC, and TIE methods.

All of these methods benefit if a small mind� is found early. Clever use of a sorted table helps in this purpose. When usingSOM for vector quantization, a good guess for mind� is found at an early stage if nodes are not searched for in linear orderbut rather all around the map. Another way to find a good guess early utilizes the fact that usually in surface inspection,the adjacent regions on the surface correlate highly. Then, the small mind� is usually found at first guess when the BMU ofthe previous region is used as an initial guess for the next one.

3.2 Methods based on search structure

We have small number of neighbors to search (hundreds) compared to the number of features (tens). This prevents theusage of the most common search trees, like k-d trees17, SR-trees18, and X-trees19, that are suitable mostly only forlower dimensional problems20. There are lots of sub-optimal methods (e.g.21,22,23) developed to avoid “the curse ofdimensionality”, but the most of these seem still require too large a number of vectors compared to our situation toprovide satisfactory speed-up, or they may for example require an impractical amount of storage space to work.

For us, one suitable method in this category is Tree Structured SOM (TS-SOM)14, a variant of the SOM made to speedup the node search both in training and classification. It consists of layers of SOMs, where the SOM of each layerconsist of dn2 nodes, where n is the number of the layer and d is the number of the dimensionality of the map (typically2). The candidate nodes in the lower layer are chosen based on the best matching node of the previous layer. Toimprove accuracy, in addition to the d*n direct child nodes, also the child nodes of nodes adjacent to the BMU aresearched. Training is done one layer at a time using a tree search for layers 2,...,n. In classification, the result is the nodein the bottom most layer, but the upper layers are used to search it efficiently. The topological order of the SOM isclearly needed to find a reasonably good node from the lower layer.

The TS-SOM limits the size and dimension of the map to be quadratic with a side length of n2 . It cannot be used tospeed up the search for map trained with some other program, but requires training of the map using the TS-SOMalgorithm itself. Even though fast training is often the desired property, the use of previously trained map or map withsome other aspect ratio might be required. For this purpose, we applied a simple alternative tree structured searchmethod that we call mean tree (MT). It can be used for any rectangular SOM. The structure in this case is built from thebottom up by averaging the code vectors of nodes in the lower layers. As in TS-SOM, the search structure of MToverlaps. In addition, the accuracy of the search is improved by a beam search, i.e. by following a couple (=beam width)of best nodes in each layer. The search is illustrated in Fig. 5, which has the same map and test vector as Fig. 3. Therectangular regions denote areas of the map which are contained by nodes followed. A larger region thus means earlierstage in the search procedure where the whole map is described by just a few nodes. Regions with dotted lines are thesecond best nodes followed and x is the final node interpreted as BMU. The topological order is needed in order to getreasonable maps by averaging the lower layers.

Fig. 5: Mean tree search. Rectangles denote the areas covered by nodes followed throughthe search tree.

The second of our own methods, focused sparse search (FSS), does not actually belong to either group one (excludingcode vectors) or two (search structure). It is presented here due to its similarities to the previous method (Somesimilarities can be found also to method presented by Lampinen et al24, for example). FSS does not require anypreprocessing, but is again based on the topology preserving property of SOM. As mentioned, similar nodes, also thebest ones, are close to each other on the trained map. The initial search in this method is to test nodes at regular intervalsaround the map. Then the neighborhoods of the beam width number of the best matching nodes are further testediteratively with a smaller and smaller radius until all the nodes in the most promising areas have been searched. Thesearch is illustrated in Fig. 6, where circles in the map denote the nodes that are tested. Larger circles mean an earlierphase in the search procedure. Filled circles are the best nodes found at the time and their neighborhoods are searchedfurther. The problem of this method is to select suitable parameters for different map sizes to ensure a reliable search tocover the whole map evenly.

4. EXPERIMENTS

We compared the presented methods in classification of high-resolution wood images. A typical board size is 5 m -by-0.35 m imaged with 0.5 mm resolution. The 21 images included in the experiments contain totally 432 MB of data, with125 000 blocks to classify. For each method, we measured the actual time spent in classification. The time is measuredwith a standard PC running on a 550 MHz processor.

4.1 Optimal search methods

For optimal search methods, the average time per board (≈6000 blocks) at a logarithmic scale is shown in Fig. 7 as afunction of the map size (from 12*8 to 45*30 nodes maps), when 60 dimensional feature vectors are used. In Fig. 8 theaverage time is shown as a function of the number of features used (from 10 to 60), when 18*12 nodes maps were used(16*16 nodes for TS-SOM). TS-SOM is included in these graphs to ease comparisons between optimal and sub-optimalmethods. The results for optimal methods are also shown in Table 2, together with the percentage of nodes totally

Fig. 6: Focused sparse search. Circles denote the tested nodes. Neighbor of filled circlesare further examined.

excluded from search. Notice that all the methods expect exhaustive search use also PDS, so most of the comparisonsare not carried out on whole vectors.

The time complexity of the sub-optimal TS-SOM method is logarithmic to the map size, and it beats optimal methodsof the first group (time complexity linear to map size) with larger maps, as can be seen from Fig. 7. The DHSS methodperforms best of all the tested optimal methods in both comparisons for this real world test data set. With DHSS, whenmore features are used the search time is even reduced, since better features provide better discrimination.

Table 2 Average time and percentage of nodes totally excluded from search.

4.2 Sub-optimal search methods

Sub-optimal methods were tested with different map sizes using 60 dimensional feature vectors. As a result, wemeasured the time and quality of the findings. Qualities are measured using two criteria. The sub-optimality rate (SOR)is defined as

incor

total

nSOR ,

n= (6)

Exhaustive PDS SOC AT DHSS

map size(nodes) features time excl. time excl. time excl. time excl. time excl.

18*12 10 0.226 0.0 % 0.197 0.0 % 0.229 25.8 % 0.161 55.9 % 0.148 67.7 %

18*12 27 0.443 0.0 % 0.313 0.0 % 0.278 41.1 % 0.328 22.3 % 0.265 49.6 %

18*12 44 0.775 0.0 % 0.476 0.0 % 0.437 27.0 % 0.330 47.2 % 0.283 63.4 %

18*12 60 1.090 0.0 % 0.528 0.0 % 0.436 31.3 % 0.285 49.3 % 0.258 70.2 %

12*8 60 0.361 0.0 % 0.260 0.0 % 0.229 25.8 % 0.161 55.9 % 0.148 67.7 %

18*12 60 1.090 0.0 % 0.528 0.0 % 0.436 31.3 % 0.285 49.3 % 0.258 70.2 %

27*18 60 2.454 0.0 % 1.220 0.0 % 0.911 36.0 % 0.578 62.8 % 0.503 72.4 %

36*24 60 6.443 0.0 % 2.384 0.0 % 1.701 35.9 % 1.068 62.5 % 0.906 72.6 %

45*30 60 15.253 0.0 % 4.467 0.0 % 2.863 37.0 % 1.755 64.2 % 1.465 72.9 %

Fig. 7: Optimal methods’ time vs. the map size. Averagetime used in node search per image when 60 dimensionalfeature vectors were used, is shown. Sub-optimal TS-SOM is added to ease comparison.

Fig. 8: Optimal methods’ time vs. number of features.Average time used in nodes search per image when 18*12nodes maps were used, is shown. Sub-optimal TS-SOM isadded to ease comparison.

Time of search (60 features)

0,1

1

10

100

0 500 1000 1500Map size (nodes)

Seco

nds

per

imag

e

Exhaustive

PDSSOC

ATDHSS

TS-SOM

Time of search (18*12 nodes)

0

0,2

0,4

0,6

0,8

1

1,2

0 20 40 60Number of features

Seco

nds

per

imag

e

ExhaustivePDSSOCATDHSSTS-SOM (16*16)

where nincor is the number test vectors for which the real BMU was not found and ntotal is the total number of testvectors. An increase in quantization error (IQE) indicates the relative increase in quantization error due to incorrectlyfound BMUs. That is,

min min

min

d dIQE ,

d

−=� �

(7)

where mind� is a sum of distances to BMUs of every test vector and mind� � is their distances to the closest codevectors found by the sub-optimal method. These two quality measures are quite linearly dependent, and the former isshown as a function of average time used per node in Fig. 9. Map sizes in the test presented in Fig. 9, are 45*30 nodesfor all, expect 32*32 nodes for TS-SOM. Methods are tested with three different beam widths (i.e. the number of bestroutes to follow in the search). Time as function of map size is shown in Fig. 10, and all the results are summed up inTable 3.

Table 3 Speed and quality of sub-optimal methods (60 features).

TS-SOM MT(beam=1)

MT(beam=2)

MT(beam=3)

FSS(beam=2)

FSS(beam=3)

FSS(beam=4)

map size (nodes) 1024 1350 1350 1350 1350 1350 1350time (s) 0.366 0.338 0.558 0.761 0.335 0.468 0.601sub-optimality rate 16.6 % 18.0 % 9.3 % 2.3 % 17.2 % 9.6 % 6.4 %increase in qerr. 2.84 % 4.73 % 2.14 % 0.46 % 5.43 % 2.46 % 1.47 %map size (nodes) 486 486 486 486 486 486time (s) 0.265 0.404 0.494 0.265 0.380 0.492sub-optimality rate 7.8 % 1.6 % 1.2 % 23.3 % 10.7 % 6.2 %increase in qerr. 1.52 % 0.22 % 0.19 % 5.46 % 1.75 % 1.57 %map size (nodes) 256 216 216 216time (s) 0.237 0.207 0.348 0.438sub-optimality rate 9.4 % 6.7 % 0.9 % 0.6 %increase in qerr. 1.53 % 1.48 % 0.18 % 0.15 %map size (nodes) 64 96 96 96time (s) 0.147 0.100 0.143 0.181sub-optimality rate 4.8 % 6.7 % 0.9 % 0.6 %increase in qerr. 0.79 % 0.36 % 0.01 % 0.00 %

Fig. 9: Time and accuracy of the search. Fig. 10: Time of search as function of map size.

Time and quality of search

0

0,02

0,04

0,06

0,08

0,1

0,12

0,14

0,16

0,18

0,2

0,2 0,3 0,4 0,5 0,6Time (seconds /(1000 nodes * 1 image))

Err

orra

te

TS-SOM

FSS

MT

Time of search

0

0,1

0,2

0,3

0,4

0,5

0,6

0,7

0,8

0 500 1000 1500Nodes

Tim

epe

rim

age

MT (b=1)

MT (b=2)

MT (b=3)

FSS (b=2)

FSS (b=3)

FSS (b=4)

TS-SOM

5. CONCLUSIONS

Most optimal fast SOM node search methods exclude a number of code vectors from the search set. The tested methods(PDS, AT, SOC, and DHSS) seem to be helpful even in as high as 60 dimensional searches. As the data is real andfeatures correlate, the most suitable optimal method in the experiment was the DHSS, which limits the search in themost discriminating direction. It should be mentioned that Tai et al.13 achieved their best results using DHSS with adiscrete cosine transformation. We limited our experiment to PCA. Also combining different search techniques couldimprove the speed, but that effect was not tested either.

In addition to optimal ones, we tested sub-optimal (TS-SOM) search methods. The two methods of our own (MT andFSS) perform well for this purpose, although cannot be used to speed up the training. FSS seems to outperform slightlyin these experiments, but the difference is marginal. However, all tested sub-optimal methods clearly outperformoptimal ones on speed with larger maps. The quality of search can be tuned, at the cost of speed, by adjustingparameters like beam width. In the experiments, the quality was directly measured e.g. as a rate of incorrectly foundBMUs. The increase in the classification error rate in actual inspection is most probably much smaller than this sub-optimality rate. However, this effect was not measured in the experiments here.

An overall result obtained is that the bottleneck of our inspection method, the speed of the code vector search, can beimproved considerably. The results indicate that inspection could be performed real time even with a standard PC. Thecomputational power of standard PCs is nowadays higher than that of the one used in our experiments. Furthermore,imaging resolution needed by lumber mills is often smaller than we have used, which reduces the amount of data toprocess. For example, current software implementation in a 550 MHz PC can be used to inspect a 30MB board image,using 60 features with 27*18 nodes detection and recognition maps, in one second. The ratio of speed and accuracy canbe tuned by adjusting for example the map size, number of features, and accuracy of the node search method.

REFERENCES

1. M. Niskanen, O. Silvén, and H. Kauppinen, “Color and Texture Based Wood Inspection with Non-supervisedClustering”, Proceedings of The 12th Scandinavian Conference on Image Analysis (SCIA2001), pp. 336-342,Bergen, 2001.

2. M. Niskanen, O. Silvén, and H. Kauppinen, “Experiments with SOM Based Inspection of Wood”, InternationalConference on Quality Control by Artificial Vision (QCAV2001), 2, pp. 311-316, Le Creusot, 2001

3. H. Kauppinen, O. Silvén, and T. Piirainen. “Self-organizing map based user interface for visual surface inspection”,11th Scandinavian Conference on Image Analysis (SCIA'99), pp. 801-808, Kangerlussuaq, 1999.

4. T. Kohonen, Self-organizing maps. 426 p., Springer-Verlag, Berlin, 1997.

5. T. Ojala, M. Pietikäinen, and D. Harwood. “A comparative study of texture measures with classification based onfeature distributions”. Pattern Recognition 29, pp. 51-59, 1996.

6. E. S. H. Cheung and A. G. Constantinides. “Fast Nearest Neighbour Algorithms for self-Organising Map and VectorQuantisation”, 27th Asilomar Conference on Signals, Systems and Computers, 2, pp. 946-950, Los Alamitos, 1993.

7. S. Kaski. “Fast Winner Search for SOM-Based Monitoring and Retrieval of High-Dimensional Data”, 9th

Conference on Artificial Neural Networks, 2, pp. 940-945, London, 1999.

8. E. Lopez-Gonzalo and L. A. Hernandez-Gomez. “Fast Vector Quantization Using Neural Maps for CELP at 2400bps”, 3rd European Conference on Speech Communication and Technology, 1, pp. 55-58, Berlin, 1993

9. M. –C. Su and H. –T. Chang. “Fast Self-Organizing Feature Map Algorithm”, IEEE Transactions on NeuralNetworks 11(03), pp. 721-733, 2000.

10. C. -D. Bei and R. M. Gray, “An improvement of the minimum distortion encoding algorithm for vectorquantization”, IEEE Transactions on Communications 33(10), pp. 1132-1133, 1985.

11. C. M. Huang, Q. Bi, G. S. Stiles, and R. W. Harris, “Fast Full Search Equivalent Encoding Algorithms for ImageCompression Using Vector Quantization”, IEEE Transactions on Image Processing 1, pp. 413-416, 1992.

12. S. -W. Ra and J. K. Kim, “Fast weight-ordered search algorithm for image vector quantization”, Electronics Letters27(22), pp. 2081-2083, 1991.

13. S. C. Tai, C. C. Lai, and Y. C. Lin, “Two Fast Nearest Neighbor Searching Algorithms for Image VectorQuantization”, IEEE Transactions on Communications 44, pp. 1623-1628, 1996.

14. P. Koikkalainen. “Fast Deterministic Self-Organizing Maps”, International Conference on Artificial NeuralNetworks, pp. 63-68, Paris, 1995.

15. S. H. Huang and S. H. Chen, “Fast encoding algorithm for VQ-based image coding”, Electronics Letters 26, pp.1618-1619, 1990.

16. D. –Y. Cheng and A. Gersho. “A Fast Codebook Search Algorithm for Nearest-Neighbor Pattern Matching”,International Conference on Acoustics, Speech, and Signal Processing, 1, pp. 265-268, Tokyo, 1986.

17. J. H. Friedman, J. L. Bentley, and R. A. Finkel. “An algorithm for finding best matches in logarithmic expectedtime”, ACM Transactions on Mathematical Software 3(3), pp. 209-226, 1977.

18. N. Katayama and S. Satoh. “The SR-tree: an index structure for spatial searching”, ACM SIGMOD InternationalConference on Management of Data, pp. 369-380, Tucson, 1997.

19. S. Berchtold, D. Keim, and H. –P. Kriehel. “The X-tree: An index structure for high-dimensional data”,International Conference on Very Large Databases (VLDB), Bombay, pp. 28-39, 1996.

20. R. Weber, H. –J. Schek, and S. Blott. “A Quantitative Analysis and Performance Study for Similarity-SearchMethods in High-Dimensional Spaces”, International Conference on Very Large Databases (VLDB), New York,1998.

21. E. Kushilevitz, R. Ostrovsky, and Y. Rabani. “Efficient Search for Approximate Nearest Neighbor in HighDimensional Spaces”, 30th ACM Symposium on Theory of Computing, Dallas, pp. 614-623, 1998.

22. P. Indyk and R. Motwani. “Approximate Nearest Neighbors: Towards removing the Curse of Dimensionality”, 30th

Annual ACM Symposium on Theory of Computing, Dallas, pp. 604-613, 1998.

23. J. Kleinberg. “Two Algorithms for Nearest-Neighbor Search in High Dimensions”, 29th Annual ACM Symposium onTheory of Computing, pp. 599-608, El Paso, 1997.

24. J. Lampinen and E. Oja. “Fast Self-Organization by the probing algorithm”, International Joint Conference onNeural Networks, 2, pp. 503-507, Washington DC, 1989.