Automatic threshold selection ant colony optimization ...

5
Automatic threshold selection based on ant colony optimization algorithm Zhiwei Ye, Zhaobao Zheng, Xin Yu, Xiaogang Ning School of Remote Sensing and Information Engineering, Wuhan University, Wuhan Hubei 430079,P.R.China E-mail [email protected] Abstract- Image segmentation is a long-term difficult problem, which hasn't been fully solved. Threshold is one of the most popular algorithms. Ant colony optimization algorithm (ACO) was recently proposed algorithm, which has been successfully applied to solve many combinatorial optimization problems. On the analysis of Ostu, we are aware that threshold selection can be viewed as a combinatorial optimization problem. Thus, we introduce a new method to select image threshold automatically based on ACO algorithm. The performance of this algorithm is compared with Ostu, and experimental results show that ACO algorithm can reveal very encouraging results in terms of the quality of solution found and the processing time required. Key words: Ant colony algorithm; threshold; image segmentation; between-class square error I. INTRODUCTION Thresholding is a significant technique for image segmentation, which is applied broadly in many fields such as computer vision, character recognition, analysis of biologic images etc. A number of methods concerning threshold selection have been put forward on the effort of technological workers. However, It is a pity that most of these algorithms suffer from local optimization and bad efficiency in practice. Hence, how to select a threshold of global optimization efficiently is a hot topic in the domain of image processing. Ant colony optimization (ACO)[1][3][5]was recently proposed by Dorigo.M et al, as a multi-agent approach to difficult combinatorial optimization problems like the traveling salesman problem (TSP), the quadratic assignment problem (QAP) and so forth. Currently, there is much ongoing activity in the scientific community to extend and apply ant-based algorithms to solve a great deal of discrete optimization problems for it's parallel and robust characters. II PRINCIPLE OF ANT COLONY OPTIMIZATION Ant algorithms were inspired by the observation of real ant colonies. Ants are social insects, that is, insects that live in colonies and whose behavior is directed more to the survival of the colony as a whole than to that of a single individual component of the colony. Social insects have captured the attention of many scientists because of the high structure level their colonies are able to achieve, especially 0-7803-9422-4/05/$20.00 C2005 IEEE when compared to the relative simplicity of the colony's individuals. An important and interesting behavior of ant colonies is their foraging behavior, and, in particular, how ants have the capability to find the shortest paths between food sources and their nest. A lot of ant species have a trail-laying and trail- following behavior when foraging. Individual ants deposit a substance called pheromone while walking. Ants can smell pheromone and follow pheromone with some probability. In this manner, ants can communicate with each other by the medium of pheromone trails and exchange information about which path should be followed. More number of ants traces a given path, more attractive this path becomes. Other ants will tend to choose following the path and deposit their own pheromone. This autocatalytic and collective behavior results in the establishment of the shortest route. As shown in Figurel, two ants start from their nest in hunt for food at the same time to two different directions. One ant chooses the path that turns out to be shorter while the other takes the longer. The ant moving in the shorter path goes back to the nest earlier and the pheromone density in this path is obviously thicker than what is deposited in the longer path. Other ants in the nest thus have high probability to follow the shorter route. These ants also deposit their own pheromone on the path. More and more ants are soon attracted to the path and hence the optimal route from the nest to the food source is established. However, the decision about whether to follow a path or not is never deterministic, thus allowing a continuous exploration of alternative routes, which can prevent the ants from getting stuck in local optimal. Such a pheromone- meditated cooperative search process leads to the intelligent swarm behavior, which is the key factor leading to the formulation of artificial ant algorithm to solve a lot of combinatorial and function optimization problems. food food nest nest 728

Transcript of Automatic threshold selection ant colony optimization ...

Page 1: Automatic threshold selection ant colony optimization ...

Automatic threshold selection based on antcolony optimization algorithm

Zhiwei Ye, Zhaobao Zheng, Xin Yu, Xiaogang NingSchool of Remote Sensing and Information Engineering, Wuhan University, Wuhan Hubei 430079,P.R.China

