A method, apparatus and device for digital processing of text

By correcting the skeleton information of the target text in calligraphy learning, dividing strokes and restoring stroke orders, widening processing, and generating standard dot sets, the shaking and bending problems of characters restored in calligraphy learning are solved, the restoration degree and aesthetic effect are improved, and personalized needs are met.

CN114494508BActive Publication Date: 2025-08-01UBTECH ROBOTICS CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111633597.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-28
Publication Date
2025-08-01
Estimated Expiration
2041-12-28

AI Technical Summary

Technical Problem

In the calligraphy learning, in the existing technology, there is jitter and bend when collecting standard dots of text through equipment to restore, and a single standard font cannot meet personalized needs.

Method used

By obtaining the skeleton information of the target text, correcting the wrong pixel points, dividing strokes and restoring stroke orders, and widening the process based on line width information to generate a standard point set.

Benefits of technology

It reduces the distortion rate in text restoration, improves the restoration and aesthetic effect of text, and meets the needs of personalized calligraphy learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114494508B_ABST
    Figure CN114494508B_ABST
Patent Text Reader

Abstract

The present application provides a method, apparatus and device for digital processing of text, which relates to the technical field of information processing, and can reduce the distortion rate of the digital standard point set in text restoration, and improve the restoration degree and aesthetic effect of text. The method includes: obtaining first skeleton information of the target text, where the first skeleton information is a plurality of pixel points extracted from the target image, and the target image is an image corresponding to the target text; correcting the pixel points with errors in the first skeleton information to obtain second skeleton information; performing stroke division and stroke order restoration on the second skeleton information to obtain first stroke order information; and performing widening processing on the pixel points in the first stroke order information according to the line width information to obtain the standard point set of the target text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information processing technologies, and in particular, to a method, apparatus, and device for digital processing of text. Background Art

[0002] When guiding students to learn calligraphy, it is often necessary to evaluate the text written by the students. Generally, the written text is compared with the standard font corresponding to the text to obtain some guiding suggestions. The standard font can be extracted from the handwritten manuscripts of calligraphy teachers.

[0003] However, when the standard point set of the text is collected by a device and restored for display, there will be situations such as jitter and bending, making the aesthetics and effect of the finally restored text unsatisfactory. Moreover, due to individuals having different preferences for the fonts of different teachers, a single standard font cannot meet the personalized needs of people for calligraphy learning. Summary of the Invention

[0004] Embodiments of this application provide a method, apparatus, and device for digital processing of text, which can reduce the distortion rate of the digitalized standard point set in text restoration and improve the restoration degree and aesthetic effect of the text.

[0005] In a first aspect, this application provides a method for digital processing of text, including: obtaining first skeleton information of a target text, where the first skeleton information is a plurality of pixel points extracted from a target image, and the target image is an image corresponding to the target text; correcting the pixel points with errors in the first skeleton information to obtain second skeleton information; performing stroke division and stroke order restoration on the second skeleton information to obtain first stroke order information; and performing widthening processing on the pixel points in the first stroke order information according to line width information to obtain the standard point set of the target text.

[0006] By correcting the pixel points with errors in the skeleton information of the target text in the embodiments of this application, and then performing widthening processing on the stroke order information obtained by performing stroke division and stroke order restoration on the corrected skeleton information, the jitter and bending phenomena occurring in the text restoration process are reduced, thereby effectively reducing the distortion rate of the digitalized standard point set in text restoration and improving the restoration degree and aesthetic effect of the text.

[0007] In some embodiments of the first aspect, the correcting the pixel points with errors in the first skeleton information to obtain second skeleton information includes:

[0008] obtaining a plurality of pixel points that meet a preset condition, where the preset condition is any pixel point having a plurality of connection directions;

[0009] Determine the distance between two adjacent pixel points among several pixel points that meet the preset conditions;

[0010] When the distance between two adjacent pixel points among several pixel points that meet the preset conditions is less than the threshold, merge and correct the two adjacent pixel points into one pixel point.

[0011] In the embodiments of the present application, by correcting incorrect pixel points, the error rate of stroke division can be reduced, thereby reducing the probability of jitter or bending occurring in text restoration.

[0012] In some other embodiments of the first aspect, the above-mentioned stroke division and stroke order restoration of the second skeleton information to obtain the first stroke order information include:

[0013] Perform stroke division on the second skeleton information according to the connectivity traversal rule to obtain the first stroke information;

[0014] Compare the first stroke information with the standard stroke information;

[0015] Restore the stroke order of the target text according to the comparison result to obtain the first stroke order information.

[0016] In some other embodiments of the first aspect, in the above-mentioned performing stroke division on the second skeleton information according to the connectivity traversal rule to obtain the first stroke information, it includes:

[0017] Traverse all pixel points in the second skeleton information according to the first direction priority;

[0018] Complete the stroke division of the second skeleton information according to the traversal result to obtain the first stroke information.

[0019] In some other embodiments of the first aspect, in the above-mentioned traversing all pixel points in the second skeleton information according to the first direction priority, it includes:

[0020] When traversing to a pixel point with two or more connectivity directions, obtain the connectivity direction of the previous pixel point traversed before the current pixel point;

