APPARATUS FOR READING HANDWRITING

Abstract: Apparatus for reading handwriting including apparatus (20) for sensing features of handwriting of an individual which features are highly characteristic of the individual but which also contain information relating to symbols being written and apparatus, which is configured for the individual, for providing a non-individual dependent output (26) indicating the symbols being written in response to the sensed features.

Description: APPARATUS FOR READING HANDWRITING FIELD OF THE INVENTION The present invention relates to computer input devices generally and more particularly to handwriting responsive computer input devices. BACKGROUND OF THE INVENTION There exists a significant amount of activity in the field of on-line handwriting recognition. The prior art current to 1990 is reviewed in "The State of the Art in On-Line Handwriting Recognition" by Charles C. Tap.pert et al , IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 12, No. 8, August, 1990- Generally speaking, on-line handwriting analysis is currently employed for two distinct applications: identity verification and input of handwritten letters and numbers into a computer. These two applications have sharply contrasting operational requirements and goals. Handwriting analysis for identity verification senses features of handwriting which are distinct for each individual and thus can be used to unambiguously identify a given individual. In contrast, handwriting analysis for alphanumeric input to a computer seeks to minimize the effect of the very features which are important for identity verification and to concentrate on universal handwriting characteristics which can be associated with given symbols independently of the individual writer. Currently existing and proposed systems providing handwriting analysis for alphanumeric input to a computer are generally geared towards recognition of how a symbol looks rather than how it is created. Accordingly, such systems employ digitizers or graphic tablets. Signature verification systems, on the other hand, attempt to identify biometric characteristics of the writer and employ indications such as pressure and acceleration during writing. U.S. Patent 4,345,239 employs pen acceleration for use in a signature verification system. U.S. Patent 5.054,088 employs both acceleration and pressure data characteristics of handwriting for identity verification. As indicated by the above patents, pen acceleration is employed for signature verification because it is a personal feature, characteristic of each individual. Accordingly, pen acceleration has not been employed for alphanumeric input. U.S. Patent 4,751,741 describes pen-type character recognition apparatus which employs pen pressure data exclusively. SUMMARY OF THE INVENTION The present invention seeks to provide improved handwriting information input apparatus. There is thus provided in accordance with a preferred embodiment of the present invention apparatus for reading handwriting including apparatus for sensing features of handwriting of an individual which features are highly characteristic of the individual but which also contain information relating to symbols being written and apparatus, which is configured for the individual, for providing a non-individual dependent output indicating the symbols being written in response to the sensed features. In accordance with a preferred embodiment of the present invention ,the apparatus for reading handwriting is contained in a hand-held housing. Preferably the apparatus for reading handwriting includes apparatus for wireless communication with a computer to which it inputs symbol data. In accordance with a preferred embodiment of the present invention, the apparatus for reading handwriting does not require a tablet. Additionally in accordance with a preferred embodiment of the invention, the apparatus for reading handwriting communicates with the keyboard input of a computer. Additionally in accordance with a preferred embodiment of the present invention there is provided apparatus for reading handwriting including personalized hand-held apparatus for sensing acceleration during handwriting and providing an output indication of handwriting content in a non-personalized form. Further in accordance with a preferred embodiment of the present invention there is provided apparatus for reading handwriting including wireless hand-held apparatus for sensing handwriting and providing an output indication of the contents thereof. Additionally in accordance with a preferred embodiment of the present invention there is provided apparatus for reading handwriting including personally trainable hand-held apparatus for sensing motion during handwriting and providing an output indication of handwriting content. Further in accordance with a preferred embodiment of the present invention there is provided apparatus for reading handwriting in real time comprising a hand held housing, a motion sensor disposed in the housing, recognizing apparatus disposed within the hosing and receiving signals from said motion sensor for sensing a plurality of handwriting characteristics and symbol recognizing apparatus disposed in said housing receiving the outputs of the plurality of parallel recognizers for providing an indication of a handwritten symbol. Additionally in accordance with a preferred embodiment of the present invention there is provided apparatus for reading handwriting including hand-held apparatus for sensing motion during handwriting and providing an output indication of handwriting content in a form corresponding to that of a conventional keyboard. Further in accordance with a preferred embodiment of the present invention there is provided apparatus for reading handwriting including hand-held apparatus for sensing motion during handwriting and providing an output indication of handwriting content in a RS-232 compatible form. Additionally in accordance with a preferred embodiment of the present invention there is provided audio-visual apparatus including apparatus for providing a human sensible output including information i at least one of audio and visual form and having as an input element hand-held apparatus for sensing motion during handwriting of the type described hereinabove. Examples of such audio-visual apparatus include a video recorder and player, a stereo audio player and a television. Further in accordance with a preferred embodiment of the present invention there is provided portable information storage and retrieval apparatus including a portable computer memory and output device and having as an input element hand-held apparatus for sensing motion during handwriting of the type described hereinabove . Examples of such portable information storage and retrieval apparatus include a digital watch with memory, a computerized diary, a computerized dictionary and electronic telephone book. Additionally in accordance with a preferred embodiment of the present invention there is provided lock apparatus including locking apparatus responsive to a predetermined electronic input and having as an input element hand-held apparatus for sensing motion during handwriting of the type described hereinabove. Examples of such locking apparatus include door locks and vehicle door locks and ignitions. Further in accordance with a preferred embodiment of the present invention there is provided magnetic card activated apparatus including apparatus for reading a magnetic card and having as a verification input element, hand-held apparatus for sensing motion during handwriting of the type described hereinabove . Examples of such magnetic card activated apparatus include automatic teller apparatus and point of sales credit card acceptance units. Various combinations of the above-mentioned structural and functional elements alone or in combination with additional elements, such as, for example, graphical input capabilities, are also within the scope of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS The present invention will be understood and appreciated more fully from the following detailed description, taken in conjunction with the drawings in which: Fig. 1 is a pictorial illustration of a handwriting reading device constructed and operative in accordance with a preferred embodiment of the present invention in an operative environment; Fig. 2 is a simplified illustration of a preferred mechanical structure of the handwriting reading device of the present invention; Fig. 3 s a simplified block diagram illustration of the handwriting reading device of Figs. 2 and 3 ; Fig. 4 is a partially schematic, partially block diagram illustration of part of the apparatus of Fig. 3; Fig. is a block diagram illustration of part of the apparatus of Fig. 4; and Figs. 6A and 6B are simplified flow charts illustrating operation of the handwriting reading device of Figs. 3 ~ 5 during handwriting reading. Fig. 6B illustrates the teaching process and Fig. 6B illustrates the recognition process. DETAILED DESCRIPTION OF A PREFERRED EMBODIMENT It has been found by the present inventor that each writer produces conventional alphanumeric characters from pen strokes selected from a set containing approximately 12 - 14 pen strokes, which set is characteristic of each individual. The present invention employs this realization to provide a personalizable handwriting input device. Appendix A contains a detailed exposition of the finding of the inventor. Reference is now made to Fig. 1, which illustrates a handwriting input device 10 constructed and operative in accordance with a preferred embodiment of the invention in a typical operating environment wherein it communicates by wireless communication with a computer 11, such as a notebook PC having an associated receiver 12, such as a model RB 1023 RF receiver, commercially available from RF Monolithics, Inc. of Dallas, Texas. Receiver 12 may communicate with computer 11 via the RS 232 port thereof or alternatively via the keyboard input thereof. The handwriting input device 10, which is illustrated in greater detail in Fig. 2, may be used on any writing surface or alternatively in the absence of a writing surface and does not require any special pad or writing substrate. Preferably the handwriting input device comprises a housing 13 in the general size and shape of an ordinary pen which is preferably provided with suitable indentations 14 for predetermined finger engagement. Disposed in housing 13 is an ink reservoir and output point assembly 16, which may be constructed and operative in any conventional manner. Alternatively no ink output may be provided. In accordance with a preferred embodiment of the present invention there is disposed in a forward location of the housing 13 an accelerometer 20, preferably operative in- three dimensions. Preferably the accelerometer 20 is located interiorly of indentations 14. A typical accelerometer which meets the size and power requirements of the invention comprises at least two and preferably three mutually orthogonally mounted Model 3031 accelerometers commercially available from EuroSensor of 20 - 24 Kirby Street, London, England. Referring additionally to Fig. 3. it is seen that the output of the accelerometer 20 is supplied via an operational amplifier 24, such as a model LT1179. commercially available from Linear Technology Corporation of Milpitas, California, to a microcontroller 26, such as an Hitachi H8/536 microcontroller including an A/D converter. Microcontroller 26 is operative to extract a plurality of predetermined features of the acceleration sensed by accelerometer 20. It is a particular feature of the present invention that a relatively small number of discrete features derived from sensed acceleration during handwriting has been found to be sufficient to map the alphanumeric symbols of a given individual. It is appreciated that the characteristics of such features vary from individual to individual and accordingly, the microcontroller must be personalized through training in order to select suitable feature characteristics for a given individual. A typical catalog of features extracted by the microcontroller 26 appears in the Tappert et al reference described hereinabove and is hereby incorporated by reference and also appears more explicitly in Appendix B. A preferred listing of software that provides the functionality of the microcontroller 26 appears in Appendix C. The microcontroller 26 provides the functionality of a bank of parallel recognizers 26. The parallel recognizers are operative to recognize 128 different symbols. They may also be operative to recognizers various graphic symbols. The parallel recognizers are also personalized by suitable training which is preferably carried out using the pen 10 and the computer 11 and involves subsequent downloading to the pen 12, so as to associate the various alphanumeric symbols with given acceleration derived features extracted by the microcontroller 26. The microcontroller 26 also provides the functionality of post-processing circuitry and is operative to select the most probable symbol from among those recognized by the bank of parallel recognizer and to encode it in a conventional universal code, such as ASCII, which is not in any way dependent on the personal handwriting characteristics of a given individual and which can be readily accepted by conventional computers. Preferably, the coded symbol output from microcontroller 26 is in a form compatible with or identical to the output conventionally received at the keyboard input of a conventional computer, such as a PC. In accordance with a preferred embodiment of the present invention, the coded output of microcontroller 26 is transmitted to computer 11 in a wireless manner by a wireless transmitter 32, such as a model MB1003, which is also commercially available from RF Monolithics, Inc. and which communicates with receiver 12 (Fig 1) . Alternatively any other suitable IR transmitter or radio transmitter may be utilized. In such a case, the computer 11 is preferably supplied with a corresponding receiver which outputs directly to the keyboard input of the computer or any other suitable input, such as an RS 232 port. Alternatively a non-wireless communication connection may be provided. A suitable battery 33 is provided to power the apparatus located within housing 13. It will be appreciated that the handwriting 1 Θ reading apparatus of the present invention is preferably a hand-held, personalized "pen" which can be carried by the individual for whom it has been personalized and used with any computer having suitable communication facilities. The computer need not be personalized in any way, inasmuch as all of the handwriting recognition hardware and software is resident in the "pen". Reference is now made to Fig. 4 and Fig. 5 which illustrate portions of the apparatus of Figs. 1 - 3 i differing levels of detail. The accelerometer 20, as noted above, preferably comprises three separate accelerometer modules, each including a bridge containing piezoresistive elements outputs via operational amplifier 24 to microcontroller 26 including A/D converter channels 44. As noted above, the microcontroller 26 provides DSP functionality, represented by block 45 which is preferably operative to extract 32 features which are combinations of components of X-acceleration, Y-acceleration and up and down movements of the pen. The output of functional block 4 is supplied to the bank of parallel recognizers 26 which includes a plurality of fuzzy comparators 46, each of which receives from reference feature storage facility 47 reference features for a plurality of alphanumeric symbols in addition to the serial input from DSP circuitry 24 which contains vectors representing the extracted features. The outputs of the fuzzy comparators 46 are supplied to corresponding error accumulators 48. The outputs of the error accumulators 48 are supplied to a fuzzy associative memory 50 which receives threshold inputs from a threshold definer 5 . Threshold definer 52 receives data inputs together with control and timing inputs. It is appreciated that in accordance with a preferred embodiment of the invention, the structure of Figs. 4 and 5 is embodied in software resident in microcontroller 26, as exemplified in Appendix C. Figs. 6A and 6B are simplified flow charts illustrating operation of the DSP block 45 (Fig 4). Fig. 6A illustrates the teaching process and Fig. B illustrates the recognition process. The DSP block operates to perform double integration of X and Y acceleration to obtain not only velocities, but also positions and travel distances. In addition, non- linear positive and negative rotations are counted, located and their length recorded. Appendix D sets forth an alogorithm for personalization of the handwriting reading device of Figs. 3-5- The personalized functions are carried out using the pen 10 and the computer 11. The user initially writes each alpha-numeric symbol. The symbol is "read" by the device which determines X, Y and Z accelerations, and employs the accelerations to extract the features listed above, in a manner set forth generally in Fig. 6. Feature recognition is achieved by recognizing the centroids of the pen-strokes of the individual writing and by classifying of each character into 12-16 pen-stroke types. The character is considered to be a sequence of certain pen-strokes and is recognized as a fuzzy string over the pen-strokes alphabet. The fuzzy rules are downloaded to the microcontroller 26 in the pen 10. The extracted features are employed to adapt fuzzy rules. The fuzzy rules are employed in the operation of a symbol recognizer which provides output indication of a recognized symbol. The actual and recognized symbols are compared to provide a difference indication which is used to further adapt the fuzzy rules until an acceptable match between the actual and recognized symbol is attained. Additionally in accordance with a preferred embodiment of the present invention there is provided audio-visual apparatus including apparatus for providing a human sensible output including information in at least one of audio and visual form and having as an input element hand-held apparatus for sensing motion during handwriting of the type described hereinabove. Examples of such audio-visual apparatus include a video recorder and player, a stereo audio player and a television. Other home appliances such as washing machines and cooking apparatus may be operated along similar principles. Further in accordance with a preferred embodiment of the present invention there is provided portable information storage and retrieval apparatus including a portable computer memory and output device and having as an input element hand-held apparatus for sensing motion during handwriting of the type described hereinabove. Examples of such portable information storage and retrieval apparatus include a digital watch with memory, a computerized diary, a computerized dictionary and electronic telephone book. Additionally in accordance with a preferred embodiment of the present invention there is provided lock apparatus including locking apparatus responsive to a predetermined electronic input and having as an input element hand-held apparatus for sensing motion during handwriting of the type described hereinabove. Examples of such locking apparatus include door locks and vehicle door locks and ignitions. Further in accordance with a preferred embodiment of the present invention there is provided magnetic card activated apparatus including apparatus for reading a magnetic card and having as a verification input element, hand-held apparatus for sensing motion during handwriting of the type described hereinabove. Examples of such magnetic card activated apparatus include automatic teller apparatus and point of sales credit card acceptance units. It will be appreciated by persons skilled in the art that the present invention is not limited by what has been particularly shown and described hereinabove. Rather the scope of the present invention is defined only by the claims which follow: APPENDI X A What the human brain tells the human hand A behavioral perspective Ehud Bar- On E.B. Research k Development Ltd. Gutt irth Bldgs, Technion, Haifa 32000, Israel September 22. 1992 Abstract This study investigates the primitives of motoric patterns of hand movement during handwriting. This is referred to as the "language" between the "hand and the "brain", and as such, has its own vocabu¬ lary and syntax. The "vocabulary" is the pen strokes and the syntax is how they are combined to pen strokes sequences. The handwriting is viewed as a high level cognitive activity of communicating, expressed as a complex motor skill and its investigation provides insight into the processes of chunking and automaticity. The main finding of this study is that pen strokes are specific to an individual writer, and character¬ ize the writer's unique motoric control mechanism. The dynamic data of many thousand handwritten characters, produced by many writers, had been analyzed. The time domain signals were segmented into dis¬ crete pen strokes units and represented as vectors in a feature space. Those vectors were clustered, using a variety of clustering techniques. We found that in spite of the fact that the hand movements during writing could take any form or shape, a particular writer employs only a very limited set of pen strokes. The results of the clustering by var¬ ious methods, yields a limited set of only twelve to fourteen types of pen strokes that accounts for ΘObrain supposedly chunks information to minimize the required attentional resources. - 15 - keywords: handwriting, human motor control. chunking, automatic- ity, connectiomsm 1 Humans motor behavior When we speak about "what the human brain tells the human hand", we speak about the kind of "motor control language", that might exist between the "brain" and the "hand". While this "brain-hand" communication can be approached from different points of view, we study it from a behavioral perspective. That is. we investigate the evidence of chunks or what is referred to as "motor programs", by analyzing the dynamic data collected during experiments in hand-writing recognition. Although all the results reported in this article consists only on the output of the handwriting process, we try to make the proposed model cognitive and biological plausible. We'll start with the cognitive plausibility. There is a strong link between cognitive mechanisms and the human motor behavior. Handwriting is the way that humans express their thoughts through the use of a complex motor skill. Rosenbaum [12], presented handwriting as culmination of several in¬ ternal translation process. First, an abstract message or idea is constructed. Then, it is formulated into appropriate linguistic expression v and then trans¬ lated as a series of efferent commands. There is a basic similarity between speech and writing, so we can assume that both share the same underlying mechanism. The phonemes in speech, correspond to pen-strokes in writing, and the morpheme in speech correspond to letters. The higher levels of ab¬ straction (i.e. words, syntax, lexicon, semantics, prosody and discourse), are probably the same. There is an empirical evidence, that the ability to sequence behavior, whether in the linguistic domain or drawing domain, depends on a central, amodal mechanism [11]. If this is true, then motoric control should be consid¬ ered as obeying the same rules of the linguistic or other sequential cognitive mechanisms. On the other hand, some of the properties that we discover about the primitives of the motor control language, might be generalized to other cognitive activities. In the case of handwriting, the efferent commands are expressed as pen-strokes. It was found by Wright [17], that different pro¬ duction mechanism are probably controlled by the same high-level graphic representation. This view of hierarchical structuring, and a "virtual" repre¬ sentation of motor movement is supported by empirical evidence. Humans can write in a consistent style when they write in small letters in their note¬ books, or when writing much bigger characters on a blackboard. Moreover, people can write with a consistent style (same pen-strokes), when using dif¬ ferent effectors like hand and foot. As in any behavioral research, resulting behavior is influenced both by the general properties of handwriting and by properties which are specific to an individual writer. This means that a considerable part of the variance can be attributed to individual differences. It has been noticed bv manv researchers that handwriting style is so distinctive, that writers can be rec¬ ognized according to their hand writing. This is also a common knowledge, and therefore signatures are recognized as a unique identifier of a specific writer. Some theories even associate personality traits with hand-writing style. As we intend to show in this article, the primitive pattern of writing, are unique for individuals writers. As any other cognitive or motor activity, human motor control goes through a process of development that is equivalent to intellectual develop¬ ment. An interesting well known phenomena is that children's drawing (and after that writing), becomes more refined over the course of development. It has been suggested by many researchers, that early drawing behavior corre¬ lates with young children's cognitive abilities. Van sommers [15], suggested that drawing may be governed by high-level rules, similar to those governing language processing, and that the development in drawing may parallel the development of language. Goodnow and Levine [9] even suggested a: "Gram¬ mar for action: sequence and syntax of children's copying." They reported several rules for sequencing drawing strokes. Examples of such rules were:" Start at leftmost point", "Start at top", "Start with vertical strokes " , "draw horizontal lines from left to right", etc. The evolutionary rationale for such rules could be to simplify motor planning. The biological plausibility of an hand writing model, involves two parts: The plausibility of the assumed neurological control, and the biomechanical properties of the hand. The preservation of the writing style while using dif¬ ferent muscles and even organs, is one of the most intriguing questions. The automaticity of writing, suggests a chunking mechanism, but this chunking mechanism is probably not in the motoric system of the hand, but somewhere in the upper control levels of the brain. Therefore, whenever we refer to the "hand", we do it metaphorically. I.e. the "hand " represents the efferent mechanism that accomplishes the motoric control. Recently, Alexander et al. [3], raised the question whether the specific concept of a "motor program", is an appropriate foundation for the development of biological plausible models of how the brain controls movements. While our current knowledge about the cortical and basal ganglia motor areas is still far from allowing a specific model, it can suggest what models are more neurologically plausible than others. Fischbach [7] discusses the finding about " face cells" and "motor command cells" as an evidence for abstraction in the brain. In the monkey's visual system, "face cells" located in the inferior temporal sulcus, were sug¬ gested as- representing a high level of abstraction. These neurons respond to faces but not to other visual stimuli. Face cells have their counterparts on the motor side. "Command" neurons have been identified in certain vertebrates that trigger fixed action patterns. Georgopolos [1] recorded electrical activ¬ ity of single neurons, and found command neurons in the monkey ' s motor cortex (precentral gyrus) that encode the direction of forelimb movement. The firing of these neurons was not associated with the contraction of a par¬ ticular muscle or with the force of the coordinate movement. Georgopoulos computed a vector by summing the firing frequencies of many neurons, and found that it is more correlated with the direction of movement than is the activity of any individual cell. The vector becomes evident several millisec¬ onds before the arm moves. He interpreted this result as evidence for motor neuron planing. Damasio and Damasio [4] discussed the linguistic behavior of patients with lesion in the left posterior temporal and inferior parietal cor¬ tex. It was found that such patients have problem in producing word forms from the available phonemes. Analyzing the accumulated empirical finding on language structures, gathered with assistance of imaging techniques like MRI (Magnetic Resonance Imaging) and PET (Positron Emmision Tomog¬ raphy), shows that linguistic activity like naming, involves the motor cortex activation together with anterior and posterior language centers in the left hemisphere. Writing is a language activity which involves a production cen¬ ter that forms words and activates the "command cells" in the motor cortex to produce pen-strokes sequences (letters) and written words. In the same way that speech is composed of a small set of phonemes, we argue that handwritten letters are composed of a small set of pen-strokes. In addition to the neurological plausibility, there are biomechanic con¬ straints on the "hand" part. Some general principles have been suggested as governing this control mechanism. For example. Flash and Hogan [8], proposed that humans tend to write in a way that minimizes jerk. That is, the third time derivative of the position signal. A more recent study [6], suggested the snap, which is the fourth derivative of position, as the cost function that is minimized. As we will see, there are alternative hypotheses about the type of constraints imposed on the biomechanics of handwriting. In spite of the fact that the principle that governs the handwriting might be universal, each writer has its own unique variation. The differences are more pronounced in the unwritten strokes (the pen movements that do not touch the writing surfaceO than in the written ones. The friction of the pen with the writing surface diminishes the characteristics of the hand control mechanism which are better revealed when the pen is up. The article starts with reviewing theories of "motor programs " , and ar¬ guing against that tei;m and what it implies. We ' ll propose an alternative connectionist model of primitive hand-writing patterns and argue that it is more biologically and cognitive plausible. Then, we describe the experiment, and the collection of the data. The fourth chapter will describe the analysis of the collected data, and the conclusions that were drawn from this analy- sis. The last chapter will discuss the results, and compare our conclusions to alternative ones. We shall conclude the article by pointing out some future directions and implications of the suggested model. 2 Attention, chunking and "motor programs" The concept of " working memory" is modeled after the "working memory" in a (von Neumann) computer, where the registers in the Central Processing Unit (CPU) have a similar function. This is also why researchers in that field prefer to talk about "motor programs". "Motor programs" are supposed to save attentional resources. According to this approach, it is assumed that the brain controls movements like handwriting, by executing "motor- programs" , much like software is used in a computer (e.g. [12] ). The "motor program" concept is attractive, as it reduces the complexity of the sequential, analytical approach by using pre-programmed sequences of a limited number of generic motor commands (or routines), to control a large repertoire of movements. Alexander et al. [3] points out difficulties with the neurological plausibility of "motor programs" that imply separation between "software" and "hardware". For example, what would constitute the software in such a model, and where it is stored when not executed, how are they assembled prior to their execution and how new programs are created. A major problem with the "motor program" approach is also the sequencing of performance: goal- directed movements are supposed to be translated into trajectories, then to joints kinematics. Muscle activation cannot be computed until the inverse dynamics is calculated and so on. Therefore, argue Alexander et al., signs of specialization for such transformations should have been found in the cortical and basal ganglia. Thusfar, neurobiological evidence seems to indicate lack of such specialization. It is assumed that the processing capacity is limited, and therefore sev¬ eral tasks that have to be carried out simultaneously compete on the same resources. The main "problem" of human-beings and other organism might be, that we lack a "parallel output channel". All the output channels, be it speech, handwriting or any other motor output, are all serial in nature. It might be that this serial output suggested a serial cognitive mechanism as well. It is the conjecture of the neural-nets literature, and of this article, that the underlying mechanism is parallel and distributed over millions of simple processing units (neurons). Therefore, the term "motor programs", that im¬ plies a serial symbolic process running in the "brain-computer" might be misleading. We prefer to speak about "motoric schemas", which are motoric patterns invoked by activation of an assembly of neurons. The connectionist view of schemas (Smolensky, 19S6) is that stored knowledge- atoms are dynamically assembled at the time of inference, into context- sensitive schemata. Rumelhart and McClelland (19S6) [14] proposed a tech¬ nique that suggests how an attentional selective mechanism might work. They propose the use of a set of mapping units which produce "dynami¬ cally programmable connections" and achieve focusing on different features on different times. Smolensky ( 19S6) maintains that schemata are coherent assemblies of knowledge atoms, where coherence or consistency is formalized under the name of harmony. He proposes the harmony principle: the cogni¬ tive system is activating coherent assemblies of atoms, and draws inferences that are consistent with the knowledge represented by the activated atoms. In much the same way, we propose to speak about "motoric schemas". This is consistent with our conjecture that there is no essential difference between the so-called "cognitive " ' and "motoric" brain. mechanism. The con¬ nectionist schema-model is also consistent with the neural evidence, that the specialization among different cortical motor areas are related to certain sequences of movements, and not to transformations as proposed by the "mo¬ tor program" literature. According to our conjecture, preparatory units and movement executing units will belong to the same schema. This is supported by the anatomical fact that the three motor areas (SMA - Supplementary Motor Area, PMC - Primary Motor Cortex and Putamen), has the same proportion of target dependent motor cells and limb dependent movement- related cells ([2] ). Another supporting evidence is that neuronal population that were supposed to represent different stages of computation (according to the "motor program" view), have been shown to be active simultaneously. 3 The experiment 3.1 Data collection Rumelhart [13] developed a system which learns to recognize cursive script as it is generated by a writer. This system learns from examples of cursive script produced by a number of writers and recorded. He collected approximately 1000 words from each of 58 writers. The average length of a word is about 8 characters, That sums up to nearly 500,000 examples of handwritten cursive characters. His results were encouraging and had been used in this research. While Rumelhart [13] was mainly interested in handwriting recognition, this article uses the same data to investigate the writing mechanism. The data were collected in the following manner. Each word in the corpus was recorded. It was then played to the writer who was instructed to write the word on a tablet digitizer. The resulting x coordinate, y coordinate and an indication of whether the pen was or was not on the paper were sampled each 10 milliseconds. The resolution ( more than 200 dpi) and the sampling rate (100 samples/sec) are those that are shown to be appropriate in the on-line hand-writing recognition literature ([16] ). The data was saved as files, and has been used for the analysis reported in this article. In addition to the data from Rumelhart 's experiment, several thousands pen strokes of Japanese handwriting were collected. Most of the data has been collected from hand written Hiragana characters, but some data has been collected during writing Kanji (idiographic) Japanese characters. Hi¬ ragana characters has the curved shapes of english hand printed characters, but without the ligature of cursive handwriting. Preprocessing of the hand-writing raw data has been made, with the goal of extracting features that will be used to segment and characterize the "pen-strokes". A pen stroke was defined as a segments of the cursive writing signal, between two consecutive zero crossing of the vertical velocity of the pen movement. Each character was segmented to several segments or "pen- strokes". A typical writing rate in English is two letters per second. Writing Japanese characters (Hiragana), takes about the same time, and a typical Hiragana character can be written in 0.3 - 0.5 seconds. 3.2 Segmentation and feature extraction The principle of segmentation and feature extraction is to segment the con¬ tinuous signals into discrete segments and to represent each segment by a feature vector in the feature space. The segmentation that produces "pen-strokes" out of the continuous sig¬ nals, depends on the different definitions of the term" pen-strokes". While most of the literature about on-line character recognition is using this term, there isn't an agreed upon definition of a "pen-stroke". For example, one often finds only the pen-state change as the only criteria. That is. defini¬ tion of a stroke as continuous pen-movement, between pen-down and pen-up consecutive states [16]. Once a "pen-stroke" is defined, there are many ways to represent it in a feature space. The on-line character recognition research employs several orthogonal transformations such as a discrete Fourier transform of the curve segments corresponding to the pen-strokes. That is, a pen-stroke is repre¬ sented by its Fourier coefficients obtained from its ι(ι) and y(t) signals. Es¬ sentially, any orthogonal transformation (e.g. Walsh transform, Karhunen- Loeve) could do in approximating the pen-strokes curves. That is, Plane curves can be approximated by orthogonal functions (Sinusoidal, polynomial or even square waves). This description can be also easily converted to the frequency domain, as was done in several studies of hand-writing recognition [16]. This mapping of the time domain to a parametric domain is advanta¬ geous when the characters can be represented by a small number of coeffi¬ cients. Therefore, periodical smooth curves lend themselves better to mod¬ eling by harmonic functions, as one needs less coefficients. On the other hand, straight line strokes require high order harmonies as they include high frequency components. This is why sinusoidal approximation is useful for characters consisting of curved strokes, as found in English cursive script, more than for Japanese Kanji characters (that are made mainly of straight line segments). K-L expansion has been proved to be a successful algorithm in machine-printed Chinese character recognition. Another successful at¬ tempt was to use a modified Hough transform for recognition of Chinese hand-written characters. The Hough transform is a technique for line detec¬ tion and has been generalized to detect arbitrary shapes. Chinese characters are line-like, and therefor lend themselves naturally to a Hough transform representation. The segmentation and feature extraction methods depend of course, on the goal. If the goal is pattern recognition, then the segmentation and feature extraction are geared toward discrimination between the various patterns. In our case, we looked for a segmentation and features that are biological plau¬ sible. Consequently, we investigated only features that might be explained by the neurobiologicai control structures, like the direction of the strokes, their curvature etc. 3.3 Hollerbach's model The segmentation and feature extraction mechanism employed was, to de¬ velop a model of the underlying handwriting process and to describe the data in terms of the parameters of the model. The model employed was derived from that of Hollerbach [10] and involved the assumption that the genera¬ tion process could be described as pair of coupled oscillators. The coupled harmonic oscillators is just one of the many models that exist. Actually, its basic assumption about the symmetric shape of the velocity profile (an half sinus shape), is probably an oversimplification. The literature about velocity profiles of pen-strokes usually assumes an asymetrical bell-shaped velocity profile. That is, a rapid-aimed movement described by a log-normal velocity profile is considered as the fundamental unit (stroke). More com¬ plex movements are described in terms of superimposed log-normal curves. The asymmetric nature of the velocity bell-shaped profile results from the global stochastic behavior of a large number of processes involved in velocity control. In spite of being an oversimplified and inaccurate model, it has a clear advantage that it is based on a control mechanism, and is neuorobiologically interpretable. This model assumed that: x = a cos(ω r t + φ) + c (1) y = bcos{ω v t) (2) In words, the idea is simply that writing involves two orthogonal pendular movements. If we speak about writing in a notebook (small size letters), we can think about the wrist horizontal movements (actually, it is more arc-like movements) and the fingers flexion andextension vertical movement. These two movements can be considered as independent. If the size of the letters is more than an intch, than the arm muscles are involved. According to this model, The y-axis consists of a series of up/down strokes whose velocity profile is assumed to be sinusoidal. The i-axis is also pendular with a constant velocity, c, to the right. Different characters are made by modulating the relative amplitudes, α and b, the relative phase, phi. and the relative frequency * - r and ω y , in the x and y directions. It is, furthermore assumed that the parameters change only when the velocity in the y direction reaches zero (end of pen-stroke). Thus, we define a stroke as the motion between zero crossings in the y velocity - v y . In addition, segmentation occurs when the pen-state changes (from pen-down to pen-up or vice versa). It should be stressed that Hollerbach's model was designed for synthesiz¬ ing handwritten-like character, by a second order mechanical system. This model does not try to imitate the human motor control, or to be used for analysis of human handwriting. However, as it is a control system model, some of the parameters might be interpreted in terms of the human biome- chanical system. For example, the parameter φ . which designates the phase shift, can be interpreted as relating to the delay in the nervous-muscular control system. As such, it can have an important diagnostic value in motor diseases. When it was applied by Rumelhart to handwriting analysis, it suffered from some drawbacks. One of them is that the model is fitted not to the image, but to the velocity profile of the stroke. This simplifications tend to work well in most of the cases of English cursive hand-writing, because of the periodical nature of the v y velocity signal. As the Hollerbach model that we used, is based mainly on the velocity sig¬ nals, we will illustrate the transformation from the x — y domain of the hand- d - 23 - Figure 2: The v x graph for the handwritten letter d written character, to the corresponding velocities. Examples of the handwrit¬ ten letter d, the corresponding velocity profiles and the reconstructed d are shown in Figures 1,2,3 and 4. As can be seen, the reconstruction isn't perfect, and the curvature of the first pen-stroke of the d is opposite to the original. This result illustrates the fact that the model tries to reconstruct the velocities and not the resulting pen strokes image. This does not exclude the fact that sinusoidal approximation worked for Rumelhart in recognition of cursive script. It turned out that in some cases (periodic signals during cursive handwriting in English) the model worked satisfactorily. The Kanji characters, on the other hand, have more short straight seg¬ ments, as can be seen in the following figures: The "mori" Kanji character in the picture, is segmented to 27 pen-strokes (the last two pen-down strokes in the third "tree" are missing). Sixteen out of the twenty seven, are strokes in which the pen touched the paper, and 11 were just for moving the pen from one line to the other. Twelve sequences of "pen-down" strokes, correspond to the visible line segments in the character. Figure 3: The v y graph for the handwritten letter d Figure 4: The reconstructed letter d T/US92/08703 - 25 - Figure 5: The separate strokes are more evident in Japanese Kanji characters. This is the Kanji character: "mori", which means: forest Figure 6: v y "mori Figure 7: The reconstructed Kanji character: "mori". The reconstructed Kanji character is depicted in the figure. 3.4 Recognizing pen-strokes sequences One of the key problems in recognizing cursive handwriting is the segmen¬ tation problem. Rumelhart [13] has devised a learning algorithm for cursive handwriting recognition which combines word recognition and letter recog¬ nition. The letter recognition is based on recognizing PMPs, and PMPs sequences make letters. This system involves simultaneously learning to rec¬ ognize and segment letters. Although Rumelhart 's experiment was done for hand- riting recognition, there are several things that can be learned from it, concerning the PMPs and their sequencing during handwriting. It was recognized in the early sixties ( [6]). that motor knowledge can be used in recognition of hand-writing. A system called Analysis by synthesis suggests that characters are recognized by their "motor programs". These "motor programs" are supposedly deduced by guessing an initial program, and iteratively updating it according to the difference between the synthesized and actual forms. The connection between reading and writing process have been corroborated by the co-occurrence of certain kinds of acquired dysgraphia and dyslexia ([5]). In contrast to ear¬ lier approaches. Edelman et al., ([6]), assumes that while readers use motor knowledge in reading, they do not seem to do so by mentally reproducing the process of writing. The connectionist model that we propose isn't both¬ ered, of course, by those distinctions between explicit simulation or implicit knowledge. This is another example of the misleading influence created by the "motor programs" metaphor. 4 The results of clustering 4.1 fixed radius clustering The basic units of clustering were the pen-strokes, each of which was rep¬ resented as a point in an n dimensional space. Out of the six features that we extracted for each stroke only three have been used. First, we used only one frequency for the modeling, so the rare strokes that involved higher har¬ monies were removed. Second, we did not differentiated between Up-strokes and Down-strokes. Up strokes contain more high order harmonies, but we limited our analysis to the basic movements, and tried to ignore the fluctu¬ ation induced by the bio-mechanical control mechanism. The third feature that wasn't used was the mid-point. For the reconstruction of the pen-strokes in the spatial domain, the x-coordinate of the midpoint in each stroke was computed. However, our preliminary analysis showed that this variable was very highly correlated with the x variable. This preliminary analysis, yielded three variables that were almost uncorrelated: Δ r , Δv and velocity. The dimension of the space were: 1. Δ v - The relative displacement on the vertical direction. 2. Δ r - The relative displacement on the horizontal direction. 3. v - υ The <_ • _. velocity at the end of the stroke is calculated according to equation below. For a pen-stroke between a and ό, which is approximated by a certain oscillation frequency, we calculate: I- = [ dx cos(2 : x t) (3) Ja - = \^-\ - \ (4) (5) It is calculated in a different way for different ut and this is an example of such a calculation. The clustering of data from many writers, didn't yield satisfactorily clus¬ tering, but the clustering of individual writers did. E.g. the clustering for a particular writer, revealed 13 compact clusters that contained 90to 14, were consistent to all the writers we analyzed. This is a corroboration to our con¬ jecture that hand writing is made out of a small number of PMPs, which are unique to an individual writer. The centroids of the clusters, were reconstructed from the feature space, and are displayed on a 2-D spatial domain. As can be seen clearly from the results, different writers have different stroke types: As each writer has about 25,000 pen-strokes that we wanted to cluster, we started with a fast clustering algorithm, similar to the k-means algorithm. The main requirement of the clustering algorithm were that it will be able to deal with very large data sets and find satisfactory clusters in few (2-3) iterations. The other requirement, which was even more important., was that the centroids will be good representations of the observations within each cluster. This requirement lead to seeking compact, hyperspherical clusters, that do not exceed a predefined radius. Elongate clusters are therefore repre¬ sented by several adjacent clusters. Those clusters will be merged in a latter stage by an hierarchical clustering algorithm. The clustering employed a two phase strategy. First, a fast "nearest centroid sorting" algorithm was employed to reveal the clusters in the large data set. Then, the resulting centroids of the clusters have been submitted to different hierarchical clustering methods. The first phase algorithm was Figure 8: Clustering of 25,000 strokes of the same writer. Gray clusters represent down strokes. Figure 9: Thirteen centroid pen-strokes of an individual writer, including their relative frequencies. - 30 - sensitive to outlier strokes, that formed separate clusters. This was the reason why we got many very small clusters. These clusters accounted for less than lOof the observations. They were considered to be noise, or very exeptional pen strokes, and have been removed so not to influence the representativeness of the centroids of the large clusters. The second phase included clustering of the resulting centroids using ten different methods. We distinguished between methods that yield compact hyperspherical clusters, and those that can detect elongate clusters. We start with the first group of eight clustering methods: 1. Average Linkage cluster analysis 2. Centroid hierarchical cluster analysis 3. complete linkage cluster analysis 4. Equal variance maximum likelihood method 5. Flexible data cluster analysis 6. McQuitty's similarity analysis 7. Median Hierarchical cluster analysis S. Ward's minimum variance cluster analysis The different methods tend to favor different characteristics such as size, shape or dispersion. For example, methods based on the least-squares cri¬ terion such as k-means or Ward's minimum variance method, tend to find clusters with roughly the same number of observations in each cluster. Aver¬ age linkage is biased toward finding clusters of equal variance. Most cluster¬ ing algorithms, except for single-linkage and density-linkage, tend to produce compact, roughly hyperspherical clusters. The clustering methods which are based on nonparametric density estimation, like the single linkage, will be discussed later in this chapter. All the above clustering methods yielded very similar results, and the tree-based partition was essentially the same. The use of many different algorithms has been employed to investigate the robustness of the clustering structure under different hierarchical clustering methods. The result of ail Figure 10: Hierarchical (compact) clustering of the 12 pen-strokes centroids of a particular writer the above method revealed the following tree-based partition of the set of the basic twelve pen-strokes (of a particular writer). From looking at the results of the hierarchical clustering, there is an ob¬ vious super-clusters that emerge. The horizontal-left strokes are one such a group, long down strokes are another group. In general we see a distinc¬ tion between horizontal strokes and vertical strokes. The horizontal strokes themselves are subdivided to horizontal-left directed strokes, and horizontal right and up directed strokes. The high velocity C shaped strokes are part of circles or ovals. It should be noticed that for a specific writer, a certain stroke is always accomplished in the same way. For example, an horizontal short stroke, like crossing a t, will be done always as left directed strokes. Someone else could use only horizontal right directed strokes for that pur¬ pose. However, it is very unlikely that the same writer will use both an horizontal-left and horizontal- right strokes. The same is true with long ver¬ tical strokes. Once the writer is using a long vertical down-stroke, he will produce vertical lines always as down strokes of the same type and velocity profile. This organization of pen strokes was consistent in all the hierarchical Figure 11: Hierarchical (Density linkage) clustering of the 12 pen-strokes of the same writer clustering algorithms that we mentioned above. The clustering methods that employ nonparametric density estimation, like the "Density linkage cluster analysis", can detect also elongated cluster shapes. These clustering techniques yielded two distinct super clusters: the "down and long pen-strokes" , and the "up and right strokes". The down strokes are those that form the "back-bone" of the English characters, while the up-right strokes are typically those that are used as ligature. 4.1.1 The "characteristic" shape of pen-strokes As was argued above, any writer has a specific set of pen strokes that char¬ acterize the writer. While the same writer will have similar pen-strokes, in writing different languages, the frequency of appearance of a specific pen strokes depends, of course, on the language. In order to characterized a spe¬ cific writer, in respect to her/his pen strokes, we suggest the "Pen-strokes Ordering Diagram" (POD). Such PODs are displayed in the following figures. In spite of their strange looking, those diagrams are quite valuable,, and convey important information about the handwriting of the analyzed writer. Figure 12: The centroids of the pen strokes of a writer, for English cursive writing. The pen-strokes are ordered according to their υ y values, from up¬ strokes to down strokes Figure 13: The centroids of the pen strokes of a Japanese writer, for Japanese Hiragana characters. The pen-strokes are ordered according to their v y val¬ ues, from up-strokes to down strokes Figure 14: The centroids of the pen strokes of a Japanese writer, for english characters. The pen-strokes are ordered according to their v v values, from up-strokes to down strokes There is a very clear distinction between the key strokes that these two writers are using. This is true to other writers as well. Each writer uses a unique set of pen-strokes: " different slopes, different curvetures, different velocity profiles and accelerations. 5 Discussion and future research We will start our discussion with comparing the conclusions of Rumelhart 's handwriting recognition experiment, and the conclusions of this study. In Rumelhart's handwriting recognition experiments, both writer dependent and writer independent recognizers have been trained. Two networks have been trained to recognize the writing of individual writers and one network has been trained on four different writers as a "writer independent" recog¬ nizer. On the writer dependent networks Rumelhart found that, for a vo¬ cabulary of 1000 words, on words never seen during training that 99top five, approximately 90On the writer independent data the results are somewhat worse. That is, about 70 According to the results in this study, we have a basis to doubt this conclusion. The inter-writer variability is too big, and more writers will not lead necessarily to better results. Another finding of Rumelhart was that writers can be trained easily to produce recognizable hand writing. He developed an "online" svstem in which the network recognizes (and can be trained) as the writer writes on the digitizer. With a little care on the part of the writer it is not difficult to achieve a score of better than 90correctly classified on the writer independent system. (It is also possible to write so that the recognizer does much more poorly than that.) Careful experiments on a person's ability to adjust to the recognizer have not been carried out. By iimiting the vocabulary to one hundred words or less, it seems to be possible to obtain near perfect performance. (It will, of course, depend on the confusability of the words.) The main conclusion was. that it would be useful to embed the recognizer in a network of networks each trained on a subset of the writers - perhaps one for printers, one for pure cursive writers etc. This line of thought led to the current study, reported in this article. That is, that it may be useful to study the individual differences among the writers. The idea of studying individual differences, as a mean towards better handwriting recognition, turned out to start a new line of research - the study of writer's unique pen-strokes, which is related to the topic of automaticity in brain - hand communication. This study started from that point. The main question that we posed was if individual writers have distinct sets of pen-strokes, which are con¬ sistent and well defined. The reanalysis of the data from this perspective encourage to believe that this is the case. Human writers have 12-14 distinct pen-strokes, which are characteristic for a certain writer. These pen-strokes are the primitive "motoric patterns", of which handwriting is composed. We showed also that the primitive pen-strokes cluster to super-clusters, thus re¬ vealing the hierarchical nature of the control mechamnism. These findings are consistent with the neurological literature, that we cited in the introduc¬ tion. That is, there might be "command cells", that get the activation for certain words (letter combinations) from another center in the brain and acti¬ vate pen-strokes mechanism. The pen-stroke is controlled by a direction and amplitude cells, that activate the corresponding primitive motoric patterns (PMPs). The next stage will be to locate the cell regions that are responsi¬ ble for this activation in the motor areas of the human brain. This is under research now with the help of Magnetic Resonance Imaging (MRI) method, when the MRI is tuned to detect cerebral blood flow. We would expect that the learning to write, should show itself as forming of such motoric activation centers, corresponding to what we have found in this study. Those findings have implications to the study of automaticity and chunk- ing. One question to be investigated is if the motor control mechanism is central and a modal, as suggested by previous researchers. This can be in¬ vestigated by studying the patterns of interference between modalities. For example, an experiment in which the subject is instructed to pronounce one character, and write another character at the same time. In addition to pre¬ dicting longer Reaction Time, we can now predict interference between the pen stroke patterns and sequences. Another interesting question is how are the motoric patterns stored and how are they retrieved when needed. Our conjecture, which is consistent with the neural net model, is that the retrieval time will be independent of the number of patterns sequences. Some sup¬ port for this conjecture is that it takes the same time to write a character in a large character set (kanji) or small character set language (Hiragana, English). Future research that will combine behavioral analysis with neurobiolog- ical research, might answer many of the questions that we raised in the introduction. References [1] R. E. Kettner A. P. Georgopoulos and A. B. Schwartz. Primate motor cortex and free arm movement to visual targets in 3-d space. Journal of Neuroscience. pages 2928-2937, 1988. [2] G. E. Alexander and M. D. Crutcher. Neural representations of the target of visually guided arm movements in three motor areas of the monkey. Journal of Neurophysiology, 64:164 - 178, 1990. [3] G. E. Alexander, M. R. De-Long, and M. D. Crutcher. Do cortical and basal motor areas use motor programs to control movement ? Behavioral and Brain Sciences, 1992. [4] A. R. Damasio and H. Damasio. Brain and language. Scientific Ameri¬ can, 267(3):88 - 95, 1992. [5] S. Edelman. Reading and writing cursive script: A computational study. PhD thesis, Weizmann Inst. of Science, Rehovot, Israel, 1988. [6] S. Edelman, T. Flash, and S. Ullman. Reading cursive handwriting by alignment of letter prototypes. International journal of Computer Vision, 5:303-305, 1990. [7] G. D. Fischbach. Mind and brain. Scientific American, 267(3):48-57, 1992. [8] T. Flash and N. Hogan. The coordination of arm movements: an ex¬ perimentally confirmed mathematical model, journal of Neuroscience, 5:1688-1703, 1985. [9] J. J. Goodnow and R. Levine. The grammar of action: Sequence and syntax in children's copying. Cognitive Psychology, pages 82-98, 1973. [10] J. M. Hollerbach. An oscillation theory of handwriting. Biological Cy¬ bernetics, 39:139-156, 1981. [11] S. W. Keele. Sequencing and timing in skilledv perception and action: An overview. In D. Allport, W. MacKay, W. Prinz, and E. Sheerer, editors, Language perception and production. Academic Press. London, 1987. [12] D. A. Rosenbaum. Human motor behavior. Academic Press, 1991. [13] D. E. Rumelhart. Segmenting and recognizing online cursive handwrit¬ ing. Technical report, PDP Lab., Stanford University, 1992. [14] David E. Rumelhart, G. E. Hinton, and R. J. Williams. Learning internal representations by error propagation. In D. E. Rumelhart and J. L. McClelland, editors, Parallel Distributed Processing, chapter 8, pages 318-362. MIT Press, 1986. [15] P. Van Sommers. Drawing and cognition: Descriptive and experimental studies of graphic production processes. Cambridge Univ. Press, Cam¬ bridge, England, 1984. [16] C. C. Tappert, C. Y. Suen, and T. Wakahara. The state of the art in on-line hand writting recognition. IEEE Trans, on Pattern Analysis and Machine Intelligence, 12(8), 1990. [17] C. E. Wright. Generalized motor programs: Reexamining claims of effector independence in writing. In M. Jeannerod, editor, Attention and performance XIII, pages 294-320. Lawrence Erlbaum, Hillsdale, N.J., 1990. APPENDIX B feat['l3] " number of spaces where out_rot » 0.1 feβt['»'»_ • number of spaces where out_rot-2.3 featC^. " number of spaces where out_rot « '«,5 featC.6 ■ number of spaces where out_rot»6,7 " number of min X. ■ number of max X. " number of min Y. • number of max Y. feat[5-] " sui length of spaces. feat[52] • relative position of spaces. APPENDIX C ..include <stdio.h> #include <stdlib.h> ^include <math.h> #include <conio.h> #include <values.h> #include <mem.h> ..include <string.h> #include <process.h> ødefine GRID 15 #define MAX_NUM OF_POINTS 1000 #define MAX NUM~OF STROKES 64 #define MAX~NUM_OF~EXTREMOMS 32 #define NUM_FEAT 53 #define NUM_SYMBOLS 72 #define DIVISER 6 #define TRUE 1 #define FALSE 0 typedef int boolean; struct TABLE_STROKES_NEW unsigned str _num int delta_x int delta_y unsigned lenght unsigned pen_status int rotation }; struct POINT { unsigned x_cor : 10; unsigned y_cor : 10; unsigned pen status : 4; }; struct TA?LE_EXTREMOMS { unsigned p_ndx : 10 unsigned x_cor : 10 unsigned y_cor : 10 unsigned pen_sts unsigned dir unsigned in_rot unsigned out_rot unsigned susp unsigned reserve }; struct FEATURES { char IDfeat[llj; /* Id feature for naie */ unsigned int feat[NUM FEAT]; > ; feat[θ] relative size of symbol 32*div_round(Xwidth,Ywidtb) feat[l] number points feat[2] number o strokes fβat[3] number o spaces feat[4] number o different levels in X for end of space feat[5] number o different levels in Y for end of space feat[6] number o Ext X in neg.rot fβat[7] diffβrβn levels in X for inX fβat[8] differen levels in Y for minX fβat[93 number o Ext in X pos.rot fβat[10] differen levels in X for maxX fβat[ll] differen levels in Y for maxX feat[12] number o Ext in Y neg.rot f β «t[13] differen levels in X for minY fβat[l4] differen levels in Y for minY fβat[15] number o Ext In Y pos.rot feat[l6] differen levels in X for maxY fβat[17] differen levels in Y for maxY fβat[l8] number o ExtXY for neg. rot fβat[19] differen levels in X for feat 4l fβat[2θ] differen levels in Y for feat 4l fβat[21] number o ExtXY for pos. rot fβ«t[22] differen levels in X for feat 44 fm«t[23] differen levels in Y for feat 44 fβat[24] number o arc parts fβat[25] number o circle parts feat[26] number o X-levels in symbol fβat[27] number o Y-lβvβlβ in symbol fββt[28] number o linear strokes (in_rot«θ) feat[29. number o pos. rot. strokes (in_rot"l) fβat[3θ] number o neg. rot. strokes (in_rot--7) fβ.t[31] number o linear strokes where dir-θ.l feat[32] number o linear strokes where dir-2,3 f β at[33] number o linear strokes where dir-4,5 fβat[3%] number o linear strokes where dir-6,7 f ββ t[35] number o strokes where out_rot-θ,l feat[36] number o strokes where out_rot"2,3 f β at[37] number o strokes where out_rot β 4,5 fβat[38] number o strokes where out rot-6,7 f**t[39] number o spaces where q a θ,l feat[4θ] number o spaces where q a 2.3 fβat[4l] number o spaces where q-4,5 f.at[42] number o spaces where q-6,7 feat[43] ■ number of spaces where out_rot-0.1 feat[44] - number of spaces where out_rot-2,3 feat[45] ■ number of spaces where out_rot«4,5 feat[46] ■ number of spaces where out_rot"6,7 fββt[47] ■ number of min X. fβat[48] - number of max X. feat[49J - number of min Y. fβat[50] ■ number of max Y. feat[51] " sum length of spaces. feat[52] ■ relative position of spaces. /" M A I N F O R T E A C H I N G #include "main.h" •finclude "stdio.h" void main( ) { FILE *f_point ; struct FEATURES feat; struct FEATURES min_feat; struct FEATURES oax~feat; int featO; int first feat-1; int file_ήdxl « 2,file_ndx2-0; char Ctemp[10j; char Binfile[30].infile[3O].minfile[3O].oaxfile[3O]; char SymId[ll],BSyaId[ll]; /• Delete all the Space's files which hold the information of previous teaching •/ { FILE "PF; PF » fopen ("space","w");fclose (PF) ; } system ("del space*.*"); /"system ("del extrm.out"); system ("del feat.out") ;"/ /' Open the files containing the X.Y.Pen of the symbol's examples ' ' / strcpy (infile, "\\work\\sym\\sya") ; strcpy (Symld, "sya") ; for (file ndxl-G;file ndxKNUM SYMB0LS;file ndxl**] { itoa (filβ_ndxl.Ctemp.10) ; strcat (infile.Ctemp) ; strcat (Symld,Ctemp) ; strcat (infile,"."); strcat (Symld,"."); strcpy (Binfile.infile) ; strcpy (BSy ld,Symld) ; file_ndx2-Q: itoa (file_ndx2,Ctemp,10) ; strcat (infile,Ctemp) ; strcat (Symld,Ctemp) ; first fβat-1; while ( ransform(infile,Ifeat) ! -Θ) { strcpy(feat.IDfeat,Symld) ; / • print features (tfeat, "feat.out"); • / if (first_feat--l) { min_feat"feat; max_feat"feat; first_feat-0; } else 7* update minimum and maximum feature according to feature of current symbol */ calc_limits (4(min_feat) ,t(max_feat) .feat) ; strcpy (infile.Binfile) ; strcpy (Symld,BSynld) ; file_ndx2*<>; itoa~(file_ndx2,Ctemp,10) ; strcat (infile,Ctemp) ; strcat (Symld,Ctemp) ; } /• of while */ strcpy (min_feat.IDfeat,BSymld) ; strcpy (aax~feat.IDfeat,BSymld) ; if (firβt_fβat!-l) /* saves the min feature and max feature of the symbol to disk */ save_min_max (min_fβat,max_fβat) ; strcpy (infile,"\\work\\sym\\βym") ; exit (θ); } ■fincludβ "main.h" / • This procedure is to read the points of the symbol froa a file an d fill it in the array of coordinates : arr_cor. '/ int read_points (struct POINT arr_cor[] .char 'filename) { FILE *fpointer; unsigned int x,y,p; unsigned int prev_x,prev_y,prev_pen; unsigned int i>0,in*0; fpointer-fopen (filename, "r*") ; prev_y-y; prev pen a p; } } else in**; } arr_cor[i] .x_cor arr_cor[i-l].x_cor; arr_cor[i] .y_cor a arr_cor[i-l].y_cor; arr_cor[i].pen_status»0; fclose (fpointer); return (i) ; /* This module includes general purpose procedures which are : (1) def_quart : a funtion that recieves two numbers , and returns the quarter of these two numbers in the range of Θ-7. (2 div_round : a function to calculate the round number of the division of two integer numbers # / .•.include 'main.h" I - A funtion that recieves two numbers , and returns the quarter of these two numbers in the range of 0-7. int def_quart (x.y) int x; int y; { if ((x>0 ) ϋ (y—θ)) return (0) if ( >0 ) ϋ (y>θ) ) return (1) if ((x"0) it (y>ø) ) return (2) if ((x<0 ) ii (y>θ) ) return (3) if ((x<0 ) ii (y-"θ)) return (4) if ((x<0 ) ii (y<0) ) return (5) if ((x-"0) ii (y<0) ) return (6) if ((x>θ ) it (y<θ) ) return (7) return (15); A function to returns the round number of the division of two integer numbers. int div round (int a, int b) { int i-θ; int tempi,temp2; templ a a; tβap2 a b; return (MAXINT) ; b) 0) a- a b; else a* a b; i**J } if ((a*a)>b) i**; if (((templ>θ) (temp2>θ)) || ((teapKΘ) ii (tesp2<θ))) return(i) ; else return (-1); finclude "aain . h" calcualtes the space features of a symbol (called froi calc_features) . void calc space feat (struct TABLE EXTREMONS extr[],int extras struct FEATURES *fβat) int i-0; boolean arr_x_levels[l6] ; boolean arr_y_levels[l6] ; unsigned int aua a 0; for (i"0;i< a 15;i**) { arr_x_levels[i]-FALSE; arr y levelβ[i] a FALSE; } for (i a θ;i<extras;i**) { default } (•feat) .fβat[52] a div_round(8*βum. ( # fβat) .fβat[l]) ; for (i a θ;i<-15;i**) { if (arr x lβ«βla[i] aa TRUE) ((( fβat) ,fβat[4])**); if (arr " y " lβ"βlβ[i] aa TRUE) ( ( ( # fβat) .fβat[5])**) : > calcualtes the rotation features of a syabol called from calc_features ) . void calc_rot (struct TABLE_EXTREM0MS extr[].int extrms, struct FEATURES *feat) { int i; for (i»l;i<-extrms;i**) { switch (extr[i].in_rot) { C&Sβ 0 * i ( ( # feat) .feat[28])**; switch (extr[i].dir) { case 0 'feat) .feat[ 31]**;break; case 1 ( • feat) .featf31]**jbreak; case 2 ( • feat) .feat[32]**;break; case 3 (•feat) .feat[32]**;break; case 4 (•feat) . featf33]** .break; case 5 ( • feat) .feat[33]**;break; case 6 ( • feat) .featf34]**;break; case 7 (•feat) .feat[34]**;break; default break; } case 1 : ( ( # feat) .feat[29])**; break; case 7 ■ (( • feat).feat[30])**; break; default. break ; } if ( (extr[i-l].pen_sts*extr[i].pen_sts)« 2) { switch (extr[i].out_rot) { (•feat) .fββt[35]** break; ( • feat) .feat[35]** break; ( • feat).feat[36]** break; ( • feat) .feat[36]** break; (•feat) .feat[373** break; (•feat) .feat[37]** break; (•feat) .feat[38]** break; (•feat) .feat[38]** break; break; } if " ( (βxtr[i-l].pen_βts*βxtr[i].pen_sts) -l) { switch 4extr[i].out_rot) { ( • feat).feat[43_* + (•feat).fβat[43]*» (•fest).fβat[44]** (•fβat).fβat[44]** ( • feat).fβat[453** case 5 : (*fβat) .feβt[45]**; case 6 : (*feat) . feat[46]**; case 7 : (*feat) .feat[46]+*; calcualtes the extreaua type features of a syabol, (called from calc_features) . void calc_βxt_typββ (struct TABLE_EXTREMOMS βxtr[],int extras, struct FBATURES *feat) { int i a 0; boolean arr_x_levels[l6]; boolean arr_y_lβvβlβ[l6]; for (i a 0;i< a 15;i**) { arr_x_levels[i]«FALSE; arr~y~levela[i]-FALSE; } for (i l;i<extras;i**) if I(I{(extr[i].dir aa 3)«-M(extr[i*l].dir aa l) || (βxtr[i*l].dir -2))) ((extr[i].dir aa 7)ii((«xtr[i*l].dir- a 5) || (βxtr[i*l].dir«6)))) if ( (βxtr[i-l].pen_βtβ*βxtr[i].pen_ats)-"2) for (i-0;i<-15;i**) { arr_x_lβvβlβ[i]-PALSE; arr y lβvβls[i]-FALSE; } for (i-l;i<βxtraβ:i**) if ( (extr[i].dir--5)iK(«tr[i*l].dir « 7) II (βxtr[i*l].dir--6)) ) ((βxtr[i].dir--3)l.<M(βxtr[i*l].dir--l) || (βxtr[i*l].dir--2))) ((βxtr[i].dir--5) ϋ (extr[i*l].dir--l)) | ((extr[i].dir--3) (βxtr[i*l].dir « 7))) if ( (βxtr[i-l].ρβn_βtβ*βxtr[i].pen_βts)-"2) { arr_x levβls[extr[i] ,x_cor] - TRUE; arr~y~lβvelβ[βxtr[i].y_cor] - TRUE; for (i-θ:i<"15:i**) { if (arr x lβvels[ i]--TRUE) ( ( ( # fβat ) . fβat[7] ) ♦♦ ) ; if (arr y levβlβ[i]--TRUE) ( ( ( # fβat) . fβat[8] ) ♦♦ ) ; for (i-0;i<-15;i**) { arr_x_levels i]-FALSE; arr y levelβ[i]-FΛLSE; } for (i » l;i<βxtras;i**) if | ( (extr[i].dir"-l)ii((extr[i*l].dir--3) II (βxtr[i*l].dir«-2)) ) (extr[i].dir--5)44((βxtr[i*l].dir--6) || (extr[i*l].dir--7)) )) { if ( (extr[i-l].pen_sts*extr[i].pen_sta)--2) { ((•f β at).f β at[9]**); arr_x_levels[extr[i].x_cor] ■ TRUE; arr_y_lβvelβ[βxtr[i].y cor] - TRUE; for (i-θ;i<-15;i**) { arr_x_levβls[i]-FALSE; arr y~levels[i]-FALSE; } for (i-l:i<extras;i**) if ((extr[i].dir--7)«.M(extr[i*l].dir--5) II (βxtr[i*l].dir«6)) ) βxtr[i].dir--l)ii((βxtr[i*l].dir--3) || (βxtr[i*l].dir--2)) ) ((βxtr[i].dir--l) ii (βxtr[i*l].dir--5) ) II ((extr[i].dir--7) ii (extr[i*l].dir--3) ) ) if ( (extr[i-l].pen_sts*extr[i].pen_sts)--2J { arr_x_levβls[βxtr[i].x_cor] - TRUE; βrr ZyI lβvβlβ [ βxtr ti]-y_cor] - TRUE; } for (i-θ.;i<-15:i**) { if (arr x levβls[i]«TRUE) ( ( ( # feat) .fβat[10])**) ; if (arr " y~lβvβlβ[i]«TRUB) ( ( ( feat) .fβat[ll])**) ; } for (i-θ;i<-15;i**) { arr x lβvβlβ[i]-PALSE; arr " y~lβvβlβ[i]-FALSE; } fo l].dir--3) || (βxtr[i*l] .dir--4) ) ) ].dir--7) || (extr[i*l] .dir«0) ) ) ) .pen_sts)--2) for (i-0;i<-15;i**) { arr_x_levels[i]-FALSE; arr y levels[i]-FALSE; } • for (i-l;i<extras;i**) if ((extr[i].dir « 7)il((extr[i*l].dir « l) || (βxtr[i*l].dir«θ))) (extr[i].dir--5)ii((extr[i*l].dir--3) || (extr[i*l].dir«4)) ) (extr[i].dir--5) ii (extr[i*l].dir--l) ) || ((extr[i].dir « -7) ii (extr[i*l].dir--3) ) ) if ( (extr[i-l].pen sts*extr[i].pen_sts)--2) { arr_x_lβvβlβ[βxtr[i].x_cor] - TRUE; arr_y_lβvβlβ βxtr[i].y_cor] - TRUE; } for (i-0;i<-15;i**) { if (arr_x lβvβlβ[i]--TRUE) ( ( ( # fβat) . feat[13] ) ♦♦) ; if (arr y lβvβls[i]«TRUE) ( ( ( » feat) .fβat[l4])**) ; > for (i-θ;i<-15:i**) { arr_x levels[i]-FΛLSE; arr y~levels[i]-FALSE; } for (i-l;i<βxtraβ:i**) if (((extr[i].dir--3)ii((extr[i*l].dir«5) || (extr[i*l].dir--4))) I (I(βxtr[i].dir--7)U.((βxtr[i*l].dir--l) || (βxtr[i*l].dir--θ)) ) ) if ((βxtr[i-l].pβn βtβ*βxtr[i].pβn_βta)--2) ( # fβatl.f β at[15Ϊ**: j r for (i-θ;i<-15;i**) { arr x levels[i]-FALSB; arr " y " lβvelβ[i]-PALSB; } for (i-l;i<extras;i**) if (((extr[i].dir--l ) ii( ( extr[i*l].dir--7) || (extr[i*l ] .dir«0) ) ) ( ( extr[i].dir--3)ii((extr[i*l].dir--5) || (extr[i * l] .dir--4 ) ) ) ((extr[i].dir--l) ii (extr[i*l] .dir--5) ) || ((extr[i]-dir--3) ii (extr[i*l] ,dir--7) ) ) { if ( (extr[i-l].pen_stβ*extr[i].pen sts)--2) { arr_x_levels[extr[i] .x_cor] « TRUE; arr y levβls[extr[i].y_cor] - TRUE; } } for (i-0;i<-15;i**) { if (arr x levels[i]--TRUE) ( ( (*feat) .feat[l6])♦♦) ; if (arr y_levels[i]--TRUE) ( ( ( # feat) . feat[17])♦♦) ; } /' for (i-0;i<-15;i**) { arr_x_levels[i]-FALSE; arr y lβvβls[i]-FALSE; } fo )--2) for (i-0;i<-15:i**) { if (arr x levels[i]"TRUE) ( { ( » feat) .feat[19]) ♦ ♦) : if (arr~y~lβvels[i]"-TRUE) { ( {»feat) .fβat[20])**) ; } /' for (i-θ;i<-15;i**) { arr_x_lβvels[i]-FALSE; arr y levels[i]-FALSE; } for (i-l;i<extraβ;i**) if ( (extr[i].out rot--3) II (βxtr[i].out rot « 4)) { if ( (βxtr[i-l].pβn sts*extr[i].pen sts)--2) { ( • feat) .feat[21]**; arr_x_lβvels[extr[i] .x_cor] ■ TRUE; arr y levels[extr[i] .y cor] - TRUE; ) } for (i-0;i<-15:i**) { if (arr_x_levels[i]--TRUE) ( ( { # feat) . feat[22])♦♦) ; if (arr_y_levels[i]--TRUE) ( ( Cfβat) .fβat[23])**) ; /' calcualtes the arc features of a syabol, (called from calc_features) . void calc arcs (struct TABLE EXTREMOMS βxtr[],int extras, 7 struct FEATURBS *feat) { int i-0; int J-0; while (Kextras) if ((βxtr[i].in rot--7) II (βxtr[i].in rot--l)) { {(•feat) .fβat[24])**; while ((βxtr[i].in rot--7) II (βxtr[i].in rot--l)) i**; } i**; } ot--7) {j**;i**;} rof-1) --l) {J**;i**;} fβat).fβat[25])*(int)(j/4); / calculates the levels features (number of diufferent levels) of a syabol (called from calc_features) . void calc syabol_levels (struct TABLE EXTREMOMS extr[],int extras, struct FEATURES # feat) { int i-0; boolean arr_x_levels[l6] ; boolean arr_y_lβvels[l6] ; for (i-0;i<-15;i**) { arr_x_lβvelβ[i]-FALSE; arr y levβlβ[i]-FALSE; } for (i-θ;i<-extras;i**) { arr_x_levelβ[βxtr[i] .x_cor] - TRUE; arr y lβvβlβ[βxtr[i].y~cor] - TRUE; } for (i-0;i<-15;i**) { if (arr x lβvβls[i]--TRUE) ( ( (*fβat) .feat[26])**) ; if (arr y levelβ[i]"TRUB) ( ( (*feat) .fβat[27])♦♦) : } calculates the nuaber of ainuaums/maximums in X and Y. (called from calc features). ••••••••••••••••••••••<_.•••••••••••••••••••••••••••••••••••.•••••••( void calc nua ainmax (struct TABLB EXTREMOMS βxtr[],int extrms, struct FEATURES *fβat) { int i; for (i-l;i<extrms;i**) { .pen sts)--2) || if (((βxtr[i].dir « 7)ti(( β xtr[i*l].dir « 5) II (extrti*l].dir«6))) || ((extr[i].dir--l)tt((extr[i*l].dir « 3) 11 (βxtrti*l].dir«2))) || ((βxtr[i].dir--l) tt ( β xtr[i*l].dir « 5)) II { (βxtr[i*l].dir--3) ) ) if ( || | | ) ) )) ) if ((( β xtr[i].dir--l)it((extr[i*l].dir--7) || (extr[i*l].dir--0))) || ((extr[i].dir--3)it((extr[i*l].dir--5) || (βxtr[i*l].dir--4))) || ((extr[i].dir--l) ii (extr[i*l].dir--5) ) | (( β xtr[i].dir--3) it ( β xtr[i*l].dir « 7) )) (•f β at).f β at[5θ]**! calculates the features of a syabol depending on the extreauas of that syabol , and fills in the structure variable: feat. ▼old calc features (struct FEATURES 'feat,int points, struct TABLB_BXTRENOMS extr[]. int extras.int featθ) int i; /• initialization •/ for (i-0;i<NUM_FEAT;i**) ( fβat) .fβat[i]-θ: (•feat) .fβat[θ] - fββtO ; (•feat) .fβat[l] - points ; (•feat) .fβat[2] - extras ; calc_βpacβ_fβat (extr,extras.feat) ; calc~rot Textr,extras,feat) ; calc~βxt_typβa (extr.extras, eat) ; cale ' aroβ (extr.extras.feat) ; cale~syabol_lβvels (extr,extras. eat) ; cale ' nua ainmax (extr,extras,feat) ; /• This aodule is for calculating and aanipulatlng extreauas . it includes four procedures : (1) calc_extreauas : To find the extreauas of the syabol , and the "change in pen" points. (2) find_aax_extra : To find the aax/ain X-coordinate and the aax/ain Y-coordinate of the syabol. (3) analyse_βxtreauas : A procedure to analyse the extreauas found so far, mainly this procedure aarks close extreauas as suspecious extreauas. (4) conv21evels : Replaces the actual coordinates of the extreauas in arr_extrβauas with the levels of these coordinates by doing quantization, (there are 16 levels). •/ finclude "aaln.h" / The input of this procedure is the array of coordinates which holds the coordinates of the syabol , and the nuaber of these points , it fills the special of points (i.e. , extreaumβ or change in pen) in the array arr_extreauas , it returns the nuaber of special points it found. 7 int calc_βxtrβmomβ (struct TABLE_EXTREMOMS arr_extreaoms[], ~ struct POINT arr_cor[],int nua_of_points) { unsigned int indE; unsigned int ndx; unsigned pβn_waβ_up; int crnt_quart,prev_quart; int crnt_rot,prβv_rot; int Sx.Sy.PSx.PSyTa.b; int firβt_point-l; int Pndx-Θ; unsigned int LastNdx; int i; indE-θ; ndx-θ; pen was up-1; Sx-0; Sy-Θ; PSx-θ; PSy-θ; a-θ;b-θ; while (ndx<nua_of_points) while (farr co [ndx].pen status)--l) Sx-(arr_cor[ndx*l] .x_cor-βrr_cor[ndx] .x_cor) ; Sy- (arr_cor[ndx*l] .y_cor-arr_cor[ndx] .y~cor) ; tSx"(arr_cor[ndx*2] .x_cor-arr_cor[ndx*l] .x_cor) ; tSy « (arr_cor[ndx*2] .y_cor-arr cor[ndx*l].y cor); a-Sx*tSy-Sy tSx; b-Sx*tSx*Sy*tSy; PSx»Sx; PSy«Sy; } else { /• for the previous ENDING extremom */ Sx"(arr_cor[ndx] .x_cor-arr_cor[Pndx] .x_cor) ; Sy-(arr_cor[ndx] .y_cor-arr_cor[Pndx] .y_cor) ; PSx » (arr_cor[Pndx] .x_cor-arr_cor[Pndx-Ϊ] ,x_cor) ; PSy » (arr_cor[Pndx].y_cor-arr_cor[Pndx-l].y~cor) ; a"PSx*Sy-PSy*Sx; b-PSx*Sx*PSy*Sy; arr_extreaoBs[indE] .p_ndx«Pndx; arr_extreaoas[indE],x_cor»arr_cor[Pndx].x_cor; arr_extr β BθBs[indE] .y_cor e arr_cor[Pndx] .y~cor; arr_extremoes[indE].pen_st8-Θ: ~ arr_extreaoas[indE] .dir-dβf_quart(PSx.PSy) ; arr extreaoa8[indE].out_rot-def quart(b.a); { int PPSx.PPSy; PPSx"(arr_cor[Pndx-l].x_cor-arr_cor[Pndx-2] .x_cor) ; PPSy M (arr_cor[Pndx-l].y_cor-arr_cor[Pndx-2].y~cor) ; a-PPSx*PSy-PPSy*PSx; b-PPSx*PSx*PPSy PSy; arr extrβaoas[indE] .in rot-def quart(b.a); } indE-->; PSx-Sx; PSy«Sy; { int tSx.tSy; Sx-(arr_cor[ndx*l] .x_cor-arr_cor[ndx].x_cor) ; Sy-(arr~cor[ndx*l] .y_cor-arr_cor[ndx] ,y_cor) ; tSx"(arr_cor[ndx] .x_cor-arr_cor[Pndx] .x_cor) ; tSy»(arr~cor[ndx].y~cor-arr_cor[Pndx].y_cor) ; a-tSx*Sy- tSy*Sx ; b-tSx*Sx*tSy*Sy ; } crnt_quart-def_quart (Sx , Sy) ; crnt~rot-dβf_quart ( b , a) ; arr_extre«oes[indE] . p_ndx«ndx ; arr~extre«OB8[ indE] .x_cor»err_cor[ndx] . x_cor ; arr~extrββ θB «[indE] . y~cor"βrr_cor[ndx] . y_cor; arr~extreBOBs[ indE] . pen_et«"l ; if Tfi-f8t_poinf l ) { arr_extrβBθBβ[ indE] . dir"15 ; arr~extreBθBβ[ indE] . in_rof l5 ; arr~βxtrβBθBβ[ indE] . out_rot » 15 ndx**; first point-θ; } else { arr_extremoas[indE].dir-def_quart(PSx,PSy) ; arr_extreaoas[indE] .in_rot-0; arr_extreaoas[indE].out_rot-def_quart(b,a) ; indE**; pen_was_up-0; } else { crnt_quart-dβf_quart(Sx,Sy) ; crnt_rot-def_quart(b,a) ; if (T (crnt_quartl-prev_quart) || ( (crnt_rot>-47 tt (prev rot<4)) || ((crnt~rot<4) tt (prev rot>-4)) ) tt (pr β v_rot!-15)) { /• regular extreaoa •/ if ((abβ(Sx)>0) tt (abβ(Sy)>θ) || (b<8)) { if ((ndx-1-arr extreaoas[indB-l].p ndx)>0) { arr_extreaoas[indE]. _ndx-ndx-l; arr_extreaoas[indE].x_cor-arr_cor[ndx-l].x_cor; arr_β treaoas[indE].y_cor-arr^cor[ndx-1]. ^cor; arr_extreaoas[indE].pen_sts-l; ~ arr_extreaoas[indE].dir-prβv_quart; arr_extreaoas[indE].in_rot-prβv_rot; arr_extreaoas[indE].out_rot"crnt_rot; indE**; } } } } ndx**; Sx"(arr_cor[ndx].x_cor-arr_cor[ndx-l].x_cor) ; Sy-(arr~cor[ndx].y_cor-arr_cor[ndx-l].y_cor) ; a«PSx*Sy-PSy*Sx; b-PSx # Sx*PSy*Sy; } /* Add the last special point to the array */ arr_extremoms[indE] .p_ndx-LastNdx; arr_extremoms[indE].x_cor-arr_cor[LastNdx] .x_cor; arr_βxtremoms[indE] .y_cor-arr_cor[LastNdx] ,y~cor; arr_extreaoas[indE],pen_βts-0; Sx-Tarr_cor[LaβtNdx-l] .x_cor-arr_cor[LastNdx-2],x_cor) ; Sy-(arr_cor[LastNdx-l] .x_cor-arr_cor[LastNdx-2].x~cor) ; PSx- ( arr_cor[LastNdx-2] .x_cor-arr_cor[LastNdx-3] .x_cor) ; PSy- ( arr_cor[ LaβtNdx-2] . y_cor-arr_cor[ LaβtNdx-3] .y~cor) ; arr_βxtrβaoBs [indE] . dir-dβf_quartTSx,Sy) ; a-PSx*Sy-PSy*Sx; ~ b-PSx Sx*PSy*Sy; arr_extreaoas[indE].in_rot-def_quart(b,a) ; arr_extremoms[indE].out_rot-15T return (indE) ; / This procedure is to find the max/min X-coordinatβ and the aax/ain Y-coordinate of the syabol. void find_max_6xtra (struct TABLE_EXTREMOMS arr_extremoms[], int nua of extras,int 'Xain.int *Xmax, int •Ymϊn.ϊnt # Yaax) { unsigned int i-0; •Xmin-12θθ; •Xaax-Θ; •Yain-1200; •Yaax-Θ; while (i<-num of extrms) { if (arr_βxtrβmomβ[i].x_cor< # Xmin) # Xmin"arr_extremoms[i] .x_cor; if (arr~βxtrβmomβ[i].x cor>*Xmax) *Xsax-arr_extreβoms[i].x_cor; if (arr xtrβaomβ[i].y~cor< # Ymin) Ymin-arr_βxtrβmoms[i] .y_cor; if (arr~βxtrβaomβ[i].yZcor> Ymax) •Ymax-arr~βxtrββomβ[i].y~cor; ! ♦♦ ; > correct dir,ln_rot,out_rot for suspicious points , called from analyse_extreauas void correct extrm (struct POINT arr cor[], struct TABLB_EXTREMOMS βxtrm[], struct TABLE~EXTREMOMS arr_βxc_βxtra[], int i.int PiTint j) { int Sx.Sy.PSx.PSy; int ndxl,ndx2; int a,b; ndxl-extrm[Pi] .p_ndx; ndx2-extrm[i] .p ndx; if (POO) { if (extrm[Pi-l] .pen sts--0) { PSx-arr_cor[ndxl].x_cor-arr_cor[extrm[Pi-l] .p ndx].x cor; PSy-arr_cor[ndxl].y_cor-arr_cor[extra[Pi-l].p2ndx].y~cor; else { PSx-arr_cor[ndxl].x_cor-βrr_cor[ndxl-l].x_cor; PSy-arr_cor[ndxl] .y_cor-arr~cor[ndxl-l].y_cor; } else {PSx-θ ; PSy-0 ; } Sx-arr_cor[ndx2] . x_cor-arr_cor[ndxl ] . x_cor ; Sy-arr_cor[ndx2] . y_cor-arr2cor[ndxl ] . y3cor; a-PSx*Sy-PSy*Sx; b-PSx*Sx*PSy*Sy; if (arr_exc_extra[J-l].out_rot!-15) arr_βxc_βxtra[J-l],out_rot-dβf_quart(b,a) ; PSx-Sx; PSy-Sy; arr_exc_extra[j] .dir-def_quart(PSx,PSy) ; arr_exc_extra[j] .in_rot-0; if (arr exc_extra[j].out rot!-15) { if (extra[i].pβn s-ts--θ) { Sx-arr_cor[βxtra[ i*l] . p_ndx] .x_cor-arr_cor[ndx2] . x_cor; Sy-arr_cor[βxtrB[i*l ] . p_ndx] .y~cor-arr~cor[ndx2] . y cor; } " else { Sx-arr_cor[ndx2*l ] . x_cor-arr_cor[ndx2] .x_cor; Sy-arr cor[ndx2*l ] .y cor-arr cor[ndx2] .y~cor; } " a-PSx*Sy-PSy*Sx; b-PSx*Sx*PSy*Sy; arr βxc βxtra[j].out rot-dβf quart(b,a); } A procedure to analyse the extreauas found so far , aainly this procedure aarks close extreauas as suspeclous extreauas. 7 int analyse extreaoas (struct POINT arr_cor[], struct TABLE_EXTREMOMS extra[], struct TABLB~EXTRBMOMS arr_βxc_βxtra[], int nua of extras) { int i.J-θ; int count-θ; int Pi-0; boolean FirstP-TRUE; for (i-l;i<num of extrms ;i* * ) { if ( ( (extrm[i].x_cor-extrm[i*l]. χ _cor)<2 || (extrm[i].y_cor-extrm[i*l] .y_cor)<2) it (extrm[i] .in_rot!-extrm[i*l]7in rot) tt (extrmfi] .dir«extrm[i*l] .dir) tt (extrm[i] .pen_sts«l) tt (extrm[i-lJ.pen_sts!-0) ) extrm[i].susp-1; else {extrm[i] .βusp-0;count**; } } extra[0] .susp-θ; extra[i] .susp-0; /•count**;*/ for (i"0;i< « nua of extrmsji**) { " " if (extrm[i] .SUSP--0) { arr_exc_extrm[j] .p_ndx-extrm[i].p_ndx; arr_ β xc_extra[j].x_cor"extrm[i].x~cor; arr_exc_extra[j] .y_cor"βxtrm[i].y~cor; arr_exc_extrB[j] .pen_sts » extra[i]7pen_sts; arr_exc_extra[j].dir « extra[i].dir; arr_exc_extra[j].in_rot -extrm[i].in_rot; arr_exc extrm[j] .out_rot-extrm[i].out rot; if (FirstP«FALSE) { correct_extra (βrr_cor,extra, arr_exc_extra,i,Pi,j) ; firstP-TRUE; } if (extra[i].pen sts--0) FirstP-TRUE; } else { if (FirstP) Pi-i-1; FirstP-FALSE; } } { /•FILE # fp; fp-fόpen ( "extra.out" , "ab*") ; for (i-θ;i<-count;i**j { fprintf (fp,"*d %d %d %d %d %d %d \n", arr_exc_extra[i] .p_ndx,arr_exc_extra[i].x_cor, arr~exc~6xtra[l] ,y_cor,arr_βxc_extra[i] .pen_stβ, arr~exc~βxtra[i] .dϊr,arr_exc_extra[i] .in_rot, arr exc extra[i].out rotj; T " fprintf ( ^ . "••••••••••••••••••••• ♦ •••••••••••••••••\n" ) ; fclosβ ( fp ) ; # / ) return (count) ; find_max_β tr (arr_βxtrβmoms,nus_of_β tras,tXaln,tXaax,tYnin,tYaax) ; x_width-Xaax-Xmin; y~width-Yaax-Ymin; while (i<-num_of_βxtraβ) { arr βxtrβmoms[l].x cor-div round((arr extremomβ[i].x_eor- XBiή) # ORID,x_wϊdth); arr extreaoas[i],y cor-div round((arr extreaoas[i].y_cor- Ymin) QRID,y_width); ! ♦♦ ! } (•fβatθ)-div_round(5θ # x_width,y_width) ; .♦include "aain.h" void print_fβaturββ (struct FEATURES *feat,char filβnaaβ[]) FILE *fp; int i; fp-fopen (filename,"ab*") fprintf (fp,"number of linear strokes •≠d\n",( # feat).featlθ); fprintf (fp,"nuaber of linear strokes where dir<4 fprintf (fp,"nuaber o inear stro es w ere dir>-4 fprintf ( fprintf ( fprintf (fp,"nuaber of strokes ro<4 -Xd\n", ( feat).featl3); fprintf (fp,"nuaber of strokes ro>-4 fprintf (fp fprintf (fp fprintf (fp, di f. evels n or m n fprintf (fp,"nuaber of Ext in X pos. rot. fprintf (fp,"diff. levels in X for maxX fprintf (fp,"diff. levels in Y for maxX fprintf (fp,"number of Ext in Y neg. rot. fprintf (fp,"diff. levels in X for minY fprintf (fp,"diff. levels in Y for minY fprintf (fp,"number of Ext in Y pos. rot. -*d\n". (*fβat) .fβat32) ; fprintf (fρ,"diff. lβvβlβ in X for aaxY -≠d\n", ( # fβat) .fββt33) ; fprintf (fp,"diff. levels in Y for aaxY -Xd\n", (*fβat) .fβat34) ; fprintf (fp, "nuaber of ext XY for neg. fprintf (fp, "different levels in. X for fprintf (fp,"different levels in Y for fprintf (fp,"nuaber of ext XY for poβ. rot fprintf (fp,"different lβvβlβ in X for fprintf (fp,"different lβvβlβ In Y for fprintf (fp,"nuaber of arc partβ -JSd\n", (*feβt) .fββt65) ; fprintf (fp,"nuaber of circle partβ -*d\n", (*fβat).fββt66); fprintf (fp,"nuaber of different X-levelβ -≠d\n", (*fβat) .fβat67); fprintf (fp,"nuaber of different Y-levelβ -*d\n", (*fβat) .fββtδβ): fprintf (fp,"βua of βquare wβightβ ■JCd\n", (*feat) .βua_βqr_w t);•/ fprintf (fp,"\nj.β\n",( # fβat).IDfeat); for (i-θ;i<NUM_FBΛT;i**) fprintf (fp."%3d". ( fβat) .fβat[i]) ; if ((1--2Θ) || (i--*»θ)) fprintf (fp,"\n"); } fcloββ (fp); } (.include "aain.h" int transform(char infilβ[30].struct FEATURES 'feat) { struct POINT arr_cor[MAX_NUM_0F_P0INTS]; / • array of coordinates •/ struct TABLE_EXTREMOMS arr_extremoms[MAX_NUM_OP_EXTREMOMS]; /• array of special points (i.e. extreauas , " changing of pen position */ struct TABLE_EXTREMOMS arr_exc_extras[MAX_NUM_OF_EXTREMOMS]; /* array of excluded extreauas . it Is excluded froa the array of extreauas by excluding close points •/ int featθ; int nua_of_pointβ,nua_of_extras,exc_nua_extras; / Reading a file and calculate the nuaber of points for the syabol,and stores the points read in the array : arr cor . * / nuB_of_pointβ-rβad_points (arr_cor,infile) ; if Tnua_of_pointβ--θ) return (θ) ; / Calculates the extreauas froa the array of coordinates , and stores it in the array : arr extrβmuβa , the function returns the nuaber of extreauas it calculated , and it is stored in nua of extras. » •• » ••••••••• • •••• / nua_of_extraβ-calc_extrβaoas (arr_extreaoas,arr_eor,nua_of_points); / Replaces the actual coordinates of the extreauas in arr_extreauas with the levels of these coordinates by doing quantization, (there are 16 levels) / conv21evβlβ (arr_βxtrβaomβ,num_of_βxtrms,tfoatθ) ; / Excludes close points in the extreauas array and stores the reaaining extreauas in arr_βxc_extras , it returns the nuaber of extreauas left after excluding. / exc_nua_extras-analysβ.extreaoaa (arr_cor,arr_extreaoas, arr_βxc_βxtrmβ,nun_of_βxtrmβ) ; / calculates the features of the syabol , and stores It in the structure variable feat. / calc features ( i(*faat),nu B _of_pointB,arr_βxc_βxtrBβ,βxc_nuB_βxtraβ,fβatθ) ; return (nua of points); } ■-.include "aain.h" / a procedure to update the minimum and maxiaua liaits of a syabol according to features of entered symbol (i.e. : feat) void calc_limits (struct FEATURES *min_feat,struct FEATURES "max feat, struct FEATURES feat) { int i; for (i-0;i<NUM_FEAT;i**) { if ((feat.feat[i])<((*min feat) .fβat[i]) ) ( (*min_feat) .feat[i])-Tfeat.feat[i]) ; if ((feat.feat[i])>((*aax_feat) .feat[i])) ( ( aax_feat) .feat[i])-(feat.feat[i]) ; } } /' Saves minimum and maximum features of a syabol do disk (i.e. spaces files) / void save_βin_aax (struct FEATURES ain_feat, struct FEATURES max_feat) { FILE *fp; char space[8] ,Ctemp[8]; int teap; strcpy (space,"space") ; tβap-ain_feat.fβat[3]; itoa (tβap.Ctββp.lO) ; strcat (space,Cteap) ; ,l,fp) ; ,l.fp) ; #include <stdio.h> ^include <stdlib.h> #include <math.h> #include <conio.h> #include <values .h> #include <meo.h> #include <string.h> #include <process .h> #define GRID 15 #define MAX_NUM_0F POINTS 1000 #define MAX_NUM_OF~STROKES 64 #define MAX NUM_0F EXTREMOMS 32 #define NUM~FEAT 53 fdefine NUM SYMBOLS 72 #define DIVΪSER 6 #define TRUE 1 fdefine FALSE 0 typedef int boolean; struct TABLE_STROKES_NEW { unsigned strk_nua int delta_x int delta_y unsigned lenght unsigned pen_status int rotation } struct POINT { unsigned x_cor 10; unsigned y_cor 10; unsigned pen_status 4; > : struct TABLE EXTREMOMS { struct FEATURES { char IDfeat[llj; /• Id feature for naae */ unsigned int feat[NUM_FEAT] ; }; fβat[43] - number of spaces where out_rot-0.1 feat[44] ■ nuaber of spaces where out_rot-2,3 feat[45] " number of spaces where out_rot-4,5 feat[46] - nuaber of spaces where out_rot-6,7 feat[47] - number of min X. fβat[48] - number of max X. feat[49] - number of min Y. fβat[50] - number of max Y. fβat[51] - aum length of spaces. feat[52] - relative position of spaces. M A I N F O R R E C O G N I T I O N (.include "main.h" (.include <stdio.h> The program reads the file temp.ltr from the disk , and calculates the matching probability for every symbol to the symbol defined in the file temp.ltr , and then stores the vector of probabilties for all symbols in the file data.in . void aain() { FILE # fp ; struct FEATURES feat; struct FEATURES ain_feat; struct FEATURES aax ' feat; /• Vector of probabilties , for each syabol we calculate that the aatching probability between it and the syabol defined in teap.ltr •/ struct { char name[9]; int prob; } vβctor[NUM_SYHBOLS]; int index; int spacβs-0; int prob-θ; char filenaae[ll]; char Snaae[8]; char Ctemp[10]; char spacβfilβ[ll]; char infile[ll]; system ("del feat.out"); for (i-θ;i<-NUM SYMBOLS;i**) { char SyaName[2θ]; char Cteap[8]; strcpy (SyaNaae,"sya") ; itoa (i,Ctemp,10) ; strcat (SymNaaβ,Ctemp) ; strcat (SymNamβ,"."); strcpy(vector[i].name,SymNamβ) ; vector[i].prob-θ; strcpy (filename. "temp.ltr") ; strcpy (infile,filenaae) ; /• get features of symbol in file: infile •/ transform (infile,tfeat) ; strcpy (feat.IDfeat,infile) ; spaces-feat.feat[3] ; itoa (spaces,Ctemp,10) ; strcpy (spacefile,"space") ; strcat (spacefile,Cteap) ; /* Open space file which corresponds to the syabol represented in the file temp.ltr */ if ((fp-fopen(βpacefile,"rb*"))I-NULL) { /* for every symbol with the saae nuaber of spaces gee ainiaua and maximum features •/ while ((freed (t(βin_fβat) .sizβof(min_feat) ,1,fp))>θ) fread (t(aax_feβt) .sizβof(mβx_fβat) .l.fp) ; n_sp_sym**; /* calcualte the probability of recognition of syabol */ strcpy(feat.IDfeat,nin_feat.IDfeat) ; prlnt_features(tfeat, "feat.out") ; strcpy (feat.IDfeat,infile) ; prob-rec (feat,ain_fβat,max_fβat) ; /• fill the probability in the appropriate index in the vector of probabilities for all the symbols */ for (indβx-G;indβx<-NUM_SYMB0LS;index**) if (strcap(min_fβat.IDfeat,vβctortindβx].name) -- 0) { vector[indexJ.prob - prob ; break: } } fclose (fp); } /• Save vector of probabilities to disk */ fp-fopen ("date.in","w*") ; for (index-0;index<NUM_SYMBOLS;index**) fprintf (fp,"Jtd j-d\n",index,vβctor[indβx].prob) ; fclose (fp); exit (θ); } # include " main . h " / • This procedure is to read the points of the symbol from a file , an d fill it in the array of coordinates : arr cor. V int read points (struct POINT arr cor[],char 'filename) { FILE • fpointer; unsigned int x.y.p; unsigned int prev_x,prev_y,prev_pen; unsigned int i-θ,in-θ; fpointer-fopen (filename, "r * ") ; prev_x-0; prev_y-0; prev pen-0; while ( (fscanf(fpointer."Xd %d Xd" ,tx.ty,tp)>0) tt (p--0)); while (fscanf(fpointer,"Xd Xd Xd".tx.ty,tp) > 0) { if (in/DIVISER DIVISER -- in) { in**; arr_cor[i] .x_cor-x; arr_cor[i] .y_cor-y; arr_cor[i] .pen_status-p; if T((abs(prev x-x)*abs(prev y-y))>3) I I (prev pen!-p)) { ! ♦♦ ; prev_x-x; prev_y-y; prev_pen-p; > } else in**; } arr_cor[l] .x_cor-arr_cor[i-l].x_cor; arr_cor[i] .y_cor-βrr_cor[i-l].y_cor; arr_cor[i] .pen_status-θ; fclose (fpointer); return (i) ; /• This aodule includes general purpose procedures which are : (1) def_quart : a funtion that recieves two numbers , and returns the quarter of these two numbers in the range of 0-7. (2) div_round : a function to calculate the round nuaber of the division of two Integer nuabers -I {.include "aain.h" /« A funtion that recieves two nuabers , and returns the quarter of these two numbers in the range of 0-7. int def_quart (x,y) int x; int y; { if ((x>0 ) it (y--0)) return (0) if ((x>0 ) tt (y>θ) ) return (1) if ((x--θ) tt (y>0) ) return (2) if ((x<0 ) tt (y>0) ) return (3) if ((x<0 ) tt (y--θ)) return (4) if ((x<0 ) ii (y<0) ) return (5) if ((x--0) tt (y<0) ) return (6) if ((x>0 ) tt (y<0) ) return (7) return (15): A function to returns the round number of the divlaion of two integer numbers. int div round (int a. int t>) { int i-0; int tempi, cβmp2; teapl-a; teap2-b; a-abs(a) ; if (b--θ) return (MAXINT) ; whilβ(a>b) { if (b>0) a--b; else a*-b; i**; } if ((a*a)>b) i**; if (((tβapl>0) it (teap2>0)) ((tβapKΘ) tt (teap2<θ))) return(l) ; else return (-1) ; } if inelude "aaln . h" calcualtes the space features of a symbol , ( called froa calc features ) . void cβlc_spβcβ_feat ( s truct TABLE EXTREMOMS extr[ ] , int extras s truct FEATURES feat ) { int i-0 ; boolean arr_x_levelβ[l6] ; boolean arr_y_levelβ[l6] ; unsigned int sua-0; for (i-θ;i<-15;i**) ( arr_x_levβls[i]-FALSB; arr_y_levβls[i]-FALSE; } for (i-0;Kextras;i**) { if (βxtr[i].pen_βts--0) { (•feat) .feat[51]"(*fβat) .fβat[51]* (βxtr[i*l].p_ndx-extr[i]. _ndx) ; sua*-extr[i].p_ndx; {(•feat).feat[3]**. : arr_x_lβvβlβ[βxtr[i*l].x_cor]-TRUE; arr~V~levβlβ[βxtr[i*l].y cor]-TRUE; switch (βxtr[i*l].dir) { "" (•feat) .fβat[39]**; break; (•feat) .fβat[39]**; break; (•feat) .fβat[4θ]**; break; (•feat) ,fββt[4θ]**; break; (•fβat).fβat[4l]**; break; (•fβat).fβat[4l]**; break; (•feat).feat[42]**; break; (•feat) .fβat[42]**; break; break; } } (•feat) .fβat[52]-div_round(8 » sum, ( fβat) .fβat[l]) ; for (i-G;i<-15;i**) { if (arr x lβvels[i]""TRUE) ( ( ( # feat) .fβat[4])**) ; if (arr~y lβvβls[i]«TRUE) ( ( ( fβat) .fβat[5])♦♦) : } calcualtes the rotation features of a symbol , (called fron calc features ) . void calc_rot (struct TABLE EXTREMOMS extr[].int extrms, struct FEATURES # feat) int i; for (i-l;i < » extrms;i** ) { switch (extr[i] .in rot) { case 0 : { . (ffeat ) .feat[28 ]) ♦♦ : switch (extr[i] dir) { case Θ (Teat feat[31 ] ♦♦ break; case 1 Cfeat .feat[31 ] ♦♦ break; case 2 (•feat .feat[32]♦♦ ■ break; case 3 ( • feat .feat[32 ] ♦♦ : break; case 4 ( • feat , feat[33] ♦♦ ! break; case 5 ( • feat , feat[33] ♦♦ ! break; case 6 ( • feat , feat[34 ] ♦♦ : break; case 7 ( • feat ,feat[34 ] ♦♦ ! break; default break; } } case 1 : ( ( # feat) ,feat[29])**; βak; case 7 : ( (*feat) .fβat[30])**; break; default: break ; } if ( (βxtr[i-l].pβn_sts*extr[i] .pβn_sts)--2) { switch (βxtr[i] ,out_rot) { case 0 ( • feat) . feat[35]** break; case 1 (*feat).feat[35]** break; case 2 ( • feat) .feat[36]** break; case 3 (•feat) . feat[36]** break; case 4 ( • feat) .fβat[37]** break; case 5 (•feat) .fβat[37]** break; case 6 ( • feat) .feat[38]** brea ; case 7 ( • feat) .feat[38]** break; default break; } if ( (extr[i-l].pen sts*extr[i] .pen sts)--l) { switch (extr[i].out_rot) { ( • feβt).feat[43]** (•feat) .feβt[43]** ( • feat) .feβt[44]** ( • feat) .feat[44]** (•fβat).fβat[45]** case 5 : ("feat) . feat[45]*+; case 6 : (*fβat) . feat[46]**; case 7 : (*fβat) .fβat[46]**; calcualtes the extreaua type features of a symbol, (called from calc features). void calc ext types (struct TABLE EXTREMOMS βxtrf .int extrms, struct FBΛTURBS fβat) { ϊ int i-0; boolean arr_x_lβvβls[l6]; boolean arr_y_lβvβlβ[l6]; for (i-0;i<-15;i**) { arr_x_lβvβlβ [ i ] -FALSE ; arr y lβvβlβ[i]-FALSE; } for (i-l;i<extrβs;i**) if rj(βxtr[i].dir « 3)tt((βxtr[i*l].dir«l) || (βxtr[i*l].dir«2) ) ) (βxtr[i].dir"7)tt((βxtr[i*l].dir « 5) || (βxtr[i*l] .dir«6)) ) ) if for (i-θ;i<-15;i**) { arr x levels[i]-FΛLSE; arr~y " lβvβla[i]"FALSE; } for (i-l;i<extras;i**) if (βxtr[i].dir « 5)tt((βxtr[i*l].dir « 7) I I (extr[i*l] .dir « 6) ) ) βxtr[i].dir«3)tt((βxtr[i*l].dir«l) || (βxtr[i*l].dir«2) ) ) βxtr[i].dir--5) tt (βxtr[i*l] .dir--l) ) || (βxtr[i].dir « 3) tt (βxtr[i*l].dir « 7) ) ) { if ((βxtr[i-l].pβn_βtβ*extr[i].pβn_βts)--2) { arr_x_lβvβlβ[βxtr[i].x_cor] - TRUE; arr~y lβvβls[βxtr[i].y~cor] ■ TRUE; for (i-Θ;i<-15;i**) ( if (arr x lβvels[i]--TRUE) ( ( (*f eat ) . f eat[7] ) ♦♦ ) : if (arr_y_levels[i]--TRUE) ( { ( » feat) . feat[8] ) ♦♦) j for (i-0;i<-15;i**) { arr_x_levels[i]-FALSE; arr y _ lβvβls[i]-FALSE; } for (i-l;i<βxtras;i**) if (j( β xtr[i].dir--l)tl((extr[i*l].dir » 3) II (βxtr[i*l].dir—2) )) ((extr[i].dir « 5)tt((extr[i*l].dir « 6) || (βxtr[i*l].dir—7) )) ) if ( (β tr[i-l].pen_βts*extr[i].pen_sts)--2) { ((•f β at).f β at[9]**); arr_x_levels[extr[i].x_cor] - TRUE; arr_y_lβvβlβ[βxtr[i].y~cor] ■ TRUE; for (i-θ;i<-15;i**) { arr_x_lβvβla[i]-FALSE; arr y lβvβlβ[ .-FALSE; } for (i-l;i<extras;i**) if (extr[i].dir--7)tt((extr[i*l].dir « 5) II (βxtr[i*l].dir«6))) βxtr[i].dir « l)tt((extr[i*l].dir « 3) II (extr[i*l].dir«2))) extr[i].dir--l) tt (βxtr[i*l].dir«5) ) || ((βxtr[i].dir « 7) tt (βxtr[i*l].dir--3) ) ) if ( (βxtr[i-l].pβn_βtβ*βxtr[i].pβn_stβ)--2) { arr_x_levels[extr[i].x_cor] - TRUE; arr~y l«vβlβ[βxtr[i].y~cor] - TRUB; } for (i-0;i<-15si**) { if (arr x lβvβlβ[i]--TRUB) ( ( (*fβat) .fβat[10])**) ; if (arr " y~lβvβlsti]«TRUB) (( ( # fβat) .fβat[ll])**) ; ) /* for (i-θ;i<-15;i**) { arr x levels[i]-FALSB; arr~y~lβvβlβ[ij-PALSB; } for (i-l;i<βxtras;i**) if ( | (β xtr[i].dir « 5)lt((βxtr[i*l].dir--3) || (βxtr[i * lj .dir«4) ) ) (( β xtr[i].dir--l ) tt((extr[i*l].dir « 7) || (βxtr[i*l] .dir--0) ) ) ) if .pen sts) * -2) for (i-0;i<-15;i**) { arr_x_lβvβls[i]-FALSE; arr y~levels[i]-FALSE; } . for (i-l;i<extrms;i**) if ( β xtr[i].dir « 7)lt((βxtr[i*l].dir"l) || (βxtr[i*l].dir«θ))) β xtr[i].dir « 5)tt(( β xtr[i*l].dir « 3) II (βxtr[i*l].dir«4))) (βxtr[i].dir«5) it (extr[i*l].dir«l)) || (( β xtr[i].dir « 7) tt (βxtr[i*l].dir « 3) ) ) { if ((βxtr[i-l].pβn_βts*βxtr[i].pβn_βts)--2) { arr_x_lβvβlβ[βxtr[i].x_cor] - TRUE; srr yIlβvβls[βxtr[i].y~cor] - TRUE; } for (i-θ;i<-15;i**) { if (arr x lβvβls[i]--TRUB) ( ( (*feat) . feat[13] )♦♦) ; if (arr~y~lβvβlβ[i]"TRUB) ( ( (*feat) .fβat[l ])♦♦) ; } /* for (i-θ;i<-15:i**) { arr x lβvels[i]-FALSB; arr " y " lβvβlβ[i]-FALSE; } for (i-l;i<extraβ;l**) l].dir « 5) II (βxtr[i*l].dir « 4)) ) ].dir»l) || (βxtr[i*l].dir«θ))) ) .pen stβ)--2) for (i-θ;i<-15;i » ») { arr x lβvβlβ[i]-FALSB; arr " y " lβvβlβ[i]"PALSB; ) for (i-l;i<extras;i**) if U(extr[i].dir--l)ti((extr[i*l].dir--7) ( β xtr[i*l].dir--0))) (jextr[i].dir « 3)tt((extr[i*l].dir--5) || (extr[i*l] .dir«4) ) ) ( (extr[i].dir--l) ii (extr[i*l] .dir--5) ) || ((βxtr[i].dir--3) it (extr[i*l] .dir--7) ) ) if ( (βxtr[i-l].pen_sts*βxtr[i] .pen_sts)--2) arr_x_levels[extr[i].x_cor] - TRUE; arr y lβvβls[βxtr[i] .y cor] - TRUE; } ) for (i-θ;i<-15;i**) { if (arr_x_l β v β l β [i]--TRUE) ( ( ( β fβat) .fβat[l6])**) ; if (arr_y_l β v β l β [i]--TRUB) ( ( ( # fβat) .fβat[17])**) ; / 4 for (i-0;i<-15;i**) { arr_x_lβvβls[i]-FALSE; arr y levels[i]-FALSE; } for (i-l;i<extras;i**) if (extr[i].out rot--5) { if ( (βxtr[i-l].pβn sts*extr[i].pen βtβ)--2) { (•feat).feat[l8]**{ arr_x_levels[extr[i].x_cor] - TRUE; arr y levelβ[extr[i].y cor] - TRUE; } } for (i-θ;i<-15;i**) ( if (arr x lβvβls[i]--TRUE) ( ( (*fβat) .feat[19])**) : if (arr~y _ lβvβlβ[i]-"TRUE) ( ( ( # fβat) .f*at[2θ])♦♦) ; ) for (l-θ;i<-15;i**) { arr_x_lβvelβ[i]-FALSE; arr-y~levals[i]-FALSE; } for (i-l;i<βxtraβ;i**) if ((βxtr[i].out rot--3) II (βxtr[i].out rot--4)) { if ((βxtr[i-l].pβn βts*βxtr[i].pβn βtβ)--2) { for (i-0;i<-15;i**) { if (arr x lβvβls[i]--TRUE) ( ( ( # fβat) .feβt[22])♦♦) ; if (arr_y lβvβlβ[i]--TRUE) ( ( ( e feat) .fβat[23])**); } / ## / calcualtes the arc features of a syabol, (called froa calc_fβaturβs) . void calc arcs (struct TABLE EXTREMOMS extr[],lnt extras, struct FEATURES *feat) { int 1-0; int j-θ; while (Kaxtras) { if ((βxtr[i].in rof-7) I I (βxtr[i].in rot«l)) { ((•fβat).fββt[24])**; while ((βxtr[i].in rot--7) | | (βxtr[i].in rot--l)) 1**; } i**J } --7) {J**;i**O t--l) l) (J**;i**;} at).feat[25])*(int)(J/4); > / calculates the levels features (nuaber of dlufferent levels) of a syabol (called from calc_fβatures) . void calc_ β ymbol_lβvels (struct TABLE_EXTREMOMS βxtr[],int extrms struct FEATURES feat) { int i-0; boolean arr_x_levβlβ[l6] ; boolean arr_y lβvβlβ[l6] ; for (i-0;i<-15;i**) { .arr x levela[i]-FALSE; arr " y " lβvβlβ[i]-FALSE; } for (i-θ;K-extrns;i**) { arr_x_lβvβls[βxtr[i].x_cor] - TRUE; arr y lβvβlβ[βxtr[i],y~cor] - TRUE; } for (i-0;K-15;i**) { if (arr x lβvβls[i]--TRUE) ( { ( fβat) .fβat[26])**) ; if (arr y lβvβlβ[i]--TRUE) ( (( # fβat) .fβat[27])**) ; } calculates the number of minumums/maximums in X and Y. (called from calc_fβaturβs) . void calc nua minmax (struct TABLE EXTREMOMS βxtr[],int extras, struct FEATURES # fβat) { int i; for (i-l;Kextras;i**) { i].pen sts)--2) I | | ) || ) ) if (((βxtr[i].dir«7)tt((βxtr[i*l].dir « 5) II (βxtr[i*l].dir«6))) || ((extr[i].dir«l)tt((extr[i*l].dlr « 3) II (extr(i*l].dir--2))) || ((βxtr[i].dir«l) tt (βxtr[i*l].dir « 5)) I I ( (βxtr[i*l].dir- ■ 3))) if { 11 | | ) ) || )) ) if ((( β xtrti].dir « l)tl(( β xtr[i*l].dir « 7) | | ( || ( ( β xtr[i*l].dir « 5) 11 ( || ( (extr[i*l].dir«5)) || ( (βxtr[i*l].dir«7)) ) calculates the features of a syabol depending on the extramums of that symbol , and fills in the structure variable: feat. void calc features (struct FBATURBS *feat,int points, struct TABLB_BXTREMOMS βxtr[], int extras,int featθ) { int i; /• initialization •/ for (l-θ;KNUM_FBAT;i**) (*fβat) .feat[i]-θ; (•feat) .fβat[θ] - featθ ; (•feat) .fβat[l] - points ; (•feat) .fβat[2] - extras ; calc_spacβ_fβat (extr,extras,feat) ; calc ' rot Jextr,extras,feat) ; calc~βxt_typββ (extr,extrms,feat) ; calc_arcβ (extr,extras,feat) ; calc~βyabol_lβvβlβ (extr,extras,feat) ; calc~nun_minmax (extr,extrms,feat) ; /• This aodule is for calculating and aanipulatlng extreauas , it Includes four procedures : (1) calc_extreauas : To find the extreauas of the syabol , and the "change in pen" points. (2) find_max_extrs : To find the sax/sin X-coordinatβ and the max/ain Y-coordinate of the syabol. (3) analyββ_βxtrβauBS : A procedure to analyse the extreauas found so far, mainly this procedure marks close extreau s as suspeclous extreauas. (4) conv21evels : Replaces the actual coordinates of the extreauas in arr_extreauas with the levels of these coordinates by doing quantization, (there are 16 levels). •/ finclude "aaln.h" / The input of this procedure is the array of coordinates which holds the coordinates of the syabol , and the nuaber of these points , it fills the special of points (i.e. , extreaums or change in pen) in the array arr_extremums , it returns the number of special points it found. int calc_βxtrβmoaβ (struct TABLE_EXTREMOMS arr_extrβaoas[], struct POINT arr_cor[],int~nua_of_points) unsigned int indE; unsigned int ndx; unsigned pβn_waβ_up; int crnt_quart,prev_quart; int crnt_rot,prev_rot; int Sx.Sy.PSx.PSy.a.b; int first_point-l; int Pndx-Θ; unsigned int LaβtNdx; int 1; indE-θ; while (ndx<nua of points) { while ((arr cor[ndx].pen status)--l) Sx-(arr_cor[ndx*l].x_cor-arr_cor[ndx].x cor) ; Sy-(arr_cor[ndx*l] .y~cor-arr~cor[ndx].y~cor) ; tSx-(arr_cor[ndx*2] .x_cor-arr_cor[ndx*l ] . x cor) ; tSy-(arr_cor[ndx*2].y_cor-arr~cor[ndx*l].y~cor) ; a-Sx*tSy-Sy*tSx; b-Sx*tSx*Sy*tSy; PSx-Sx; PSy-Sy; } else { /* for the previous ENDING extreaoa */ Sx « (arr_cor[ndx].x_cor-arr_cor[Pndx].x_cor) ; Sy"(arr_cor[ndx] .y_cor-arr~cor[Pndx].y~cor) ; PSx"(arr_cor[Pndx].x_cor-arr_cor[Pndx-ϊ].x_cor) ; PSy-(arr_cor[Pndx].y~cor-arr_cor[Pndx-l].y~cor) ; a « PSx*Sy-PSy # Sx; ~ " "" ~ b»PSx*Sx*PSy Sy; arr_extrβaoaβ[indE].p_ndx»Pndx; arr_extreeoae[indE].x~cor « arr_cor[Pndx].x_cor; arr_βxtrβBθBβ[indE].y~cor-arr~cor[Pndx].y~cor; arr_extrβBoaβ[indB].pβn_βt8"θ; arr_βxtrβB0Bβ[indE].dir»def_quart(PS ,PSy) ; arr extreaoa*[indE].out rot-dβf quart(b,a); { int PPSx.PPSy; PPSx-(arr_cor[Pndx-l].x_cor-arr_cor[Pndx-2].x_cor) ; PPSy"(arr_cor[Pndx-l].y_cor-arr_cor[Pndx-2].y_cor) ; a"PPSx*PSy-PPSy PSx; "" ~ b-PPSx PSx*PPSy # PSy; arr βxtrβaoaβ[indE].in rot-dβf quart(b,a); } indE**; PSx-Sx; PSyaSy; { int tSx.tSy; Sx"(arr_cor[ndx * l].x_cor-arr_cor[ndx].x_cor) ; Sy"(arr~cor[ndx * l].y_cor-arr_cor[ndx].y_cor) ; tSx«(arr_cor[ndx].x_cor-arr_cor[Pndx].x_cor) ; tSy»(arr_cor[ndx].y~cor-arr_cor[Pndx].y_cor) ; a-tSx Sy-tSy*Sx; b«tSx Sx*tSy # Sy; } crnt_quart«dβf_quart(Sx,Sy) ; crnt rot"dβf_quart(b,a) ; arr_βxtrβaoaβ[indE].p_ndx-ndx; arr ' extreaoae[indE].x~cor»arr_cor[ndx].x_co ; arr~βxtrβBθBβ£indE].y_cor-arr_cor[ndx].y_cor; arr~extrβBoaβ[indE].pβn_βt8-l; if Tfirβt_poinfl) { arr_extreaoae[indE].dir"15; βrr~βxtrββoaβ[indE].in_rot«15; arr~βxtrβBθBβ[indE].out_rot"15; ndx** ; first point-0; } else { arr_extremoms[indE] .dir-def_quart(PSx.PSy) ; arr_ex remoBs[indE] . in_rot-0; arr_extremoms[indE] .out_rot-def_quart(b,a) ; indE**; pen_was_up-G; } else { crnt_quart-def_quart(Sx.Sy) ; crnt_rot-def_quart(b,a) ; if [ (crnt_quart!-prev quart) || ( (crnt_rot>-4) tt (prev_rot<4) ) || ( (crnt~rot<4) tt (prev rot>-4)) ) tt (prev_rotf -15) ) { /* regular extreaoa */ if ((abs(Sx)>0) tt (abs(Sy)>0) || (b<0)) if ( (ndx-l-arr_extreaoas[indE-l] .p ndx)>0) { arr_extreaoas[indE].p_ndx-ndx-l; arr_extremoms[indE] .x_cor-arr_cor[ndx-l] .x_cor; arr_extreaoas[indE] .y_cor-arr~cor[ndx-l].y~cor; arr_extreaoas[indE] .pen_s s-l; ~ ( arr_extreaoas[indE].dir-prev_quart; arr_extreaoas[indE] .in_rot-prev_rot; arr_extremomβ[indE] ,out_rot-crnt_rot; indE**; } } } } ndx**; Sx-(arr_cor[ndx],x_cor-arr_cor[ndx-l] .x_cor) ; Sy-(arr_cor[ndx].y_cor-arr_cor[ndx-l] .y_cor) ; a-PSx*Sy-PSy*Sx; b-PSx*Sx*PSy*Sy; PSx-Sx; PSy-Sy; prev_.quart-crnt_quart; prev_rot-crnt_rot; } /• end of while (arr_cor[ndx] .penstatus--l) •/ if ( (pen_was_up--0) tt (arr_cor[ndx-l].pen_βtatus--l) ) { /• ending extreaoa •/ Pndx-ndx-1 ; pen_was_up-l; LastNdx-ndx-1; } ndx**; } /• ndx<-NuaOfPointβ */ /• Add the last special point to the array */ arr_extremoms[indE].p_ndx-LastNdx; arr_extreaoaa[indE].x~cor-arr_cor[LastNdx].x_eor: arr_extreaoBa[indE].y_cor-arr_cor[LaβtNdx].y~cor; arr_extreaoBs[indE].pen_sts-07 ~ Sx-Tarr_cor[La β tNdx-l] .x_cor-arr_cor[LastNdx-2].x_cor) : Sy-(arr_cor[LastNdx-l].x~cor-βrr~cor[LaβtNdx-2].x~cor) ; PSx-(arr_cor[LastNdx-2].x_cor-arr_cor[LastNdx-3].x cor) ; PSy-(arr_cσr[La β tNdx-2] .y~cor-arr2cor[LastNdx-3].y~cor) ; arr_extreaoBs[indE].dir-def_quartTSx,Sy) ; a-PSx*Sy-PSy*Sx; b-PSx*Sx*PSy*Sy; arr_extreaoaa[indE].in_rot-def_quart(b,a) ; axr_extreaoas[indE].out_rot-157 return (indE); / This procedure is to find the aax/ain X-coordlnate and the aax/ain Y-coordlnate of the syabol. void find_max_βxtra (struct TABLE_EXTRBMOMS arr_extreaoas[], int nun of extras,int •Xalή.lnt *Xaax, int •Yaϊn.ϊnt Ymax) { unsigned int i-0; •Xain-1200; •Xaax-0; •Yain-1200; •Yaax-Θ; while (K-nua of extras) { if (arr_extreaoBβ[l].x_eor< Xain) • Xain-arr_extreaoms[i].x_cor; if (arr xtremoms[l].x~eor>*Xaax) Xaax-arr~extreBoas[l].x~cor: if (βrr~βxtrβaoBβ[i].y~cor<*Yain) •Yain-arr~extreBoas[i].y_cor; if (arr~extraBoaβ[i].y~eor>*Yaax) •YBax-arr~βxtrβBθBs[i].y_cor; i**; } ) / • correct dlr,in_rot,out_rot for suspicious points , called froa analyae_extreauas void correct extra (struct POINT arr_cor[], atruct TABLE EXTREMOMS extra[], struct TABLE~BXTREMOMS arr_βxc_βxtra[], int i.int PiTint J) { int Sx.Sy.PSx.PSy; int ndxl,ndx2; int a.b; ndx 1 -e tra [Pi ] . p_ndx; ndx2-extrm[i] .p_ndx; if (Pi>0) { if (extrm[Pi-l].ρen sts--0) { PSx-arr_cor[ndxl].x_cor-arr_cor[e trm[Pi-l].p ndx].x_cor; PSy-arr_cor[ndxl] .y_cor-arr_cor[extra[Pi-l].p^ndx].y_cor; else ( PSx-arr_cor[ndxl] .x_cor-arr_cor[ndxl-l].x_cor; PSy-arr_cor[ndxl] .y_cor-βrr_cor[ndxl-l].y^cor; } else (PSx-OjPSy-θ; } Sx-arr_cor[ndx2] .x_cor-arr_cor[ndxl] .x_cor; Sy-arr_cor[ndx2].y_cor-arr_cor[ndxl] .y_cor; a-PSx'Sy-PSy'Sx; b-PSx*Sx*PSy # Sy; if (arr_exc_extra[J-l] .out_rot!-15) arr_exc_extrm[J-l].out_rot-def_quart(b,a) ; PSx-Sx; PSy-Sy; arr_exc_extrm[J] .dir-def_quart(PSx,PSy) ; arr_exc_extrm[Jj.in_rot-θ; if (arr exc extra[J].out rott-15) { if (βxtrm.i].pen βtβ--θ) { Sx-arr_cor[extra[i*l] .p_ndx] .x_cor-βrr_cor[ndx2] .x_cor; Sy-arr cor[extra[i*l] .p ndx] .y_cor-arr cor[ndx2].y cor; } " - . - else { Sx-arr_cor[ndx2*l] .x_cor-arr_cor[ndx2] ,x_cor; Sy-arr cor[ndx2*l] .y cor-arr_cor[ndx2].y cor; } a-PSx*Sy-PSy*Sx; b-PSx*Sx*PSy Sy; arr_exc_βxtra[ j] .out_rot-def_quart(b,a) ; } A procedure to analyse the extreauas found so far , mainly this procedure aaxks close extremuas as suspeclous extreauas. 7 int analyse extreaonβ (struct POINT arr cor[], struct TABLE_EXTREMOMS extra[], struct TABLE_EXTREMOMS arr_βxc_βxtra[], int nua of_extras) { int i.J-θ; int count-0; int Pi-0; - 89 - boolean FirstP-TRUE; for (i-1;i<num_of_extrms;i++) { if (((ex r [i].x_cor-extrm[i+l].x_cor) <2 (extrm[i] .y_cor-extrm[i+l] .y_cor) <2) && (ex rπ_[i] .in_rot! -extrm[i+l] .in_ro ) && (ex r_n[i].dir--extrm[i+l].dir) && (extrm[i].pen_sts--l) && (extrm[i-l].pen_sts. -0) ) extrm[i].sus p-i ; else {extrm[i].susp-0;count* * ; } } ex rm[0] .susp-G; extrm[i].susp-0; /•count**;*/ for (i-0;i<-num_of_extrms;i+ * ) { ] .susp»-0) exc_extrm[ j .p_ndx»extrm[i] .p_ndx; xc_extrm[ j .x_cor»extrm[i] .x_cor; xc_extrm[ j .y_cor«extrm[i] .y_cor; xc_extrm[ j . pen_sts«extrm[i] .pen_sts; xc_extrm[ j .dir"βxtro[i] .dir; xc_extn[ j .in_rot -extrm[i] .in_rot; xc_extrm[ j out_rot-extrm[i] . out_rot ; irstP--FALSE) ect_extrm (arr_cor,extrm, exc extra,i,Pi,j) ; tP-TRUE; ].pen_sts«0) FirstP-TRUE; } else { if (FirstP) Pi-i- 1; FirstP-FALSE; } } { /•FILE *fp; fp»fopen ("extrm.out" , "ab+") ; for (i-0;i<-count;i+*) { fprintf (fp,"2d %d %d %d %d %d %d \n", arr_exc_extrm[i] .p_ndx,arr_exc_extrm[i].x_cor, arr_exc_extrm[i] .y_cor,arr_exc_extrm[i].pen_sts, arr_exc_extrm[i] .dir,arr_exc_extrm[i] .in_ro , arr_exe_extrm[i] .out_rot) ; } fprintf (fp, " • •••• < '\n"); fclose (fp);*/ ) return ( count ) ; Replaces the actual coordinates of the extremuas in arr_extreaums with the levels of these coordinates by doing quantization,( there are 16 levels).it also calculates featø : i.e. the relative size of symbol-32*div_round(Xwidth.Ywidth) . void conv21evels (struct TABLE_EXTREMOMS arr_extreaoas[]. int nua of extras,int *featθ7 { int. x_width , y_width ; Int Xain . Xaax , Ymin . Yaax ; int i-θ ; f ind_aax_extra ( arr_extreaoas , nua_of _βx tras , tXain , tXaa , tYain , Yaax) ; x_width-Xaax-Xain; y~width-Yaax-Ymin; while (K-num of extrms) { arr extresoms[i].x cor-div round((arr extreaoas[i].x cor- Xmin) # αRID,x_wϊdth); arr extreaoas[i].y cor-div roun ((arr extreaoas[i].y cor- Ymin) # QRID,y width); i**: ) (•featø)-div_roun (5θ*x_width.y_width) ; #include "main.h" void print_features (struct FEATURES *feat,char filenaoe[] FILE » fp; int i; fp-fopen (filename, "ab*" ) ; / • fprinittf (fp,"name of symbol -?s\n" .(*feat) . IDfeat fprintf (fp,"size of symbol -*d\n" , ( # feat) . featO) ; fprintf (fp, "number of points - d\n" , (*feat) . featl) fprintf (fp, "number of str -ϊd\n" , (*feat) . feat2) ; fprintf (fp, "number of spaces -Xd\n" , (*feat) . feat3) fprintf (fp, "number of diff. levels in X for end of space-Xd\n", (*feat) .featl) ; fprintf (fp, "number of diff. levels in Y for end of space-Xd\n", ( # feat) .feat5) ; fprintf (fp, "nuaber of spaces for q< -)td\n" (•feat) .featβ) ; fprintf (fp, "nuaber of spaces for q>-4 -Xd\n , (*feβt) .featβ) ; fprintf (fp, "nuaber of spaces ro<4 -J5d\n H .( # feat).feat73); fprintf (fp, "nuaber of spaces ro>- « *d\n",( # feat) .feat75); fprintf (fp, "nuaber of linear strokes -≠d\n". ( # feat) .featlO); fprintf (fp, "nuaber of linear strokes where dir<4 -Xd\n". ( feat).feat69); fprintf (fp, "nuaber of linear strokes where dir>-4 -J-d\n", (*feat).feat71); fprintf (fp, "nuaber of strokes with pos.rot -*d\n", ( feat) .featll) ; fprintf (fp, "nuaber of strokes with neg.rot •!-d\n",( # feat).featl2) ; fprintf (fp, "nuaber of strokes ro<4 -Xd\n". ( # feat) .featl3); fprintf (fp, "nuaber of strokes ro.*" 1 -. ■≠d\n". (*feat) .featl5) ; fprintf (fp, "nuaber of Ext in X neg. rot. -*d\n". ( » feat) .featl7) ; fprintf (fp."diff. levels in X for minX -≠d\n", • feat featlβ); fprintf (fp "diff. levels in Y for minX -Xd\n", •feat featl9): fprintf (fp, "number of Ext in X pos. rot. -J5d\n", •feat . feat20) fprintf (fp,"diff. levels in X for maxX -J!d\n". •feat feat21) fprintf (fp,"diff. levels in Y for maxX -Xd\n", •feat ,feat22) fprintf (fp, "number of Ext in Y neg. rot. -J!d\n", •feat feat29); fprintf (fp,"diff. levels in X for minY -Xd\n", •feat feat30) ; fprintf (fp,"diff. levels in Y for minY - d\n", •feat feat3D ; fprintf (fp, "number of Ext in Y pos. rot. -Xd\n" , (*feat) .feat32] fprintf (fp,"diff. levels in X for πaxY fprintf (fp,"diff. levels in Y for maxY fprintf (fp,"nu..ber of ext XY for neg. rot fprintf (fp, "different levels in X for ext fprintf (fp, "different levels in Y for ext fprintf (fp, "number of ext XY for pos. rot fprintf (fp, "different levels in X for ext fprintf (fp, "different levels in Y for ext fprintf (fp, "number of arc parts fprintf (fp, "number of circle parts fprintf (fp. "number of different X-levels ■ fprintf (fp, "number of different Y-levels ■ fprintf (fp,"sum of square weights « Xd\n", ( # feat) .sum_sqr_wgt) ; • / fprintf (fp."\nXs\n". ( feat) .IDfeat) ; for (i-0;KNUM FEAT;i**) { fprintf (fp."X3d".( , feat) .feat[i]); if ((1--20) | | (1-- 0)) fprintf (fp."\n"); } fcloβe (fp); if incl ude " main . h " in t trans fora ( char infile[ 30] , s truc t FEATURES * feat ) { struct POINT arr_cor[MAX_NUM_0F_P0INTS_ ; / • array of coordinates */ struct TABLE_EXTREMOMS arr_extremoms[MAX_NUM_OF_EXTREHOMS] ; /* array of special points (i.e. extremuas , changing of pen position */ struct TABLE_EXTREMOMS arr_exc_e rms[MAX_NUM_0F_EXTREM0MS] ; / • array of excluded extremums , it Is excluded from the array of extreaums by excluding close points */ int featO; int num_of_points,nua_of_extras,exc_num_extras; / Reading a file and calculate the nuaber of points for the syabol,and stores the points reed in the array : arr cor . ' / num_of_points-rβad_points (arr_cor,infile) ; if Tnum_of_polnts--0) return (0) ; / Calculates the extremuas froa the array of coordinates , and stores it in the array : arr_extreauas , the function returns the number of extremums it calculated , and it is stored in nua of extras. ϊ#,ϊ / nua_of_extrmβ-calc_extremoms (arr_extremoms,arr_cor,nua_of_points) ; / Replaces the actual coordinates of the extreauas in arr_.xtre.uii with the levels of these coordinates by doing quantization, (there are 16 levels) / conv21evels (arr_extreaoms,num_of_extras,tfeatθ) ; / Excludes close points in the extreauas array and stores the remaining extreaums in arr_βxc_extraβ , it returns the nuaber of extreaums left after excluding. / exc_nua_extras-analyse_extreaoas (arr_cor,arr_extrβBoas, arr_exc_extrmβ,num_of_extrma) ; / calculates the features of the syabol , and stores it in the structure variable feat. - — / calc_featureβ (t(*feat) ,num_of_points,arr_exc_extras.βxc_num_extrmβ,fβatO) ; return (num of points); } ♦include "main.h" / a function which recieves as input the features of a sym b ol . an d maximum and minimum features , and returns the estimation of the probability that the entered syabol is the symbol with the min and max features. int rec (struct FEATURES feat.struct FEATURES min feat, struct FEATURES max feat) { int D; int theta; int W; unsigned long teap-0; unsigned long sum_w-Θ; int tempi; int N-0; int Rv; int i; for (i-0;i<NUM FEAT;i**) { if ((feat.feat[i]<-aax_feat.fβat[i]) tt (feat.fβat[i]>-min_feat.featfi])) theta-0; else (theta-l;N**; } if ((min feat.feat[i]*aax feat.feat[i])--0) { W-0; D-32 # fβat.feat[i]-l6; } elae { D-abs(div_round(32 feat.feat[i],min_feat.feat[i]* aax~fβat.feat[i])-l6) ; W-div round (32 # ain feat. feat[i] , min feat.feat[i]*aax feat. feat.i] ) ; } if ((W--16) tt (theta--.)) theta-8; teap * -(D*theta) ; teapl - (int)lθθ*teap/sua w; Rv - div_round((NUM_FEΛT-N) , (10θ-tβmpl),NUM_FEΛT); return max (Θ.Rv) ; APPENDIX D // Number of points // Number of dimentions // Number of centroids .♦include "start.h" finclude <graphics.h> .♦include <stdlib.h> finclude <stdio.h> finclude <conio.h> finclude <math.h> int prepare (int xc[][],int 'ml.int •m2,int *o3,int - m-, ) ; void βelect_beg (int cntr[][],int ml,int m2,int n3,int t ) float distance (int xc[],int cntr[]); float sum_dist (int cntr[][],int x[]j; /* Main program for clustering •/ void main ( ) { int x[N_P0INT][DIMENSI0N],il.i2.i3.num points. i H ; int center[N CENTER][DIMENSI0N].prev cntr[DIMENSI0N], new_cntr[DIMENS ON]; int errorcode; int max_x,aax_y,ain_x,min_y; long sum_def-0; ~ float cur_dist-0, eigh [N_P0INT] .comm_weight,dist-0; /• Initialization of coordinates of all the points •/ for (il-θ;il<N POINTjil**) for (12-0;i2 " <DIMENSI0N;i2**) { x[il][i2]-0; } nuo_points - prepare (x,tmin_x,tmax_x,tmin_y,tmax_y) ; select_beg(center,min_x,nax_ ,ain_y,max_y) ; /• Calculating for every centroid it's new position according it's previos position and it's distance froa all the points. • / for (il-0;il<N CENTERjil**) { for (12-0;i2<DIMENSI0N;i2**) { new_cntr[i2] • 0; prev cntr[i2]-center[il][i2] ; } /• Calculating the membership value of each point to the current centroid */ for (i3"θ.comm weight-0; 13<num points;i3**) { if ((cur_dist-distance (tx[i3][0] .tcenter[il][0]) ) <0.0001) w β ight[i3]"l.Θ; else weight[i3]"(l/cur_dist)/sua_dist(center.tx[13][0]) ; comm weight ♦- weight[i3] # *eight[i3] ; for Ti'r-0;i''<DIMENSI0N;i'»**) new cntr[i ]*- w β ight[i3]'w β ight[i3] , x[i3][i'»] : } /* Calculation of the new position of the centroid •/ for (i4-G;i'4<DIMENSION;i ' 4 * +) { new_cntr[i4]/-comm_weight; center[il][i'*] ■ new cntr[i'4] ; } /• Checks the moveaent of the current centroid and stops the iterations if it is saall (less then 3). •/ if (il--N_CENTER-l) { • if ( (dist*-distance(prev_cntr,tcenter[il][0]))<3) break; dist - 0; 11--1; } else { dist*- distance(prev cntr,tcenter[il][0]) ; } /• Printing the points and the centroids */ for (il-Θ;iKnua points;il**) { printf ("\n Point # %d : ",il); for (12-Θ;i2<DIMENSI0N;i2**) printf (" ≠5 ",x[il][i2]) ; } printf ("\n\n\n\n"); for (il-0;il<N CENTERjil**) { printf ("\n CENTER f %d : ",il); for (12-Θ;i2<DIMENSI0N;i2**) printf (" %5d " ,centβr[il][i2]) ; } gβtch (); ^include "start. h" /* This procedure selects the initial set of centroids void select_beg(int cntr[N_CENTER][DIMENSION] ,int min. x. int max_x,int min_y,int max_y) cntr[83[l3- ■ min_y*2/3; cntr[83[23- ■ 200; cntr[8 33-100; cntr[83[43- 0; cntr[93[03-max_x*2/3; cntr[93[l3"min_y » 2/3; cntr[93[23- 200; cntr[93C33- 100; cntr[93[43- 10; cntr[103[03 ■ max_x*2/3; cntr[103[l3 » max_y # 2/3; cntr[103[23 -100; cnt ' r[103[33 -100; cntr[103[43 -20; cntr[ll3[03 -min_x » 2/3; cntr[H3[l -max_y » 2/3; cntr[H3[2 -300; cntr[ll][3]' ■100; cntr[H3[43' ■ 30; •/ .-.include "start. " (Cinclude <time.h> #include <stdlib.h> (.include <stdio.h> /• This procedure gets the points from file or from other input device and calculates the maxiαυms and miniauas fo each dimβntion (two dimentions in this example •/ int prepare nt xc[N_P0INT][DIMENSION] ,int min_x,int •max_x, int # ain y.int *max_y) ~ ~ { countl ■ θ; while ( fscanf (fp,"≠6d≠6d≠6d:.6d≠6d≠6d\n",4count2. txc[countl3[θj.4xc[countl3[l].*xc[countl][23. txc[countl][33.txc[countl][43) > 0) { /• xc[countl][0]*-100; xc[countl3[l]*-100;*/ •aax_x - aax( # max_x,xc[countl][03) *max~y - ■ax(*max~y,xc[coun'tl3[l3) *min~x - min(*min~x,xc[countl3[03) *min~y - Bin(*ain " y,xc[countl][13) countl**; } fclosβ (fp) ; return countl ; ifinclude <aath.h> (.include "start.h" /• This function gets two points and returns the sqr of the distance between this points •/ float distance (int pointl[DIMENSION] ,int point2[DIMENSI0N]) int i_c; float sum; for (i_c-0,suβ-0.0;i_c<DIMENSION;i c«--) sum*-( (float) (pointl[i_c3-ρoint2[i c3) )•( (float) (pointl[i c3- point2[i_c3))i return sum ; > - 102 - (.include "start.h" float diβtancβ(int pnt[],int cntr[]); /* This function gets a point and the positions of all centroids and returns the sum of sqr distances between this point and all the centroids */ float au diet (int cntr[N CENTER][DIHENSION], int point[DIMENSION])

Claims: C L A I M S 1. Apparatus for reading handwriting comprising: a sensor for sensing features of handwriting of an individual which features are highly characteristic of the individual but which also contain information relating to symbols being written; and circuitry, which is configured for the individual, for providing a non-individual dependent output indicating the symbols being written in response to the sensed features. 2. Apparatus according to claim 1 and wherein said sensor and said circuitry are contained in a hand¬ held housing. 3. Apparatus according to claim 1 and also comprising a transmitter for wireless communication with a computer to which said transmitter inputs symbol data. 4. Apparatus according to claim 1 and wherein said non-individual dependent output is suitable for communication with the keyboard input of a computer. 5. Apparatus for reading handwriting comprising: personalized hand-held apparatus for sensing acceleration during handwriting and providing an output indication of handwriting content in a- non-personalized form . 6. Apparatus according to claim a d also comprising a transmitter for wireless communication with a computer to which said transmitter inputs said output indication. 7. Apparatus according to claim 6 and wherein said output indication is suitable for communication with the keyboard input of a computer. 8. Apparatus for reading handwriting comprising: wireless hand-held apparatus for sensing handwriting and providing an output indication of the contents thereof. 9. Apparatus according to claim 8 and wherein said hand-held apparatus senses acceleration during handwriting. 10. Apparatus according to claim 8 and wherein said apparatus is trainable. 11 Apparatus for reading handwriting comprising: personally trainable hand-held apparatus for sensing motion during handwriting and providing an output indication of handwriting content. 12. Apparatus according to claim 11 and wherein said hand-held apparatus senses acceleration. 13- Apparatus according to claim 11 and also comprising a transmitter for wireless communication with a computer to which said transmitter inputs symbol data. 14. Apparatus according to claim 11 and wherein said non-output indication is suitable for communication with the keyboard input of a computer. 1 . Apparatus for reading handwriting in real time comprising: a hand held housing; a motion sensor disposed in said housing; a plurality of parallel recognizers disposed within said hosing and receiving signals from said motion sensor for sensing a plurality of handwriting characteristics; and symbol recognizing means disposed in said housing receiving the outputs of said plurality of parallel recognizers for providing an indication of a handwritten signal. 16. Apparatus according to claim 1 and wherein said motion sensor is operative to sense acceleration. 17. Apparatus according to claim 15 and also comprising a transmitter for wireless communication with a computer to which said transmitter inputs symbol data. 18. Apparatus according to claim 1 and wherein said indication is suitable for communication with the keyboard input of a computer. 19. Apparatus for reading handwriting comprising: hand-held apparatus for sensing motion during handwriting and providing an output indication of handwriting content in a form corresponding to that of a conventional keyboard. 20. Apparatus for reading handwriting comprising: hand-held apparatus for sensing motion during handwriting and providing an output indication of handwriting content in a RS-232 compatible form. 21. Audio-visual apparatus including apparatus for providing a human sensible output including information in at least one of audio and visual form and having as an input element hand-held apparatus for sensing motion during handwriting. 22. Audio-visual apparatus according to claim 21 and wherein said hand-held apparatus comprises: a sensor for sensing features of handwriting of an individual which features are • highly characteristic of the individual but which also contain information relating to symbols being written; and circuitry, which is configured for the individual, for providing a non-individual dependent output indicating the symbols being written in response to the sensed features. 23. Portable information storage and retrieval apparatus including a portable computer memory and output device and having as an input element hand-held apparatus for sensing motion during handwriting. 24. Apparatus according to claim 23 and wherein said hand-held apparatus comprises: a sensor for sensing features of handwriting of an individual which features are highly characteristic of the individual but which also contain information relating to symbols being written; and circuitry, which is configured for the individual, for providing a non-individual dependent output indicating the symbols being written in response to the sensed features. 25. Lock apparatus including locking apparatus responsive to a predetermined electronic input and having as an input element hand-held apparatus for sensing motion during handwriting. 26. Apparatus according to claim 25 and wherein said hand-held apparatus comprises: a sensor for sensing features of handwriting of an individual which features are highly characteristic of the individual but which also contain information relating to symbols being written; and circuitry, which is configured for the individual, for providing a non-individual dependent output indicating the symbols being written in response to the sensed features. 27. Magnetic card activated apparatus including apparatus for reading a magnetic card and having as a verification input element, hand-held apparatus for sensing motion during handwriting. 28. Apparatus according to claim 27 and wherein said hand-held apparatus comprises: a sensor for sensing features of handwriting of an individual which features are highly characteristic of the individual but which also contain information relating to symbols being written; and circuitry, which is configured for the individual, for providing a non-individual dependent output indicating the symbols being written in response to the sensed features.

Inventors: BARON EHUD, ORBACH ZVI, BARON, EHUD, ORBACH, ZVI
Applicants: BARON EHUD, ORBACH ZVI, BARON, EHUD, ORBACH, ZVI
Application year: 1992
Main classification: G06K9
IPC codes: G06F3, G06K9, G06T7, G07C9