Buletnul Stntfc al Unverstat Poltehnca dn Tmsoara, ROMANIA Sera AUTOMATICA s CALCULATOARE PERIODICA POLITECHNICA, Transactons on AUTOMATIC CONTROL and COMPUTER SCIENCE Vol.49 (63, 2004, ISSN 224-600X Improved Methods of Geometrc Shape Recognton usng Fuzzy and Neural Technques Ioan Z. MIHU, Arpad GELLERT and Hora V. CAPRITA Computer Scence Department, Lucan Blaga Unversty of Sbu, str. Eml Coran, nr. 4, 550025 Sbu, ROMANIA E-Mal: oan.z.mhu@ulbsbu.ro, arpad.gellert@ulbsbu.ro, hora.caprta@ulbsbu.ro Abstract Recognton of hand-drown shapes represents a helpful applcaton n drawng packages and automated sketch entry n handheld computers. In ths paper we propose a herarchcal archtecture for on-lne geometrc shape recognton, whch utlzes a fuzzy functon for flterng the angular dfferences along the shape boundares and a multlayer feed-forward neural network for classfcaton and on-lne tranng. Our method examnes the geometrc shape as a whole n a way smlar to the human recognton process, usng nformaton that s nvarant n terms of scalng, translaton and rotaton. Such nvarant nformaton s represented by the nternal angles of the shape and the key concept of our work s that the neural network learns these angles. Both, the optmal archtecture of the neural network and the fuzzy classfer are chosen based on the crteron of performance maxmzaton. Keywords: Geometrc Shape Recognton, Neural Networks, Neural Shape Classfcaton, Fuzzy Systems I. INTRODUCTION The capacty of the neural networks to solve complex problems learnng by examples, gves them a hghly large potental of applcablty. Buldng ntellgent systems that can model human behavor has captured the attenton of the world for years. So, t s not surprsng that a technology such as neural networks has generated great nterest. Ulgen, et al. n ther work [3], mplemented a geometrc shape classfer and they have used a neural network wth bnary synaptc weghts (BSW. The BSW algorthm, whch was mplemented on a three layer network, determnes the thresholds for the hdden and output layer nodes and the weghts of the synaptc lnks between the layers, n addton to the number of hdden layer nodes n one feed-forward pass. The man concept of the algorthm can be explaned as the separaton of globally ntermngled patterns wthn an n-dmensonal space through the formaton of hyperplanes that separate dfferent classes of patterns at a local regon n the space. In our prevous work [0], we used a multlayer feedforward neural network to recognze the basc geometrc shapes such as crcles, rectangles or trangles. We chose the best confguraton of the neural network based on the results obtaned wth our test mages. In ths paper we present an mproved shape recognton system, ntroducng a corner-detecton algorthm, n order to elmnate the classfcaton mstakes. The corner-detecton algorthm elmnates the false corners and detects the real corners, mprovng n ths way, the classfcaton accuracy. II. THE MULTILAYER FEEDFORWARD NEURAL NETWORK Ths secton ntroduces the backpropagaton learnng algorthm addressed by the archtecture presented n ths paper. More detaled descrptons can be found n classc ntroductory books [6]. The typcal artfcal neuron model represents a devce wth n nputs and a sngle output. The output y of the -th neuron of the network s computed as: n y = σ ( p = σ W, j x j ( j= for =, 2,, m; where W, j represents a coeffcent or synaptc weght assocated wth the j-th nput x j and the -th neuron. The weghted sum p s called potental. The nonlnear actvaton functon σ n ths case s the sgmod, and the
network s traned usng the gradent descent method known as backpropagaton. σ ( x = (2 x + e Equaton ( can be rewrtten n a matrx form as r r r y = σ ( p = σ ( W x (3 Usually, the actvaton functon σ represents some saturatng non-lnear functon. Neurons are often organzed n layers, all neurons n a layer sharng the same nputs and havng ther outputs connected to the nputs of the next [q] layer. The weght matrxes are then shown as W, where q s the layer number. Neural networks usually undergo a learnng process. The synaptc-weght matrxes are teratvely updated accordng to a learnng rule. One of the smplest one s the Hebb rule: T W W ( y r r = + α x ; (4 where α s a learnng factor. Though ths rule s seldom used as stated, most of the commonly used learnng rules are slght modfcatons of equaton (4. Multlayer neural networks are used for pattern classfcaton, pattern matchng, and functon approxmaton. By addng a contnuously dfferentable functon, such as Gaussan or sgmod functon, t s possble for the network to learn practcally any nonlnear mappng to any desred degree of accuracy. There are several ways that multlayer neural networks can have ther connecton weghts adjusted to learn mappngs. The most popular technque s the backpropagaton algorthm and ts many varants. V IN V HID VOUT x 0 y 0 nput-output pars { x d r } r,, called prototypes. The backpropagaton (BP learnng rule s a gradent-descent algorthm that updates the weghts to mnmze the squareerror on the learnng prototypes. For that purpose an error sgnal s computed for each layer [4]: [ L] [ ] ( d y σ ( p [ L] L δ = (5 mq [ q ] [ q ] δ = Wk, δ k σ + + + k= ( p dσ v for q =, 2,, L-, where σ ( v =. dv The equatons (5 and (6 are vald for all the neurons ( =, 2,, m q of layer q. Once the errors have been back-propagated, the weghts are updated as: W [ q ] T = W ( (6 r r + α δ y (7 for q =, 2,, L, where r y r = x. III. GEOMETRIC SHAPE RECOGNITION The classcal technques based on shape parttonng nto segments, followed by a syntactcal analyss to match wth a predefned shape, are strongly affected by nose and are weak n terms of generalzaton. In order to elmnate these lmtatons of the classcal methods, our method examnes the geometrc shape as a whole n a way smlar to the human recognton process. Human bengs recognze such basc shapes regardless of the varatons n sze, nose on the shape border, translaton, rotaton, and n the case of trangles, regardless of the type of the trangle. That means that not the segments are mportant n the recognton process but the angles, whch represent the relevant nformaton relatvely to the geometrc shape. The key concept s that the neural network learns the nternal angles of a shape. As a consequence, the neural network tranng process wll be smplfed, therefore only a few tranng samples that represent a class of shapes are suffcent. Our applcaton s am s to recognze the basc geometrc shapes (ellptc, rectangular and trangular shapes. [0] x N y R A. Feature Extracton Fg.. A multlayer perceptron wth 2 actve layers (one hdden layer. Multlayer networks make t possble to mplement any r r arbtrary functon y = Φ(x, x r beng the nput of the frst [L] layer and y r r = y representng the output of the last layer L. Often the actvaton functon σ s a hyperbolc tangent. The functon Φ s learned by repeated presentaton of The purpose of preprocessng s to create an ntermedate representaton of the nput data and t s performed on-lne (pror to the applcaton of recognton task. The preprocessng step can be defned as a feature extracton process that s mportant snce t prepares nput data that s nvarant n terms of scalng, translaton and rotaton. The feature extracton s performed on the captured ponts along the boundary of the shape.
Snce the geometrc shapes are hand-drawn usng the mouse, the nformaton could nclude nose due to the varatons n capture speed of the mouse and erratc hand moton whle drawng. We have to extract the features of the shape and to elmnate the nose appeared whle drawng, keepng only the essental characterstcs. Also the hand-drawn shape may contan nterruptons that must be elmnated unfyng the segments. The feature extracton process s composed of a number of steps, and the frst of them s the calculaton of the shape s weght center. Calculaton of the shape weght center. For the calculaton of the weght center of a gven geometrc shape the next formulas are used: x C n n x y = 0 = 0 =, yc =, (8 n n where x c s the horzontal poston of the shape s weght center, y c s the vertcal poston of the shape s weght center, n s the number of captured ponts whle drawng, x s the horzontal poston of each captured pont, and y s the vertcal poston of each captured pont. Extracton of sgnfcant ponts. The next step n the feature extracton process s the determnaton of the sample ponts. There are calculated n angularly equspaced vectors that start from the shape s weght center; n s the number of sample ponts. The ntersecton of these vectors wth the boundary of the shape represents the sample ponts of that shape. The next step conssts n the calculaton and the tracng out of the tangent vectors to the shape n these ponts. In our applcaton the tangent vectors are obtaned by the unon of the sample ponts; unfyng two successve sample ponts a tangent vector s obtaned. (x C, y C Fg. 2. Extracton of sample ponts (the ntersectons of the vectors wth the shape s boundary. As we can see n fgure 2, a very mportant parameter n the recognzng process s the number of sample ponts. For an effcent extracton of the relevant nformaton necessary for the recognton process of the geometrc shape, we have to use a suffcent number of sample ponts. B. On-lne Data Acquston and Processng When we want to create a new geometrc shape to be processed by the recognton system, we have to draw t wth the mouse on the applcaton s frame. The drawng process can be nterrupted anytme and resumed to complete the shape. The on-lne data acquston and processng conssts of the followng steps: capturng successve ponts on the shape s boundary; extractng sgnfcant ponts; detectng the shape s corners; calculatng the angles between consecutve segments. Capturng successve ponts on the shape s boundary. The pont capturng process s based on the drag and drop event handled by the operatng system. The event generaton frequency s constant on a certan computer but dependent on hardware platform. On the other hand, the drawng speed s dfferent from user to user or even from nstance to nstance of the same user. On the drag and drop event there are captured a number of ponts that are not neghbors n the real shape s boundary and that depends on the drawng speed. Thus, f on the applcaton s frame are panted only the captured ponts obtaned on the drag and drop event, a dscontnuous copy of the real shape results. To solve ths problem we used an algorthm, whch calculates and stores all the ponts between any two consecutve captured ponts obtaned on the drag and drop event. Extractng sgnfcant ponts. As t was descrbed n chapter A, there are calculated n angularly equspaced vectors startng from the shape s weght center (n beng the number of sgnfcant ponts a parameter whch wll be chosen n order to maxmze the applcaton s performance. The angular dstance between any two consecutve vectors s: 360 dst = (9 n The ntersecton of these vectors wth the shape s boundary represents the sgnfcant ponts of that shape (for n vectors there wll be n sgnfcant ponts. By tracng lne segments between any two sgnfcant ponts an approxmaton of the geometrc shape s obtaned (fgure 2. Detectng the shape s corners. In our prevous work [0], the sgnfcant ponts often avoded the shape s corners. In ths stuaton, a relevant nternal angle was replaced by other two successve angles. In fgure 3 one corner of the trangle was replaced by two other corners and n ths way, because the shape had four sgnfcant nternal angles, the recognton system msclassfed t as rectangle. In other words a part of the relevant nformaton was lost and n addton other nformaton (nose appeared, whch often
led to wrong classfcaton of the shapes. We mplemented an algorthm, whch elmnates these defcences, and mproves the classfcaton accuracy. (x C, y C example, the angles between the two consecutve segments and the horzontal axes belong to the frst quadrant: α, = α α ( α 2 [0, 90 α 80 where α, α 2 are the angles between the segments and the horzontal axes, and α s the angle between the two segments. 2 Fg. 3. Extracton of sgnfcant ponts. One corner of the trangle was avoded. α α 2 The corner-detecton algorthm calculates the dstances from the ponts on the real shape to the straght segment defned by two consecutve sgnfcant ponts (fgure 4. The dstances are calculated only for the ponts whch are stuated between those two sgnfcant ponts on the shape s boundary. If all dstances are less than a certan threshold (T, we consder that the shape s approxmaton s correct. Our experments showed that a threshold value of 2, leads to best expermental results. If one of the dstances exceeds the threshold value, the maxmum dstance s calculated and one of the two sgnfcant ponts are replaced wth the pont stuated at the maxmum dstance from the lne segment. Ths s lustrated n fgure 4, where the sgnfcant pont (x 2, y 2 wll be replaced wth the real corner of the shape (x, y. (x, y (x, y d (x 2, y 2 Fg. 4. Detecton of the shape s corners The dstance between the current pont (x, y from the shape and the straght segment ((x, y, (x 2, y 2, s calculated usng the followng equaton: ax + by + c d =, (0 2 2 a + b where a = y 2 y, b = x x2, and c = x2 y x y2. Calculatng the angles between consecutve segments. The angle between two consecutve segments s determned by calculatng the angles between each segment and the horzontal axes (fgure 5. The angle s calculated dependng on the quadrant t belongs to. In fgure 5 for α Fg. 5. Calculaton of the angle between two consecutve segments, wth α, α 2 [0,90. C. Fuzzy Classfcaton To generate the nput data for the neural network, after the feature extracton process follows the adaptaton of the obtaned nformaton. The nternal angles of a geometrc shape offer the relevant nformaton necessary to the classfcaton process. The angles between the consecutve tangent vectors are calculated and we obtan n angles, whch wll be classfed nto four categores (fuzzy. Each angle wll receve a membershp value dependng on the category to whch t belongs, as t follows: 2 for the angles less than 75 degrees; 3 for angles between 75 and 0 degrees; for angles between 0 and 45 degrees; 0 for the angles greater than 45 degrees; The membershp values must be gven n such a way that, after the addton of the membershp values accordng to the n angles, to obtan dfferent sums for each class of geometrc shape. We have consdered that the mportant angles are the angles less than 45 degrees. In the case of a rectangle or a trangle, along the sdes we wll have angles near to 80 degrees; because these angles are not sgnfcant, they receve 0 as membershp value, n other words these angles wll not contrbute to the sum. Snce the number of angles less than 45 degrees offers the relevant nformaton necessary to the recognton process of the basc geometrc shapes, only these angles, through ther consstent membershp values, wll contrbute to ths sum, whch wll be a value from the nterval [0, 3n]. Usng the sum of the angles membershp values the dmensons of the shape don t matter (there s no dfference between a lttle trangle and a bg one, and not even the dmensons of the sdes (there s no dfference between a square and a rectangle, only the nternal angles matter.
D. Neural Recognton of the Shape The neural network s archtecture and the learnng algorthm used were presented n secton II. The nput vector for the neural network wll be obtaned after the seral codng of the sum of the membershp values accordng to the nternal angles of a gven geometrc shape. In ths way, the sum s value determnes the number of bts on n the seral code, and the rest of bts are 0. The neural network s statcally traned before ts effectve use. That means that the network wll be traned usng a set of prototypes (a number of representatve learnng shapes. Before startng the tranng process the weghts are randomly ntalzed. Durng the tranng process, f the shape s correctly classfed, only a backward step s made. If the shape s ncorrectly classfed, the backward step wll be repeated untl the classfcaton becomes correct and one more tme after that. For ts effectve use, the neural network s ntalzed wth the weghts generated by the statc tranng process. Durng the effectve run-tme classfcaton process only the forward step s performed. The dmenson of the neural network s nput vector must be calculated takng nto consderaton the most dsadvantageous case that appears when all the angles takes part of the category 3 (angles between 75 and 0 degrees. In ths case the calculated sum wll have the maxmum value (3n, and therefore we need 3n neurons n the nput layer of the neural network. Consequently the neural network s nput vectors are sequences of 3n bnary values. Snce the neural network must recognze three categores of shapes (rectangles, trangles and crcles, n the output layer we wll have three neurons, one for each category. The neuron wth the hghest output value wll wn, specfyng the category n whch the shape takes part. Snce the neural network used n ths work has three layers, the dmenson of the hdden layer represents a parameter and t s value wll be establshed based on the crteron of the performance maxmzaton. IV. EXPERIMENTAL RESULTS The neural network was statcally traned wth 0 learnng shapes for each shape category. After the learnng process the recognton system was evaluated usng 30 test shapes for each category. In ths chapter a number of archtectural parameters are vared and the obtaned results are presented. As we specfed n secton III, n the feature extracton process we have to use a number of sample ponts as great as possble and n ths way we can extract effcently the relevant nformaton necessary for the recognton process of the geometrc shape. But f we use too many sample ponts there s a rsk of appearance of the nose n the extracted nformaton. Usually the nose appears because of the undesrable hand movements whle drawng wth the mouse. Therefore, the number of sample ponts represents another parameter that must be chosen based on the crteron of the performances maxmzaton. We synthesze n the table the nfluence of ths parameter on the performances of the geometrc shape recognton system. As t can be seen, the optmal number of sample ponts s 32. TABLE. The nfluence of the number of sample ponts on the shape classfcaton. Shape 6 32 48 64 Crcles 63.33 00 96.66 96.66 Trangles 56.66 60 60 80 Rectangles 86.66 70 63.33 26.66 All shapes 68.88 76.66 73.33 67.77 The nternal angles of the shapes are classfed nto four categores n the fuzzyfcaton stage. We showed n secton III, that the lttle angles are the most mportant n the classfcaton process. We have also presented a varant of fuzzyfcaton. The method of accordng the membershp values represents the thrd parameter that nfluences the performances of the recognton system. In our prevous work [0], we studed four methods of fuzzyfcaton and, dependng on the results, we chose the best soluton n order to maxmze the applcaton performance. In the same tme we have decreased the tranng tme of the neural network from 0000 teratons to 000. In table 2 are presented the obtaned results. TABLE 2. Dfferent methods of fuzzyfcaton of the nternal angles Shape Method I Method II Method III Method IV Crcles 00 96.66 00 00 Trangles 23.33 0 76.66 73.33 Rectangles 96.66 00 90 00 All shapes 73.33 65.55 88.88 9. The four fuzzyfcaton methods ntroduced n our prevous work, were used wthout the corner-detecton algorthm. As can be seen, the fourth method of fuzzyfcaton represents the best soluton. We contnued our work by studyng the nfluence of the neural network s archtecture on the performances of the recognton system. We vared the number of neurons n the hdden layer and we evaluated the recognton rate for 5, 0 and 20 neurons n hdden layer. The obtaned results are presented n table 3. TABLE 3. The nfluence of the number of neurons from the hdden layer on the effcency of the recognton system. Shape 5 0 20 Crcles 96.66 00 00 Trangles 23.33 73.33 73.33 Rectangles 00 00 00 All shapes 73.33 9. 9. We can observe that the optmal soluton s to use ten neurons n the hdden layer. If we ncrease the number of neurons n ths layer over ten, the effcency of the neural network doesn t change, but the tranng tme grows up exponentally. We mproved after that the effcency of the recognton system, ntroducng the corner-detecton algorthm descrbed n secton III. Also we used the
fuzzyfcaton method presented n the same secton. The evaluaton results are presented n table 4. our system and fgure 7 presents strongly dstorted shapes, whch can t be recognzed. TABLE 4. The classfcaton accuracy of the recognton system usng the corner-detecton algorthm Shape category Classfcaton accuracy [%] Crcles 96.66 Trangles 00 Rectangles 96.66 All shapes 97.77 Fg. 6. Recognzed dstorted shapes. V. CONCLUSION In ths work we presented a method of recognzng the basc geometrc shapes. Both tranng and recognton process are made by extractng the features from the tranng (test samples, and by classfyng the nternal angles of the shape. The nformaton obtaned after the fuzzyfcaton process s used as nputs for the multlayer feedforward neural network. The network learns the three classes of geometrc shapes by ther nternal angles; the values of the nternal angles are nvarant n terms of scalng, translaton and rotaton. We studed the nfluence of the number of sgnfcant ponts used n the feature extracton process on the effcency of the recognton system. A small number of sgnfcant ponts (less than 32 s not suffcent for a correct recognton of the geometrc shapes. In ths case the nformaton obtaned n the feature extracton process s not suffcently consstent to assure the desred performances of the recognton system. On the other hand f we use too many sgnfcant ponts (over 32, there s a rsk of appearance of the nose n the extracted nformaton. The nose, whch usually appears because of the undesrable hand movements whle drawng wth the mouse, overlaps the relevant nformaton and n ths way t degrades the performances of the recognton system. The evaluatons drove us to the concluson that the optmal number of sgnfcant ponts s 32. After that, we studed dfferent fuzzyfcaton methods of the nternal angles. The effected tests drove us to the concluson that the lttle angles (less than 90 degrees are very mportant, because the number of these angles offers the relevant nformaton necessary to the recognton system. Also we studed the nfluence of the neurons number from the hdden layer on the effcency of the neural network used n the recognton process. The tests show that the optmal soluton for the number of neurons n ths layer s ten. Fnally we ntroduced the corner-detecton algorthm whch mproved the classfcaton accuracy of the recognton system. In our opnon the results show acceptable classfcaton accuracy of 97.77% obtaned on our test mages. Our system works properly and recognzes even the dstorted shapes, neglectfully drawn by the user. Fgure 6 presents neglectfully drown shapes recognzed by Fg. 7. Unrecognzed dstorted shapes. One of the development drectons of the recognton system s to elmnate these defcences and to classfy the trapezum as rectangle, and respectvely, the ellpse as crcle. Another development drecton conssts of ncreasng the varety of geometrc shapes, whch the system can recognze. REFERENCES [] P. Comon, J. L. Voz and M. Verleysen, Estmaton of performance bounds n supervsed classfcaton, In M. Verleysen, edtor, ESANN: European Symposum on Artfcal Neural Networks, Bruxelles, pp. 37-42, 994. [2] L. S. Davs, Understandng shape: angles and sdes, IEEE Trans. on Computers, vol. C-26, pp. 25-32, 977. [3] K. Fukunuga, Statstcal pattern classfcaton, Handbook of Pattern Recognton and Image Proc., San Dego, CA: Academc Press, pp. 3-32, 986. [4] K. I. Funahash, On the approxmate realzaton of contnuous mappngs by neural networks, Neural Networks, Vol. 2, pp. 83-92, 989. [5] I. Guyon, Neural networks and applcatons, Internal Report AT & T Bell Labs, 990. [6] J. Hertz, A. Krogh and R. Palmer, Introducton to the Theory of Neural Computaton, Santa Fe Insttute Studes n Scences of Complexty, Addson-Wesley, Redwood Cty, Calforna, 99. [7] F. Hornk, Multlayer feedforward networks are unversal approxmators, Neural Networks, Vol. 2, pp. 359-363, 989. [8] A. Khotanzad, J. Lu, Classfcaton of nvarant mage representatons usng a neural network, IEEE Trans. on Acoustcs, Speech and Sgnal Processng, vol. 38, pp. 24-222, 990. [9] B. Kosko, Neural networks and fuzzy systems: a dynamcal systems approach to machne ntellgence, Prentce Hall, 992. [0] I. Z. Mhu, A. Gellert and C. N. Sucu, Geometrc shape recognton usng fuzzy and neural technques, In Proceedngs of the th Internatonal Scentfc Symposum SINTES, pp. 354 358, Craova, 2003. [] S. J. Perantons and P. J. G. Lsboa, Translaton, rotaton, scale nvarant pattern recognton by hgher-order neural networks and moment classfers, IEEE Trans. on Neural Networks, vol. 3, pp. 243-25, 992. [2] R. J. Schalkoff, Artfcal Neural Networks, McGraw-Hll, 997. [3] F. Ulgen, N. Akamatsu and M. Fukum, On-lne shape recognton wth ncremental tranng usng a neural network wth bnary synaptc weghts, Industral Applcatons of NNs, CRC Press, pp. 59-92, 999. [4] J. M. Zurada, Introducton to Artfcal Neural Systems, West Publshng Company, St. Paul, 992.