[0021] If there is a connectivity direction in the connectivity directions of the current pixel point that is the same as that of the previous pixel point, continue the connectivity traversal in the same connectivity direction as the previous pixel point.

[0022] In some other embodiments of the first aspect, after the above-mentioned when traversing to a pixel point with two or more connectivity directions, obtaining the connectivity direction of the previous pixel point traversed before the current pixel point, it further includes:

[0023] If there is no connection direction in the connection directions of the current pixel point that is the same as that of the previous pixel point, continue the connectivity traversal according to the second direction priority.

[0024] In some other embodiments of the first aspect, in the above-mentioned stroke division of the second skeleton information according to the connectivity traversal rule to obtain the first stroke information, it includes:

[0025] Count the number of strokes in the above-mentioned first stroke information;

[0026] Determine whether the number of strokes obtained by statistics is consistent with the actual number of strokes of the above-mentioned target character;

[0027] When the number of strokes obtained by statistics is inconsistent with the actual number of strokes of the above-mentioned target character, perform connectivity traversal on the pixel points with multiple connection directions in the above-mentioned second skeleton information according to the third direction priority until the number of strokes obtained by statistics is consistent with the actual number of strokes of the above-mentioned target character.

[0028] In some other embodiments of the first aspect, in the above-mentioned widening process of the pixel points in the first stroke order information according to the line width information to obtain the standard point set of the above-mentioned target character, it includes:

[0029] Obtain the contour information of the above-mentioned target character, and the above-mentioned contour information is composed of multiple contour points;

[0030] Calculate and obtain the distance information from each pixel point in the above-mentioned first stroke order information to the above-mentioned contour point;

[0031] Take the minimum distance value in the above-mentioned distance information as the line width information of the currently calculated pixel point.

[0032] In a second aspect, the present application provides a text digitization processing device, including:

[0033] A skeleton information acquisition unit, configured to acquire the first skeleton information of a target character, where the first skeleton information is a plurality of pixel points extracted from a target image, and the target image is an image corresponding to the target character;

[0034] A pixel point correction unit, configured to correct the pixel points with errors in the above-mentioned first skeleton information to obtain second skeleton information;

[0035] A stroke order restoration unit, configured to perform stroke division and stroke order restoration on the above-mentioned second skeleton information to obtain first stroke order information;

[0036] A pixel widening unit, configured to widen the pixel points in the above-mentioned first stroke order information according to the line width information to obtain the standard point set of the above-mentioned target character.

[0037] In some embodiments of the second aspect, the above-mentioned pixel correction unit includes:

[0038] A pixel acquisition subunit, configured to acquire a plurality of pixels that meet a preset condition, where the preset condition is any pixel having multiple connection directions;

[0039] A distance determination subunit, configured to determine the distance between two adjacent pixels among the plurality of pixels that meet the preset condition;

[0040] A pixel correction subunit, configured to, when the distance between two adjacent pixels among the plurality of pixels that meet the preset condition is less than a threshold, merge and correct the two adjacent pixels into one pixel.

[0041] In some other embodiments of the second aspect, the above-mentioned stroke order restoration unit includes:

[0042] A stroke division subunit, configured to perform stroke division on the above-mentioned second skeleton information according to the connectivity traversal rule to obtain first stroke information;

[0043] A stroke information comparison subunit, configured to compare the above-mentioned first stroke information with standard stroke information;

[0044] A stroke order restoration subunit, configured to restore the stroke order of the above-mentioned target character according to the comparison result to obtain the above-mentioned first stroke order information.

[0045] In some other embodiments of the second aspect, the above-mentioned stroke division subunit is specifically configured to:

[0046] Traverse all pixels in the above-mentioned second skeleton information according to the first direction priority;

[0047] Complete the stroke division of the above-mentioned second skeleton information according to the traversal result to obtain the above-mentioned first stroke information.

[0048] In some other embodiments of the second aspect, the above-mentioned stroke division subunit is specifically further configured to:

[0049] When traversing a pixel with two or more connection directions, obtain the connection direction of the previous pixel traversed before the current pixel;

[0050] If there is a connection direction in the connection directions of the current pixel that is the same as that of the previous pixel, continue the connectivity traversal in the same connection direction as the previous pixel.

[0051] In some other embodiments of the second aspect, the above-mentioned stroke division subunit is specifically further configured to:

[0052] If there is no connected direction in the connected directions of the current pixel point that is the same as that of the previous pixel point, continue the connectivity traversal according to the second direction priority.

[0053] In some other embodiments of the second aspect, the above-mentioned stroke dividing sub-unit is specifically further configured to:

[0054] Count the number of strokes in the above-mentioned first stroke information;

[0055] Determine whether the number of strokes obtained by counting is consistent with the actual number of strokes of the above-mentioned target character;

[0056] When the number of strokes obtained by counting is inconsistent with the actual number of strokes of the above-mentioned target character, perform connectivity traversal on the pixel points with multiple connected directions in the above-mentioned second skeleton information according to the third direction priority until the number of strokes obtained by counting is consistent with the actual number of strokes of the above-mentioned target character.

[0057] In some other embodiments of the second aspect, the above-mentioned pixel widening unit includes:

[0058] A contour information acquisition sub-unit, configured to acquire the contour information of the above-mentioned target character, and the contour information is composed of multiple contour points;

