Method, device, electronic device and storage medium for extracting stroke skeleton information
By acquiring the target image and using the mapping relationship in the preset reference database, the stroke skeleton information is automatically extracted, which solves the problems of low extraction efficiency and relying on manual operations in the prior art, and achieves efficient and accurate automatic extraction.
Patent Information
- Application Number
- CN201910955021.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-10-09
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2039-10-09
AI Technical Summary
In the prior art, the efficiency and accuracy of stroke skeleton information extraction are low, and rely on manual operation, which increases cost and time.
By obtaining the target image, determining the reference text corresponding to the target text, and using the mapping relationship in the preset reference database, the reference stroke skeleton information is extracted, and the target stroke skeleton information is finally determined based on the target text image and reference stroke skeleton information.
The automatic extraction of stroke skeleton information is realized, which reduces the need for manual intervention, improves extraction efficiency and accuracy, and reduces costs.
Smart Images

Figure CN112633428B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of computer graphics, and particularly to a method, apparatus, electronic device, and storage medium for extracting stroke skeleton information. Background Art
[0002] For text glyphs, especially those in Chinese, Japanese, Korean, etc., their glyphs are all composed of strokes, and strokes are the basic units that make up the text.
[0003] Stroke skeleton extraction is an important technical support in the field related to fonts. Being able to accurately extract stroke skeleton information is of self-evident importance for promoting the development of related technologies in this field. However, due to the complexity and diversity of text structures, the extraction of stroke skeleton information has always been a technical problem in this field. Especially for relatively complex glyphs, the work of stroke skeleton extraction mostly relies on manual operation, which requires a large amount of human and material costs, and the extraction efficiency and accuracy are relatively low.
[0004] It can be seen that there is an urgent need for a method for extracting stroke skeleton information to overcome various technical problems in the prior art. Summary of the Invention
[0005] This application provides a method, apparatus, electronic device, and storage medium for extracting stroke skeleton information to solve the technical problems of low efficiency and accuracy in extracting stroke skeleton information in the prior art.
[0006] In a first aspect, this application provides a method for extracting stroke skeleton information, including:
[0007] Obtain a target image, where the target image includes a target text image;
[0008] Determine a reference text corresponding to the target text image according to the target image and a preset reference database;
[0009] Determine reference stroke skeleton information according to the reference text and the preset reference database, where the preset reference database includes a mapping relationship between the reference text and the reference stroke skeleton information;
[0010] Determine target stroke skeleton information according to the target text image and the reference stroke skeleton information.
[0011] In a possible design, the determining the target stroke skeleton information according to the target text image and the reference stroke skeleton information includes:
[0012] Determine first skeleton data according to the target text image and a preset image processing algorithm, where the first skeleton data includes a set of feature points;
[0013] Determine each single-stroke skeleton point set of the target text image according to the set of feature points;
[0014] Determine second skeleton data according to all the single-stroke skeleton point sets;
[0015] Determine third skeleton data according to the second skeleton data and a preset processing algorithm;
[0016] Determine the target stroke skeleton information according to the third skeleton data and the reference stroke skeleton information.
[0017] In a possible design, the determining each single-stroke skeleton point set of the target text image according to the set of feature points includes:
[0018] Determine an endpoint subset according to the set of feature points and a preset two-dimensional convolution algorithm;
[0019] Determine an intersection point subset according to the set of feature points and a preset intersection point extraction algorithm;
[0020] Determine a target text image skeleton point set according to a random point subset, a key point subset, and the reference stroke skeleton information, where the key point subset includes the endpoint subset and the intersection point subset, and the set of feature points includes the random point subset;
[0021] Match the target text image skeleton point set with the reference stroke skeleton information to obtain each single-stroke skeleton point set of the target text image.
[0022] In a possible design, the determining third skeleton data according to the second skeleton data and a preset processing algorithm includes:
[0023] Determine a plurality of skeleton segment data according to the second skeleton data and a preset connection algorithm;
[0024] Determine third skeleton data according to all the skeleton segment data and a preset clustering algorithm.
[0025] In a possible design, the obtaining a target image includes:
[0026] Obtain an input image;
[0027] Preprocess the input image to determine the target image.
[0028] In a second aspect, the present application provides a stroke skeleton information extraction device, including:
[0029] An obtaining module, configured to obtain a target image, where the target image includes a target text image;
[0030] The first processing module is used to determine the reference text corresponding to the target text image according to the target image and a preset reference database;
[0031] The second processing module is used to determine reference stroke skeleton information according to the reference text and the preset reference database, and the preset reference database includes the mapping relationship between the reference text and the reference stroke skeleton information;
[0032] The third processing module is used to determine target stroke skeleton information according to the target text image and the reference stroke skeleton information.
[0033] In a possible design, the third processing module is specifically configured to:
[0034] Determine first skeleton data according to the target text image and a preset image processing algorithm, where the first skeleton data includes a set of feature points;
[0035] Determine each single-stroke skeleton point set of the target text image according to the set of feature points;
[0036] Determine second skeleton data according to all the single-stroke skeleton point sets;
[0037] Determine third skeleton data according to the second skeleton data and a preset processing algorithm;
[0038] Determine the target stroke skeleton information according to the third skeleton data and the reference stroke skeleton information.
[0039] In a possible design, the third processing module is specifically configured to:
[0040] Determine a subset of endpoint points according to the set of feature points and a preset two-dimensional convolution algorithm;
[0041] Determine a subset of intersection points according to the set of feature points and a preset intersection point extraction algorithm;
[0042] Determine a target text image skeleton point set according to the subset of random points, the subset of key points, and the reference stroke skeleton information, where the subset of key points includes the subset of endpoint points and the subset of intersection points, and the set of feature points includes the subset of random points;
[0043] Match the target text image skeleton point set with the reference stroke skeleton information to obtain each single-stroke skeleton point set of the target text image.
[0044] In a possible design, the third processing module is specifically configured to:
[0045] Determine a plurality of skeleton segment data according to the second skeleton data and a preset connection algorithm;
[0046] Determine the third skeleton data according to all the skeleton segment data and a preset clustering algorithm.
[0047] In a possible design, the obtaining module is specifically configured to:
[0048] Obtain an input image;
[0049] Preprocess the input image to determine the target image.
[0050] In a third aspect, the present application provides an electronic device, including:
[0051] At least one processor; and
[0052] A memory communicatively connected to the at least one processor; wherein,
[0053] The memory stores instructions executable by the at least one processor, and when the instructions are executed by the at least one processor, the at least one processor is enabled to execute the stroke skeleton information extraction method involved in the first aspect and the optional solutions.
[0054] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium storing computer instructions, and the computer instructions are used to cause a computer to execute the stroke skeleton information extraction method involved in the first aspect and the optional solutions.
[0055] The stroke skeleton information extraction method, device, electronic device and storage medium provided by the present application first obtain a target image, the obtained target image includes a target text image, then determine a reference text corresponding to the target text image according to the target image, and then determine reference stroke skeleton information according to the determined reference text and a preset reference database, where the preset reference database includes a mapping relationship between the reference text and the reference stroke skeleton information, and finally determine the target stroke skeleton information according to the target text image and the reference stroke skeleton information. Thus, automatic extraction of stroke skeleton information can be achieved, and the entire extraction process does not require manual intervention, reducing the extraction cost while improving the efficiency and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] The accompanying drawings herein are incorporated into the specification and form a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure.
[0057] Figure 1 FIG. is a schematic diagram of an application scenario of the stroke skeleton information extraction method provided by an embodiment of the present application;
[0058] Figure 2Schematic flowchart of a method for extracting stroke skeleton information provided by an embodiment of the present application;
[0059] Figure 3 Schematic diagram of a reference stroke skeleton provided by an embodiment of the present application;
[0060] Figure 4 Schematic flowchart of a method for determining target stroke skeleton information provided by an embodiment of the present application;
[0061] Figure 5 Schematic diagram of a first skeleton data provided by an embodiment of the present application;
[0062] Figure 6 Schematic flowchart of a method for determining a single stroke skeleton point set provided by an embodiment of the present application;
[0063] Figure 7 Schematic diagram of a second skeleton data provided by an embodiment of the present application;
[0064] Figure 8 Schematic flowchart of a method for determining a third skeleton data provided by an embodiment of the present application;
[0065] Figure 9 Schematic diagram of an extracted target stroke skeleton provided by an embodiment of the present application;
[0066] Figure 10 Schematic diagram of the structure of a stroke skeleton information extraction device provided by an embodiment of the present application;
[0067] Figure 11 Schematic diagram of the structure of an electronic device provided by an embodiment of the present application.
[0068] Through the above-mentioned drawings, specific embodiments of the present disclosure have been shown, and there will be more detailed descriptions hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of the present disclosure in any way, but to illustrate the concept of the present disclosure to those skilled in the art by referring to specific embodiments. Detailed implementation manners
[0069] Here, exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of methods and devices consistent with some aspects of the present application as detailed in the appended claims.
[0070] In the description and claims of this application and the above-mentioned drawings, terms such as "first", "second", "third", "fourth", etc. (if any) are used to distinguish similar objects and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances so that the embodiments of this application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.
[0071] For the glyphs of characters, especially languages such as Chinese, Japanese, and Korean, their glyphs are all composed of strokes, and strokes are the basic units that make up characters. Therefore, stroke skeleton extraction is an important technical support in the field related to fonts. However, due to the complexity and diversity of character structures, the extraction of stroke skeletons has always been a technical problem in this field. Especially for more complex glyphs, the extraction work mostly relies on manual operation, which requires a large amount of human and material resources, and at the same time, the extraction efficiency and accuracy are very low.
[0072] In view of the above problems in the prior art, this application provides a method, device, electronic device, and storage medium for extracting stroke skeleton information. First, a target image is obtained, and the target image includes a target character image. Then, a reference character corresponding to the target character image is determined according to the target image. After that, according to the determined reference character and a preset reference database, reference stroke skeleton information is determined, where the preset reference database includes the mapping relationship between the reference character and the reference stroke skeleton information. Finally, the target stroke skeleton information is determined according to the target character image and the reference stroke skeleton information, thereby realizing the automatic extraction of stroke skeleton information. The entire extraction process does not require manual intervention, reducing the extraction cost while also improving the efficiency and accuracy.
[0073] The technical solution of this application will be described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0074] Figure 1 FIG. is a schematic diagram of an application scenario of the method for extracting stroke skeleton information provided in an embodiment of this application. As Figure 1 shown, the method for extracting stroke skeleton information provided in this application is executed by an electronic device, where the electronic device can be a mobile phone, a computer, a tablet computer, etc. Figure 1The computer 1 is used as an example. The stroke skeleton information extraction method provided by the present application can realize the extraction of the stroke skeleton information of the text contained in the target image.
[0075] First, obtain the target image, which includes the target text image. Figure 1 As shown, for example, if the target text is the Chinese character "事", an image containing the target text image 2 is obtained, and then the reference text corresponding to the target text image 2 is determined based on the target image. For example, the reference text corresponding to the target text image 2 is determined in a preset reference database. Obviously, the reference text is also the Chinese character "事". The difference is that the fonts of the reference text "事" and the target text "事" may be different. After the reference text is determined, the reference stroke skeleton information is determined based on the reference text and the preset reference database, wherein the preset reference database includes a mapping relationship between the reference text and the reference stroke skeleton information. Therefore, the determined reference stroke skeleton information is the stroke skeleton information of the reference text. Finally, the target stroke skeleton information is determined based on the target text image and the reference stroke skeleton information, thereby realizing the automatic extraction of the stroke skeleton information of the target text "事". No manual intervention is required in the entire extraction process, which reduces the extraction cost while improving efficiency and accuracy.
[0076] Figure 2 A schematic diagram of a method for extracting stroke skeleton information provided in an embodiment of the present application. Figure 2 As shown, the stroke skeleton information extraction method provided in this embodiment can be executed by an electronic device, and the method includes:
[0077] S21: Acquire a target image, where the target image includes a target text image.
[0078] Get a target image, where the target image includes a target text image. For example, if the target text is the Chinese character "事", you can refer to Figure 1 The target text image 2 in the figure is the image of the Chinese character "事". The target text image can be obtained by taking a photo or scanning the target text, and the image containing the target text image is the target image.
[0079] Optionally, acquiring the target image includes:
[0080] S211: Obtain input image.
[0081] Inputting target text and obtaining an image containing the input target text can be understood as taking a photo or scanning the input target text to obtain an input image.
[0082] S212: Preprocess the input image to determine a target image.
[0083] Preprocess the input image containing the target text to obtain the target image. The preprocessing can be image denoising and image binarization. For example, Gaussian smoothing operation can be used to remove the noise in the acquired input image, and then, the input image is binarized by using image binarization processing. Finally, the target image is obtained after preprocessing. Among them, other methods can also be used for image denoising processing, such as using the neighborhood averaging method. Any means that can perform image denoising processing to achieve the target processing result can be adopted. In this regard, the embodiments of the present application do not make limitations.
[0084] S22: Determine the reference text corresponding to the target text image according to the target image and the preset reference database.
[0085] After obtaining the target image, determine the reference character corresponding to the target text image according to the obtained target image and the preset reference database. For example, the reference text corresponding to the target text image can be determined in the preset reference database according to the target image.
[0086] Specifically, it can be to find the glyphs similar to the target text in the preset reference database according to the target text in the target image. Among them, the preset reference database contains multiple glyph binary maps of different fonts, and each binary map corresponds to a text. It can be understood that there may be multiple texts found in the preset reference database that are similar in glyph to the target text, and the multiple texts have the same glyph but different fonts. If there is only one text in the preset reference database that is similar in glyph to the target text, determine this text as the reference text corresponding to the target text image; if there are multiple texts in the preset reference database that are similar in glyph to the target text, the reference text can be determined according to the glyph difference value between the target text and the multiple texts, and the text corresponding to the minimum difference value is the reference text.
[0087] It should be noted that when determining the reference text corresponding to the target text image according to the target image, it is determined according to the same text. In other words, the target text and the reference text belong to the same text, have similar glyphs, and different fonts.
[0088] S23: Determine the reference stroke skeleton information according to the reference text and the preset reference database.
[0089] Among them, the preset reference database includes the mapping relationship between the reference text and the reference stroke skeleton information.
[0090] The preset reference database can be built offline, which may include multiple sets of binary images of glyphs of different fonts and the mapping relationship between reference text and reference stroke skeleton information. The mapping relationship refers to the corresponding relationship between each text in the preset reference database and each stroke skeleton information of the respective glyphs. It can be understood that when the reference text is determined, the reference stroke skeleton information can be determined based on the determined reference text and the preset reference database. It is worth understanding that the reference stroke skeleton information is the skeleton information of each stroke of the reference character.
[0091] Specifically, continue to refer to Figure 1 The target character image 2 is a target character "事", so the reference character determined in the preset database is also "事". The reference stroke skeleton information is determined according to the reference character and the preset reference database, and the reference stroke skeleton information is determined, such as Figure 3 As shown, Figure 3 A schematic diagram of a reference stroke skeleton provided in an embodiment of the present application.
[0092] S24: Determine target stroke skeleton information according to the target text image and reference stroke skeleton information.
[0093] After determining the reference stroke skeleton information, the target stroke skeleton information is determined according to the target text image and the reference stroke skeleton information. It can be understood that the target text in the target text image and the reference text corresponding to the reference stroke skeleton information belong to the same text, and the two have similar glyphs. When the reference stroke skeleton information is determined, each stroke skeleton information of the target text glyph can be determined based on the reference stroke skeleton information, thereby determining the stroke skeleton information of the target text, that is, the target stroke skeleton information, and realizing automatic extraction of the target text stroke skeleton information.
[0094] The stroke skeleton information extraction method provided by the present embodiment first obtains a target image, wherein the target image includes a target text image, and then determines the reference text corresponding to the target text image according to the target image and a preset reference database. After the reference text is determined, since the preset reference database includes a mapping relationship between the reference text and the reference stroke skeleton information, each stroke skeleton information of the reference text can be determined, that is, the reference stroke skeleton information. The target text in the target text image and the reference text belong to the same text. Therefore, when the reference stroke skeleton information is determined, the target stroke skeleton information can be determined according to the target text image and the reference stroke skeleton information, thereby realizing the extraction of the target text stroke skeleton information. The present invention overcomes the problems of manual operation required in the prior art, which increases the extraction cost, and has low extraction efficiency and accuracy. The stroke skeleton information extraction method provided by the present embodiment does not require manual intervention in the entire process, realizes automatic extraction, reduces the extraction cost, and improves efficiency and accuracy.
[0095] exist Figure 2 Based on the embodiment shown, a possible implementation of step S24 is as follows: Figure 4 As shown, Figure 4 A schematic diagram of a process for determining target stroke skeleton information provided in an embodiment of the present application, the implementation method includes:
[0096] S241: Determine first skeleton data according to the target text image and a preset image processing algorithm.
[0097] The first skeleton data includes a feature point set.
[0098] The target text image is processed by a preset image processing algorithm to determine the skeleton data of the target text in the target text image, which is the first skeleton data. The preset image processing algorithm may be an image thinning processing algorithm. The target text image after image binarization is processed by the image thinning processing algorithm to obtain the skeleton data of the target text. The skeleton data may be presented in various forms such as a matrix and a graph. For example, the skeleton data may be presented in a concrete manner by using a graph, such as Figure 5 As shown, Figure 5 A schematic diagram of a first skeleton data provided in an embodiment of the present application, wherein the target text is the Chinese character "事", and the target text image is Figure 1 2 in the above example, the first skeleton data is obtained as Figure 5 The embodiment of the present application does not limit the presentation form of the skeleton data.
[0099] It can be understood that the first skeleton data includes a plurality of data that make up the skeleton data. If each data is called a feature point, then the set of feature points constitutes the first skeleton data. In other words, the first skeleton data includes the set of feature points.
[0100] S242: Determine the set of skeleton points for each single stroke of the target text image according to the set of feature points.
[0101] The set of feature points constitutes the first skeleton data. In other words, the first skeleton data includes the set of feature points. It can be understood that each single stroke corresponding to the first skeleton data is composed of feature points. According to this set of feature points, the set of skeleton points for each single stroke of the target text image can be determined. Among them, each set of single-stroke skeleton points can be understood as a set composed of the skeleton points that make up each single stroke.
[0102] In a possible design, determining the set of skeleton points for each single stroke of the target text image according to the set of feature points can be achieved through Figure 6 the steps shown below. Figure 6 FIG. is a schematic flow chart for determining the set of single-stroke skeleton points provided by an embodiment of the present application. The implementation steps include:
[0103] S2421: Determine the subset of end points according to the set of feature points and a preset two-dimensional convolution algorithm.
[0104] The first skeleton data includes the set of feature points. By performing a preset two-dimensional convolution algorithm operation on the first skeleton data, multiple end points of the first skeleton data can be determined. The set of points composed of the multiple end points is the subset of end points, thereby realizing the determination of the subset of end points according to the set of feature points and the preset two-dimensional convolution algorithm.
[0105] S2422: Determine the subset of intersection points according to the set of feature points and a preset intersection point extraction algorithm.
[0106] Similar to step S2421, the first skeleton data includes the set of feature points. By performing a preset intersection point extraction algorithm process on the first skeleton data, multiple intersection points of the first skeleton data can be determined. The set of points composed of the multiple intersection points is the subset of intersection points, thereby realizing the determination of the subset of intersection points according to the set of feature points and the preset intersection point extraction algorithm.
[0107] S2423: Determine the set of target text skeleton points according to the subset of random points, the subset of key points, and the reference stroke skeleton information.
[0108] Among them, the subset of key points includes the subset of end points and the subset of intersection points, and the set of feature points includes the subset of randomly sampled points.
[0109] After determining the endpoint subset and the intersection point subset according to steps S2421 and S2422, the endpoints and intersection points are saved as the key points of the first skeleton data, and the set of points composed of the key points is the key point subset. In other words, the key point subset includes the endpoint subset and the intersection point subset.
[0110] Randomly sample the feature points in the feature point set included in the first skeleton data, and the obtained feature points are random points, and the set of points composed of the random points is the random point subset.
[0111] Apply the Coherent Point Drift (CPD) algorithm to the random point subset and the key point subset to perform non-rigid point set registration with the reference stroke skeleton information, and the obtained point set registration result constitutes the skeleton point set of the target text image.
[0112] S2424: Match the skeleton point set of the target text image with the reference stroke skeleton information to obtain the skeleton point set of each single stroke of the target text image.
[0113] The preset reference database includes the mapping relationship between the reference text and the reference stroke skeleton information. The mapping relationship refers to the corresponding relationship between each text in the preset reference database and the skeleton information of each stroke of its respective glyph. In other words, the skeleton information of each stroke of each text in the preset reference database is known, so the skeleton information of each stroke of each text can be classified offline. Classification can be understood as classifying the reference stroke skeleton information belonging to the same class into one class. For example, the skeleton information of each stroke of each text in the preset reference database can be classified according to the direction of the stroke skeleton and the order of the stroke skeleton.
[0114] Match the skeleton point set of the target text image with the reference stroke skeleton information that has been classified in advance, then the skeleton points of each single stroke of the target text can be obtained, and the set of points composed of each single stroke skeleton point is the skeleton point set of each single stroke, so as to obtain the skeleton point set of each single stroke of the target text image.
[0115] It can be understood that the skeleton point set of the target text image is matched with the reference stroke skeleton information, and the points that can complete the matching are selected to form the skeleton points of each single stroke of the target text, and the points that cannot complete the matching are excluded.
[0116] S243: Determine the second skeleton data according to all the single stroke skeleton point sets.
[0117] After determining each single-stroke skeleton point set of the target text image, by reproducing the text using all the single-stroke skeleton point sets, the second skeleton data of the target text image can be obtained. As previously described, a way to concretely present the skeleton data is a skeleton diagram, such as Figure 7 shown Figure 7 is a schematic diagram of a second skeleton data provided by an embodiment of the present application,
[0118] It can be understood that the points in each single-stroke skeleton point set can reproduce each single stroke, and each single stroke can constitute the second skeleton data.
[0119] S244: Determine the third skeleton data according to the second skeleton data and a preset processing algorithm.
[0120] After determining the second skeleton data of the target text image, the third skeleton data can be determined by processing the second skeleton data with a preset processing algorithm.
[0121] In a possible design, determining the third skeleton data according to the second skeleton data and a preset processing algorithm can be achieved through the Figure 8 steps shown Figure 8 is a schematic flowchart of determining the third skeleton data provided by an embodiment of the present application, such as Figure 8 shown, and this implementation method includes:
[0122] S2441: Determine a plurality of skeleton segment data according to the second skeleton data and a preset connection algorithm.
[0123] After determining the second skeleton data, connecting the second skeleton data using a preset connection algorithm can obtain a series of skeleton segment data, that is, a plurality of skeleton segment data are determined. Among them, the preset connection algorithm can be a preset edge connection algorithm, and any algorithm that can achieve connecting skeleton points to obtain skeleton segment data can be used. In this regard, the embodiments of the present application do not make limitations.
[0124] S2442: Determine the third skeleton data according to all the skeleton segment data and a preset clustering algorithm.
[0125] It can be understood that after determining a plurality of skeleton segment data, all the skeleton segment data can be clustered using a preset clustering algorithm, the clustering effect can be evaluated, and the category with the best clustering effect is retained. The skeleton segments corresponding to the best category constitute the third skeleton data, thereby determining the third skeleton data.
[0126] The following will describe steps S2441 and S2442 in detail. For the convenience of description, the second skeleton data is presented by a second skeleton diagram, and the third skeleton data is presented by a third skeleton diagram.
[0127] After determining the second skeleton data, that is, after determining the second skeleton graph, a series of skeleton segments are obtained according to a preset edge connection algorithm. The starting point and the ending point of each skeleton segment are selected, and the distances between the starting points and the ending points of pairwise skeleton segments are calculated respectively. The skeleton segment with the shortest distance is selected, and the selected skeleton segments are connected. Then, the distances between the connected skeleton segments and the remaining skeleton segments are calculated, and the shortest connected skeleton segment that has been selected is continuously selected, and the shortest connected skeleton segment that has been selected once is connected again. This operation is repeated until an edge connection graph connecting all the skeleton segments of the target text is established. In the established edge connection graph, an optimal connection path is selected, and a skeleton pruning operation is performed on the optimal connection path to obtain a final connection path. The final connection path is the optimal stroke path, and the optimal stroke path constitutes the third skeleton graph. The data corresponding to the third skeleton graph is the third skeleton data.
[0128] S245: Determine the target stroke skeleton information according to the third skeleton data and the reference stroke skeleton information.
[0129] After determining the third skeleton data, determine the target stroke skeleton information according to the third skeleton data and the reference stroke skeleton information.
[0130] Specifically, the CPD algorithm is used again for the point set constituting the third skeleton data, and non-rigid point set registration is performed with the corresponding reference stroke skeleton information. The point set corresponding to the obtained result constitutes the skeleton data of the target text in the target text image. In other words, the target stroke skeleton information is determined, and thus, the extraction operation of the target stroke skeleton information is completed. As Figure 9 shown, Figure 9 is a schematic diagram of the target stroke skeleton after extraction provided by an embodiment of the present application.
[0131] For the stroke skeleton information extraction method provided in this embodiment, first, the first skeleton data is determined according to the target text image and a preset image processing algorithm. Among them, the first skeleton data includes a feature point set. Then, each single stroke skeleton point set of the target text image is determined according to the feature point set. After each single stroke skeleton point set is determined, the second skeleton data can be determined according to all the determined single stroke skeleton point sets. The second skeleton data can be understood as the skeleton data composed of the preliminary extraction results of the stroke skeleton information. Then, the third skeleton data is determined according to the second skeleton data and a preset processing algorithm. Finally, the target stroke skeleton information is determined according to the third skeleton data and the reference stroke skeleton information, and the extraction of the stroke skeleton information is completed. It overcomes the problems in the prior art that manual operations are required, increasing the extraction cost, and the extraction efficiency and accuracy are relatively low. During the entire extraction process, no manual intervention is required, realizing automated operation, reducing the extraction cost, and improving the efficiency and accuracy.
[0132] Figure 10 This is a schematic structural diagram of a stroke skeleton information extraction device provided by an embodiment of the present application. The stroke skeleton information extraction device provided by this embodiment is used to execute the stroke skeleton information extraction method provided by each of the above embodiments. As Figure 10 shown, the stroke skeleton information extraction device 100 provided by this embodiment includes:
[0133] An acquisition module 101, configured to acquire a target image, where the target image includes a target text image.
[0134] A first processing module 102, configured to determine a reference text corresponding to the target text image according to the target image and a preset reference database.
[0135] A second processing module 103, configured to determine reference stroke skeleton information according to the reference text and a preset reference database, where the preset reference database includes a mapping relationship between the reference text and the reference stroke skeleton information.
[0136] A third processing module 104, configured to determine target stroke skeleton information according to the target text image and the reference stroke skeleton information.
[0137] The implementation principle and effect of the stroke skeleton information extraction device provided by this embodiment are similar to those of the above Figure 2 method embodiment, and will not be elaborated here.
[0138] Optionally, the acquisition module 101 is specifically configured to:
[0139] Acquire an input image;
[0140] Perform preprocessing on the input image to determine the target image.
[0141] The implementation principle and effect of this embodiment are similar to those of steps S211-S212 in the above method embodiment, and will not be elaborated here.
[0142] In a possible design, the third processing module 104 is specifically configured to:
[0143] Determine first skeleton data according to the target text image and a preset image processing algorithm, where the first skeleton data includes a set of feature points;
[0144] Determine a set of single stroke skeleton points of the target text image according to the set of feature points;
[0145] Determine second skeleton data according to all the sets of single stroke skeleton points;
[0146] Determine third skeleton data according to the second skeleton data and a preset processing algorithm;
[0147] Determine the target stroke skeleton information based on the third skeleton data and the reference stroke skeleton information.
[0148] This embodiment is similar to the above Figure 4 method embodiment in terms of implementation principle and effect, and will not be elaborated here.
[0149] In a possible design, the third processing module 104 is specifically configured to:
[0150] Determine an endpoint subset according to the feature point set and a preset two-dimensional convolution algorithm;
[0151] Determine an intersection point subset according to the feature point set and a preset intersection point extraction algorithm;
[0152] Determine a target text image skeleton point set according to the random point subset, the key point subset, and the reference stroke skeleton information, where the key point subset includes the endpoint subset and the intersection point subset, and the feature point set includes the random point subset;
[0153] Match the target text image skeleton point set with the reference stroke skeleton information to obtain each single stroke skeleton point set of the target text image.
[0154] This embodiment is similar to the above Figure 6 method embodiment in terms of implementation principle and effect, and will not be elaborated here.
[0155] In a possible design, the third processing module 104 is specifically configured to:
[0156] Determine a plurality of skeleton segment data according to the second skeleton data and a preset connection algorithm;
[0157] Determine the third skeleton data according to all the skeleton segment data and a preset clustering algorithm.
[0158] This embodiment is similar to the above Figure 8 method embodiment in terms of implementation principle and effect, and will not be elaborated here.
[0159] Figure 11 This is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As Figure 11 shown, the electronic device 800 provided in this embodiment includes:
[0160] At least one processor 801; and
[0161] A memory 802 communicatively connected to the at least one processor 801; wherein,
[0162] The memory 802 stores instructions executable by at least one processor 801. The instructions are executed by at least one processor 801 to enable at least one processor 801 to execute each step of the above-mentioned stroke skeleton information extraction method. For details, reference may be made to the relevant descriptions in the foregoing method embodiments.
[0163] In an exemplary embodiment, the embodiment of the present application provides a non-transitory computer-readable storage medium storing computer instructions for causing a computer to execute each step of the stroke skeleton information extraction method in the above-mentioned embodiments. For example, the readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0164] Those skilled in the art will readily conceive of other implementations of the present disclosure after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include known common knowledge or conventional technical means in the technical field not disclosed herein. The specification and examples are only regarded as exemplary, and the true scope and spirit of the present disclosure are pointed out by the claims.
[0165] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.
Claims
1. A method for extracting stroke skeleton information, characterized in that, Comprising: Obtain a target image, where the target image includes a target text image; Determine a reference text corresponding to the target text image according to the target image and a preset reference database; Determine reference stroke skeleton information according to the reference text and the preset reference database, where the preset reference database includes a mapping relationship between the reference text and the reference stroke skeleton information; Determine first skeleton data according to the target text image and a preset image processing algorithm, where the first skeleton data includes a set of feature points; Determine a subset of end points according to the set of feature points and a preset two-dimensional convolution algorithm; Determine a subset of intersection points according to the set of feature points and a preset intersection point extraction algorithm; Determine a set of skeleton points of the target text image according to a subset of random points, a subset of key points, and the reference stroke skeleton information, where the subset of key points includes the subset of end points and the subset of intersection points, and the set of feature points includes the subset of random points; Match the set of skeleton points of the target text image with the reference stroke skeleton information to obtain a set of skeleton points for each single stroke of the target text image; Determine second skeleton data according to all the sets of single stroke skeleton points; Determine a plurality of skeleton segment data according to the second skeleton data and a preset connection algorithm; Determine third skeleton data according to all the skeleton segment data and a preset clustering algorithm; Determine target stroke skeleton information according to the third skeleton data and the reference stroke skeleton information; The determining the third skeleton data according to all the skeleton segment data and a preset clustering algorithm includes: Select the starting point and the ending point of each skeleton segment, and calculate the distance between the starting point and the ending point between every two skeleton segments respectively; Select the skeleton segment with the shortest distance for connection, and calculate the distance between the connected skeleton segment and the remaining skeleton segments; Select the connected skeleton segment with the shortest distance for connection; Repeat the above steps until an edge connection graph connecting all the skeleton segments of the target text is established; Select an optimal connection path in the edge connection graph; Perform a skeleton pruning operation on the optimal connection path to obtain a connection path, where the connection path constitutes a third skeleton graph, and the data corresponding to the third skeleton graph is the third skeleton data; The determining the target stroke skeleton information according to the third skeleton data and the reference stroke skeleton information includes: Adopt a consistent point set drift algorithm to perform non-rigid point set registration on the point set constituting the third skeleton data and the reference stroke skeleton information to obtain the target stroke skeleton information.
2. The stroke skeleton information extraction method according to claim 1, wherein The obtaining the target image includes: Obtain an input image; Perform preprocessing on the input image to determine the target image.
3. A device for extracting stroke skeleton information, characterized in that, Comprising: An obtaining module, configured to obtain a target image, where the target image includes a target text image; A first processing module, configured to determine a reference text corresponding to the target text image according to the target image and a preset reference database; A second processing module, configured to determine reference stroke skeleton information according to the reference text and the preset reference database, where the preset reference database includes a mapping relationship between the reference text and the reference stroke skeleton information; A third processing module, configured to determine target stroke skeleton information according to the target text image and the reference stroke skeleton information; Specifically, the third processing module is configured to: Determine first skeleton data according to the target text image and a preset image processing algorithm, where the first skeleton data includes a set of feature points; Determine each single-stroke skeleton point set of the target text image according to the set of feature points; Determine second skeleton data according to all the single-stroke skeleton point sets; Determine third skeleton data according to the second skeleton data and a preset processing algorithm; Determine the target stroke skeleton information according to the third skeleton data and the reference stroke skeleton information; Specifically, the third processing module is configured to: Determine a subset of end points according to the set of feature points and a preset two-dimensional convolution algorithm; Determine a subset of intersection points according to the set of feature points and a preset intersection point extraction algorithm; Determine a skeleton point set of the target text image according to a subset of random points, a subset of key points, and the reference stroke skeleton information, where the subset of key points includes the subset of end points and the subset of intersection points, and the set of feature points includes the subset of random points; Match the skeleton point set of the target text image with the reference stroke skeleton information to obtain each single-stroke skeleton point set of the target text image; Specifically, the third processing module is configured to: Determine a plurality of skeleton segment data according to the second skeleton data and a preset connection algorithm; Determine third skeleton data according to all the skeleton segment data and a preset clustering algorithm; Specifically, the third processing module is configured to: select the starting point and the ending point of each skeleton segment, and calculate the distance between the starting point and the ending point between each pair of skeleton segments; Select the skeleton segment with the shortest distance for connection, and calculate the distance between the connected skeleton segment and the remaining skeleton segments; Select the connected skeleton segment with the shortest distance for connection; Repeat the above steps until an edge connection graph connecting all the skeleton segments of the target text is established; Select an optimal connection path in the edge connection graph; Perform a skeleton pruning operation on the optimal connection path to obtain a connection path, where the connection path forms a third skeleton graph, and the data corresponding to the third skeleton graph is third skeleton data; Adopt a consistent point set drift algorithm to perform non-rigid point set registration on the point set constituting the third skeleton data and the reference stroke skeleton information to obtain the target stroke skeleton information.
4. An electronic device, characterized in that, Including: At least one processor; And A memory communicatively connected to the at least one processor; where The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the stroke skeleton information extraction method according to claim 1 or 2.
5. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to execute the stroke skeleton information extraction method according to claim 1 or 2.
Citation Information
Patent Citations
Automatic extraction method of strokes of Chinese character based on manifold learning
CN107092917A