Next Patent: Method and apparatus for contour tracking of an image through a class of non linear filters
Next Patent: Method and apparatus for contour tracking of an image through a class of non linear filters
Plaque It!
Sponsored by: Flash of Genius |
[0001] The present invention relates to a method for recognition of a handwritten character.
[0002] There is an increasing need for recognition of handwriting. Portable data handling devices, such as PDAs (Personal Digital Assistant), mobile phones or portable computers, are becoming increasingly popular. In order to enter data into these portable devices, a text insertion unit is needed.
[0003] Text insertion units have formerly been implemented as keyboards. This, however, sets limits to the minimum size of the portable device, and therefore a different way of inserting text into the device is needed in order to enable smaller devices.
[0004] The keyboards are now being replaced by some kind of recognition of handwritten text. A common solution is to arrange a pressure-sensitive area where a user can write characters. The characters are then interpreted and handled by the portable device. It is, of course, also of interest to replace keyboards of regular stationary computers.
[0005] Thus, recognition of handwritten characters is an important task in portable devices. The recognition is commonly performed by comparing the handwritten character with reference characters that are stored in a database in the portable device. One such method is disclosed in U.S. Pat. No. 4,284,975.
[0006] The recognition should be fast in order to avoid annoying delays for the user. This requirement is especially hard to live up to for logographic writing systems, such as the Chinese. The Chinese writing system consists of up to 20,000 characters. Since the handwritten character has to be compared with a very large number of reference characters when recognition of a Chinese character is performed, the recognition becomes slow.
[0007] According to U.S. Pat. No. 4,284,975, differences in coordinates between points on the handwritten character and points on the reference character are calculated. These differences are used to calculate a distance measure between the points.
[0008] Today, the differences are computed in at least two steps. Two characteristics defining a point could be stored in different areas for easy access to the value of a characteristic by referring to the register where it is stored. A computation of a difference between two points is then performed in two subtractions in order to compare the two characteristics of the point. In these subtractions the registers holding the values of the characteristics could be referred to directly. However, this means that a lot of memory is needed, as the two characteristics are stored separately. Another method is to compress the values of the two characteristics for storage of each point separately. This means that less memory is required but the characteristics of the point have to be decompressed before the computation of the differences in characteristics is performed. This gives a slower method.
[0009] It is an object of the invention to provide a faster method for recognizing handwritten characters.
[0010] The object of the invention is achieved by a method for recognition of a handwritten character. The method comprises the steps of determining a plurality of position features defining the handwritten character, and comparing the handwritten character to reference characters stored in a database in order to find the closest matching reference character. The step of comparing comprises the steps of computing a difference between one of the plurality of position features of the handwritten character and a position feature of one of the reference characters, and determining, by lookup in a predefined table, a distance measure based on the computed difference. The step of comparing further comprises the steps of repeating the steps of computing a difference and determining a distance measure for each of the plurality of position features of the handwritten character, and computing a cost function based on the determined distance measures.
[0011] The inventive method is based on the understanding that a fast method for recognition of a handwritten character requires that the comparing that is to be performed between the handwritten character and a vast amount of reference characters is fast. Thus, if the step of comparing is speeded up, the entire recognition method becomes much faster. The step of comparing characters comprises the step of comparing several position features of the characters. According to the invention, the comparison of the position features is performed very fast. The step of comparing a position feature of the handwritten character to a position feature of a reference character includes a table lookup to determine a distance measure between the position features. This table lookup is faster than an actual calculation of a distance measure. Thus, each comparison of the handwritten character to a reference character becomes much faster and a small increase in the speed of comparing position features results in a considerably faster method of recognizing a handwritten character.
[0012] In other words, since discrete distances between feature points are measured, only a small number of different distance measures may be obtained. The invention is based on an insight that this could be used for faster recognition. Thus, these different distance measures according to the invention are stored in a table for fast access to a distance measure based on the computed difference. Then, the distance measures need not be determined by calculation, but in stead a table lookup will give the distance measure, whereby the determining of the distance measure is speeded up.
[0013] Possible values of the position features may be known before the start of the recognition, since the way the position features are determined during the recognition is known. Thus, the possible distance measures between the position features may also be known, whereby the table could be calculated and stored before the recognition is started.
[0014] The position features define the handwritten character. Preferably, the position features are points and/or vectors in the handwritten character. The vectors could, for example, describe a straight line between two points on the character or a derivative in a point of the character. The handwritten character could, of course, also be defined by any combination of points and vectors.
[0015] The distance measure is a function of the difference between a position feature of the handwritten character and a position feature of the reference character. This function does not have to be very complex; the distance measure is anyhow determined faster by a table lookup than by an actual calculation. In the context of this invention the term character is defined as any symbol that could be written. In some cases a character could be a part of such a symbol or a combined structure of such symbols.
[0016] Preferably, each position feature is defined by at least two characteristics. The step of computing a difference between a position feature of the handwritten character and a position feature of the reference character comprises the computing of a difference between each characteristic of the position feature of the handwritten character and corresponding characteristics of the position feature of the reference character. Two characteristics are normally-needed for defining a position feature, such as an x- and a y-coordinate for a point or an x- and a y-direction for a vector. In determining a distance measure, the differences in both characteristics for the compared position features are needed so that both characteristics contribute to the distance measure.
[0017] According to a preferred embodiment of the invention, the step of computing a difference for each characteristic is performed in a single operation. The method according to the invention computes the differences of the characteristics by storing the characteristics of each position feature in a single record and uses knowledge of which bits in the record represent each characteristic to compute the differences. Thus the position features could be stored in a small memory space and, in addition to the fast step of determining a distance measure, the step of computing the differences is very fast since only one machine code operation is needed for the computation of the difference in position features.
[0018] Preferably, the step of determining position features comprises a step of determining a location of the position features in a grid. Thereby, the position features of the handwritten character could easily be matched with corresponding position features of the reference characters.
[0019] In a preferred embodiment, the position features of the handwritten character and the reference characters comprise coordinates of comparison points. Thus, certain comparison points of the handwritten character could be compared to predefined comparison points of the reference characters in order to find a matching reference character.
[0020] Preferably, the step of determining position features comprises the step of determining an x-coordinate and a y-coordinate of the comparison point in a grid. Thereby, the position of a comparison point is easily described by two characteristics.
[0021] In a preferred embodiment, the grid is of a size of 16×16 positions and the coordinates of one comparison point are represented by one data byte. This grid size is optimal for unambiguously representing Chinese characters and for storing a position of one comparison point in a small amount of memory space.
[0022] Preferably, the distance measure received from the table lookup in the predefined table is a function of the Euclidean distance between the comparison point of the handwritten character and a comparison point of the reference character. The Euclidean distance gives an equally weighted measure of the difference in the x- and y-directions. The function could be the squared Euclidean distance, which gives an integer result if the entered differences are integer numbers.
[0023] In another embodiment, the position features of the handwritten character and the reference characters comprise positions and directions of comparison vectors. The comparison vectors could also be combined with the comparison points to define the characters. When the position features comprise comparison vectors the directions of strokes of the handwritten character are compared to corresponding comparison vectors of the reference characters defining the direction of strokes of the reference characters.
[0024] In this embodiment, the distance measure received from the table lookup in the predefined table is a function of a difference between curvatures of the handwritten character and the reference characters. This means that the derivatives of the strokes are compared.
[0025] Preferably, the method further comprises the step of centering the handwritten character in the grid before the step of determining the position features of the handwritten character is performed. As a result, a translation of the position of the handwritten character is accounted for and the position is adapted to the positioning of the reference characters. Thereby, the handwritten character could be drawn at any place, where detection of the writing is active.
[0026] Advantageously, the method further comprises the step of scaling the handwritten character to a normalized size in accordance with the size of the reference characters, before the step of determining the position features of the handwritten character is performed. Thus, the size of the handwritten character is not crucial for recognition.
[0027] In a preferred embodiment, the method further comprises the step of determining the number of strokes that forms the handwritten character. This is a way of classifying the characters to avoid comparing the handwritten character to every single reference character.
[0028] Preferably, the step of comparing the handwritten character to reference characters comprises the step of initially comparing the handwritten character to reference characters that are formed by the same number of strokes. As a result, the handwritten character initially is compared to the reference characters that are most likely to be the closest matching reference character.
[0029] In addition, the step of comparing preferably further comprises the step of comparing the handwritten character to reference characters that are formed by a few strokes fewer than the handwritten character to allow for erroneous merging of strokes. It is not unusual that two strokes are merged because the writer does not lift the pen when he is supposed to. This arrangement means that the right closest matching reference character should be found even if the writer wrongfully merges two strokes.
[0030] Moreover, the step of comparing preferably further comprises the step of comparing the handwritten character to reference characters that are formed by a few strokes more than the handwritten character to allow for erroneous lifting of a pen. This arrangement means that the reference character should be found even if the writer wrongfully lifts the pen in a stroke.
[0031] In another preferred embodiment, a stroke of the handwritten character is compared to a corresponding stroke of the reference character, wherein the corresponding strokes are determined by the order in which the strokes of the handwritten character are drawn. Thus, the corresponding position features of the reference characters are easily related to the position features of the handwritten character to which they correspond. This is especially useful for Chinese characters, since these have a special scheme for the order in which strokes should be drawn. This means that a skilled writer of Chinese characters seldom draws strokes of a character in the wrong order.
[0032] Preferably, the method further comprises the step of reorganizing the order of the strokes of the handwritten character to allow for erroneous order of drawing the strokes. This arrangement makes it possible to find a correct closest matching reference character even if the writer draws the strokes of the character in the wrong order.
[0033] In a prefer-red embodiment, the method further comprises the step of computing an affine transformation of the handwritten character to compensate for possible slant of the handwritten character, and subsequently comparing the transformed character to the reference characters of the database. This arrangement results in that the correct closest matching reference character can be found even if the writer draws a sloping character.
[0034] The object of the invention is also achieved by a device for recognition of a handwritten character and for transforming it into a digital format. The device comprises means for determining a plurality of position features defining the handwritten character, a database, comprising reference characters, and means for comparing the handwritten character to the reference characters of said database in order to find the closest matching reference character. Said means for comparing comprises means for computing a difference between one of the plurality of position features of the handwritten character and a position feature of one of the reference characters, and a predefined table, which defines a distance measure based on differences in position features. Said means for comparing further comprises means for determining a distance measure by lookup in said predefined table, and means for computing a cost function based on the determined distance measures.
[0035] Such a device could be used for input of text to a data handling device, thus replacing or complementing the keyboards. The table lookup according to the invention makes the recognition of handwritten characters very fast. Thus annoying waiting times are eliminated.
[0036] The object of the invention is also achieved by a computer program according to claim
[0037] The present invention will now be described in more detail by way of example referring to the appended drawings.
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045] In
[0046] Referring to FIGS.
[0047] Referring to
[0048] Referring to
[0049] The preprocessing comprises the step of centering, step
[0050] The handwritten character is constituted of strokes, that is lines drawn without lifting the pen. Each stroke is sampled and position features are determined. The sampling could detect a position feature at specific intervals and the location of the pen at that time determines the position feature. Alternatively, the start and end positions of the stroke are determined. An additional position is determined by calculating which point on the stroke that deviates most from a straight line between the start and end position. Further additional positions could be determined in the same manner. A position feature of the handwritten character could be coordinates of a sampled point. It could alternatively be a direction vector between two adjacent sampled points or a curvature vector, defining the difference in direction between two adjacent direction vectors.
[0051] The strokes are listed according to the order in which they are drawn. The first stroke of the handwritten character is then compared to the first stroke in the reference character and so on. This is especially useful for Chinese characters since the stroke order is unambiguous. However, if the strokes are drawn in the wrong order, this could be accounted for by reshuffling the order of the strokes. The reshuffling could be performed by comparing each stroke of the handwritten character to each stroke of the reference character and determining which stroke is the best match to each stroke of the handwritten character.
[0052] The handwritten character is represented by a plurality of position features. These position features could comprise coordinates of sampled points, direction vectors, curvature vectors or any combination of these. The position features of the handwritten character are compared to position features of the reference characters in order to find the closest matching reference character. The position features of the reference characters are predefined and represent the same characteristics as the position features extracted from the handwritten character. However, it is not necessary that there is a corresponding position feature for every position feature of the handwritten character. One position feature of the reference character could be used for comparison with two or more position features of the handwritten character, or vice versa. The strokes need varying numbers of position features to be well defined. Thus, three position features of the handwritten character could be compared to four position features of a reference character. In this case, it is necessary to determine which position features of the reference character correspond to the position features of the handwritten character. This implies that the three position features of the reference character that differ least from the position features of the handwritten character could be selected as corresponding position features of the reference character. Alternatively, one position feature of the handwritten character could be assigned two corresponding position features and two distance measures could be calculated for this position feature.
[0053] In a preferred embodiment, the position features comprise comparison points of the characters. The positions of the comparison points in the grid are determined by its x- and y-coordinates. The grid preferably consists of 16×16 squares and thus a comparison point could be represented by one byte of data since four bits are needed for the x- and y-coordinates, respectively.
[0054] Referring to
[0055] could be used as the distance measure, where f and g are functions and (x
[0056] In the preferred embodiment, the table defines the distance measure as the squared Euclidean distance between the points, i.e. the table gives the result of
[0057] This gives a positive value for all distances and further gives an integer result if the two differences are integer numbers.
[0058] The coordinates (X
[0059] If a 16×16 grid is used, all points are not guaranteed to be at most 8 x-ticks away from each other. However, strokes of Chinese characters are mainly drawn left to right or downwards, so there will be little risk of confusion. Alternatively, an 8×8 grid could be used, which means that-only three bits would have to be used for representation of each coordinate. This would however yield a resolution that is too coarse for Chinese characters, but could be used for other applications.
[0060] The lookup in the table returns a result of a distance measure. This determination of a distance measure, step
[0061] If the sum of the determined distance measures of a reference character exceeds the sum of the closest matching reference character so far before all distance measures have been determined for the reference character, the comparing could be interrupted. In that case, the reference character is rejected before all distance measures have been determined, because the sum of the distance measures is already too high.
[0062] The steps
[0063] Referring to
[0064] However, when a user draws a handwritten character, two strokes could be merged together erroneously or a single stroke could be divided into two if the user lifts the pen in the middle of the stroke. This means that the handwritten character should be compared to reference characters with a slightly different number of strokes. The positioning of the strokes in the handwritten character is investigated. Pairs of strokes where one stroke has its end close to the beginning of the other stroke are merged, step
[0065] Further, a stroke could be divided, step
[0066] Thus, a great part of the reference characters are never compared to the handwritten character, since these reference characters have a number of strokes that differ too much from the number of strokes of the handwritten character.
[0067] Referring to
[0068] As can be seen from the above, a great number of comparisons have to be made. The handwritten character should be compared to many different reference characters. Furthermore, the handwritten character could have been drawn in a slightly erroneous manner. In order to compensate for this, some transformations (merging of strokes, dividing of strokes, affine transformations) need to be made of the handwritten character and the new characters obtained from these transformations have to be compared to the reference characters. It is therefore a great advantage if the comparison between characters is fast. This is accomplished by the table lookup for the determining of distance measures according to the invention.
[0069] Above, the description has been made essentially on the basis of the characters being written on a display and being detected at the same time as they are written. An alternative is that the characters are detected, for instance scanned, after they have been written on a piece of paper. This concerns handwritten characters as well as typewritten ones. Thus, the detection comprises, instead of the operation of recognizing the display writing, the operation of reading (scanning) the characters from the piece of paper. Position features of the read characters are thus detected and recognition could be performed as described above.
[0070] Referring to
[0071] The data handling device
[0072] The means for comparing
[0073] The means for comparing
[0074] When the closest matching character is displayed the user could be asked to check if the handwritten character has been correctly recognized. If the user rejects the closest matching character, the data handling device
[0075] The data handling device
[0076] It should be emphasized that the preferred embodiment described herein is in no way limiting and that many alternative embodiments are possible within the scope of protection defined by the appended claims. For example, the grid could be of other sizes, e.g. 8×8 or 32×32, or even of asymmetrical size, such as 16×8. It is, however, appropriate that the grid size is a power of two, as the x- and y-coordinates are represented in binary numbers. Accordingly, for example three or five bits could be used to represent a coordinate.