[0059] A distance acquisition sub-unit, configured to calculate and acquire the distance information from each pixel point in the above-mentioned first stroke sequence information to the above-mentioned contour point;

[0060] A line width determination sub-unit, configured to use the minimum distance value in the above-mentioned distance information as the line width information of the currently calculated pixel point.

[0061] In a third aspect, the present application provides a text digitization processing device, including a processor, a memory, and a computer program stored in the above-mentioned memory and executable on the above-mentioned processor. When the above-mentioned processor executes the above-mentioned computer program, the method described in the first aspect or any optional manner of the first aspect is implemented.

[0062] In a fourth aspect, the present application provides a computer-readable storage medium, and the above-mentioned computer-readable storage medium stores a computer program. When the above-mentioned computer program is executed by a processor, the method described in the first aspect or any optional manner of the first aspect is implemented.

[0063] In a fifth aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on a text digitization processing device, the text digitization processing device is caused to execute the steps of the text digitization processing method described in the first aspect above.

[0064] It can be understood that the beneficial effects of the above-mentioned second aspect to the fifth aspect can refer to the relevant descriptions in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0066] Figure 1 is a schematic flowchart of a method for text digitization processing provided by an embodiment of the present application;

[0067] Figure 2 is a schematic diagram of an image of the skeleton information of a target text provided by an embodiment of the present application;

[0068] Figure 3 is a schematic flowchart of a method for correcting error pixel points provided by an embodiment of the present application;

[0069] Figure 4 is a schematic diagram of an image of partial skeleton information of a target text provided by an embodiment of the present application;

[0070] Figure 5 is a schematic flowchart of a method for stroke division provided by an embodiment of the present application;

[0071] Figure 6 is a schematic flowchart of another method for stroke division provided by an embodiment of the present application;

[0072] Figure 7 is a schematic flowchart of a method for widening pixel points provided by an embodiment of the present application;

[0073] Figure 8 is a schematic diagram of the effect of a standard point set obtained after widening pixel points provided by an embodiment of the present application;

[0074] Figure 9 is a schematic diagram of the structure of a text digitization processing device provided by an embodiment of the present application;

[0075] Figure 10 is a schematic diagram of the structure of a text digitization processing device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0076] In the following description, specific details such as specific system architectures and technologies are presented for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, those skilled in the art should understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from obscuring the description of the present application.

[0077] It should be understood that the term "and / or" used in the specification and claims of the present application refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations. Additionally, in the description of the specification and claims of the present application, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.

[0078] It should also be understood that references to "one embodiment" or "some embodiments" etc. described in the specification of the present application mean that specific features, structures, or characteristics described in connection with that embodiment are included in one or more embodiments of the present application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "comprise", "include", "have", and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0079] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of a method for text digitization processing provided by an embodiment of the present application. Figure 2 which is a schematic diagram of an image of the skeleton information of a target text. In combination with Figure 2 the method for text digitization processing provided by an embodiment of the present application will be specifically described as follows:

[0080] Step S101: Obtain the first skeleton information of the target text. The above first skeleton information is a plurality of pixel points extracted from the target image, and the above target image is the image corresponding to the above target text.

[0081] In an embodiment of the present application, the target character is any character in a handwritten manuscript written by a user, such as a calligraphy teacher. Before obtaining the first skeleton information of the target character, an image of the user's handwritten manuscript is first collected by a device. For example, a scanned image is obtained by scanning the user's handwritten manuscript with the device, and then each character-corresponding image in the scanned image is obtained through image cropping processing, that is, the target image is obtained. After obtaining the target image, the skeleton information of the target character is extracted from the target image through an image morphology algorithm and a thinning algorithm, and the skeleton information of the target character is obtained.

[0082] Specifically, a predetermined area in the above target image is obtained. The predetermined area is an area of a specified color, and the specified color is generally the color corresponding to the current character. The image information and contour information of the target character are extracted from the predetermined area, and then the connected area is determined from the extracted image information and contour information through opening and closing operations to obtain a clearer and more uniform connected area. Then, the skeleton information of the target character is obtained from the connected area through a thinning algorithm. The thinning algorithm used here is the Skeletonize algorithm. For example, the above method is used to extract the skeleton information of the target character "thumb", and the obtained skeleton information is as shown in Figure 2 shown. As shown in Figure 2 shown, the skeleton information of "thumb" is the black line composed of multiple pixel points in the figure.

[0083] Step S102: Correct the pixel points with errors in the above first skeleton information to obtain the second skeleton information.

[0084] In an embodiment of the present application, according to the connectivity of each pixel point, pixel points with only one connectivity direction can be obtained, such as the starting point or ending point of a stroke; pixel points with two or more connectivity directions.

[0085] As can be seen from Figure 2 , there will be some error information in the obtained first skeleton information, which is mainly manifested at the positions of stroke turning or intersection. If these incorrect pixel points are retained, it may lead to low similarity or accuracy of the finally restored target character, with bending or jitter phenomena, and the restoration degree and aesthetics cannot reach the ideal effect. Therefore, it is necessary to correct the pixel points with errors in the obtained first skeleton information to obtain the corrected second skeleton information.

