Combnng Cellular Automata and Partcle Swarm Optmzaton for Edge Detecton Safa Djemame Ferhat Abbes Unversty Sétf, Algera Mohamed Batouche Mentour Unversty Constantne, Algera ABSTRACT Cellular Automata can be successfully appled n mage processng. In ths paper, we propose a new edge detecton algorthm, based on cellular automata to extract edges of dfferent types of mages, usng a totalstc transton rule. The metaheurstc PSO s used to fnd out the optmal and approprate transton rules set of cellular automata for edge detecton task. Ths combnaton ncreases the effcency of the algorthm, and ensures ts convergence to an optmal edge as shown n varous experments. Comparsons are made wth standard methods (Canny) and other algorthms based on Cellular Automata and Genetc Algorthms. Obtaned results are promsng. General Terms Image Processng, Artfcal lfe, Complex systems, Metaheurstcs. Keywords Cellular automata, Edge detecton, Complex systems, Metaheurstcs, Partcle swarm optmzaton, Rule Optmzaton. 1. INTRODUCTION Edge detecton s one of the most mportant operatons used n mage processng, namely n bologcal and medcal applcatons, where an edge becomes an mportant feature. Several edge detectors have been proposed n the lterature for enhancng and detectng edges. The common approach s to apply the frst (or second) dervatve to the smoothed mage and to fnd the local maxma (or zero-crossng). However, the majorty of dfferent methods may be grouped nto two categores: Gradent based edge detecton: (frst dervatve or classcal). Laplacan based edge detecton: (second dervatve). Nevertheless, these methods present drawbacks: some operators are desgned to be senstve to certan types of edges. Varables nvolved n the selecton of an edge detecton operator nclude edge orentaton, nose envronment and edge structure. So, these methods present problems of false edge detecton, mssng true edges, edge localzaton, hgh computatonal tme and problems due to nose etc. Although many edge detecton methods have been developed n the past years, however t s stll a challengng problem. In an attempt to make a contrbuton n ths feld, we nvestgate the world of complex systems and artfcal lfe. Indeed, cellular automata (CA) have proven effectve n the feld of mage processng. Several works cted n the lterature have focused on ther propertes to perform varous mage processng tasks such as [1]: calculatng dstances to features, calculatng propertes of bnary regons such as area, permeter and convexty, performng smple object recognton.. Hernandez et al. [2] presented CA for elementary 2-D mage enhancement. Wongthanavasu et al. [3] presented 3-D CA for edge detecton on bnary and grayscale mages, and compared ts performance evaluaton to wellknown edge operators. But the space of CA rules s enormous, 2 512 for a bnary CA wth eght nearest neghbors. And only a small set of rules among ths huge number s lkely to gve the rght result. From a modelng pont of vew, t s thus desrable to have some theoretcal constrants, helpng us to choose rules whch can gve the rght behavor. Ths ssue remans an area of actve research. These nclude the work of Rosn [4] who employed a determnstc method: sequental floatng forward search (SFFS), t has the advantages to be smple to mplement, not randomzed, t does not requre many parameters. Applyng genetc algorthms remans a domnant method n research nto extractng CA rules [5],[6],[7],[8],[9]. In [10], the authors descrbe a dfferent approach based on a contnuous transton functon, nstead of usng a classcal dscrete cellular automata. The objectve of ths work s twofold: frst, t presents a new method for detectng contours, from the applcaton of a CA rule; on the other hand, t proposes a new method for solvng the problem of optmzng the search space and extractng the subset of rules lkely to acheve the desred task by usng the metaheurstc Partcle Swarm Optmzaton (PSO). 2. RELATED CONCEPTS Ths secton presents the basc concepts used n ths work: cellular automata and partcle swarm optmzaton. 2.1 Cellular Automata Cellular automata (CA) were frst ntroduced by John von Neumann (after a suggeston by Stanslaw Ulam) n the late 1940 s [11], [12]. But only n the late 1960 s, when John Horton Conway developed the Game of Lfe [2], dd cellular automata become more well-known and popular. CA became more practcal and mmensely popular after the recent book of Wolfram A New Knd of Scence [13]. The popularty of cellular automata can be explaned by the enormous potental that they hold n modelng complex systems, n spte of ther smplcty. A cellular automaton s a regular d-dmensonal lattce of cells (d s n most cases only one or two), each cell has a state chosen among a fnte set of states and whch can evolve n tme. The state of a cell at tme t+1 depends on the state at tme t of a lmted number of cells called ts neghborhood. At every unt of tme, the same rules are smultaneously appled to all cells of the grd, producng a new generaton of cells dependng completely on the prevous generaton. Cellular automata are massvely parallel systems, workng n a 16
synchronous way, where several teratons take place untl convergence. In recent years, Cellular automata have been successfully used to study complex systems n several domans such as Physcs (lattce gas automata, Isng model), Mathematcs(dfferental equatons), Cryptography, Bology, Socology, Economcs, Engneerng, smulaton of fre propagaton, smulaton of urban development, graphc effects generaton,... 2.2 Partcle Swarm Optmzaton The Partcle Swarm Optmzaton (PSO) s a populaton based stochastc optmzaton technque developed by Dr. Eberhart and Dr. Kennedy n 1995[14], nspred by socal behavor of brd flockng or fsh schoolng. The PSO algorthm conssts of a set of potental solutons evolvng to approach a convenent soluton (or set of solutons) for a problem. Beng an optmzaton method, the am s to fnd the global optmum of a real-valued functon (ftness functon) defned n a gven space (search space). The socal metaphor that led to ths algorthm can be summarzed as follows: the ndvduals that are part of a socety hold an opnon that s part of a "belef space" (the search space) shared by every possble ndvdual. Indvduals may modfy ths "opnon state" based on three factors: The knowledge of the envronment (ts ftness value) The ndvdual's prevous hstory of states (ts memory) The prevous hstory of states of the ndvdual's neghborhood PSO s ntalzed wth a group of random partcles (solutons) and then searches for optma by updatng generatons. In every teraton, each partcle s updated by followng two "best" values. The frst one s the best soluton (ftness) t has acheved so far (the ftness value s also stored). Ths value s called P (or P-best). Another "best" value that s tracked by the partcle swarm optmzer s the best value, obtaned so far by any partcle n the populaton. Ths best value s a global best and called P g (or g-best). After fndng the two best values, the partcle updates ts velocty and postons accordng to equaton (1) and (2). V t1 t t t t t V c1r1 ( P X ) c2r2 ( Pg X X X V (2) t1 t t1 Where: V s the velocty of each partcle, X s the current poston of each partcle, c 1 and c 2 are acceleraton constants, r 1 and r 2 are random numbers n the range [0,1], P s the best poston of each partcle, P g s the best poston of the swarm. The orgnal PSO has been modfed by Sh and Eberhart [15] who ntroduced an nerta weght ω to balance explotaton and exploraton. Eq.(1) becomes: V t1 t 1 1( 2 2 g t t t t V c r P X ) c r ( P X ) (3) PSO s a smple algorthm, easy to mplement. The smplcty of PSO mples that the algorthm s nexpensve n term of memory requrement. In recent years, PSO has become very popular n the doman of optmzaton, because of these favorable characterstcs. PSO dstances tself from the other ) (1) evolutonary methods (typcally the genetc algorthms) on two essental ponts: It emphaszes the cooperaton rather than the competton and there s no selecton, the dea s that a partcle even f t s presently medocre deserves to be preserved, because t may be the one whch wll allow future success. 3. THE PROPOSED APPROACH 3.1 Edge Detecton Rules In ths work, the class of CAs used s called totalstc CAs. The state of each cell n a totalstc CA s represented by a number (usually an nteger value drawn from a fnte set), and the value of a cell at tme t depends only on the sum of the values of the cells n ts neghborhood (possbly ncludng the cell tself) at tme t 1 [13]. Totalstc CA don t take nto account the poston of the cells. Ths knd of CA allows the optmzaton of search space. Cellular automata and ts transton functon are defned as follows: Each cell has two states: 0 or 1. A cell s sad to be alve f ts value s equal to one, t s called dead f ts value s zero. The neghborhood consdered s that of Moore (8 neghborng cells). The total number of decson rules s calculated as follows: Number of states: 2, whch are: 1 alve, and 0 dead. The number of lvng neghbors can vary between 0 and 9, consequently the number of decson rules wll be equal to 2 ^ 10 = 1024, we obtan a total of 1024 possble patterns.ths s a qute large number of possble rules to be tested. It s worth to realze that not all the rules are nterestng. It s nterestng to select only the rules that present more effcency for edge detecton of any knd of mage. The transton rule of our CA s defned as follows: the future status (FS) of the central cell s set to the value n the lne (Bnary representaton), correspondng to the table ndex (NAC), after countng the number of alve cells NAC, for example: Interpretaton of rule 120: Rule number 120 Bnary 0 0 0 1 1 1 1 0 0 0 (FS) representaton NAC 0 1 2 3 4 5 6 7 8 9 In the ntal pattern, the number of alve cells NAC s equal to four, by applyng the rule 120 above; we see that NAC s equal to four corresponds to the future status FS of the central cell that becomes equal to 1. 3.2 Hybrd CA-PSO Algorthm The CA-PSO algorthm attempts to fnd the best edge by applyng a rule of the CA, randomly taken among a set of 1024 rules, on the nput mage. The ftness functon s computed between the ground truth mage and the one obtaned by the CA rule. PSO parameters are adjusted, another partcle (rule) s chosen among the swarm, and the same process s repeated untl convergence, whch s reached when the best ftness s obtaned. So the rule yeldng to the best ftness s then retaned. The populaton (search space) represents the set of CA rules. Each partcle s a rule from 1024 rules. At each step of the PSO algorthm, the swarm sze s fxed to 30 n order to speed the convergence of the process. Each partcle of the swarm s characterzed by: 17
Its poston: t represents the number of the rule. It s a value coded on 10 bts, n the range [0..1023] Its velocty: a real number, ntalzed to 0. Its role s to gude the process untl convergence. Its ftness: t s the objectve functon whch measures the qualty of the segmented mage obtaned after applcaton of the correspondng rule. It s ntalzed to zero. The proposed approach takes advantage of the calculatng facultes of the CA, to transform the ntal confguraton defned by the numercal mage lattce as dscrete nput data, n order to fnd ts edges. 3.3 The Ftness Functon The objectve functon used to drve the rule selecton has a crucal effect on the fnal results. We consder here the SSIM ndex. The structural smlarty ndex (SSIM) s a recent method for measurng the smlarty between two mages. SSIM s desgned to mprove on tradtonal methods lke peak sgnal-to-nose rato (PSNR) and mean squared error (MSE), whch have proved to be nconsstent wth human eye percepton. The structural smlarty ndex measures the mage smlarty, takng nto account three ndependent channels: lumnance, contrast and structure [16]. The SSIM metrc between two mages x and y s defned as: (2 x y C1)(2 xy C2 ) SSIM ( x, y) 2 2 2 2 ( C )( C x y 1 x y 2 ) (4) where μ x, μ y, σ x 2, σ y 2, σ xy are respectvely the mean of x, the mean of y, the varance of x, the varance of y, and the covarance of x and y. Followng Wang et al [20], C 1 s set to (0.01 x 255) 2 and C 2 = (0.03 x 255) 2. The resultant SSIM ndex s a decmal value between -1 and 1, and value 1 s only reachable n the case of two dentcal sets of data. 3.4 CA-PSO Algorthm for Edge Detecton Algorthm 1 below shows how our CA-PSO operates and gves ts dfferent steps. In ths algorthm, the PSO process s ntalzed, then each partcle of the swarm (a rule) s converted n bnary representaton and appled to the nput mage pxel by pxel, accordng to the transton functon defned n secton (3.1). At each step, the NAC s evaluated, and the correspondent transton s appled on the mage. So we obtan an output mage (edge map). We compute ts ftness compared to the reference mage we have. Another partcle s selected among the swarm, PSO parameters are updated, ths allows to obtan a new swarm (another set of rules) to test. The same steps are repeated untl a convergence crteron s reached. At the end of the process, we obtan as outputs the best packet of rules and the best edges. Algorthm 1: Steps of the CA-PSO edge detecton 1 Intalzaton of the PSO: read nput mage, ntalze swarm-sze, The mean ftness rato obtaned s about 99%, whch ndcates a hgh robustness of the optmal packet of rules The process of searchng for rules takes a random tme, whch can be short or long. The explanaton s that snce the swarm has a sze of 30 partcles, selected randomly, t s 2 For = 1 to swarm-sze do 3 Partcle[].poston = random (1023) 4 Partcle[]. velocty = 0, 5 Partcle[].ftness = 0, 6 Endfor 7 For = 1 to swarm-sze do 8 P-best[] = partcle[] //best ntal poston 9 Endfor 10 G-best = partcle[1] ///best global poston 11 Whle (stop crteron) s not satsfed do 12 For p=1 to swarm-sze do 13 /////Applcaton of CA rule for each partcle 14 For each pxel of the mage do 15 Compute NAC 16 Apply the transton rule, save the result n a new mage: edge 17 endfor 18 Compute partcle[p].ftness 19 Endfor 20 ////comparson of ftness 21 For =1 to swarm-sze do 22 If partcle[].ftness > p-best[].ftness then 23 P-best[] = partcle[] ///best local poston 24 Endf 25 If g-best[].ftness>partcle[].ftness then 26 G-best[] = partcle[] /// best global poston 27 Endf 28 Endfor 29 For = 1 to swarm-sze do 30 Update PSO parameters: poston and velocty accordng to equatons (1) and (2).////ths allows to 31 obtan a new swarm (another set of rules) to test. 32 Endfor 33 endwhle 34 Return to step 2 4. EXPERIMENTAL RESULTS Ths secton presents some results of the CA-PSO algorthm. We have used a sngle value of swarm-sze = 30 through all these experments. The qualty of the edges s evaluated by both vsual appearance and ftness value. Experments were carred on a Pentum (Processor 3.40 GHz, 512 RAM), usng Matlab 2009. 4.1 Best Packet of Rules Experments carred on tens of dfferent knds of mages (synthetc, bnary, grayscale, color ) show that among a set of 2 10 rules, three best rules are extracted, whch gve excellent edges, after only one applcaton of the totalstc CA rule on the nput mage. These rules are: rule 56, rule 120, and rule 112. Ther bnary representaton s: Rule 56 : 000111000 Rule 112 : 0001110000 Rule 120 : 0001111000 possble that the rght rule s n the frst swarm, as t may be possble that we fnd the correct rule after havng made several changes n swarms, what s stll evdent s that after dentfyng the correct subset of rules, these rules can be 18
drectly appled on the mage to be processed, and quckly leads to the result that s the segmented mage. 4.2.Vsual Results 4.2.1. Bnary Synthetc Images Fgure 5 shows synthetc mages contanng letters, shapes The results are compared wth an algorthm based on CA and genetc algorthm (EV-CA) descrbed n [5] and [7]. It can be seen that dfferent regons are correctly segmented by CA-PSO. The obtaned edges are thn, contnuous, wthout nose around. Fg. 5. Edge detecton of characters, shapes and rabbt mages. (a) nput mage (b) Ev-CA result [5],[7] ( c) CA-PSO result (rule 112) However, these are smple examples of bnary synthetc mages, many rules lead to the same result, meanng t s easy to detect edges for such examples. In the next paragraphs, we wll consder more complex mages. 4.2.2. Real Grayscale Images In fgure 6, CA-PSO algorthm s tested on three well-known grayscale mages: Lena, boat and cameraman. Obtaned results are stll good, n comparson wth the standard detector of Canny. Edges are correct, contnuous, fne. 19
Fg.6. Edge detecton on Lena, boat and cameraman mages. (a) nput mage (b) Canny result (c) CA-PSO result (rule 112) The result of CA-PSO s sharply good, he allowed to extract all the edges n orgnal mage wth a hgh accuracy. 4.2.3. Real color mages Experments carred on color mages where the ntenstes changes dstnctly gve good results. Fgures 7 and 8 show results of CA-PSO on two real color mages, from the Berkeley segmentaton benchmark database. (d) (e) (f) Fg. 7. Edge detecton on real color mage (Brd) (a) Orgnal mage (b) Ground truth (c) Canny result (d) CA-PSO result (rule 120) (e) CA-PSO result (rule 510) (f) CA-PSO result (rule 56) The results clearly demonstrate that CA-PSO method has good effect and produces a correct contour outlne of edge. Edges are clean and contnuous, close to the ground truth mage. 20
(d) (e) (f) Fg. 8. Edge detecton on real color mage (sland) (a) Input mage (b) Ground truth (c) Canny result (d) CA-PSO (rule 112) (e) CA-PSO (rule 120) (f) CA-PSO (rule 56) CA-PSO algorthm has good detecton effects, for the three results (rules 112, 120, 56), edges are contnuous and no false edges are detected. Contnuty of edge s strong; the method has good effect n the detals and good accuracy. 4.3. Ftness Values The followng table llustrates the values of ftness functon, obtaned between the orgnal mages above (characters, shapes, rabbt, brd, sland) and ther ground-truth replca. For smple bnary mages, the ground truth replca s hand-made. For brd and sland mage, the ground truth s avalable on the Berkeley Benchmark ste. All the values notced n the table below are the result of SSIM functon between the ground truth and respectvely Canny, Ev-CA and CA-PSO methods. Table 1. SSIM values for Canny, EV-CA and CA-PSO methods Method CANNY EV-CA CA-PSO Characters 0.98775422 0.9726516 0.99547786 Shapes 0.9811263 0.9715647 0.9987343 0.9858974 0.9726549 0.9974553 Rabbt Brd 0.98622844 0.99262532 Island 0.98392303 0.99944197 In all performed tests, as well as those llustrated above (and others not mentoned n ths paper) and varous types of mages, the PSO-CA method has proved a better performance compared to standard known detectors (Canny) and compared to methods based on CA, wth a qualty edge equal to or exceeds that of the methods mentoned above. So we can conclude that CA-PSO algorthm gves satsfactory results n qualty of edges. It deserves to be mproved to treat other types of more complex mages (textured...). 5. CONCLUSION In ths paper, a new method for edge detecton s proposed. It s based on the hybrdaton of two powerful paradgms n complex systems and artfcal lfe: cellular automata and partcle swarm optmzaton. An evolutonary process extracts the local rules of a CA able of detectng contours for several types of mages. For ths we used the PSO to evolve the set of rules for CA canddates for solvng ths task. The process yelded three rules, whch gve the best ftness and provde a satsfactory contour. After tryng the soluton developed on a multtude of mages of dfferent types and by comparng the results obtaned wth other exstng contours detectors, beng ether standard (Canny), or based on prevous cellular automata work, we can conclude that our soluton has proven effectve for treatng varous types of mages and get very satsfactory results. Expermental results are encouragng, and comparson aganst standard methods (Canny) and another algorthm based on CA and genetc evoluton demonstrate the feasblty, the convergence and the robustness of PSO-CA algorthm. As future prospects, t s nterestng to further explore the fascnatng capabltes of bo-nspred methods and emergence to fnd solutons to varous problems, partcularly to nvestgate the followng ssues: tryng to optmze the CA rules by varous technques such as Quantum PSO, Trbes, Tabu Search, Ant Colony Optmzaton. 6. REFERENCES [1] Rosn P.L. Tranng Cellular Automata for Image Processng, IEEE Transactons on Image Processng, Vol. 15, No. 7 (2006) 2076-2087. [2] Hernandez G., Hermann J.J., Cellular Automata for Elementary Image Enhancement Graphcal Models and Image Processng (GMIP), vol. 4, N 58, (1996) 82-89. [3] Wongthanavazu S., Lursnsap C., A 3-D CA Based Edge Operator for 3-D Images, The proceedngs of the 11 th IEEE nt. Conference on Image Processng (IEEE- ICIP 2004), IEEE press, (2004) 235-238. [4] Rosn P.L, Image Processng Usng 3-state Cellular Automata, Computer Vson and Image Understandng, Elsever vol. 114, (2010), 790-802. [5] Slatna S., Batouche M., Melkem K.E, Evolutonary Cellular Automata Based-Approach for Edge-Detecton, Internatonal workshop on Fuzzy Logc and Applcatons WILF 2007, vol LNAI 4578, (2007) 404-411. [6] Kazar O., Slatna S., Evolutonary Cellular Automata forimage Segmentaton and Nose Flterng Usng Genetc Algorthms, Journal of Appled Computer Scence and Mathematcs, n 10 (5), (2011) 33-40 [7] Batouche M., Meshoul S., Abbassene A., On Solvng Edge Detecton by Emergence, Internatonal Conference on Industral, Engneerng and other Applcatons of Appled Intellgent Systems, vol. LNAI 4031, (2006) 800-808. [8] Bull L., A. Adamatzky, A learnng classfer system approach to the dentfcaton of cellular automata, J. Cellular Automata 2 (1) (2007) 21 38. [9] Terrazas G., Sepmann P., Kendall G., Krasnogor K.O, An Evolutonary Methodology for the Automated Desgn 21
of Cellular Automaton-based Complex Systems, J. Cellular Automata 2 (1) (2007) 77 102. [10] Djemame S., Djdel O., Batouche M., Image Segmentaton Usng Contnuous Cellular Automata, IEEE catalog, ISBN 978-1-4577-0905-0, (2011) 94-97. [11] Shan Y., Yang A., Applcatons of Complex Adaptve Systems IGI publshng, Hershey, NewYork, ISBN- 13:978-1-59904-962-5, 2008 [12] Shan Y., Yang A., «Intellgent Complex Adaptve Systems», IGI publshng, Hershey, NewYork, ISBN- 13: 978-1-59904-719-5, 2008 [13] Wolfram S., A New Knd of Scence, Wolfram meda. ISBN 1-57955-008-8, 2002 [14] Kennedy J., Eberhart R.C, A Dscrete Bnary Verson of the Partcle Swarm Algorthm, In: Proceedngs of IEEE Conference on Systems, Man, and Cybernetcs, (1997) 4104-4109. [15] Sh Y., Eberhart R., A Modfed Partcle Swarm Optmzer, In: Proceedngs of IEEE Internatonal Conference on Evolutonary Computaton, Anchorage, Alaska,1998, pp. 66 73. [16] Wang Z., Bovk A.C., Shekh H.R., Smoncell E.P., Image Qualty Assessment: from Error Vsblty to Structural Smlarty, IEEE Trans. Image Process. 13 (4) (2004) 600 612. 22