E-mail [email protected]

Abstract- Image segmentation is a long-term difficult problem,which hasn't been fully solved. Threshold is one of the mostpopular algorithms. Ant colony optimization algorithm (ACO)was recently proposed algorithm, which has been successfullyapplied to solve many combinatorial optimization problems.On the analysis of Ostu, we are aware that threshold selectioncan be viewed as a combinatorial optimization problem. Thus,we introduce a new method to select image thresholdautomatically based on ACO algorithm. The performance ofthis algorithm is compared with Ostu, and experimental resultsshow that ACO algorithm can reveal very encouraging resultsin terms of the quality of solution found and the processingtime required.Key words: Ant colony algorithm; threshold; imagesegmentation; between-class square error

I. INTRODUCTION

Thresholding is a significant technique for imagesegmentation, which is applied broadly in many fields suchas computer vision, character recognition, analysis ofbiologic images etc. A number of methods concerningthreshold selection have been put forward on the effort oftechnological workers. However, It is a pity that most ofthese algorithms suffer from local optimization and badefficiency in practice. Hence, how to select a threshold ofglobal optimization efficiently is a hot topic in the domainof image processing.

Ant colony optimization (ACO)[1][3][5]was recentlyproposed by Dorigo.M et al, as a multi-agent approach todifficult combinatorial optimization problems like thetraveling salesman problem (TSP), the quadratic assignmentproblem (QAP) and so forth. Currently, there is muchongoing activity in the scientific community to extend andapply ant-based algorithms to solve a great deal of discreteoptimization problems for it's parallel and robust characters.

II PRINCIPLE OF ANT COLONY OPTIMIZATION

Ant algorithms were inspired by the observation ofrealant colonies. Ants are social insects, that is, insects that livein colonies and whose behavior is directed more to thesurvival of the colony as a whole than to that of a singleindividual component of the colony. Social insects havecaptured the attention ofmany scientists because of the highstructure level their colonies are able to achieve, especially

0-7803-9422-4/05/$20.00 C2005 IEEE

when compared to the relative simplicity ofthe colony'sindividuals. An important and interesting behavior of antcolonies is their foraging behavior, and, in particular, howants have the capability to find the shortest paths betweenfood sources and their nest.

A lot of ant species have a trail-laying and trail-following behavior when foraging. Individual antsdeposit a substance called pheromone while walking. Antscan smell pheromone and follow pheromone with someprobability. In this manner, ants can communicate with eachother by the medium ofpheromone trails and exchangeinformation about which path should be followed. Morenumber of ants traces a given path, more attractive this pathbecomes. Other ants will tend to choose following the pathand deposit their own pheromone. This autocatalytic andcollective behavior results in the establishment of theshortest route. As shown in Figurel, two ants start fromtheir nest in hunt for food at the same time to two differentdirections. One ant chooses the path that turns out to beshorter while the other takes the longer. The ant moving inthe shorter path goes back to the nest earlier and thepheromone density in this path is obviously thicker thanwhat is deposited in the longer path. Other ants in the nestthus have high probability to follow the shorter route. Theseants also deposit their own pheromone on the path. Moreand more ants are soon attracted to the path and hence theoptimal route from the nest to the food source is established.However, the decision about whether to follow a path or notis never deterministic, thus allowing a continuousexploration of alternative routes, which can prevent the antsfrom getting stuck in local optimal. Such a pheromone-meditated cooperative search process leads to the intelligentswarm behavior, which is the key factor leading to theformulation of artificial ant algorithm to solve a lot ofcombinatorial and function optimization problems.

food food

nest nest

728

Page 2: Automatic threshold selection ant colony optimization ...

(a) (b)Fig. 1 Movement of ant from nest to food and back (a) two ants start fmdingthe food and (b)pheromone is deposited more quickly on the shortest pathand most of the ants choose the shortest path in final