[0086] It should be noted that there are incorrect pixel points in the first skeleton information, which are generally pixel points corresponding to the positions of stroke turning or intersection. For example, a pixel point with four connectivity directions may be represented as two pixel points with three connectivity directions. That is, two pixel points with three connectivity directions may be an incorrect representation of a pixel point with four connectivity directions, and the two pixel points with three connectivity directions can be corrected by merging them into one pixel point.

[0087] Please refer to Figure 3 , Figure 3 which is a schematic flowchart of a method for correcting incorrect pixel points provided by an embodiment of the present application, Figure 4 and is an image schematic diagram of partial skeleton information of a target character provided by an embodiment of the present application. In combination with Figure 4 the method for correcting incorrect pixel points provided by an embodiment of the present application will be specifically described as follows:

[0088] Step S301, obtain a plurality of pixel points that meet the preset conditions.

[0089] In the embodiment of the present application, the above preset condition is any pixel point with multiple connectivity directions. Since pixel points with two directions are not likely to generate errors, any pixel point with multiple connectivity directions in the preset condition is generally a pixel point with three or more connectivity directions.

[0090] There may be multiple pixel points that meet the preset conditions in the first skeleton information. Obtain a plurality of pixel points that meet the preset conditions from the first skeleton information, and judge these pixel points that meet the preset conditions to determine whether a certain pixel point is an incorrect pixel point.

[0091] Step S302, determine the distance between two adjacent pixel points among the plurality of pixel points that meet the preset conditions.

[0092] In the embodiment of the present application, after obtaining the pixel points that meet the preset conditions from the first skeleton information in a certain order, calculate and determine the distance between two adjacent pixel points among the plurality of pixel points that meet the preset conditions.

[0093] In some embodiments of the present application, the distance between the two adjacent pixel points can be determined by counting the number of other pixel points that do not meet the preset conditions existing between the two adjacent pixel points. For example, if the number of other pixel points that do not meet the preset conditions existing between the two adjacent pixel points is 2, it is considered that the distance between the two adjacent pixel points is 2, and so on.

[0094] Step S303: When the distance between two adjacent pixel points among a plurality of pixel points that meet a preset condition is less than a threshold, the two adjacent pixel points are merged and corrected into one pixel point.

[0095] In an embodiment of the present application, the threshold is a pre-set value used to determine whether there is an erroneous pixel between two adjacent pixel points. When the distance between two adjacent pixel points among a number of pixel points that meet the preset conditions is less than the threshold, any one of the two adjacent pixel points is considered to be an erroneous pixel point, and the two adjacent pixel points are merged and corrected into one pixel point.

[0096] like Figure 4 In the box shown, there are two gray pixels 1 and 2, and the distance between them is small. It can be considered that any one of the pixels is an erroneous pixel, that is, the stroke "raised" is incorrect. " is divided into two strokes, and an error occurs at the position where it should intersect with the stroke "shu (丨)", forming two intersection points with the stroke "shu (丨)", that is, Figure 4 Pixel 1 and pixel 2 are shown in FIG.

[0097] In some embodiments of the present application, when merging two adjacent pixels into one pixel, it is not a simple matter of deleting or eliminating any one of the two adjacent pixels. Instead, all pixels between the two adjacent pixels (including the two adjacent pixels) are merged and corrected into one pixel, and the position of the merged and corrected pixel is the position of any pixel between the two adjacent pixels. For example, pixel 1 and pixel 2 are moved to the pixel in the middle position between pixel 1 and pixel 2, that is, three pixels are merged into one pixel to ensure the smoothness and aesthetic effect of stroke restoration.

[0098] Step S103 , performing stroke division and stroke order restoration on the second skeleton information to obtain first stroke order information.

[0099] In an embodiment of the present application, since the second skeleton information is composed of multiple pixel points and all strokes are connected together, in order to smoothly and accurately restore the target text, it is also necessary to split the strokes in the second skeleton information, that is, to divide the second skeleton information into strokes and restore the stroke order to obtain the stroke order information of the target text.

[0100] See Figure 5 , Figure 5 This is a flow chart of a stroke division method provided in an embodiment of the present application, which is described in detail as follows:

[0101] Step S501 : dividing the second skeleton information into strokes according to a connectivity traversal rule to obtain first stroke information.

[0102] In this embodiment of the present application, the connectivity traversal rule is to start with a pixel point that has only one connected direction, and to perform connectivity traversal according to a first direction priority until a corresponding end point with only one connected direction is found. The first stroke information is composed of multiple stroke sets, each stroke set consisting of pixels corresponding to a stroke, and each stroke set includes a pixel point as a starting point and a pixel point as an end point.

[0103] Here, the first directional priority is a pre-set priority for connectivity traversal, typically based on the direction of handwriting conventions. For example, pixels in the second skeleton information are traversed from top to bottom and left to right. When traversing from the starting point to the ending point, all traversed pixels are considered the pixel set of a stroke.

[0104] In some embodiments of the present application, all pixels in the second skeleton information are traversed based on the first direction priority, and the second skeleton information is divided into strokes based on the traversal results to obtain the first stroke information. During the traversal process, the pixels from the starting point to the ending point are considered as one stroke, that is, the result of one traversal. The resulting first stroke information is the result of the traversal of multiple strokes.

