Handwritten multi-line character segmentation method, device and equipment
By setting estimated height, width and height thresholds, and offset matrices, and combining various segmentation operations, the problem of inaccurate segmentation of multi-line characters in handwritten text is solved, achieving efficient and accurate character segmentation and standardized typesetting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SUNIA PTE LTD
- Filing Date
- 2023-03-31
- Publication Date
- 2026-07-21
AI Technical Summary
Existing technologies lack methods for segmenting and organizing multi-line characters in handwritten text, and cannot adjust abnormal strokes and character line spacing while preserving the user's handwriting, resulting in inaccurate segmentation.
By setting estimated height, width and height thresholds, and offset matrices, operations such as deleting abnormal strokes, pre-segmentation, handling isolated points, re-segmenting excessively large lines, re-sorting lines, merging spaces, and judging single characters are performed to achieve accurate segmentation of handwritten multi-line characters.
It improves the accuracy of segmenting handwritten multi-line characters, ensuring that the segmented text is neatly and properly formatted without altering the original handwriting.
Smart Images

Figure CN116363659B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, and device for segmenting handwritten multi-line characters. Background Technology
[0002] With the development of technology, people are becoming increasingly accustomed to using handwriting tablets or touchscreens to handwrite text. When handwriting text, unlike typing and chatting on ordinary mobile devices, existing technology can simulate real-world handwriting, that is, handwriting within the same space. The strokes on the handwriting tablet or touchscreen are directly mapped into the text, similar to drawing.
[0003] Therefore, to better identify each character in text, existing technologies include handwritten character segmentation, primarily used to separate letters and numbers in handwritten text. It helps computers recognize and interpret handwritten text, supporting machine learning and natural language processing applications. Its main principle is to use various data processing techniques to analyze the shape, size, spelling, continuity, and other features of handwritten characters, and then identify each character based on these features.
[0004] However, existing technologies lack methods for segmenting and organizing text, meaning they lack methods to adjust abnormal strokes, character line spacing, etc., while preserving the user's handwriting. Summary of the Invention
[0005] In view of the above technical problems, the present invention provides a method, apparatus and device for segmenting handwritten multi-line characters. The method can segment and organize handwritten multi-line characters in text and improve the accuracy of line segmentation.
[0006] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.
[0007] According to one aspect of this disclosure, a method for segmenting handwritten multi-line characters is proposed for recognizing text, wherein the text includes multiple lines of handwritten characters, each character consisting of one or more strokes, each of which can be read; the segmentation method includes:
[0008] Set the estimated height, width and height thresholds, and offset matrix of the current text. The estimated height is a first proportion of the height of all the positions of the number of strokes. The width and height thresholds are the larger of the average width and height of all the strokes. The offset matrix is the minimum X-axis value of the current object minus the estimated height, and the maximum X-axis value plus the square rectangle of the strokes contained in the comparison object within the estimated height range.
[0009] Based on the estimated height, the width and height thresholds, and the offset matrix, one or more segmentation operations are performed on the text. The segmentation operations include deleting abnormal strokes; pre-segmentation; separating isolated points and inverted strokes into separate lines; re-segmenting excessively large lines; re-sorting lines; spatial merging; dividing lines into multiple lines if the word spacing in the middle of a line is too large; and determining whether the entire text is a single character.
[0010] Furthermore, the deletion of abnormal strokes includes deleting strokes that have one of the following conditions:
[0011] Both width and height are greater than 5 times the aforementioned width and height thresholds;
[0012] The height is greater than 7 times the width and height thresholds;
[0013] The height is greater than 3.75 times the estimated height.
[0014] Furthermore, the pre-segmentation includes segmenting the strokes that have one of the following conditions into the next line:
[0015] The maximum X-axis value of all strokes in the current row minus the maximum X-axis value of the existing strokes is greater than the estimated height;
[0016] The minimum Y-axis value of the existing stroke minus the maximum Y-axis value of all strokes in the current row is greater than twice the estimated height;
[0017] The minimum Y-axis value of the stroke is greater than the maximum Y-axis value of the offset matrix.
[0018] Furthermore, the isolated points and reverse strokes are on a separate line, including:
[0019] The strokes that do not belong to all of the strokes containing points with a positive Y-axis value and an area of 95.449974% of the information interval are arranged in a separate line.
[0020] The aforementioned excessive row re-segmentation includes:
[0021] If the height of a row in the already classified rows is greater than twice the estimated height, it is divided into rows by the number of classes based on density clustering analysis.
[0022] Furthermore, the reordering of rows includes placing rows with smaller center values of their bounding rectangles at the front.
[0023] Furthermore, the space merging includes: comparing the characters in two adjacent lines, and merging the two adjacent lines when one of the following conditions is met;
[0024] The minimum Y-axis value of the current row is greater than the minimum Y-axis value of the compared row, and the maximum Y-axis value of the current row is less than the maximum Y-axis value of the compared row;
[0025] The current row and the comparison row have a height less than 0.9 times the estimated height, and the ratio of the overlap height of the current row and the comparison row to the height of the two rows is greater than 0.85;
[0026] The overlap height of the current row and the comparison row is greater than 0.9 times the height of the two rows, and the height of the overlap position of the current row and the comparison row is greater than 0.9 times the merged height of the overlap position of the two rows.
[0027] Furthermore, the excessive spacing between words in the middle of a line, resulting in multiple lines, includes:
[0028] If the distance between two characters in the same line is greater than 5 times the estimated height, then the line is divided into two lines using the middle of the two characters as the dividing line.
[0029] Furthermore, the determination of whether the entire text is a single character includes:
[0030] If the entire text consists of multiple lines and the width of the entire text is greater than twice its height, then it is not a single word;
[0031] If the height of the entire text is greater than twice its width, it is a single word.
[0032] According to a second aspect of this disclosure, a handwritten multi-line character segmentation device is provided, comprising: a preset module, the preset module being used to set an estimated height, width and height thresholds, and an offset matrix for the current text, wherein the estimated height is a first proportional value of the height of all stroke positions, the width and height thresholds are the larger of the average width and height of all the strokes, and the offset matrix is a rectangle formed by subtracting the estimated height from the minimum X-axis value of the current character and adding the estimated height to the maximum X-axis value; and an execution module, the execution module being used to perform one or more segmentation operations on the text based on the estimated height, the width and height thresholds, and the offset matrix, wherein the segmentation operations include deleting abnormal strokes; pre-segmentation; separating isolated points and inverted strokes into separate lines; re-segmenting excessively large lines; re-sorting lines; merging spaces; dividing lines into multiple lines if the word spacing between words is too large; and determining whether the entire text is a single character.
[0033] According to a third aspect of this disclosure, a handwritten multi-line character segmentation device is provided, comprising: setting an estimated height, a width and height threshold, and an offset matrix for the current text, wherein the estimated height is a first proportional value of the height of all the stroke positions, the width and height threshold is the larger of the average width and height of all the strokes, and the offset matrix is a rectangle formed by subtracting the estimated height from the minimum X-axis value of the current character and adding the estimated height to the maximum X-axis value; performing one or more segmentation operations on the text based on the estimated height, the width and height threshold, and the offset matrix, wherein the segmentation operations include deleting abnormal strokes; pre-segmentation; separating isolated points and inverted strokes into separate lines; re-segmenting excessively large lines; re-sorting lines; merging spaces; dividing lines into multiple lines if the word spacing between words is too large; and determining whether the entire text is a single character.
[0034] The technical solution disclosed herein has the following beneficial effects:
[0035] Based on the handwritten multi-line character segmentation method, abnormal strokes are first removed to avoid affecting the segmentation and subsequent recognition results. Pre-segmentation is then used to roughly segment the strokes into multiple lines. Then, isolated points and reverse strokes are grouped into a single line; excessively large lines are further segmented, and the lines are reordered, spaces are merged, and lines with excessively large word spacing are divided into multiple lines to improve line segmentation accuracy. Finally, whether a second segmentation method needs to be added is determined based on whether the entire text consists of single characters.
[0036] This invention does not alter the original handwriting, but precisely and efficiently segments handwritten multi-line characters, resulting in a more standardized and neat layout for handwritten text. Attached Figure Description
[0037] Figure 1 This is a flowchart of a handwritten multi-line character segmentation method as described in the embodiments of this specification;
[0038] Figure 2 This is a schematic diagram of the text to be operated in the embodiments of the specification;
[0039] Figure 3 for Figure 2 A diagram of the text after deleting abnormal strokes;
[0040] Figure 4 This is another schematic diagram of text to be operated in the embodiments of the specification;
[0041] Figure 5 for Figure 4 A diagram of the text after segmentation;
[0042] Figure 6 This is a schematic diagram illustrating one possible result of determining whether an entire text is a single character in an embodiment of the specification.
[0043] Figure 7This is a schematic diagram illustrating another result of determining whether an entire text is a single character in the embodiments of the specification;
[0044] Figure 8 This is a structural diagram of a handwritten multi-line character segmentation device according to an embodiment of the specification.
[0045] Figure 9 This specification describes a terminal device for implementing a handwritten multi-line character segmentation method in an embodiment of the present invention.
[0046] Figure 10 This is a computer-readable storage medium used to implement a handwritten multi-line character segmentation method in the embodiments of this specification. Detailed Implementation
[0047] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this disclosure more comprehensive and complete, and to fully convey the concept of the example embodiments to those skilled in the art. The described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a full understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced with one or more of the specific details omitted, or other methods, components, apparatus, steps, etc., can be employed. In other instances, well-known technical solutions are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0048] Furthermore, the accompanying drawings are merely illustrative of this disclosure. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0049] like Figure 1 As shown in the embodiments of this specification, a method for segmenting handwritten multi-line characters is provided. The execution subject of this method can be a terminal device, such as a mobile phone, tablet computer, or personal computer. This method is applied to the recognition of text, which includes multiple lines of handwritten characters. Each character is composed of one or more strokes, and each stroke can be read. Specifically, the method may include the following steps S101-S102:
[0050] In step S101, the estimated height, width and height thresholds, and offset matrix of the current text are set. The estimated height is a first proportion of the height of all the stroke positions. The width and height thresholds are the larger of the average width and height of all the strokes. The offset matrix is the minimum X-axis value of the current object minus the estimated height, and the maximum X-axis value plus the square rectangle of the strokes contained in the comparison object within the estimated height range.
[0051] In the estimated height, the stroke height can refer to the vertical height covered by each stroke, that is, the distance from the highest point to the lowest point of the stroke. The stroke height at all stroke positions can be the average height of all strokes. The first ratio value can be 0.89. Then the estimated height is 0.89 * the stroke height at all stroke positions.
[0052] In the width and height threshold, the width and height of a stroke can refer to the horizontal width and vertical height covered by each stroke. The average width and average height of all strokes can refer to the average value obtained by adding the width and height of all strokes separately and dividing by the number of strokes. The larger of the average width and average height values refers to the value of the larger average width and average height, which is the width and height threshold.
[0053] In the offset matrix, the minimum X-axis value of the current character can be the X-axis coordinate of the leftmost stroke of the current object in the horizontal direction. The maximum X-axis value can be the X-axis coordinate of the rightmost stroke of the current object in the horizontal direction. Comparison object: refers to the reference object, that is, the object that the current object needs to be compared with. The current object can be the current character, and the comparison object is other characters compared with the current character, such as adjacent characters; the current object can also be the characters in the current line. Right rectangle: refers to a rectangle in which all corners are right angles.
[0054] Specifically, in this embodiment of the invention, the left boundary value of the current object is obtained by subtracting the estimated height from the minimum X-axis value of the current object. The right boundary value of the current object is obtained by adding the estimated height to the maximum X-axis value of the current object. Then, it is determined whether there is a horizontal overlap between the current object and the reference object: if the right boundary value of the current object is less than the left boundary value of the reference object, or the left boundary value of the current object is greater than the right boundary value of the reference object, then there is no horizontal overlap; if the right boundary value of the current object is greater than or equal to the left boundary value of the reference object, and the left boundary value of the current object is less than or equal to the right boundary value of the reference object, then there is a horizontal overlap. If there is a horizontal overlap, the rectangle formed by all the strokes in the reference object is shifted to the right by the distance between the left boundary value of the current object and the left boundary value of the reference object, thus obtaining the offset matrix. If there is no horizontal overlap, the offset matrix is 0. By calculating the offset matrix, it is possible to combine the strokes or lines of text in handwritten text in the correct order, thereby achieving automatic text segmentation and recognition.
[0055] In step S102, based on the estimated height, the width and height thresholds, and the offset matrix, one or more segmentation operations are performed on the text. The segmentation operations include deleting abnormal strokes; pre-segmentation; separating isolated points and inverted strokes into separate lines; re-segmenting excessively large lines; re-sorting lines; spatial merging; dividing lines into multiple lines if the word spacing in the middle of a line is too large; and determining whether the entire text is a single character.
[0056] The specific details of the segmentation operation are obtained from the following implementation method.
[0057] In one embodiment, deleting abnormal strokes includes deleting strokes that have one of the following conditions:
[0058] Width and height are both greater than 5 times the width and height thresholds; height is greater than 7 times the width and height thresholds; height is greater than 3.75 times the estimated height.
[0059] Among them, such as Figure 2 As shown, Figure 2 The abnormal strokes are two diagonal lines that cross the character. By deleting the abnormal strokes, these two diagonal lines are identified and deleted. In existing electronic handwriting records, each stroke has a corresponding record; after identifying the abnormal stroke, it can be directly deleted. After deleting the abnormal stroke, as... Figure 3 As shown.
[0060] In one implementation, the pre-segmentation can be triggered by conditions 1-3:
[0061] Condition 1: The maximum X-axis value of all strokes in the current row minus the maximum X-axis value of the existing strokes is greater than the estimated height; Condition 2: The minimum Y-axis value of the existing strokes minus the maximum Y-axis value of all strokes in the current row is greater than twice the estimated height; Condition 3: The minimum Y-axis value of the existing strokes is greater than the maximum Y-axis value of the offset matrix.
[0062] like Figure 4 As shown, if the strokes in the current row satisfy both conditions 1 and 3, or both conditions 2 and 3, then the current stroke belongs to the next row.
[0063] In one embodiment, the isolated point and the reverse stroke are arranged in a separate line, including: the strokes that do not belong to all the strokes and whose Y-axis value is distributed in a positive interval with an area of 95.449974%, and are arranged in a separate line.
[0064] Specifically, such as Figure 5 As shown, Figure 5 Yes Figure 4 This describes the results of performing operations on isolated points and reverse strokes as separate lines. Isolated points refer to one or more discrete strokes that are not connected to other strokes. In handwritten characters, these points are usually caused by improper writing or hand tremors. Reverse strokes refer to strokes where the hand movement is opposite to the normal direction. For example, normally we write a straight line from top to bottom, but reverse strokes are from bottom to top; or we write an arc clockwise, but reverse strokes are counterclockwise, and so on. The presence of these reverse strokes can also affect character recognition.
[0065] If the Y-axis coordinate of a stroke is not within the normal distribution confidence interval (95.449974%) of the Y-axis coordinates of all strokes in the current row, then this stroke is considered not to belong to the current row and is treated as a separate row.
[0066] In one embodiment, the oversized row resegmentation includes: in the already classified rows, if the row height is greater than twice the estimated height, dividing the rows by the number of classes based on density clustering analysis.
[0067] For details, please continue reading. Figure 5 , Figure 5 Yes Figure 4 The result of the large line re-segmentation operation. If the height of a line is greater than twice the estimated height, that line will be re-segmented. The specific re-segmentation method uses density clustering analysis to cluster the strokes in the line into several categories, and then assigns different categories of strokes to different lines. If there are several categories of strokes, then the line is divided into several lines. This effectively avoids some excessively large lines affecting the overall text recognition performance.
[0068] In one embodiment, the reordering of rows includes placing rows with smaller center values of their bounding rectangles at the front.
[0069] Please continue reading for more details. Figure 5 , Figure 5 Yes Figure 4 The result after reordering the rows. The rows with smaller center values of their bounding rectangles are placed at the front, and the rows with higher center values are placed before the rows with lower center values. This makes the vertical structure of the text clearer and the entire text look more natural and fluid.
[0070] In one implementation, please refer to... Figure 5 , Figure 5 Yes Figure 4 The result of the space merging operation, wherein the space merging includes: comparing the characters in two adjacent lines, and merging the two adjacent lines when one of the following conditions is met;
[0071] The minimum Y-axis value of the current row is greater than the minimum Y-axis value of the compared row, and the maximum Y-axis value of the current row is less than the maximum Y-axis value of the compared row;
[0072] The current row and the comparison row have a height less than 0.9 times the estimated height, and the ratio of the overlap height of the current row and the comparison row to the height of the two rows is greater than 0.85;
[0073] The overlap height of the current row and the comparison row is greater than 0.9 times the height of the two rows, and the height of the overlap position of the current row and the comparison row is greater than 0.9 times the merged height of the overlap position of the two rows.
[0074] In one implementation, please refer to... Figure 5 , Figure 5 Yes Figure 4 The result of splitting excessively large line spacing into multiple lines includes:
[0075] If the distance between two characters in the same line is greater than 5 times the estimated height, then the line is divided into two lines using the middle of the two characters as the dividing line.
[0076] In one implementation, such as Figure 6 and Figure 7 As shown, Figure 6 and Figure 7 These are two results after the operation of "determining whether the entire text is a single character". Determining whether the entire text is a single character includes:
[0077] If the entire text consists of multiple lines and the width of the entire text is greater than twice its height, then it is not a single word;
[0078] If the height of the entire text is greater than twice its width, it is a single word.
[0079] Based on the same line of thought, such as Figure 8 As shown, an exemplary embodiment of this disclosure also provides a handwritten multi-line character segmentation device 800, including a preset module 801, which is used to set the estimated height, width and height thresholds, and offset matrix of the current text. The estimated height is a first proportion of the height of all stroke positions, the width and height thresholds are the larger of the average width and height of all strokes, and the offset matrix is a rectangle formed by subtracting the estimated height from the minimum X-axis value of the current character and adding the estimated height to the maximum X-axis value. An execution module 802 is used to perform one or more segmentation operations on the text based on the estimated height, the width and height thresholds, and the offset matrix. The segmentation operations include deleting abnormal strokes; pre-segmentation; separating isolated points and inverted strokes into separate lines; re-segmenting excessively large lines; re-sorting lines; merging spaces; dividing lines into multiple lines if the word spacing is too large; and determining whether the entire text is a single character.
[0080] Using the aforementioned handwritten multi-line character segmentation device 800, abnormal strokes are first removed to avoid them affecting segmentation and subsequent recognition results. Pre-segmentation is then used to roughly segment strokes into multiple lines. Isolated points and reverse strokes are then used to group them into a single line; excessively large lines are further segmented, and the lines are reordered, spaces are merged, and lines with excessively large word spacing are divided into multiple lines to improve line segmentation accuracy. Finally, whether a second segmentation method needs to be added is determined based on whether the entire text consists of a single character.
[0081] The handwritten multi-line character segmentation device 800 does not change the original handwriting, but performs precise and efficient segmentation of handwritten multi-line characters, making the handwritten text have a more standardized and neat layout.
[0082] The specific details of each module / unit in the above-mentioned device have been described in detail in the method section of the implementation. For any undisclosed details, please refer to the implementation content of the method section, and therefore will not be repeated here.
[0083] Based on the same idea, this specification also provides a handwritten multi-line character segmentation device, such as... Figure 9 As shown.
[0084] The handwritten multi-line character segmentation device can be the terminal device or server provided in the above embodiments.
[0085] Handwritten multi-line character segmentation devices can vary considerably depending on configuration and performance. They may include one or more processors 901 and memory 902, which may store one or more application programs or data. The memory 902 may include readable media in the form of volatile memory cells, such as random access memory (RAM) and / or cache memory, and may further include read-only memory cells. The application programs stored in the memory 902 may include one or more program modules (not shown in the figures), including but not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Furthermore, the processor 901 may be configured to communicate with the memory 902 and execute a series of computer-executable instructions stored in the memory 902 on the handwritten multi-line character segmentation device. The handwritten multi-line character segmentation device may also include one or more power supplies 903, one or more wired or wireless network interfaces 904, one or more I / O interfaces (input / output interfaces) 905, one or more external devices 906 (e.g., keyboards, drawing tablets, Bluetooth devices, etc.), and may also communicate with one or more devices that enable users to interact with the device, and / or with any device that enables the device to communicate with one or more other computing devices (e.g., routers, modems, etc.). This communication can be performed through the I / O interface 905. Furthermore, the device can also communicate with one or more networks (e.g., local area networks (LANs)) through the wired or wireless interface 904.
[0086] Specifically, in this embodiment, the handwritten multi-line character segmentation device includes a memory and one or more programs, wherein one or more programs are stored in the memory, and one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the handwritten multi-line character segmentation device, and is configured to be executed by one or more processors. The one or more programs include computer-executable instructions for performing the following:
[0087] Set the estimated height, width and height thresholds, and offset matrix of the current text. The estimated height is a first proportion of the height of all the positions of the number of strokes. The width and height thresholds are the larger of the average width and height of all the strokes. The offset matrix is the minimum X-axis value of the current object minus the estimated height, and the maximum X-axis value plus the square rectangle of the strokes contained in the comparison object within the estimated height range.
[0088] Based on the estimated height, the width and height thresholds, and the offset matrix, one or more segmentation operations are performed on the text. The segmentation operations include deleting abnormal strokes; pre-segmentation; separating isolated points and inverted strokes into separate lines; re-segmenting excessively large lines; re-sorting lines; spatial merging; dividing lines into multiple lines if the word spacing in the middle of a line is too large; and determining whether the entire text is a single character.
[0089] Based on the same idea, exemplary embodiments of this disclosure also provide a computer-readable storage medium storing a program product capable of implementing the methods described above. In some possible embodiments, various aspects of this disclosure can also be implemented as a program product including program code, which, when the program product is run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this specification according to the various exemplary embodiments of this disclosure.
[0090] refer to Figure 10 As shown, a program product 1000 for implementing the above-described method according to an exemplary embodiment of the present disclosure is described. This product may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a personal computer. However, the program product of the present disclosure is not limited thereto. In this document, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0091] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0092] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, carrying readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium, capable of sending, propagating, or transmitting programs for use by or in conjunction with an instruction execution system, apparatus, or device.
[0093] The program code contained on the readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0094] Program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing devices can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0095] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, terminal device, or network device, etc.) to execute the method according to the exemplary embodiments of this disclosure.
[0096] Furthermore, the above figures are merely illustrative representations of the processes included in the methods according to exemplary embodiments of this disclosure, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Additionally, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0097] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to exemplary embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0098] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0099] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A method for segmenting handwritten multi-line characters, characterized in that, The method is applied to text recognition, wherein the text includes multiple lines of handwritten characters, each character consisting of one or more strokes, and each stroke can be read. The segmentation method includes: Set the estimated height, width and height thresholds, and offset matrix of the current text. The estimated height is a first proportion of the height of all the positions of the number of strokes. The width and height thresholds are the larger of the average width and height of all the strokes. The offset matrix is the minimum X-axis value of the current object minus the estimated height, and the maximum X-axis value plus the square rectangle of the strokes contained in the comparison object within the estimated height range. Based on the estimated height, the width and height thresholds, and the offset matrix, one or more segmentation operations are performed on the text. These segmentation operations include: deleting abnormal strokes; pre-segmentation; separating isolated points and inverted strokes into a single line; re-segmenting excessively large lines; re-sorting lines; spatial merging; dividing lines into multiple lines if the word spacing is too large; and determining whether the entire text is a single character. Separating isolated points and inverted strokes into a single line includes strokes that do not belong to all of the strokes and whose Y-axis value contains a positive interval area of 95.449974%, which are then separated into a single line. Re-segmenting excessively large lines includes: in already classified lines, if the line height is greater than twice the estimated height, dividing it into lines according to the number of clusters based on density clustering analysis. The space merging involves comparing the characters in two adjacent lines and merging the two adjacent lines if one of the following conditions is met: The minimum Y-axis value of the current row is greater than the minimum Y-axis value of the compared row, and the maximum Y-axis value of the current row is less than the maximum Y-axis value of the compared row; The current row and the comparison row have a height less than 0.9 times the estimated height, and the ratio of the overlap height of the current row and the comparison row to the height of the two rows is greater than 0.85; The overlap height of the current row and the comparison row is greater than 0.9 times the height of the two rows, and the height of the overlap position of the current row and the comparison row is greater than 0.9 times the merged height of the overlap position of the two rows; The pre-segmentation includes dividing the strokes that have one of the following conditions into the next line: The maximum X-axis value of all strokes in the current row minus the maximum X-axis value of the existing strokes is greater than the estimated height; The minimum Y-axis value of the existing stroke minus the maximum Y-axis value of all strokes in the current row is greater than twice the estimated height; The minimum Y-axis value of the stroke is greater than the maximum Y-axis value of the offset matrix.
2. The handwritten multi-line character segmentation method according to claim 1, characterized in that, The deletion of abnormal strokes includes deleting strokes that have one of the following conditions: Both width and height are greater than 5 times the aforementioned width and height thresholds; The height is greater than 7 times the width and height thresholds; The height is greater than 3.75 times the estimated height.
3. The handwritten multi-line character segmentation method according to claim 1, characterized in that, The reordering of rows includes placing rows with smaller center values of their bounding rectangles at the front.
4. The handwritten multi-line character segmentation method according to claim 1, characterized in that, The excessive spacing between words in a line divides the line into multiple lines, including: If the distance between two characters in the same line is greater than 5 times the estimated height, then the line is divided into two lines using the middle of the two characters as the dividing line.
5. The handwritten multi-line character segmentation method according to claim 1, characterized in that, The determination of whether the entire text is a single character includes: If the entire text consists of multiple lines and the width of the entire text is greater than twice its height, then it is not a single word; If the height of the entire text is greater than twice its width, it is a single word.
6. A handwritten multi-line character segmentation device, comprising: The preset module is used to set the estimated height, width and height thresholds, and offset matrix of the current text. The estimated height is a first proportion of the height of all stroke positions. The width and height thresholds are the larger of the average width and height of all strokes. The offset matrix is a rectangle formed by subtracting the estimated height from the minimum X-axis value of the current character and adding the estimated height to the maximum X-axis value. The execution module is configured to perform one or more segmentation operations on the text based on the estimated height, the width and height thresholds, and the offset matrix. The segmentation operations include deleting abnormal strokes and pre-segmentation. Isolated points and inverted strokes are placed on separate lines; large lines are then split; lines are reordered; spaces are merged. The word spacing between lines is too large, resulting in multiple lines. Determine whether the entire text consists of single characters; The isolated points and reverse strokes are listed as separate lines, including strokes that do not belong to all the strokes and whose Y-axis value positive distribution interval area is 95.449974%, which are listed as separate lines; the excessively large lines are further segmented, including: in the already classified lines, if the line height is greater than twice the estimated height, the lines are divided according to the number of classes based on density clustering analysis. The space merging involves comparing the characters in two adjacent lines and merging the two adjacent lines if one of the following conditions is met: The minimum Y-axis value of the current row is greater than the minimum Y-axis value of the compared row, and the maximum Y-axis value of the current row is less than the maximum Y-axis value of the compared row; The current row and the comparison row have a height less than 0.9 times the estimated height, and the ratio of the overlap height of the current row and the comparison row to the height of the two rows is greater than 0.85; The overlap height of the current row and the comparison row is greater than 0.9 times the height of the two rows, and the height of the overlap position of the current row and the comparison row is greater than 0.9 times the merged height of the overlap position of the two rows; The pre-segmentation includes dividing the strokes that have one of the following conditions into the next line: The maximum X-axis value of all strokes in the current row minus the maximum X-axis value of the existing strokes is greater than the estimated height; The minimum Y-axis value of the existing stroke minus the maximum Y-axis value of all strokes in the current row is greater than twice the estimated height; The minimum Y-axis value of the stroke is greater than the maximum Y-axis value of the offset matrix.
7. A handwritten multi-line character segmentation device, comprising: processor; and a memory configured to store computer-executable instructions, which, when executed, cause the processor to: Set the estimated height, width and height thresholds, and offset matrix of the current text. The estimated height is the first proportional value of the height of all stroke positions. The width and height thresholds are the larger of the average width and height of all strokes. The offset matrix is a square rectangle formed by subtracting the estimated height from the minimum X-axis value of the current character and adding the estimated height to the maximum X-axis value. Based on the estimated height, the width and height thresholds, and the offset matrix, one or more segmentation operations are performed on the text, including deleting abnormal strokes and pre-segmentation. Isolated points and inverted strokes are placed on separate lines; large lines are then split; lines are reordered; spaces are merged. The word spacing between lines is too large, resulting in multiple lines. Determine whether the entire text consists of single characters; The isolated points and reverse strokes are listed as separate lines, including strokes that do not belong to all the strokes and whose Y-axis value positive distribution interval area is 95.449974%, which are listed as separate lines; the excessively large lines are further segmented, including: in the already classified lines, if the line height is greater than twice the estimated height, the lines are divided according to the number of classes based on density clustering analysis. The space merging involves comparing the characters in two adjacent lines and merging the two adjacent lines if one of the following conditions is met: The minimum Y-axis value of the current row is greater than the minimum Y-axis value of the compared row, and the maximum Y-axis value of the current row is less than the maximum Y-axis value of the compared row; The current row and the comparison row have a height less than 0.9 times the estimated height, and the ratio of the overlap height of the current row and the comparison row to the height of the two rows is greater than 0.85; The overlap height of the current row and the comparison row is greater than 0.9 times the height of the two rows, and the height of the overlap position of the current row and the comparison row is greater than 0.9 times the merged height of the overlap position of the two rows; The pre-segmentation includes dividing the strokes that have one of the following conditions into the next line: The maximum X-axis value of all strokes in the current row minus the maximum X-axis value of the existing strokes is greater than the estimated height; The minimum Y-axis value of the existing stroke minus the maximum Y-axis value of all strokes in the current row is greater than twice the estimated height; The minimum Y-axis value of the stroke is greater than the maximum Y-axis value of the offset matrix.