In all these algorithms, a set of ant-like or software antssolve the problem under consideration through a cooperativeeffort. However, different from the above mentioned antalgorithms, P.S. Shelokar [2] proposes a new ant algorithmfor clustering problem. That is, each artificial ant discoversa possible partition of objects in a given dataset and thelevel of partitioning is measured subject to certain metric.Information associated with an ant about clustering ofobjects is accumulated in the global information hub(pheromone trail matrix) and is utilized by the other ants toconstruct possible clustering solutions and iterativelyimprove them. The algorithm works for a given maximumnumber of iterations and the best solution found with respectto a given metric represents an optimal or near-optimalpartitioning of objects into subsets in a given dataset. In thisnew ant-based clustering algorithm the author views theclustering problem as an assignment optimization problem.That is,N objects are to be assigned into M subsetswithout prior knowledge. For one object it hasM candidateclusters, and for all the objects there are NM collocations.In case of some small-scale problems, it can be easily solvedby exhaust algorithm, whereas, for some large-scaleproblems, it can hardly be raveled out by exhaust algorithmbecause of enormous computations up to date. Generically,to a certain extent the problem can be solved by someoptimization algorithms such as genetic algorithm (GA) andsimulate annealing (SA) etc and satisfying solution can beavailable from these algorithms. The author has succeededin solving several difficult clustering problems by ACOalgorithm and results produced proved to be superior to thatofGA and SA. In the paper, threshold selection is viewed asa combinatorial problem and to be solved by this newproposed ACO algorithm.

In general, application the new ACO algorithm tooptimization problem includes several critical aspects asfollows.

(1)How to encode a solution about the problem to behandled?

(2)How to construct an efficient fitness function?(3)How to configure a group ofproper parameters to

the algorithm?(4)What strategy used to build a solution?(5)When to terminate the algorithm?The paper is organized from below. Section 3 describes

the step involved the advanced algorithm to solve thresholdselection problem, while Section 4 reports evaluation of theexperiments results of our algorithm and Ostu'sthresholding algorithm. Eventually, conclusions of thecurrent work are reported in Section5.

HI ACO FOR THRESHOLD SELECTION PROBLEM

In many application ofimage processing, the gray

levels ofpixels belonging to the object are substantiallydifferent from the gray levels belongs to the background.Thresholding[7] then becomes a simple but effective tool toseparate objects from the background. There are manymethods to select threshold, which can be categorizedrelying on the information they are exploiting, such ashistogram, classes square error, fuzzy set, entropy and soforth. General speaking, different criteria as minimum error,cross-entropy, maximum entropy etc are employed bydifferent algorithm for threshold selection method. All thesealgorithms have their own merits and defects at the sametime. Performance of these algorithms are concerned withthe concrete images to be handled. According to evaluationresult of lee and Sahoo etc it is suggested that maximumbetween-class square error should be a good method toselect proper threshold on the condition that images must beprocessed on real time and the number ofpixels in eachclass are close to each other.

In nature, maximum classes square error belongs toOstu emthod, which employs a criterion for maximizing thebetween-class variance of pixel intensity and can detectproper threshold to segment picture automatically. In thecase of bi-level thresholding of an image, the pixels aredivided into two classes, CO with gray levels [1, ..., t] and

Cl with gray levels [t+l, ..., L].Using discriminant analysis, Otsu defined the

between-class variance of the thresholded image by(t)2 =2 (t)xo2(t)x (A (t)- u2 (t))2 (1)Where Co (t) is the amount of pixels in CO,