[0105] In other embodiments of the present application, when traversing to a pixel point with multiple connectivity directions, that is, with two or more connectivity directions, the connectivity direction of the previous pixel point traversed before the current pixel point is obtained. If the connectivity direction of the current pixel point has the same connectivity direction as the previous pixel point, the connectivity traversal is continued according to the same connectivity direction as the previous pixel point; if the connectivity direction of the current pixel point does not have the same connectivity direction as the previous pixel point, the connectivity traversal is continued according to the second direction priority until the corresponding end point is found, that is, the pixel point with only one connectivity direction is used as the end point of the stroke. For example, when the connectivity direction of the previous pixel point traversed before the current pixel point is downward, it is determined that the current pixel point has a downward connectivity direction, and the connectivity traversal is continued in the downward direction first; if the current pixel point does not have a downward connectivity direction, the connectivity traversal is performed according to the second direction priority, such as in the order of downward, right, upper right, upward, lower left, left, lower right, upper left, etc., until the corresponding end point is found. The traversal direction of each pixel point in the second direction priority referred to here is different from the traversal direction in the first direction priority.

[0106] In other embodiments of the present application, since a pixel point with multiple connected directions may have multiple stroke information, especially a pixel point with three or more connected directions, there may be more than two stroke information. For example, the character "十" should actually be two strokes, but when performing connectivity traversal, the pixel point where the two strokes intersect has four connected directions, and the stroke information obtained by traversal includes at least three strokes, such as a horizontal stroke from left to right; a horizontal stroke from left to right and then to the bottom; a stroke from top to bottom, etc. At this time, if the stroke from left to right is When a stroke from one side to the right and then to the next side is taken as one stroke, the final stroke information will be inaccurate, which will result in the inability to obtain accurate stroke order information when restoring the stroke order. In order to solve this problem, the embodiment of the present application records the pixel points that have been traversed and have multiple connectivity directions during the connectivity traversal process, so that when it is determined that the stroke information obtained by the traversal is erroneous stroke information, the connectivity traversal is performed on these pixel points with multiple connectivity directions according to different direction priorities, thereby eliminating the erroneous stroke information and obtaining more accurate stroke information.

[0107] See Figure 6 , Figure 6 This is a flow chart of another stroke division method provided in an embodiment of the present application, which is described in detail as follows:

[0108] Step S601: Count the number of strokes in the first stroke information.

[0109] In the embodiment of the present application, when performing stroke division, each stroke obtained by division is recorded once, and the number of all strokes in the first stroke information is finally obtained by counting.

[0110] Step S602: determining whether the number of strokes obtained by counting is consistent with the actual number of strokes of the target character.

[0111] In an embodiment of the present application, the actual number of strokes of the target text can be obtained by identifying the text in the target image and obtaining the number of strokes of the corresponding text.

[0112] Step S603: When the number of strokes obtained by counting is inconsistent with the actual number of strokes of the target text, the pixel points with multiple connection directions in the second skeleton information are subjected to connectivity traversal according to the third direction priority until the number of strokes obtained by counting is consistent with the actual number of strokes of the target text.

[0113] In an embodiment of the present application, the number of strokes in the stroke information obtained by statistical traversal is counted and compared with the actual number of strokes of the target character. If the numbers are inconsistent, the stroke information obtained by traversal is considered incorrect stroke information, and the connectivity traversal needs to be performed on the pixel points with multiple connectivity directions in the second skeleton information according to different direction priorities until the number of strokes in the stroke information obtained by traversal is consistent with the actual number of strokes of the target character.

[0114] In practical applications, during the process of performing connectivity traversal on the pixel point, all the pixel points with multiple connectivity directions that have been traversed are recorded, as well as the connectivity directions that the pixel point with multiple connectivity directions has traversed. For example, if the current pixel point with multiple connectivity directions has been traversed in the downward direction, when performing connectivity traversal on the pixel point with multiple connectivity directions next time, other directions outside the traversed directions are selected according to the third direction priority to perform connectivity traversal on the pixel point.

[0115] In practical applications, it may be that the number of strokes in the stroke information finally obtained by traversal still cannot be consistent with the actual number of strokes of the target character. At this time, manual intervention is required to identify the actual connectivity directions of some pixel points with large interference, and then perform connectivity traversal on the pixel point again according to the actual connectivity directions until the number of strokes in the stroke information finally obtained by traversal is consistent with the actual number of strokes of the target character.

[0116] Step S502: Compare the above first stroke information with the standard stroke information.

[0117] Step S503: Restore the stroke order of the above target character according to the comparison result to obtain the above first stroke order information.

[0118] In an embodiment of the present application, the standard stroke information is a set of strokes of a standard font collected in advance, including stroke order information. By comparing the first stroke information with the standard stroke information, the trajectory similarity between different strokes is calculated, and according to the level of the trajectory similarity, the stroke order corresponding to each stroke set in the first stroke information is determined from the standard stroke information to obtain the stroke order information corresponding to the first stroke information.

[0119] In some embodiments of the present application, the algorithm used for calculating the trajectory similarity is the Dynamic Time Warping (DTW) algorithm. By comparing the stroke sets in the first stroke information and the standard stroke information pairwise, the trajectory similarity between two stroke sets is calculated to realize the restoration of the stroke order of the target character.

