A Hierarchical Syntactic Shape Analyzer

8
IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-1, NO. 1, JANUARY 1979 A Hierarchical Syntactic Shape Analyzer THEODOSIOS PAVLIDIS, SENIOR MEMBER, IEEE, AND FARHAT ALI Abstract-In many cases a picture is described in terms of various plane objects and their shape. This paper describes a parser whose in- put is a piecewise linear encoding of a contour and whose output is a string of high-level descriptions: arcs, corners, protrusions, intrusions, etc. Such a representation can be used not only for description but also for recognition. Previous syntactic techniques for contour description have often used high-level languages for the description of contours. This has been necessary in order to guarantee contour closure and eliminate the noise. In the present approach the numerical prepro- cessing of the contour removes most of the noise and also produces the answers to certain simple questions about its shape. Therefore, simpler grammars can be used for the contour description. Examples of de- scriptions of contours are given for handwritten numerals, white blood celis, and pnrnted wiring circuit boards. Index Terns-Contour description, handwritten numeral description, printed wiring board description, regular expressions, syntactic pattern recognition, white blood cell description. I. INTRODUCTION S YNTACTIC TECHNIQUES have been used for shape recognition for a long time. We refer the reader to the book by Fu [1] for a general treatment plus a review of the earlier literature. Also a number of recent papers illustrate various applications of this approach [2]-[8]. Syntactic schemes can produce "anthropomorphic" descriptions of the data and therefore facilitate the development of recognition algorithms. A discussion of this approach in the context of the general problem of shape analysis can be found elsewhere [9], [10]. When the methodology is applied to the descrip- tion of boundaries of plane objects it seems to have two disadvantages: 1) the direct syntactic analysis is faced with the need to handle the effects of noise which cause rather complicated strings; 2) the parsing of the whole boundary may need the use of context-sensitive grammars for the description of the complete object. In this paper we develop further an approach which has been recently proposed [11] and which seems to overcome these disadvantages. Our method is hierarchical and involves three steps. 1) Boundary tracing and polygonal approximation of Manuscript received January 7, 1977; revised March 23, 1978. This research was supported in part by the Engineering Division of the Na- tional Science Foundation under Grants ENG-72-04133, ENG76- 16808, and ENG76-22311 of the Control and Automation Program, and in part by a Mellon Foundation Equipment Grant. T. Pavlidis is with the Department of Electrical Engineering and Computer Science, University of California, Berkeley, CA 94720, on leave from the Department of Electrical Engineering and Computer Sci- ence, Princeton University, Princeton, NJ 08540. F. Ali was with the Department of Electrical Engineering and Com- puter Science, Princeton University, Princeton, NJ 08540. He is now at the Harvard Business School, Boston, MA 02163. the contour by the split-and-merge algorithm [3], [12], [13] . This is the most time-consuming step because it requires the scanning of the original picture matrix and also involves extensive numerical computations. Originally, it was imple- mented in Fortran on an IBM 360-91 machine, but recently we have been able to adapt the software so that it can be performed on a DEC 11/45 under the UNIX operating sys- tem [14] . The slowdown in execution time from the 360-91 has been by a factor of 25. 2) Syntactical parsing for features, described in this paper and implemented in the C language under the UNIX operating system of a DEC PDP 11/45 machine. 3) Description and/or classification through regular expressions using the UNIX software for the implementation. This step depends on the particular application and it is only briefly summarized here. Examples of its application to hand- written numeral description and recognition and the inspec- tion of printed wiring boards are given elsewhere [15], [16] . In this paper we include only a summary of the results using IEEE Data Base 1.2.2. We also illustrate briefly its application to contours of white blood cells (both for nuclei and the cyto- plasm) and to the contours of printed circuits. Systematic studies of both applications are currently in progress. We have proposed in the past polygonal approximations as means of eliminating the noise while preserving local details [12], [13]. The choice of the error of approximation deter- mines how closely the approximation fits the original data. In the present work a small subset of the input data (e.g., 20 characters) [15] is used as a design set during that process. Approximations for different values of the error are chosen and displayed on top of the original boundaries, and the fmal value chosen satisfied a subjective judgement of good fit. Since humans seem to use context for noise elimination and the approximation process is context-free it was decided to emphasize faithful representation at the expense of leaving some noise in. The complete syntactic description often encounters prob- lems because it has to worry about closing boundaries, etc. One way around these difficulties is to process syntactically only up to a certain level. An example of this approach can be found in the work of Horowitz [3] . The starting symbols of the grammar were positive peak (PP) and negative peak (NP). An initial string of these symbols is assumed to be generated by nongrammatical means or by a different gram- mar. The grammatical rules are then used for the generation of the final form of the waveform. Conversely, during parsing one proceeds only until he determines the occurrence of peaks. The final classification is not necessarily grammatical. This approach is highly localized and therefore simple context- free or linear grammars can be used. 0162-8828/79/0100-0002$00.75 C 1979 IEEE 2

Transcript of A Hierarchical Syntactic Shape Analyzer

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-1, NO. 1, JANUARY 1979

A Hierarchical Syntactic Shape Analyzer

THEODOSIOS PAVLIDIS, SENIOR MEMBER, IEEE, AND FARHAT ALI

Abstract-In many cases a picture is described in terms of variousplane objects and their shape. This paper describes a parser whose in-put is a piecewise linear encoding of a contour and whose output is astring of high-level descriptions: arcs, corners, protrusions, intrusions,etc. Such a representation can be used not only for description but alsofor recognition. Previous syntactic techniques for contour descriptionhave often used high-level languages for the description of contours.This has been necessary in order to guarantee contour closure andeliminate the noise. In the present approach the numerical prepro-cessing of the contour removes most of the noise and also produces theanswers to certain simple questions about its shape. Therefore, simplergrammars can be used for the contour description. Examples of de-scriptions of contours are given for handwritten numerals, white bloodcelis, and pnrnted wiring circuit boards.

Index Terns-Contour description, handwritten numeral description,printed wiring board description, regular expressions, syntactic patternrecognition, white blood cell description.

I. INTRODUCTIONS YNTACTIC TECHNIQUES have been used for shape

recognition for a long time. We refer the reader to thebook by Fu [1] for a general treatment plus a review of theearlier literature. Also a number of recent papers illustratevarious applications of this approach [2]-[8]. Syntacticschemes can produce "anthropomorphic" descriptions of thedata and therefore facilitate the development of recognitionalgorithms. A discussion of this approach in the context ofthe general problem of shape analysis can be found elsewhere[9], [10]. When the methodology is applied to the descrip-tion of boundaries of plane objects it seems to have twodisadvantages: 1) the direct syntactic analysis is faced withthe need to handle the effects of noise which cause rathercomplicated strings; 2) the parsing of the whole boundary mayneed the use of context-sensitive grammars for the descriptionof the complete object.In this paper we develop further an approach which has been

recently proposed [11] and which seems to overcome thesedisadvantages. Our method is hierarchical and involves threesteps. 1) Boundary tracing and polygonal approximation of

Manuscript received January 7, 1977; revised March 23, 1978. Thisresearch was supported in part by the Engineering Division of the Na-tional Science Foundation under Grants ENG-72-04133, ENG76-16808, and ENG76-22311 of the Control and Automation Program,and in part by a Mellon Foundation Equipment Grant.T. Pavlidis is with the Department of Electrical Engineering and

Computer Science, University of California, Berkeley, CA 94720, onleave from the Department of Electrical Engineering and Computer Sci-ence, Princeton University, Princeton, NJ 08540.F. Ali was with the Department of Electrical Engineering and Com-