(02 (t) is the amount ofpixels in Cl, u1 (t) is the means

for C0, /u2 (t) is the means for C1 .For bi-level thresholding, Otsu verified that the optimal

threshold T is chosen so that the between-classvariance a(t)2 is maximized when t is altered from 0 to L;that is,

T= Arg max( C(t)2) 1.<t < L (2)The essence of Ostu algorithm is to compute the

between-class variance. More gray level the image has,more time for computation will be needed. In practicalimage processing, to eliminate the influence by uneven light,local threshold selection method is often utilized. That is, animage is divided intoK blocks with size of M xN pixels,and for every subimage the Ostu method is applied to selectthreshold. Here, the total times ofvariance computation forlocal threshold isK multiples of that of the global threshold.For instance, a 256 gray level image with size of2000 x 2000 pixels is divided into 400 blocksby100 x 100, then 1024000 times of variance computationwill be needed to get all the local thresholds. There is nodoubt that this millions of computations will degrade theefficiency of the algorithm and makes it unsatisfying to

729

Page 3: Automatic threshold selection ant colony optimization ...

process images of large size.In fact, as is mentioned above, the inward of Ostu is a

process to pursue the maximum between-class variance,which can be viewed as an optimization problem. Hence, wecan employACO to deal with it.

In regard to 256 gray level images, the candidatethreshold is between 0 and 255.which can be encoded by 8bits binary code. Namely, the values between 0 and 255 arecoded from 00000000 to 11111111 l.The element of every bitcan be choose as 0 or 1. In substance, it is a combinatorialproblem with 8 elements. Each element can label 1 or 0,thusit has 28 =256 combinations. Ifwe try all 256 thresholds toget the optimal threshold ,it is the Ostu's method. Here weutilize ACO to solve it. More details are described hereafter.

To solve threshold selection problems through ACOalgorithm is to obtain maximum between-class variance ofthresholded images. The algorithm considers R ants to buildsolutions. An ant starts with an empty solutionS of lengthNwhere each element ofthe string represents the cluster labelof the test samples. As an illustration, a representativesolution string S in Table 1 constructed forN = 8 andK = 2 is given below as.

TABLE I EXAMPLE OF ASSIGNMENT

I 10 10 1 0 1 lo l0As is shown in tablel, the first element of the above

string is labeled as number 1;the second element is markedas number 0 and so on. To build a solution, the ant uses thepheromone trail to allocate each element of string S with anappropriate cluster label. The pheromone matrix is set tosome small value ro initially. The trail value rv. at location(i, j) stands for the pheromone density of the sample relatedto cluster j. As for solving the problem of assigningN samples toK clusters, the size ofpheromone matrix isNxK . (in the article it is 8 x 2 ) In this manner, eachsample is associated withK pheromone concentrations.

By pheromone-mediated communication, each ant willdevelop such a solution to problem at every iteration. As thealgorithm iterates, the pheromone matrix evolves. Aftergenerating a population ofR trial solutions, a mutation orcalled local search process is performed to improve thefitness of these solutions. Then the pheromone matrix isupdated according to quality of solutions produced by theants, conducted by modified pheromone matrix, the antsconstruct improved solution and above steps will go on untilsome rule is satisfied .in the paper, the algorithm ends upwith maximal cycle.

Let us consider for the purpose of illustration. We nowilluminate the course of current iteration t. Ants build theirsolutions based on the information provide by thepheromone matrix updated at the end of iteration t -1. Asexplained earlier, ants begin with empty solution strings andthe intensity of trail of first iteration is set to an arbitrary

small value (0.1 in our experiment). To generate a solutionS, the ant selects label of each element of string by thefollowing rules.

(l)Using probability qo, cluster having the maximum

pheromone concentration is chosen ( q0 being a prioridefined number, 0 < qo < 1, qo =0.2 in oursimulations),and /or

(2)One ofK (two)clusters using stochastic distributionwith probability (1- qo ),denote as p, .

The first process is known as exploitation while thelatter is termed as biased exploration .to explain how theabove-mentioned procedures work simultaneously, considerdeveloping a solution .we generate numbers randomly fromuniform distribution in the range between 0 and 1 .thegenerated random number are, say(0.68,0.72,0.83,0.45,0.23,0.98,0.01,0.48) thus, only element7is assigned to appropriate clusters by using fist procedure(i.e clusters chosen with highest pheromone concentration)since random number corresponding the element are lessthan qo .in the meantime ,the remaining elements of the

solution string SI are assigned to one oftwo clusters byusing the second procedure since their correspondingrandom numbers are more than qo .

In the second process, the ant uses roulette rule todecide which class number should be chosen with anormalized pheromone probability by (pheromoneprobability is normalized to 1)

Tu(t)Pij (t) = DTy (t)

j=l

(3)

Where pi is the normalize pheromone probability for

element i falls into cluster ,zj stands for pheromone

intensity for sample(bit) i; K (in the paper,K is 2.) is thenumber of clusters, andt means iteration times.

For example, the pheromone intensity of first elementare V00 = 0.25,t l = 1.75 respectively.Correspondingly, the normalized probability of element 1ispOO = 0.125, Po0 = 0.875 . Label of sample 1 can bedecided by generation a number from uniform distributionin the range [0 1], thus if the random number generated isbetween 0 and poo, cluster number 0 is chosen as the label

of first element, if it is higher than po0 cluster number 1 ischosen. Supposed the random number generated is0.25,which is higher than 0.125, hence, the first element isassigned to cluster number 1. The remaining elements canbe assigned by analogy and the complete solution is built. Inlike wise, the other ants can construct their solutions. After

730

Page 4: Automatic threshold selection ant colony optimization ...

labeling a sample the ant steps and use the same rule tochoose the class number for the next bit. When it allots thelast bit, it stops. Analogously, all the ants implement aboveprocedures in parallel. After all the ants finishes their tour,the fitness of all the solutions is computed and local searchis performed in current iteration, then the pheromone matrixis updated.

The quality of solution is measured by the objectivefunction as between-class square error. Mathematically, theobjective function can be formulated as.Maxf(t) = 'oj (t) x WI (t) x (p0 (t) - pu1 (t))2 (4)

Such that t is a gray level between 0 and 255 whichcan be obtained through decoding assignment solution.

wo (t) is amount of pixels whose gray value is lower

than t; co, (t) is amount of pixels whose gray value ishigher than t; p0(t) is the means of pixels with gray valueless than t; , I (t) is the means of pixels with gray valuemore than t.

After getting S, we can compute fitness of eachsolution string. In succession, we employ local search toimprove the solution, which is similar to mutation operationin GA. According to a given threshold (local searchprobability PJ, ) some label in the solution is changed toanother number (in the range of clusters number.) In thiswise, a new solution is produced. Then fitness of the newsolution is calculated. If fitness of the new solution is morethan that of the old solution, the old solution is replaced bythe new solution; otherwise the new solution is rejected.More specifics can be found in [4][2].

Subsequent to execution of local search operation, thebestL Solutions is chosen and the pheromone matrix is tobe updated .he pheromone matrix holds information aboutgood combination provided by ants. In this paper, the best Lsolutions are selected out and used to update thepheromone .let r, (t + 1) be the intensity at time t +1,(tis iteration times) the trial information is updated as thefollowing rule.

L

tij (t + 1) = p-r. (t) + EA ri i NL ,j = 1I..KX; (S)Wherep is a coefficient which lies between [0,1] that

(1-p ) represents evaporation, lower value of p suggeststhat the information gathered in the past iterations isforgotten faster. The value of Ar..' is equal to F,, if

cluster j is allocated to ith element ofthe solution built byant and zero otherwise. An optimal solution is that solutionthat maximizes the objective function value of formula (4).The value of best solution in memory is substituted with thevalue of the solution which has the maximal objectivefunction value ofthe current iteration if it's objective

function value is more than that ofthe best solution inmemory. The process mentioned above comprises foremostiteration of the algorithm.

In a general way, As for a 256 gray leve image, thequasi threshold will vary 25 gray levels around the optimalthreshold[ 6]. Therefore , to avoid falling into local optimalthreshold a fluctuant thresholdA is imposed in our test. Thatis ,after main circle ends we get a quasi threshold .Thenanother local search is performed , that we change t in therang of [t- A,t+A] and compute between-class variance toget optimal threshold.

In brief, the algorithm mainly involves five stu-ps viz.(1) generating R solutions by ants via pheromoneinformation (2) performing local search operation on newlygenerated solutions, (3) updating pheromone trial matrix,(4)the algorithm repetitively carries out (1)(2)(3) these threesteps for a given maximum iterations. In the end, solutionhaving biggest function value represents the quasi thresholdof input image (5) In the light of given fluctuant threshold A,another local search is executed to get the optimal thresholdon the rule ofbiggest between- class variance.

IV EXPERIMENTS AND DISCUSSION

We implement the algorithm to threshold 10 imagesincluding lena and several aerial images. To evaluate theperformance of our algorithm, we have compared it withOstu algorithm. A colony of 10 ants are employed in thealgorithm and the algorithm ends when it iterates 6times.Two images and segmented results are showed in Figure 2.Parameters of ant algorithm have important influence on theresult, which will be illuminated later.

As we can see from Table 2 that the worst quasithreshold has only lIgray levels difference to the bestcorresponding threshold, in addition, the best quasithreshold has no difference with corresponding optimalthreshold. Furthermore, the method can get the sameoptimal threshold as that of Ostu. In contrast, allmaximum times ofvariance computation is below 118,while the Ostu algorithm need 256 times of computation. Itis obvious that our method can reduce the computation timeand enhance the efficiency of old class square errormethod.(in table 2 no means image No. ,times is the totaltimes of variance computation ,quasi and best denote quasithreshold and best threshold respectively.)

TABLE II EXPERIMENTAL RESULTNo. Our method Ostu

Cycles Times Quasi Best Times Best1 6 118 101 101 256 1012 6 118 139 144 256 144

3 6 118 121 132 256 132

4 6 118 113 111 256 1115 6 118 79 86 256 86

6 6 118 128 126 256 126

7 6 118 141 141 256 141

731

Page 5: Automatic threshold selection ant colony optimization ...

6

6

6

118 144 140 256 140

118 143 152 256 152

118 106 104 256 104

I Segn

We have tried different group ofparameters on thealgorithm. Experimental result suggests thatp =0.5, qo = 0.2 maybe a good configuration for our test.

Number of ants maybe adopts in proportion as dimension ofthe problem. In the paper, 10 ants are used. Local searchpercentage is 30% and local search probability P,s = 0.1 isenough to improve the result searching by ants.

V CONCLUSIONS

In summary, ACO algorithm has been developed toselect image threshold in this paper. Experimental resultsprove that our newly proposed algorithm can succeed infinding optimal threshold to segment images. Surely, it can

be applied to seek for muti-threshold for imagesegmentation question. However, some drawbacks of ouralgorithm mainly lies in that the number of threshold mustbe given as priori knowledge and good configuration ofparameters needs to be studied farther. Hence, further workcan be done along two main research directions.* How to use this algorithm without being given the

number of the threshold?* How to apply ant colony optimization algorithm to

generic image segmentation problem?

ACKNOWLEDGMENT

This paper is financially supported by NSFC(No.40271094).

REFERENCES

[1].Coloring A, Dario M, and Manifesto V. Distributed Optimization by antcolonies. Proc, I"s European Conf. Artificial Life, Pans, France;Elsevier, 1991:134-142

[2].P.S.Shelokar, V.K.JayRaman, B.D.Kulkarni. An ant colony clusteringapproach for clustering ANALYTICAL CHMICAL ACTA 509,2004 :187-195

[3].Colorini A, Dorigo M, and Manifesto V. Positive feedback as a searchstrategy. Technical Report 91-016 Polytechnic did Milan 1991

[4] .P.Franti etc Randomised Local Search Algorithm for the ClusteringProblem, Pattern Analysis &Application 2000 vol3 358-369

[5]. Christine Solnon. Ants Can Solve Constraint SatisfactionProblems .IEEE TRANSACTIONS ONEVOLUTIONARYCOMPUTATION, VOL.6, NO.4,2002 347-357

[6]. Zheng hong, Pan Li the automatic selection ofimage threshold on thebasis of genetic algorithm.journal ofimage andgraphics (chiese) vol4(A) No 4 Apr 1999 327-330

[7]. Survey over image thresholding techniques and quantitativeperformance evaluation , Journal ofElectronic Imaging January 2004,13(1) 146-1

732

8

lo9

. . - . . . .