[0120] In some other embodiments of the present application, after restoring the stroke order of the above target text according to the comparison result to obtain the first stroke order information, since there are too few pixel points in each stroke set, when finally restoring the target text, jitter or bending phenomena will occur, and the purpose of accurately restoring the target text cannot be achieved, and the aesthetic effect of the target text is reduced. To avoid this situation, it is necessary to add points to the pixel points in the first stroke order information, that is, add pixel points to each stroke order.

[0121] In practical applications, the addition of points to the first stroke order information can be completed by means of a quadratic Bezier curve to obtain the second stroke order information.

[0122] Step S104, according to the line width information, widen the pixel points in the above first stroke order information to obtain the standard point set of the above target text.

[0123] In the embodiments of the present application, after obtaining the first stroke order information or the second stroke order information, a reducible standard point set after digitizing the target text can be basically obtained, and the purpose of improving the digital reduction degree of the target text can be basically achieved. However, due to the lack of line width information, each stroke in the finally obtained standard character point set has the same width, resulting in a low aesthetic effect of the text obtained by digital reduction. To improve the digital reduction effect and aesthetic effect of the target text, it is also necessary to obtain the line width information of the pen tip on the contour, widen the pixel points in the first stroke order information or the second stroke order information, and restore the pen tip effect of the target text.

[0124] Please refer to Figure 7 , Figure 7 which is a schematic flowchart of a method for widening pixel points provided by an embodiment of the present application, and is described in detail as follows:

[0125] Step S701, obtain the contour information of the above target text, and the above contour information is composed of multiple contour points.

[0126] In the embodiments of the present application, the contour information of the target text is obtained from the target image. As Figure 2 shown, the white part in the target image is the target text, and the contour points of the target text can be extracted from the target image to obtain the contour information of the target text.

[0127] Step S702, calculate and obtain the distance information from each pixel point in the above first stroke order information to the above contour point.

[0128] In the embodiments of the present application, to calculate the distance information from each pixel point in the first stroke order information to the obtained contour points, in order to reduce the amount of calculation, contour points within the predetermined area range of each pixel point can be obtained, and the distance between the pixel point and the contour points within the predetermined area range can be calculated to obtain the distance information between each pixel point and each contour point.

[0129] Step S703: Use the smallest distance value in the above distance information as the line width information of the currently calculated pixel point.

[0130] In the embodiments of the present application, the smallest distance value in the distance information is used as the line width of the currently calculated pixel point, and a circle is drawn with this line width as the radius to achieve the purpose of restoring the pen tip, and finally a standard point set of the target text is obtained. As Figure 8 shown, Figure 8 is a schematic diagram of the effect of a standard point set obtained by performing a widening process on pixel points provided by the embodiments of the present application.

[0131] Through the above method provided by the embodiments of the present application, digital processing of multiple target texts of a calligraphy manuscript can be realized, so as to obtain diverse standard point sets, which is convenient to provide diverse standard fonts for users to learn calligraphy writing, meeting the personalized needs of people for calligraphy learning.

[0132] In the embodiments of the present application, by correcting the pixel points with errors in the skeleton information of the target text, and then performing stroke division and stroke order restoration on the corrected skeleton information to perform a widening process on the obtained stroke order information, the jitter and bending phenomena that occur during the text restoration process are reduced, thereby effectively reducing the distortion rate of the standard point set obtained after digitization during text restoration and improving the restoration degree and aesthetic effect of the text.

[0133] It should be understood that the magnitudes of the sequence numbers of the above steps in the embodiments do not mean the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.

[0134] Based on the text digital processing method provided in the above embodiments, the embodiments of the present application further provide an apparatus embodiment for implementing the above method embodiments.

[0135] Please refer to Figure 9 , Figure 9 is a schematic diagram of the text digital processing apparatus provided by the embodiments of the present application. Each unit included is used to execute Figure 1 the respective steps in the corresponding embodiments. Specifically, please refer to Figure 1 the relevant descriptions in the corresponding embodiments. For the sake of convenience of description, only the parts related to this embodiment are shown. Refer to Figure 9 , the text digital processing apparatus 9 includes:

[0136] A skeleton information acquisition unit 91, configured to acquire first skeleton information of a target character, where the first skeleton information is a plurality of pixel points extracted from a target image, and the target image is an image corresponding to the target character;

[0137] A pixel point correction unit 92, configured to correct pixel points with errors in the first skeleton information to obtain second skeleton information;

[0138] A stroke sequence restoration unit 93, configured to perform stroke division and stroke sequence restoration on the second skeleton information to obtain first stroke sequence information;

[0139] A pixel widening unit 94, configured to widen pixel points in the first stroke sequence information according to line width information to obtain a standard point set of the target character.

[0140] In some embodiments of the present application, the pixel point correction unit 92 includes:

[0141] A pixel point acquisition subunit, configured to acquire several pixel points that meet a preset condition, where the preset condition is any pixel point with multiple connection directions;

[0142] A distance determination subunit, configured to determine the distance between two adjacent pixel points among several pixel points that meet the preset condition;