puter Science, Princeton University, Princeton, NJ 08540. He is nowat the Harvard Business School, Boston, MA 02163.

the contour by the split-and-merge algorithm [3], [12], [13] .

This is the most time-consuming step because it requires thescanning of the original picture matrix and also involvesextensive numerical computations. Originally, it was imple-mented in Fortran on an IBM 360-91 machine, but recentlywe have been able to adapt the software so that it can beperformed on a DEC 11/45 under the UNIX operating sys-tem [14] . The slowdown in execution time from the 360-91has been by a factor of 25. 2) Syntactical parsing for features,described in this paper and implemented in the C languageunder the UNIX operating system of a DEC PDP 11/45machine. 3) Description and/or classification through regularexpressions using the UNIX software for the implementation.This step depends on the particular application and it is onlybriefly summarized here. Examples of its application to hand-written numeral description and recognition and the inspec-tion of printed wiring boards are given elsewhere [15], [16] .

In this paper we include only a summary of the results usingIEEE Data Base 1.2.2. We also illustrate briefly its applicationto contours of white blood cells (both for nuclei and the cyto-plasm) and to the contours of printed circuits. Systematicstudies of both applications are currently in progress.We have proposed in the past polygonal approximations

as means of eliminating the noise while preserving local details[12], [13]. The choice of the error of approximation deter-mines how closely the approximation fits the original data. Inthe present work a small subset of the input data (e.g., 20characters) [15] is used as a design set during that process.Approximations for different values of the error are chosenand displayed on top of the original boundaries, and the fmalvalue chosen satisfied a subjective judgement of good fit.Since humans seem to use context for noise elimination andthe approximation process is context-free it was decided toemphasize faithful representation at the expense of leavingsome noise in.The complete syntactic description often encounters prob-

lems because it has to worry about closing boundaries, etc.One way around these difficulties is to process syntacticallyonly up to a certain level. An example of this approach canbe found in the work of Horowitz [3] . The starting symbolsof the grammar were positive peak (PP) and negative peak(NP). An initial string of these symbols is assumed to begenerated by nongrammatical means or by a different gram-mar. The grammatical rules are then used for the generationof the final form of the waveform. Conversely, during parsingone proceeds only until he determines the occurrence ofpeaks. The final classification is not necessarily grammatical.This approach is highly localized and therefore simple context-free or linear grammars can be used.

0162-8828/79/0100-0002$00.75 C 1979 IEEE

2

PAVLIDIS AND ALI: HIERARCHICAL SYNTACTIC SHAPE ANALYZER

The localization of boundary grammars can be seen byexamining carefully some of the examples described bySwain and Fu (17] and by Lee and Fu (18], as well as theearlier work by Ledley (19]. In particular, the stochasticindexed grammars for the production of the chromosomeboundaries have four groups of rules with the groups being verysimilar to each other. One might choose only one group ofrules and then put together the strings generated by them by a

nongrammatical algorithm.In general, successful applications of syntactic techniques

have emphasized the local aspects [2]. The importance oflocal features for shape analysis has also been pointed out byRosenfeld [20], [21] and it can also be seen in much of theapplications work [22], [23].The final recognition algorithm is designed in an interactive

way. By this time the description of the boundaries is quitecompact and it is not unusual for most members of a classto have almost identical string representations. One can thenfind regular expressions which characterize each class.The proposed method includes as special cases two earlier

efforts. The peak detector by Horowitz [3] and the hand-written numeral recognizer by Pavlidis and Ali [13].

II. THE GRAMMARIn this section we describe a general-shape grammar which

is applicable to any type of plane contours. It assumes thatthe boundaries of the objects of interest consist of concatena-tions of entities which are listed next. A formal name isassigned to each one of them for convenience:

1) arcs which can be approximated by a quadratic curve

and which have as a formal name QUAD;2) sharp protrusions or intrusions with formal name TRUS;3) long linear segments with formal name LINE;

4) short segments having no regular shape with formalname BREAK.

The polygonal approximations encode the boundary in a

sequence of vectors V. A QUAD will be approximated by a

subsequence where both the length and the vertex angle willbe more or less uniform. A LINE will be either a single vectoror a set of mutually almost colinear vectors. A BREAK will beapproximated by one or two vectors of very short length. Wemay also assume that a TRUS always consists of two LINES

either separated by a BREAK or in direct sequence. If theLINES are close to being parallel, then the TRUS iS called a

STROKE. Otherwise, it is called a CORNER.These formal names will be used as nonterminals for the

grammar. Each one of them has a set of attributes: in particu-lar, a LINE has both a direction and length. A QUAD can havea length, a curvature, a center, etc. A STROKE can have a

direction, a length, etc. Formally, the production rules in-clude semantics and are listed next:

BDY e BDY + TRUS/BDY + QUADBDY TRUS/QUADTRUS STROKE/CORNER

STROKE -4 LINE1 + BREAK + LINE2 angle of (LINE1,LINE2) differs from 180' by less than e

STROKE -* LINE1 + LINE 2 angle of (LINE I, LINE2) differsfrom 1800 by less than e

CORNER - LINE1 + BREAK + LINE2 angle of (LINE1,LINE2) > e

CORNER - LINE1 + LINE2 angle of (LINE 1, LINE2) > eLINE - LINE + V angle of (LINE, V) is less than eQUAD - QUAD + V {variance of V-angle < 8; variance

of V-length <8 ;}

The parameters 6 and e are specified by the user dependingon the application.

It is obvious that in its present form the grammar does notguarantee the production of closed boundaries. Since ourintention is to use it in a nongenrative fashion, this is not areal problem. Given a sequency of vectors V, a parser basedon this grammar will map them into a string of nonterminalswhich will eventually be BDY. If we are interested in thedetection of strokes, comers, etc., then the parsing shouldstop when the string of vectors has been mapped to the non-terminals STROKE, CORNER, QUAD, LINE, and BREAK.The semantic rules are very important for this grammar

because the strings generated (or parsed) do not consist ofsymbols from a finite alphabet but are rather sequencesof real vectors. (In practice, the vector lengths and anglesare described by a finite number of bits; therefore, in a sense,we do have a finite "alphabet." But its cardinality is so large,say 1015 or more, as to be for all practical purposes infinite.)The rules given previously are somewhat unrealistic becauseof the inherently fuzzy or probabilistic nature of the defini-tions of features like stroke, corner, arc, etc. It will be morerealistic to replace them by the following stochastic grammar:

STROKE - LINE1 + BREAK + LINE2 angle of (LINE1,LINE2) differs from 1800 by less than e. Pro-bability Pl (e).

STROKE -* LINE1 + LINE2 angle of (LINE1 , LINE2) differsfrom 180° by less than e. Probability p2(e).

CORNER LINE1 + BREAK + LINE2 angle of (LINE1,LINE2)> e. Probability p3(e).

CORNER - LINE1 + LINE2 angle of (LINE1, LINE2) > 6.Probability p4(e).

LINE - LINE + V angle of (LINE, V) is less than e.Probability p5 (e).

QUAD - QUAD + V {variance of V-angle < 5; variance ofV-length <8 ;} Probability P6(8).