[0143] A pixel point correction subunit, configured to, when the distance between two adjacent pixel points among several pixel points that meet the preset condition is less than a threshold, merge and correct the two adjacent pixel points into one pixel point.

[0144] In some embodiments of the present application, the stroke sequence restoration unit 93 includes:

[0145] A stroke division subunit, configured to perform stroke division on the second skeleton information according to a connectivity traversal rule to obtain first stroke information;

[0146] A stroke information comparison subunit, configured to compare the first stroke information with standard stroke information;

[0147] A stroke sequence restoration subunit, configured to restore the stroke sequence of the target character according to the comparison result to obtain the first stroke sequence information.

[0148] In some embodiments of the present application, the stroke division subunit is specifically configured to:

[0149] Traverse all pixel points in the second skeleton information according to a first direction priority;

[0150] Complete stroke division of the second skeleton information according to the traversal result to obtain the first stroke information.

[0151] In some embodiments of the present application, the above-mentioned stroke dividing sub-unit is further specifically configured to:

[0152] When traversing to a pixel point with two or more connectivity directions, obtain the connectivity direction of the previous pixel point traversed before the current pixel point;

[0153] If there is a connectivity direction in the connectivity directions of the current pixel point that is the same as that of the previous pixel point, continue the connectivity traversal in the same connectivity direction as the previous pixel point.

[0154] In some embodiments of the present application, the above-mentioned stroke dividing sub-unit is further specifically configured to:

[0155] If there is no connectivity direction in the connectivity directions of the current pixel point that is the same as that of the previous pixel point, continue the connectivity traversal according to the second direction priority.

[0156] In some embodiments of the present application, the above-mentioned stroke dividing sub-unit is further specifically configured to:

[0157] Count the number of strokes in the above-mentioned first stroke information;

[0158] Determine whether the number of strokes obtained by counting is consistent with the actual number of strokes of the above-mentioned target character;

[0159] When the number of strokes obtained by counting is inconsistent with the actual number of strokes of the above-mentioned target character, perform a connectivity traversal on the pixel points with multiple connectivity directions in the above-mentioned second skeleton information according to the third direction priority until the number of strokes obtained by counting is consistent with the actual number of strokes of the above-mentioned target character.

[0160] In some embodiments of the present application, the above-mentioned pixel widthening unit 94 includes:

[0161] A contour information acquisition sub-unit, configured to acquire the contour information of the above-mentioned target character, where the contour information is composed of multiple contour points;

[0162] A distance acquisition sub-unit, configured to calculate and acquire the distance information from each pixel point in the above-mentioned first stroke order information to the above-mentioned contour point;

[0163] A line width determination sub-unit, configured to use the smallest distance value in the above-mentioned distance information as the line width information of the currently calculated pixel point.

[0164] It should be noted that for the information interaction, execution process, etc. between the above-mentioned modules, since they are based on the same concept as the method embodiments of the present application, their specific functions and the technical effects brought about can be specifically referred to in the method embodiment part, and will not be elaborated here.

[0165] Figure 10 is a schematic diagram of a text digitization processing device provided by an embodiment of the present application. As Figure 10 shown, the text digitization processing device 10 of this embodiment includes: a processor 100, a memory 101, and a computer program 102 stored in the memory 101 and executable on the processor 100, such as a speech recognition program. When the processor 100 executes the computer program 102, the steps in the above-mentioned various text digitization processing method embodiments are implemented, such as Figure 1 the steps 101-104 shown. Alternatively, when the processor 100 executes the computer program 102, the functions of each module / unit in the above-mentioned device embodiments are implemented, such as Figure 9 the functions of the units 91-94 shown.

[0166] Exemplarily, the computer program 102 can be divided into one or more modules / units. One or more modules / units are stored in the memory 101 and executed by the processor 100 to complete the present application. One or more modules / units can be a series of computer program instruction segments capable of performing specific functions, and these instruction segments are used to describe the execution process of the computer program 102 in the text digitization processing device 10. For example, the computer program 102 can be divided into a skeleton information acquisition unit 91, a pixel point correction unit 92, a stroke sequence restoration unit 93, and a pixel widening unit 94. For the specific functions of each unit, please refer to Figure 1 the relevant descriptions in the corresponding embodiments, which will not be elaborated here.

[0167] The text digitization processing device may include, but is not limited to, a processor 100 and a memory 101. Those skilled in the art can understand that Figure 10 this is only an example of the text digitization processing device 10 and does not constitute a limitation on the text digitization processing device 10. It may include more or fewer components than shown in the figure, or combine certain components, or different components. For example, the text digitization processing device may also include an input / output device, a network access device, a bus, etc.

[0168] The so-called processor 100 may be a Central Processing Unit (CPU), or may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0169] The memory 101 may be an internal storage unit of the text digitization processing device 10, such as the hard disk or memory of the text digitization processing device 10. The memory 101 may also be an external storage device of the text digitization processing device 10, such as a plug-in hard disk equipped on the text digitization processing device 10, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. Further, the memory 101 may also include both the internal storage unit of the text digitization processing device 10 and the external storage device. The memory 101 is used to store computer programs and other programs and data required by the text digitization processing device. The memory 101 may also be used to temporarily store data that has been output or is to be output.

[0170] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned text digitization processing method can be implemented.

[0171] The embodiment of the present application provides a computer program product. When the computer program product runs on the text digitization processing device, it enables the text digitization processing device to implement the above-mentioned text digitization processing method when executed.

[0172] Those skilled in the art can clearly understand that, for the convenience and conciseness of description, only the above-mentioned division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiments can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of this application. The specific working processes of the units and modules in the above system can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.

[0173] In the above embodiments, the descriptions of the respective embodiments have their own emphases. For the parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0174] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or by a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. A professional technician can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0175] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit the same; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included in the protection scope of this application.

Claims

1. A method for digital processing of text, characterized in that, The method includes: Obtaining first skeleton information of the target text, where the first skeleton information is a plurality of pixel points extracted from a target image, and the target image is an image corresponding to the target text; Correcting the pixel points with errors in the first skeleton information to obtain second skeleton information, including: Obtaining a plurality of pixel points that meet a preset condition, where the preset condition is any pixel point with multiple connection directions; determining the distance between two adjacent pixel points among the plurality of pixel points that meet the preset condition; when the distance between two adjacent pixel points among the plurality of pixel points that meet the preset condition is less than a threshold, merging and correcting the two adjacent pixel points into one pixel point; Performing stroke division on the second skeleton information according to the connectivity traversal rule to obtain first stroke information; Comparing the first stroke information with standard stroke information; Restoring the stroke order of the target text according to the comparison result to obtain first stroke order information; Performing widthening processing on the pixel points in the first stroke order information according to line width information to obtain a standard point set of the target text.

2. The text digitization processing method according to claim 1, wherein In the performing stroke division on the second skeleton information according to the connectivity traversal rule to obtain first stroke information, it includes: Traversing all pixel points in the second skeleton information according to a first direction priority; Completing stroke division of the second skeleton information according to the traversal result to obtain the first stroke information.

3. The text digitization processing method according to claim 2, characterized in that, In the traversing all pixel points in the second skeleton information according to a first direction priority, it includes: When traversing a pixel point with two or more connection directions, obtaining the connection direction of the previous pixel point traversed before the current pixel point; If there is a connection direction in the connection directions of the current pixel point that is the same as the previous pixel point, continuing the connectivity traversal in the same connection direction as the previous pixel point.

4. The text digitization processing method according to claim 3, characterized in that, After the obtaining the connection direction of the previous pixel point traversed before the current pixel point when traversing a pixel point with two or more connection directions, it further includes: If there is no connection direction in the connection directions of the current pixel point that is the same as the previous pixel point, continuing the connectivity traversal according to a second direction priority.

5. The text digitization processing method according to claim 1, characterized in that, In the performing stroke division on the second skeleton information according to the connectivity traversal rule to obtain first stroke information, it includes: Counting the number of strokes in the first stroke information; Determining whether the counted number of strokes is consistent with the actual number of strokes of the target text; When the counted number of strokes is not consistent with the actual number of strokes of the target text, performing connectivity traversal on the pixel points with multiple connection directions in the second skeleton information according to a third direction priority until the counted number of strokes is consistent with the actual number of strokes of the target text.

6. The text digitization processing method according to claim 1, wherein In the performing widthening processing on the pixel points in the first stroke order information according to line width information to obtain a standard point set of the target text, it includes: Obtaining contour information of the target text, where the contour information is composed of a plurality of contour points; Calculating and obtaining the distance information from each pixel point in the first stroke order information to the contour points; Use the smallest distance value in the distance information as the line width information of the currently calculated pixel point.

7. A text digitization processing device, characterized in that, The device includes: A skeleton information acquisition unit, configured to acquire first skeleton information of target text, where the first skeleton information is a plurality of pixel points extracted from a target image, and the target image is an image corresponding to the target text; A pixel point correction unit, configured to correct incorrect pixel points in the first skeleton information to obtain second skeleton information, including a pixel point acquisition subunit, a distance determination subunit, and a pixel point correction subunit; the pixel point acquisition subunit is configured to acquire a plurality of pixel points that meet a preset condition, where the preset condition is any pixel point with a plurality of connection directions; the distance determination subunit is configured to determine the distance between two adjacent pixel points among the plurality of pixel points that meet the preset condition; the pixel point correction subunit is configured to, when the distance between two adjacent pixel points among the plurality of pixel points that meet the preset condition is less than a threshold, merge and correct the two adjacent pixel points into one pixel point; A stroke order restoration unit, including a stroke division subunit, a stroke information comparison subunit, and a stroke order restoration subunit; the stroke division subunit is configured to perform stroke division on the second skeleton information according to a connectivity traversal rule to obtain first stroke information; the stroke information comparison subunit is configured to compare the first stroke information with standard stroke information; the stroke order restoration subunit is configured to restore the stroke order of the target text according to the comparison result to obtain first stroke order information; A pixel widening unit, configured to perform widening processing on the pixel points in the first stroke order information according to the line width information to obtain a standard point set of the target text.

8. A text digitization processing device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and is characterized in that when the processor executes the computer program, it implements the text digitization processing method according to any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the text digitization processing method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • On-line character recognizing method and device therefor

    JP1998049627A

  • Work support system, work support method, and program

    JP2019191904A