Instead of probabilities, one may use fuzzy characteristicfunctions. The relation between the two can be explained asfollows. Stating that two vectors having angles equal to 70 canbe mapped into a LINE with 96 percent probability impliesthat in 96 percent of the cases when such vectors are seen theyhave been obtained as approximations of the same straightline with the break occurring either because of noise or be-cause of imperfections in the algorithm for fmding the poly-gonal approximations. Stating that such vectors form astraight line with "degree of straightness," 0.96 means that weassign this number intuitively to the configuration.The assignment of probabilities makes the parsing process

more complicated. On the other hand, certain simplificationsare possible. It is obvious that the rules for LINE and QUAD

3

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-1, NO. 1, JANUARY 1979

are so simple that it would be rather presumptuous to use

syntactic methods for their detection. We shall describe inthe next section a set of procedures for preprocessing thevertex string before the use of the parser and also certainprocedures which are utilized by the parser.

III. PREPROCESSING OF THE VERTEX STRINGBefore attempting to parse the polygonal approximation

of a boundary, a number of nonsyntactic operations must beperformed. The input to the preprocessor and, subsequently,the parser are a sequence of vectors V, representing the poly-gonal approximation of a contour and a set of parameterswhich depend on the application. In this and the next twosections such parameters are given names in capital letters.(We should point out that the method is quite robust withrespect to their choice and only one set of values was usedfor all the examples reported in the paper.) The junctionsof the vectors correspond to the vertices of the polygon.Following common practice, we assign a sign to each vertex,+ if it is convex, - if it is concave. Thus the term "positivevertices" is synonymus to "convex vertices," etc.The index of a vertex is the same as that of the vector pre-

ceding it. For example, the fifth vertex is formed by the fifthand sixth vectors. We shall use the expression "a vector (or a

vertex) is placed in a stack (or a list, etc,)" and mean that therespective index is placed in the stack or list.A number of elementary operations are performed first on

the sequence V. The average length laver of the vectors isestimated, and it is used as a measure of significant length inthe sequence. In particular, we define

toll = laver * SCTOLL

where SCTOLL is a scale factor, depending on the application.In most cases discussed in this paper, it was chosen equal to 1.Generally, if one is interested in recognizing subsets of con-

tours (e.g., detection of faults or coastline features), SCTOLL

should be chosen less than 1 while values equal to 1 or greaterare appropriate for global-shape analysis. In our tests we usedthe same value (1) for both types of problems with reasonableresults, and therefore, it is likely that the choice of the precisevalue is not critical. Next the boundary is edited by merging

vectors which form an angle less than PNEGANG if they are

either in sequense or separated by a vector of very smalllength (less than toll/PELF). Typical values for these param-

eters are

PNEGANG = 100; PELF = 5.

It seems that these values should be valid for all applications,and their choice is not particularly important in any case.

(As a rule, this is true for all parameters used in this paper.

Angle tolerances reflect the ability of humans to perceivechanges in direction and length tolerances describe perceptionof relative lengths.) Next the first convex vertex after a stringof concave ones is chosen as the starting point of the parser.

This guarantees that the boundary is "broken" at a junction oftwo nonterminals and not inside one. Finally, the extrema

of the contour in four directions (high, low, right, left) are

determined.Since we deal only with local features, all our algorithms

deal only with substrings of the input consisting of successive

TABLE IDETECTOR FOR QUAD

InUt: A subset of the array V (the contents of C); A starting index I Sidevariance tolerance UTSID; Angle variance tolenrance UTANG- (See note 1);5thinimunvertex angle allowed for a quadratic arc QUADANG, and op'imal angle O0TQANG;(See note 2);

Output: Labeling of vertices as belonging to the same quadratic arc. Lengtn, lo-cation and confidence level of the arc.

Stems:1. Set first index equal to one plus I

2. Do stemps 3-7 while all checks are true.

3. Increment the index.

4. Update the average vertex angle a and normalized angle variance v(Tne latter equals the variance divided by the square of the average*.

5. Update average side length and normalized side variance v (The firstand the last side are treated specially and their lenghfs are ignoredduring these calculations).

6. lf either of the normalized variances exceeds the respective threshold,Sz.t frO VIC 199.2.

7. Label tentatively the curent vertex as belonging to QUAD.

d. evaluate the center of gravity of the vertices already examined and the to-tal length of the sides L. If the first side is less than the averalelength, then it is teseed for inclusion in the 4UAD (in terms of the ).if its lengtn exceeds a, then only a subset of it with length eoual to asisincluded and only a is added to L. The last side is similarly treated.

9. If the number of sides is a least three make the tentative labels permenant.

10. Evaluate the confidence level of the QUAD.(v + v ) i)(l+

c =1 - K,first .last(UTANG + UTSID) 30 Lwhere 1fir t and 11.3t are the lentgth of the first and last side (Seenote 3)tls ls

lBoth are normalized tolerances, and the value of 0.3125 seems to beappropriate for both of them.2The values of 800 and 1200, respectively, seem appropriate for them.

These choices are based on the assumption that most polygonal approx-imations of circles will be hexagons, while none will be squares ortriangles.3This formula is heurestic, and it is justified as follows. If both

variances are zero (i.e., the input string is part of a regular polygon),then c = 1. The same value is also returned if the average angle equalsthe OPTQANG. Because of the total lengths of the first and last sidehave been ignored in the previous steps, they are considered now. Iftheir sum is significant in comparison L, then this decreases the likeli-hood of having detected a QUAD. Thus each of the terms reflects ameasure of distance from an ideal quadratic arc. The smaller they arethe closer the QUAD is to the ideal case. Note that the first term isalways less than 1, the second will be guaranteed to be less than 1 ifOPTQANG and QUADANG are chosen properly, and the third willexceed 1 only in very extreme cases. Thus, although theoretically therange of c includes negative values, in practice it is expected to be be-tween 0 and 1.

TABLE IIDETECTOR FOR LINE

lnDut: A subset ot the array V (see note 1). An angle tolerance COLANG (itsvalue is different at different calls of the procedure; see main algorithm);

Qqt.ut: Labeling of vertices, direction and length of LINE.

SteD3:

1. If any vertices have been already labeled by QUAD, ignore them.

2. For all indices in the input string do tne following:

3. lf two successive vectors form an angle less than COLANG then they arereplaced by a single vector with similar endpoints.

4. If two vectors are separated by a third one with length less than 118of the shorter of the two and they form an angle less than COLANthen they are replaced by a single vector with similar endpoints.

lBoth are normalized tolerances, and the value 0.3125 seems to beappropriate for both of them.

vertices of the same sign. If desired, vertices with a very wideangle or having one side of a very small length may be ignoredin the process of selecting such substrings. The critical size isdetermined by an input parameter. The vertices belonging tosuch a substring are placed in a stack C which is then scannedby the main parser and the other detectors called by it. Actu-ally, we have chosen to have this procedure formally as part ofthe parser rather than the preprocessor.Tables I and II describe the "local" detectors for QUAD and

LINE. These are nonsyntactic and they simply examinesequences of vertices to verify whether they are "good"

4

PAVLIDIS AND ALI: HIERARCHICAL SYNTACTIC SHAPE ANALYZER

TABLE IIITRUS PARSER

Buffer Contents Action

LL?? reduce 2 & shift 1LSL? reduce 3 & shift 2LSSL reduce 4 & shift 3LSSS reduce 2, relabel & shift 1LSS# reduce 3 & stopLS## reduce 2 & stop

stopstop

_________________ -------------------_____

ILL

Fig. 1. State transition diagram of the automaton of Table III.

a, 2

L L L ~~~IREDUCEO(I)0~~~~~~~~~~~~~~

[REDUCE IBACKSPACE 2

Fig. 2. State transition diagram of the automaton of Table IV.

TABLE IVTRUS PARSER

approximations of quadratic arcs or straight lines. They are

not really part of the preprocessor since they are called atdifferent instances by the parser.

IV. THE PARSER FOR TRUS

We describe first the parser for TRUS which uses the LINEdetector presented in the previous section. The parser is a

finite automaton with a buffer of size, at most, four and usinga "shift-reduce" parsing [241. The bound on the buffer sizeis justified in cases where a preprocessing of the boundary hasbeen performed. In our model this is implemented by restric-tions on the production of BREAK. The automaton alwayslooks at the complete contents of the buffer. We assume thata decision can be made whether a line is short (S) or long (L),depending not only on the current line but also on the con-

tents of the buffer. The need to examine the latter may sug-

gest that we actually have a context-sensitive parser, which isnot the case because of the limit on its size. We could haveeasily constructed a fmite automaton in the strict sense of theterm to do the same tasks, but it would have a much largernumber of states. Table III and Fig. 1 describe this automa-ton. The operation "shift k" means obtain the next k lines as

the return of the line detector operating on the boundary."Reduce k" means emptying the first k elements of the bufferand mapping them into a TRUS. The "relabel" operationconsists of labeling the remaining contents of the buffer by L.The symbol # stands for end of input, while ? denotes an

empty portion of the buffer. Configurations involving thosesymbols occur only at the beginning and the end of theparsing.A somewhat different configuration, which is, however,

equivalent to the above, is shown in Table IV and Fig. 2. Ituses states explicitly and the operation "shift" has only one

argument, while the operation "reduce" applies to all thecontents of the buffer. Operation "reduce (1)" applies onlyto the first two entries of the buffer.This automaton can be implemented by the algorithm shown

in Table V, where a "shift" is replaced by a recursive call tothe algorithm itself. This calls the line detector and, depend-ing on the state, examines the length of its retum. The func-

TABLE VPARSER FOR TRUS

llyt0: A subset of the array V (chosen by the main algorithbo). two applicaicaaependent parameters: N6GSTK, BIAS. The parameter COLANG; a starting index 1and an initial "state,'. (The latter is 0 when the procedure is first called bythe main algorithm).

Qutjptt: Labeling of the vertices.

Steps:

1. Call LINE detector. If no LlNE is lound, then re2urq. Else set I equal tothe next index after the last one returned by the LINtE detector.3Switch: Perform the following steps for the respective values of "state'."state": - 0 - 1 - 2 - 3step: - 2 - 3 - N - 9

2. ("state, = 0 ) Set "statea=1; call TRUS; then return.

3. (state = 1. This seans that two LINEs have been detected): If the secondLINE is smaller than the first and its lenath is less then the minimum of"toll" and NEGSTK-1xmark"iIAS then do step 4. Else do step 5.

4. (Treat LINE as BREAK) Set "state"= 2; call THUS; then rettrq.5. A THUS has been found. Verify sesantics by calline "sflusti'; set ',state" 1

and call ThUS; then ret3rn.

n. ("state" = 2. A third LlNE has been found separated from the tirst by aBREAK). If the third LlNE is shorter than the first, and its length is lessthan "'toll" and the distance between the end of the first LINE ana the be-ginning of the second is less than the miniunm of "toll" andEGS1K-smark"BIAS do step 7. Else do step d.

7. (New LINE is treated as a BREAK). Set "state" = 3; call THiUS; then re"urn.

6. A THUS has been found. Verify semantics oy calling stilush; set "state" = 1and call THUS; then return.

9. ( "state" = 3; Four LINES have been found with the two middle ones con-sidered as BREAKs.) If the fourth LINE exceeds in length the previous twothen do step 10. Else do step 11.

10. A TRUS has seen found. Verify semantics by calling "sflush"'; set ,s"ate" = 1and call TRUS; then retrqn.

11. A change of scale seems to have occured. It is possible that "he first andsecond lines form a TaUS while the third and fourth are part of anothernonterminal. Verify semantics by calling "fslush"; Set I equal to oneafter the last index of the second LINE. Set "s"ate" =Si and call THUS;then return.

tions of "reduce" are performed by the subprogram 'sflush'which also performs a number of semantic checks. In particu-lar, if the TRUS found is "small," it sets 'reparse' = 1. Thisvariable is used by the main algorithm (see next section).The constant NEGSTK is an upper bound on what is consid-

ered to be a BREAK. The value 13/60 was chosen for it. BIASmeasures the steps by which the tolerance for BREAK is ad-justed. The value 1 seemed appropriate for it. As we pointedout earlier, such choices do not seem critical for the method.This algorithm detects only pairs of lines which form a sig-

nificant angle. The 'sflush' procedure incorporates parts whichexamine semantic information. In particular, depending on

the size of the angle formed by the two lines, the TRUS may

be further specified as a CORNER or a STROKE.

V. THE MAIN PARSERIf we had complete confidence that the approximation of

the boundary was an accurate reflection of the shape of theobject and if we were operating in a noise-free environment,

state action new state

0 shift 1I shift lala If L reduce 1

If S shift 2

2 shif t 2a2a It L reduce 1

If S shift 3

3 shift 3a3a It L reduce 1

If S reduce(1) 4

4 backspace by 2 1

_

Ii

5

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-1, NO. 1, JANUARY 1979

(a) (b)

----------+---------hf hc hr

.----------------+.-n f tnc nr

mf mc mr.--------- +.--------f t c lr

--------------------

(c)

Fig. 3. Notations used for the output of the parser. (a) Principaldirections. An arc is labeled by the direction closest to its orientedbisectrix. (b) Definition of the orientation of arcs and their bisec-trices. (c) Location code for arcs with respect to the object whoseboundary they form. For a closed contour its extrema in the x andy directions are found and the rectangle defined by them is divided in12 parts as shown in the figure. An arc is labeled by the symbolsof the small rectangle where its midpoint lies.

then the parsing of the boundary could be performed by analgorithm implementing a finite automaton which examinesthe boundary sequentially. (The automaton would be a com-bination of those used by the LINE and QUAD detectors andthe parser for TRUS.) Thus shape could be described, ineffect, by regular expressions. Unfortunately, things are notquite as simple and one has to resort to stochastic automata.However, because of the preprocessing and the hierarchicalorganization of our approach in general, we have to use onlystochastic finite automata rather than higher order stochasticparsers [1]. Furthermore, we simulate a stochastic parserby a set of deterministic ones operating in the following way.The contents of C are examined by each one of them and, ifaccepted, a level of confidence is assigned to the result. Thefinal decision about the proper parse is made on the basis ofa maximum likelihood criterion. This is similar to earlierapproaches [25], [26] where stochastic grammars havebeen used.We proceed now with the description of an algorithm imple-

menting this approach. First we point out that the differentparsers have basically similar structures, and they differ only inthe value of certain parameters. Thus we have a single pro-gram, executed a number of times for different parametervalues. As we mentioned in Section III, the parsing algorithmdeals only with substrings of the input consisting of successivevertices of the same sign and contained in a stack C which isthen scanned a number of times with the following goals.First, a check is made as to whether pairs of vertices which arefar apart along the boundary are geometrically close. Thismight mean that this part of the boundary has come from a"broken loop." An altemative geometrical configurationhaving a closed loop is produced and both V-strings are parsed.First TRUSS with high confidence levels are detected and thecorresponding vertices are removed from further considera-tion. A second pass is used to detect QUAD s and then a thirdto detect TRUSS with lower confidence levels. If any QUADShave been found, the one with the lowest confidence level is

TABLE VIBOUNDARY PARSER

onaS: Array V- Various parameters depending on the application. (See notesbw) A starting index determined by the preprocessor.

QOUSut0: A description of the boundary in terms of QUADS, STHOKES, COANEkHS etc.

1. Set "mask" to the sign of the current angle (initially a convex one).

2. Form a stack C of indices of vertices of the same sign as "mask". Do notinclude an index if the corresponding side has length less than NEGLENG.

3. If "reparse" is less than 9, check if the vectors placed in the stack C seesto nave come from a broken loop. This is determined by a heuristic tech-nique. If they do set "reparse"=tO.

4..Initialization: "mark'=1.

5. Parse according to the rule for ThUS using CULANG=O; Since "mark" = 1 tnisalso imposes tight limits on bhiAK.

6. Apply the QUAD detector on the vertices in C which have not been already la-beled as belonging to TRUS. (i.e. mark a series of sides and vertices asrepresenting a quadratic arc according to the rules described in the previ-ous section).

7. "mark"=0 (this relaxes the bounds on BiEAK).

d. Set "comp' = 0.

9. Parse the sides in C not already labeled by QUAD according to the rulefor THUS using COLANG = ADDANG + NEGANG.

10. If no TRUS was found: Aepeat parse according to the rule for THUStightening the condition for colinearity, in particular setting COLANG= NiGANG.

11. If "comp"=O and if any QuADs have been found in C and if the confidencelevel of any of them is less than CONF, eliminate the QUAD with thelowest confidence level, set "comp"=1 and go to step 9. Otherwise goto step 13.

12. lf "comp = 1 compare the confidence level of the two parses and keepthe result. of the parsing which yields the higher values.

13. If all the vectors have been examined, rearrange the tokens so that thestarting point is at the upper left corner and syt"t the string.14.Tnen: If reparse >0

close gap or eliminate stroke as needed, set reparse=O, and go to step1.

TABLE VIIMEANING OF SHAPE DESCRIPTORS

Cnar Possiole Values uxplanation

1 ,- his character describes whether tie arc is convex(+) orconcave( -).

a ,<, Tnis character describes whether the sezment is classi-fied as a stroke(l), a corner(< ), or a quadratic arc( ).

3 0-7 This describes the orien'ation of "he oisectrix of asegment. See figures 3a and 3b.

4 p,q,r,s,t,u,N Inis is 'he measure of the external ancle between thefirs' and last side of an are. They are quantized in in-tervals of 45 degrees, except V which stands for anyexternal angle greater than 270 degrees.

5 h,n,m,l This indicates the vertical location of the arp in termsof quartiles of a frame (see fig. 3c).. TIlassunes thedefinition of a frame for the object. If it is the onlyone in the picture and covers mosm of its area, thenthis might be the picture frame. Utherwise tne f'rame mayconsism of a rectantle circumscribed to the objec'. Thiseasily found by the proprocessor discussed in section 2.

6 f,c g The frame is divided horizontally into three equal re-gions: left(f), centre(c), right(g). See fiq. 3c.

7 L.M,S,N This indicates the leng'h of the arc as a function oftotal parameter and average segment leneth of the ob-ject. The notation used is Large(L), riddle(M),Small(S), and Negligible(N).

eliminated (provided that level is less than a threshold) and thethird pass is repeated. The confidence levels of the two parsesare then compared and the one with the highest is kept. Addi-tional parses are performed if there is an indication of abroken loop or very small TRUSS have been detected. The onewith the highest confidence level is then chosen as the fimalone. Table VI contains a detailed description of the algorithm.The following notations have been used:

NEGLENG: If a side has size less than that it is considered asnoise;

NEGANG, ADDANG: Angle tolerances while testing for co-linearity.

The output of this parser is a compact representation of theobject as a sequence of descriptors, each consisting of eightcharacters. The meaning of the characters is shown in TableVII and Fig. 3. It can be seen that a descriptor gives a fairlycomplete description of the arc. For example, the descriptor +<3rhfL represents a large, sharp, convex corner facing NWlocated at the top left of the object. Fig. 4 shows a typical ex-ample of an encoding. In addition to these descriptors, our

6

PAVLIDIS AND ALI: HIERARCHICAL SYNTACTIC SHAPE ANALYZER

Fig. 4. Example ofencoding of the boundary ofa handwritten numeral.

TABLE VIIIENCODING OF HANDWRITTEN NUMERALS 5, 6, AND 7

5/5/1/ 0/14: +<3qhcS9 +*OshgS9 -'OsncS3 + 7smcM9 +'4slfS9 -'4smcS9 +<5( fS515/5/1/ 0/11: +<4snfM9 +,OshgM9 -<OrnfS3 +^7tlcM9 + 4slfS9 -!4smcS925/5/1/ 0/14: +<3qhfS9 +tOshgh9 -Os3nfS9 +.7ulc9 *,3smfS3 -,4smcS9 +<5rmfS935/5/1/ 0/13: +<3qhcl9 +iOshgS9 - OsneM9 +.IOslgI1 +j14s1fS9 -4slcS9 .(4ruf1055/5/1/ 0/14: +<3qhcM9 +10shgh9 -^OsncS9 + OslcS9 +,4slSf9 -'4smcS9 +<5mrfS965/5/1/ 0/15: +<3qhcM9 +,OshgS9 -<7rhcM9 +^7rlcS9 +13s3lS2 - 4mfS9 +<5mrfS9d6/5/1/ 0/12: +<lrhcS3 -<lrhcS9 +|OshgM9 -<7qncM9 + bslfM9 +<3rmfS3-, 33:3fs9 +<4rnfSg91/5/1/ 0/13: +<3rhfS3 -<2phfS9 +uOshgM9 -<7rncS9 +^7slcM9 +.3smfS9- 4smcS9 +<5onfS9105/5/1/ 0/14: +<3qhfS9 +3Oshg639 -<7rhcS9 +^7slcM9 +j3smfS2 -14smcM6 +<4rnfS9115/5/1/ 0/13: +<3qhfh9 +.OshgM9 -lOrnfS9 +<7rlg89 +41slfS9 -:4smcS9 +<5m4fS9

6/b/2/ 0/10: + lshg9 -<lrmcM9 + 7VlcL916/6/2/ 0/11: + lshgM9 -, lsmfM9 + 6VmcL926/b/2/ 0/ 6: + 2shcM9 -<lrmcM9 +77VlcL956/6/2/ 0/ 8: + 1shRM9 -<OnncM9 + 6VlcL966/b/2/ 0/10: + lshc3 9 -, lslfM9 +.7VlcL97o/6/21 0/ 9: + 2shgM9 -<1rncm3 + 7VlcL966/6/1/ 0/11: +123hgM9 -<lrmcI.M3 +<1mgS9 +<7rlgM9 +<5rlfM996/6/2/ 0/ 9: + lshcM9 -tlsmcS3 + mcL9106/6/2/ 0/10: + lshch2 -,:lsmfM9 + 7VmcL9126/b/1/ 0/10: +,lshgS9 -<lrcM19 + VrncLg

7/7/1/ 0/ d: +j4shfM9 +<lrhgL9 + 531lf19 -<5rhcM917/7/1/ 0/ 7: +,5shfM9 +<lrhgS9 + 6s1fL9 - 5shRM927/7/1/ 0/ 9: +<3rhfM9 +<lqhgM9 + 6slgL9 -16shct9 +16sncS937/7/1/ 0/11: +<3rhfS9 +<lrhgM9 +I6s1cM9 -,5shcM9 +,6shfN957/7/1/ 0/ 7: +.4ShfMS9 +<lrhgL9 +,5slfL6 -<5rhcM957/7/1/ 0/12: +<3qhfS9 + .iM9+ 5slfM9 I6 shcM? +6snf6967/7/1/ 0/ 8: +|5shfS9 +<lrhgM9 +.5slfL9 -:,5shgM9d7/7/l/ 0/ : +,4shfM9 +<lrh_L9 +16slcL9 -<5rhcM997/7/1/ 0/ Z: +4shfM9 +<lrhgL9 +'5slfL9 -<5rhcM9107/7/1/ 0/ 6: +,4shfM9 +<lrhgL9 +,6slcL9 -<5rhgM9

program outputs some information which is useful for docu-mentation and reference purposes. This consists of five num-bers separated by slashes (/). The first two are identificationlabels, the third is the number of contours for that particularobject (i.e., the number of holes plus one), the fourth is thevalue of the variable 'reparse,' and the last one the number ofsegments of the polygonal approximation.An illustration of the usefullness of these results is offered

by their application in the recognition of handwritten nu-merals. The majority of the strings produced by it from vari-ous examples of a single numeral are virtually identical. Fur-thermore, the strings corresponded to our intuitive descriptionof the numeral; therefore, it is relatively easy to characterizeeach class in terms of regular expressions, i.e., strings whichcan be recognized by a finite automaton. This is demonstratedin Table VIII, where strings representing the outside contoursof ten samples from each of the numerals "5", "6," and "7"are shown. A handwritten numeral classifier based on thisalgorithm has been described in detail elsewhere [15]. Therecognition rates achieved were significantly higher than thoseobtained by other techniques on the same data base [13],[27]. In particular, we were able to achieve an error rate of1.46 percent and a rejection rate of 1.04 percent on thedesign set of 480 characters. We checked our results on atesting set of 840 digits and had an error rate of 3.57 percentand rejection rate of 3.45 percent. Thus we had an overallerror plus rejection rate of 5.37 percent on the total set of1320 characters.Tables IX and X show examples of encodings corresponding

to the contours of the printed wiring board of Fig. 5 and the

TABLE IXENCODING OF CONTOURS OF PRINTED WIRING BOARDS

1/0/1/ 0/1l: + 2uhcL -<7plcS +<7qlcS +<5rlfS -<4pmfS1/0/2/ 0/ 9: -^lVmcL2/0/3/ 0/45: +!2shgL +*I6slgH -,5slcS +.4ulfS -<3mgS -<5qngS

-<6ancN + '5snfS -<2qncN -<3qngS2/0/3/ 0/ 9: -<lqlfM -<3qlgH -^5thcL2/0/3/ 0/ 9: +<OqnfN - 4VmcL3/0/2/ 0/26: + 2VhgS -57qhgM +.6slfM -<4phcS1/0/2/ / 6: -<7qhfM - 3VmcL/0/1/ 0/26: +123hfM (<OpnPM +*6slcM -<4qngS

5/0/2/ 0/45: +,1shcS + OphcS -<OpncS +16slfS-<l q9S +.14s1fl -<3qlfS - 4qmcS+<5qnfN +<3qnfN -<5rnmS +14snnf' -<3qn'S -<5qhfS + 4shfN -<3qhf-S

5/0/2/ 0/ 6: - 2VncL6/0/2/ 0/30: +*OuhgS -<7QbcS +<7qncS -'0rncN +<1qncS +<7qmcS

-!UswcN +<lqmcS + tslfL + 3qhfjo/0/2/ OX d: - bVnoL7/0/2/ 0/32: +^4VhcS -<lphcS +^OrngM -<7plfS +!6slfS -^5rhgS7/0/2/ 0/ 9: -^6VmcLo/0/1/ 0/12: + 2rhcL +.77lPS - 6smcl4 +<7olcS +<5rlfM9/0/4/ 0/39: +'4uhfS + lqhgS -<lqngS +!0ing:A -<7qngS +'2slqM

-<5rngIl +^4VnfS -<lqncN +<lrncN -02sncN +<3qncN -<3rngS - bqhcS9/0/4/ 0/ 9: +<4qhcS -<5rftjS - 2VmoL9/0/4/ 0/ 4: -j4sngL -'OshfL9/0/4/ 0/ o: - 2VncL10/0/1/ 0/45: +j2snfS +sul,sL + 4plfS11/0/2/ 0/15: + 7V,;nL11/0/2/ 0/ 6: -^6VncL12/0/2/ 0/13: +^OVmcL12/0/2/ 0/10: -^4VmcL13/0/2/ 0/13: +<3qhfh +7VMcL13/0/2/0/ 6: -^2VmcL14/0/2/ 0/15: +*OVncL -<4pnfN14/0/2/ 0/ 7: -^6VncL15/0/2/ 0/12: +<3qhfM +^7VncL15/0/2/ 0/ 9: +*7phcS - 3VmcL16/0/2/ 0/14: + OVncL16/0/2/ 0/11: +<OmcS -<OmlfS -S5VncLI17/0/2/ 0/13: +^OVncL17/0/2/ 0/ d: -^6VmcLlo/0/2/ 0/12: +^OVncL18/0/2/ 0/ o: -^2VmcL19/0/2/ 0/14: 4VmcL19/0/2/ 0/ 6: -^6VmcL20/0/2/ 0/19: +^5VlfM -<2qmcM +<lrhgS +<7qngM -<7qlcM20/0/2/ 0/ 9: - lVmcL21/0/2/ 0/11: +<3qhflM +.7VcL.21/0/2/ 0/ 9: +5ophcS - lumcL -<5rhgS22/0/2/ 0/14: + 2VncL +<6qlfM22/0/2/ 0/0: -^2VmcL23/0/3/ 0/23: +<2rocl -ClqncS + 7ulcMi +<3rmfS - 4uneS +<5rmfS +<3qh6S-(4rhfN +|3sfrS -<2qhfN23/0/3/ 0/ 3: -j0snfL -:j4slPL23/0/3/ 0/ 4: - OsnfL -,4sngL24/0/2/ 0/13: + OVncL24/0/2/ 0/ o: - oVncL25/0/2/ 0/14: 4VmcL -<OqbhS25/0/2/ 0/ 6: -^5ViccL

2X3S21)

2

17@:

15 (

13)

0

025

22

00

019

( 14

012

Fig. 5. Contours of a printed wiring board whose descriptions are givenin Table IX. Note that the size notations in the table (L, M, S, N) arerelative with respect to the size of the whole contour.

blood cell contours of Fig. 6. Encodings of wiring boardscan be used for two purposes: the first is description of aboard which serves as a model for manufacturing [J. F. Jarvis,personnal communication]; the second is detection of defects[8], [28], [29]. An inspection of Fig. 5 and Table IX revealsthat defects manifested as protrusions or intrusions can bedetected as strokes of "negligible" length and, in particular,by the regular expression 'I N" where" "stands for anycharacter (see also [16] ). Such expressions occur only in therepresentations of objects 5, 6, and 9. Note also that holesare identified by a negative sign since they are indeed concaveboundaries. This is by no means a complete diagnostic system,

7

IEEE TRANSACTIONS ON PATTERN ANALYSIS AND MACHINE INTELLIGENCE, VOL. PAMI-1, NO. 1, JANUARY 1979

TABLE XENCODING OF WHITE BLOOD CELL BOUNDARIES

(Each boundary can be either from a cytoplasm or a nucleus)

1/o/1/ 0/10:+ 1VncL-55lfN2/0/1/ 0/17:+.2shfM- 2tmcM+ luhgS-<OqngS+ 7sigM-<5pmfS+<tiqmfS/0/1/ 0/13:+. uVmcL/1/021 v/ d:+_lungL-<6plcS+<5rlfM4/0/2/ 0/12:+.3uh fM-<1rmcS+<1qmgS-<2rlgS+.2smgS+<OqlgS+^6slgM-<5qtfS5/0/1/ 0/13:+ 4VmcL6/0/2/ 0/ o:+^bVmcLb/0/2/ 0/12:+.3VnfL- lsmcM+'OtmgM1/0/1/ 0/15:+ bVmcL-<2qhcN0/0/2/ 0/13:+J3snfS-<2omcM+ lungM-<6pmcS+<6qlcS-<6qlfS+<5rlfSd/0/2/ 0/ o:+ 4VmcL9/0/1/ 0/12:+ OVmcL10/0/2/ O/ 6:+,3shcN+<1qhgS+^bVmcL-<IrhgS10/0/2/ 0/15:+<2qhfS-<2qhcS+'Ouhgh-<6qhcS-<OrnfSn6bifM-<4pnf'S.<4qhfS11/0/1/ 0/14:+ 3rnfM. 7VmaL12/0/1/ 0/14:+.3uhfl- 2tmclh^0V1mSL-<5qmfS42/0/1/ 0/10:+ 4VmcL40/0/1/ 0/10 :UOVncL44/0/2/ 0/11:.+3nrcL44/0/2/ 0/ 5:+ uVacL

4,O/11 :+3 vmc L4u/0/1/ 0/11:+ OVmcL47/0/1/ 0/ 9:+.4VmcL46/0/1/ 0/ 9:+.OVncL49/0/1/ 0/ 7 :+^4VncL50/0/2/ 0/ 9:+ 3VncL50/0/2/ v/ 4:+.j2stcL+.kl1fL51/0/1/ 0/ 9:+ 3VncL52/0/1/ v/1o:.+7Vng4:- .bshcS-<1qmfS+-6VmfM53/0/2/ 0/ 9:+ 4VncL53/0/2/ O/ d:+.3VncL54/0/1/ 0)/17:+-2VhcM- OsngN+<lqneN. 5VlcL-b4sneS55/0/1/ 0/16:+ 4uum4M-<2qhcS+ 0amgM-<6rncS

3

9

5

II

oC49

52

5'

53 54 55

Fig. 6. Contours of white blood cells whose descriptions are given inTable X. Contours 42-48 are not shown since they are almostidentical to 49.

but it shows the power of the approach. Without any addi-tional effort, the same software which was used as a basis forrecognition of handwritten numerals has produced a detectorfor certain faults of printed wiring boards.

Similarly, a comparison of Fig. 6 and Table X shows that a

faithful and compact description of the shape of the bloodcells has been obtained. Convex contours are given by theregular expression "+ ^ * V L," while nuclei which are notconvex include the expression "- [I<"] [LMS] "'. Notethat small concavities due to noise are either ignored com-

pletely because of the preprocessing or found having negligiblelength [N] . In this example many nuclei have been "broken"due to overthresholding. In this case, the number of com-

ponents is an important shape descriptor.

VI. DISCUSSION OF RESULTS

We believe that we have shown the feasibility of a hierarchi-cal approach to shape description. Thus it is possible to use

common building blocks for diverse applications. The firstmajor component is the curve-fitting algorithm which achieves

the noise elimination and data reduction. We have used poly-gonal approximations by the split-and-merge algorithm be-cause they can be computed quite fast and they also produceapproximations in agreement with human intuition. One canexpect better results by using higher order approximations,either by quadratics [30], [311 or splines with variable knots[32]. However, there are no known algorithms which canperform such approximations both rapidly and with numericalstability. A possible solution to this problem might be achievedby the following strategy. First, a polygonal approximation iscarried out and its quality is evaluated locally, not only by theerror norm but also by other criteria of local fit. Then certainparts of it might be replaced by higher order polynomials. Inone approach, this is done through the use of fuzzy character-istic functions [33]. However, such functions seem to be toosensitive to noise. Another approach is to use some of thesimpler syntactic descriptors, like LINE and QUAD, at an ear-lier level and attempt to verify their conclusions by directcurve fitting.The syntactic analysis used is of a rather simple type, and

this suggests that one might be able to handle a large class ofpattern-recognition problems without using anything morepowerful than stochastic finite automata; therefore, notonly will the processing be quite fast but also the grammaticalinference problem [34] might be simplified. It seems that thelatter problem is the major remaining obstacle in the wide-spread use of syntactic techniques. The corresponding prob-lem for techniques based on scalar measurements (e.g.,Fourier descriptors [27]) is that of determining separatinghyperplanes. There exist many fast and simple solutions tothe latter [35] , while this is certainly not the case with gram-matical inference, especially if one is interested not in anygrammar, but in one with certain minimum properties. Forexample, the automaton with the minimum number ofstates accepting a given set of strings. It may tum out thatthe latter problem is NP-complete [36], which would implythat algorithms for its solution would require exponentialtime. Therefore, it is important to encode the input in asshort strings as possible. The approach described in this paperproduces much shorter strings than direct chain encodings [1 ] .On the other hand, its output has the well-defined quantiza-tion of the chain code; therefore, it shares its advantages.The method is not without its limitations. In particular, it

shares with other contour-tracing techniques the problemthat points which are near each other in the plane may bequite far apart in the boundary (see [11, fig. 7.12]). Simi-larly, interior contours are examined separately from theexterior, and this results in some loss of information. How-ever, techniques which overcome these two problems requiretime in proportion to the area, or the square of the length ofthe contour and, therefore, tend to be much slower. For areview of such methods see [11] .

ACKNOWLEDGMENT

The authors wish to thank Dr. J. M. S. Prewitt of the Na-tional Institutes of Health for the blood cell samples, and Dr.J. F. Jarvis of Bell Telephone Laboratories for the circuitboard samples used in the illustrations of the methodologydescribed in this paper.

8

PAVLIDIS AND ALI: HIERARCHICAL SYNTACTIC SHAPE ANALYZER

REFERENCES

[1] K. S. Fu, Syntactic Methods in Pattern Recognition. New York:Academic, 1974.

[2] K. S. Fu, Ed., Syntactic Pattern Recognition, Applications. NewYork: Springer, 1977.

[3] S. L. Horowitz, "A general peak detection algorithm with appli-cations in the computer analysis of electrocardiograms," Com-mun. Ass. Comput. Mach., vol. 18, pp. 281-285, May 1975.

(41 G. C. Stockham, L. N. Kanal, and M. C. Kyle, "Structural patternrecognition of carotid pulse waves using a general waveform pars-ing system," Commun. Ass. Comput. Mach., vol. 19, pp. 688-695, 1976.

[5] H. Y. Feng and T. Pavlidis, "Decomposition of polygons intosimpler components: Feature extraction for syntactic patternrecognition," IEEE Trans. Comput., vol. C-24, pp. 636-650,June 1975.

[6] B. Moayer and K. S. Fu, "A syntactic approach to fingerprintpattern recognition," Pattern Recognition, vol. 7, pp. 1-23,1975.

[7] -, "A tree system approach for fingerprint pattern recogni-tion," IEEE Trans. Comput., vol. C-25, pp. 262-274, 1976.

[81 J. F. Jarvis, "Feature recognition in line drawings using regularexpressions," in Proc. 3rd Joint Int. Pattern Recognition Conf.,(Coronado, CA), Nov. 8-1 1, 1976, pp. 189-192.

[9] T. Pavlidis, "A review of algorithms for shape analysis," Comput.Graphics Image Processing, vol. 7, pp. 243-258, 1978.

[10] -, Structural Pattern Recognition, New York: Springer, 1977.[11] -, "Syntactic pattern recognition on the basis of functional

approximation," in Pattern Recognition and Artificial Intelli-gence, C. H. Chen, Ed. New York: Academic, 1976, pp. 389-398.

[12] T. Pavlidis and S. L. Horowitz, "Segmentation of plane curves,"IEEE Trans. Comput., vol. C-23, pp. 860-870, Aug. 1974.

[13] T. Pavlidis and F. Ali, "Computer recognition of handwrittennumerals by polygonal approximations," IEEE Trans. Syst.,Man, Cybern., vol. SMC-5, pp. 610-614, Nov. 1975.

[141 K. Thomson and D. M. Richie, UNIX Programmer's Mannual,Bell Telephone Labs., Tech. Rep. 6th ed., May 1975.

[15] F. Ali and T. Pavlidis, "Syntactic recognition of handwrittennumerals," IEEE Trans. Syst., Man, Cybern., vol. SMC-7 pp.

537-541, July 1977.[161 T. Pavlidis, 'The application of a general pattern recognition

system to the automatic inspection and description of printedwiring boards," in Proc. 7th Annu. Symp. Automatic ImageryPattern Recognition (College Park, MD), May 23-24, 1977,pp. 147-151.

[17] P. H. Swain and K. S. Fu, "Stochastic programmed grammars

for syntactic pattern recognition," Pattern Recognition, vol. 4,pp. 83-100, 1972.

[18] H. C. Lee and K. S. Fu, "A stochastic syntax analysis procedureand its application to pattern classification," IEEE Trans. Com-put., vol. C-21, pp. 660-666, 1972.

[19] R. S. Ledley, "High speed automatic analysis of biomedical pic-tures," Science, vol. 146, pp. 216-223, Oct. 1964.

[20] A. Rosenfeld and E. Johnson, "Shape synthesis, I," Univ. ofMaryland, Tech. Rep., Sept. 1970.

[21] A. Rosenfeld and J. S. Weszka, "Picture recognition and scene

analysis," Univ. of Maryland. Tech. Rep. TR-407, Sept. 1975.[22] L. D. Harmon, "Automatic recognition of print and script,"

Proc. IEEE, vol. 60, pp. 1165-1176, 1972.[23] P. Lemkin, "A literature survey of the technological basis for

automated cytology," Univ. of Maryland, Tech. Rep. TR-386,June 1975.

[241 A. V. Aho and J. D. Ullman, The Theory ofParsing, Translation,and Compiling, vol. I; Parsing. Englewood Cliffs, NJ: Prentice-Hall, 1972.

[25] L. W. Fung and K. S. Fu, "Stochastic syntacting decoding forpattern classification," IEEE Trans. Comput., vol. C-24, pp. 662-667, 1975.

[26] , "Maximum-likelihood syntactic decoding," IEEE Trans.Inform. Theory, vol. IT-21, pp. 423-430, 1975.

[27] E. Persoon and K. S. Fu, "Shape discrimination using Fourierdescriptors," IEEE Trans. Syst., Man, Cybern., vol. SMC-7,pp. 170-179, 1977.

[ 281 C. Harlow, "Image analysis and graphs," Comput. GraphicsImage Processing, vol. 2, pp. 60-82, 1973.

[29] M. Ejiri, T. Uno, M. Mese, and S. Ikeda, "A process for detectingdefects in complicated patterns," Comput. Graphics Image Pro-cessing, vol. 2, pp. 326-339, 1973.

[301 L. S. Davis, "Understanding shape I: Angles and sides," IEEETrans. Comput., vol. C-26, pp. 297-303, 1977.

[311 D. B. Cooper and N. Yalabik, "On the cost of approximatingand recognizing a noise perturbed straight line or a quadraticcurve segment in the plane," IEEE Trans. Comput., vol. C-25,pp. 1020-1032, 1976.

[321 D. E. McClure, "Nonlinear segmented function approximationanalysis of line patterns," Quart. Appl. Math., vol. 33, pp. 1-37,Apr. 1975.

[33] L. P. Chang and T. Pavlidis, "Functional approximation withvariable-knot variable-degree splines," Comput. Sci. Lab., Prince-ton Univ., Tech. Rep. 201, Feb. 1976.

[34] K. S. Fu and T. L. Booth, "Grammatical inference-Part I: Intro-duction," IEEE Trans. Syst., Man, Cybern., vol. SMC-5, pp. 95-111, 1975.-, "Grammatical inference-Part II: Survey," ibid., vol. SMC-5,pp. 409-423, 1975.

[351 R. 0. Duda and P. E. Hart, Pattern Classification and SceneAnalysis. New York: Wiley, 1973.

[36] A. V. Aho, J. E. Hopcroft, and J. D. Ullman, The Design andAnalysis of Computer Algorithms. Reading, MA: Addison-Wesley, 1974.

Theodosios Pavlidis (S'62-M'64-SM'77) wasbor in Salonica, Greece, on September 8, 1934.

.........He received the Diploma in Mechanical andElectrical Engineering from the National Tech-nical University of Athens, Greece, in 1957,and the M.S. and Ph.D. degrees in electrical en-gin eerig from the University of California atBerkeley, in 1962 and 1964, respectively.

Since 1964 he has been at Princeton Univer-~' sityl, Princeton, NJ, where is a Professor of

Electrical Engineering and Computer Science.During the 1978-1979 academic year he is a Visiting Professor ofElectrical Engineering and Computer Science at the University ofCalifornia at Berkeley. He has been a consultant to Frankford Arsenal,ARPA, and RCA. His research interests include pattern analysis, pic-ture processing, systems theory, and approximation theory. He is theauthor of two books, Biological Oscillators: Their Mathematical Analy-sis (Academic Press, 1973) and StructuralPattern Recognition (Springer-Verlag, 1977), and over 100 technical papers.

Dr. Pavlidis is a member of ACM and Sigma Xi. He is a member ofthe Editorial Committee of the IEEE TRANSACTIONS ON PATTERN ANALYSISAND MACHINE INTELLIGENCE and an Associate Editor of the Bulletin ofMathematical Biology, Computer Graphics and Image Processing, andPattern Recognition. He is a Co-Guest Editor of a Special Issue on PatternRecognition and Artificial Intelligence of the IEEE TRANSACTIONS ONPATTERN ANALYSIS AND MACHINE INTELLIGENCE. He was the Chairmanof the 1977 Symposium on Adaptive Processes, the program Cochair-man of the 1978 Workshop on Pattern Recognition and ArtificialIntelligence, and he is the General Chairman of the Fifth InternationalJoint Conference on Pattern Recognition.

j hM: Farhat Ali was born in Hyderabad, Pakistan, onSeptember 5, 1954. He received teBSEdegree in electrical engineering and computerscience in 1977 from Princeton University,Princeton, NJ. He is currently working towardsthe M.B.A. degree at Harvard Business School,Boston, MA.Mr. Ali is a member of Sigma Xi, Tau Beta

E .aaD Pi, Eta Kappa Nu., and Phi Beta Kappa.