Font library generation method, device, electronic device and storage medium

By acquiring the text image collection and using preset processing algorithms to generate the target font library, the problem of complex and inefficient font library production in the existing technology is solved, high-quality and automated font library generation is achieved, and the text style is maintained.

CN112669407BActive Publication Date: 2025-01-10톈진 파운더 핸드롸이팅 디지털 테크놀로지 컴퍼니 리미티드 +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910984727.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-10-16
Publication Date
2025-01-10
Estimated Expiration
2039-10-16

AI Technical Summary

Technical Problem

In the prior art, the font library production process is complex, inefficient, high cost and poor quality. Especially for languages ​​with a large number of characters, such as Chinese and Japanese, it is difficult to accurately ensure the text style.

Method used

By obtaining the text image collection, determining the reference font library and target stroke trajectory data, and using preset processing algorithms to generate the target text image, thereby automatically generating the entire set of font library, simplifying the process, improving efficiency and maintaining the text style.

Benefits of technology

It realizes automatic generation of font libraries, reduces production costs, improves the quality of font libraries, and can accurately ensure the writing style of the original text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112669407B_ABST
    Figure CN112669407B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, electronic device and storage medium for generating a character library. The character library generating method provided by the present application obtains a set of text images, wherein the obtained set of text images includes at least one text image, and then determines a first reference character library based on the obtained text image, and then determines target stroke trajectory data based on the text images in the text image set and the first reference character library, wherein the determined target stroke trajectory data can characterize the shape characteristics of the text image, and finally determines the target text image based on the target stroke trajectory data and a preset processing algorithm to generate a target character library, thereby being able to realize automatic generation of a whole set of character libraries through text images. The character library generation process is concise, which improves the efficiency of character library production and reduces production costs. Moreover, the characters in the generated character library can maintain the writing style of the original characters, and the character library has a high quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer graphics technology, and in particular to a font library generation method, device, electronic device and storage medium. Background Art

[0002] With the rapid development of communication technology, especially the widespread use of smart terminals, people are exposed to a variety of fonts in their work and life, which leads to an increasing demand for various fonts.

[0003] In the prior art, the production of a font library usually requires a professional font library design team. The production process generally involves manually producing hundreds to thousands of reference characters, processing, modifying and producing each character based on the reference characters, obtaining the required target fonts, and generating a complete font library based on the target fonts.

[0004] It can be seen that the production process of a character library requires huge manpower and material resources, especially for character libraries with a large number of characters such as Chinese and Japanese, the production process is even more complicated and time-consuming. Not only does it require a large number of reference characters, but its production cycle is long and the production efficiency is low. In addition, the production process of the character library relies on manual labor, especially for reference characters with, for example, a cursive style, the prepared character library cannot accurately maintain the text style, and the quality of the character library is poor. Summary of the invention

[0005] The present application provides a font generation method, device, electronic device and storage medium to solve the technical problems of the existing font production process being complicated, inefficient, high production cost and poor font quality.

[0006] In a first aspect, the present application provides a method for generating a character library, comprising:

[0007] Acquire a text image set, wherein the text image set includes at least one text image;

[0008] Determine a first reference character library according to the character image set, wherein the first reference character library belongs to a preset reference character library set;

[0009] Determine target stroke trajectory data according to the character images in the character image set and the first reference character library, wherein the target stroke trajectory data is used to characterize shape characteristics of the character images;

[0010] A target character image is determined according to the target stroke trajectory data and a preset processing algorithm, so as to generate a target character library according to the target character image.

[0011] In a possible design, determining a first reference character library according to the character image set includes:

[0012] Determine a corresponding reference character image set according to the character image set and the preset reference character library set;

[0013] Determine a reference stroke skeleton data set according to the reference character image set and the preset reference character library set, wherein the preset reference character library set includes a mapping relationship between each reference character image and reference stroke skeleton data;

[0014] The first reference character library is determined according to the character image set and the reference stroke skeleton data set.

[0015] In a possible design, determining target stroke trajectory data according to the character images in the character image set and the first reference character library includes:

[0016] Determine skeleton data according to the text image and a first preset image processing algorithm, wherein the skeleton data includes a feature point set;

[0017] According to a preset extraction algorithm, the feature point set is matched with the reference stroke skeleton data set to determine the stroke trajectory data;

[0018] Target stroke trajectory data is determined according to the stroke trajectory data and a preset filtering algorithm.

[0019] In a possible design, determining a target text image according to the target stroke trajectory data and a preset processing algorithm includes:

[0020] Determine target stroke style data according to the target stroke trajectory data and a preset training model, wherein the target stroke style data includes target stroke coordinate data and target stroke center of gravity data;

[0021] Determine target stroke detail data according to the target stroke trajectory data, wherein the target stroke detail data includes target stroke width data and target stroke end contour feature data;

[0022] Determine target stroke connection probability data according to the target stroke trajectory data and the first reference character library;

[0023] Determine target stroke position data according to the target stroke style data and the first reference character library;

[0024] Determine a target stroke closed contour path according to the target stroke detail data and the target stroke position data;

[0025] Determine a single stroke image according to the target stroke closed contour path and a preset filling algorithm;

[0026] Determine a target stroke image according to the single stroke image and the target stroke connection probability data;

[0027] The target text image is determined according to the target stroke image and a preset superposition method.

[0028] In a possible design, generating a target character library according to the target character image includes:

[0029] Determining a modified text image according to the target text image and a second preset image processing algorithm;

[0030] Based on a preset vector algorithm, a target character library is generated according to the modified text image and the text image set.

[0031] In a second aspect, the present application provides a character library generation device, comprising:

[0032] An acquisition module, used to acquire a text image set, wherein the text image set includes at least one text image;

[0033] A first processing module, configured to determine a first reference character library according to the character image set, wherein the first reference character library belongs to a preset reference character library set;

[0034] A second processing module, configured to determine target stroke trajectory data according to the character images in the character image set and the first reference character library, wherein the target stroke trajectory data is used to characterize shape characteristics of the character images;

[0035] The third processing module is used to determine a target text image according to the target stroke trajectory data and a preset processing algorithm, so as to generate a target character library according to the target text image.

[0036] In a possible design, the first processing module is specifically used to:

[0037] Determine a corresponding reference character image set according to the character image set and the preset reference character library set;

[0038] Determine a reference stroke skeleton data set according to the reference character image set and the preset reference character library set, wherein the preset reference character library set includes a mapping relationship between each reference character image and reference stroke skeleton data;

[0039] The first reference character library is determined according to the character image set and the reference stroke skeleton data set.

[0040] In a possible design, the second processing module is specifically used to:

[0041] Determine skeleton data according to the text image and a first preset image processing algorithm, wherein the skeleton data includes a feature point set;

[0042] According to a preset extraction algorithm, the feature point set is matched with the reference stroke skeleton data set to determine the stroke trajectory data;

[0043] Target stroke trajectory data is determined according to the stroke trajectory data and a preset filtering algorithm.

[0044] In a possible design, the third processing module is specifically used to:

[0045] Determine target stroke style data according to the target stroke trajectory data and a preset training model, wherein the target stroke style data includes target stroke coordinate data and target stroke center of gravity data;

[0046] Determine target stroke detail data according to the target stroke trajectory data, wherein the target stroke detail data includes target stroke width data and target stroke end contour feature data;

[0047] Determine target stroke connection probability data according to the target stroke trajectory data and the first reference character library;

[0048] Determine target stroke position data according to the target stroke style data and the first reference character library;

[0049] Determine a target stroke closed contour path according to the target stroke detail data and the target stroke position data;

[0050] Determine a single stroke image according to the target stroke closed contour path and a preset filling algorithm;

[0051] Determine a target stroke image according to the single stroke image and the target stroke connection probability data;

[0052] The target text image is determined according to the target stroke image and a preset superposition method.

[0053] In a possible design, the third processing module is specifically used to:

[0054] Determining a modified text image according to the target text image and a second preset image processing algorithm;

[0055] Based on a preset vector algorithm, a target character library is generated according to the modified text image and the text image set.

[0056] In a third aspect, the present application provides an electronic device, including:

[0057] at least one processor; and

[0058] a memory communicatively connected to the at least one processor; wherein,

[0059] The memory stores instructions that can be executed 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 character library generation method involved in the first aspect and the optional solution.

[0060] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the character library generation method involved in the first aspect and the optional scheme.

[0061] The character library generation method, device, electronic device and storage medium provided by the present application first obtain a text image set, wherein the obtained text image set includes at least one text image, then determine a first reference character library based on the obtained text image, wherein the first reference character library belongs to a preset reference character library set, then determine target stroke trajectory data based on the text images in the text image set and the first reference character library, wherein the determined target stroke trajectory data can characterize the shape characteristics of the text image, finally determine the target text image based on the target stroke trajectory data and a preset processing algorithm, and generate a target character library based on the determined target text image, thereby being able to realize automatic generation of a whole set of character libraries through text images, the character library generation process is simple, the character library production efficiency is improved, and the production cost is reduced. Moreover, the characters in the generated character library can maintain the writing style of the original characters, and the character library quality is high. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0063] Figure 1 A schematic diagram of an application scenario of the character library generation method provided in an embodiment of the present application;

[0064] Figure 2 A flowchart of a method for generating a character library provided in an embodiment of the present application;

[0065] Figure 3 A schematic diagram of a process for determining a first reference character library provided in an embodiment of the present application;

[0066] Figure 4 A schematic diagram of a process for determining target stroke trajectory data provided by an embodiment of the present application;

[0067] Figure 5 A schematic diagram of target stroke trajectory data provided by an embodiment of the present application;

[0068] Figure 6 A schematic diagram of a process for determining a target text image provided by this embodiment;

[0069] Figure 7 A schematic diagram of a process for generating a target character library provided in an embodiment of the present application;

[0070] Figure 8 A schematic diagram of a standard character library and a target character library having the same character image provided in an embodiment of the present application;

[0071] Fig. 9 A schematic diagram of the structure of a character library generation device provided in an embodiment of the present application;

[0072] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0073] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0074] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying 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 implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of methods and devices consistent with some aspects of the present application as detailed in the appended claims.

[0075] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0076] With the rapid development of communication technology and the widespread use of smart terminals, people are exposed to a variety of character libraries in their work and life, which makes the demand for various character libraries growing day by day. However, in the prior art, the production process of a character library requires huge manpower and material resources, especially for character libraries with a large number of characters such as Chinese and Japanese, the production process is even more complicated and time-consuming. Not only does it require a large number of benchmark characters, but its production cycle is long and the production efficiency is low. In addition, the production process of the character library relies on manual labor, especially for benchmark characters with, for example, a cursive style, the prepared character library cannot accurately maintain the text style, and the character library quality is poor.

[0077] In response to the above-mentioned problems in the prior art, the present application provides a font generation method, device, electronic device and storage medium, by first acquiring a text image set, the acquired text image set including at least one text image, then determining a first reference font based on the acquired text image, wherein the first reference font belongs to a preset reference font set, and then determining target stroke trajectory data based on the text images in the text image set and the first reference font, the determined target stroke trajectory data can characterize the shape characteristics of the text image, finally determining the target text image based on the target stroke trajectory data and a preset processing algorithm, and generating a target font based on the determined target text image, thereby being able to automatically generate a whole set of fonts through at least one text image, the font generation process is concise, the font production efficiency is improved, the production cost is reduced, and the generated font can maintain the writing style of the original text, and the font quality is high.

[0078] The technical solution of the present application is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0079] Figure 1 A schematic diagram of an application scenario of the character library generation method provided in the embodiment of the present application. Figure 1 As shown, the character library generation method provided in the present application is executed by an electronic device, wherein the electronic device may be a mobile phone, a computer, a tablet computer or a laptop computer, etc. Figure 1 The computer 1 is used as an example. The character library generation method provided in the present application can realize the automatic generation of a whole character library through at least one text image, and the generated character library can maintain the writing style of the original text. The character library generation method provided in the present application can be applied to the production of character libraries of any text style.

[0080] First, a text image set is obtained, wherein the obtained text image set includes at least one text image. Figure 1As shown, for example, the text in the text image is the Chinese character "密" (mì). The obtained set of text images includes this text image 2. Then, a first reference font library is determined based on the set of text images. Next, target stroke trajectory data is determined based on the text image 2 in the set of text images and the first reference font library. The target stroke trajectory data can represent the shape characteristics of the text image. Finally, a target text image is determined based on the target stroke trajectory data and a preset processing algorithm, and a target font library is generated based on the target text image. Thus, an entire font library can be automatically generated through the text image, and the generated font library can maintain the text style of the original text image. Refer to Figure 1 , for example, a text image 3 in the target font library is the Chinese character "岢" (kě). The Chinese character "岢" maintains the text style of the component "山" (shān) in the Chinese character "密". It should be noted that Figure 1 only shows a text image in the font library generated by the font library generation method provided in this application.

[0081] Figure 2 is a schematic flowchart of a font library generation method provided by an embodiment of this application. As Figure 2 shown, the font library generation method provided in this embodiment can be executed by an electronic device. The method includes:

[0082] S21: Obtain a set of text images, where the set of text images includes at least one text image.

[0083] Obtaining a set of text images, where the obtained set of text images includes at least one text image. It can be understood that at least one text is written, and the written text can be photographed or scanned to obtain the corresponding text image. The at least one text image constitutes the set of text images. Refer to Figure 1 the text image 2 in

[0084] S22: Determine a first reference font library based on the set of text images, where the first reference font library belongs to a preset set of reference font libraries.

[0085] Determining a first reference font library based on the set of text images, where the first reference font library belongs to a preset set of reference font libraries. It can be understood that after obtaining the set of text images, the optimal reference font library is determined from the preset set of reference font libraries based on the set of text images, and the optimal reference font library is defined as the first reference font library. It should be understood that the optimal reference font library is the reference font library that best matches all the text images in the set of text images among the multiple preset reference font libraries in the preset set of reference font libraries.

[0086] In a possible design, the implementation manner of determining the first reference font library based on the set of text images is as Figure 3 shown Figure 3A schematic diagram of a process for determining a first reference character library provided in an embodiment of the present application, wherein the implementation method includes:

[0087] S221: Determine a corresponding reference text image set according to the text image set and a preset reference character library set.

[0088] The text image set includes at least one text image. Each text image in the text image set is identified from each preset reference character library of the preset reference character library set. The identified text images existing in the preset reference character library set constitute a reference text image set.

[0089] For example, all text images in a text image set are identified in a preset reference character library set according to Unicode, and the identified text images with consistent Unicode constitute a reference text image set, wherein each preset reference character library contains all text images in the text image set.

[0090] S222: Determine a reference stroke skeleton data set according to a reference text image set and a preset reference font set.

[0091] The preset reference character library set includes a mapping relationship between each reference character image and reference stroke skeleton data.

[0092] The preset reference character library can be constructed offline, and multiple preset reference character libraries constitute a preset reference character library set, wherein each preset reference character library contains a mapping relationship between a reference text image and reference stroke skeleton data. In other words, the preset reference character library set includes a mapping relationship between each reference text image and reference stroke skeleton data, and the mapping relationship refers to the corresponding relationship between each text image in the preset reference character library and the stroke skeleton data of the respective glyphs. Therefore, it can be understood that after the reference text image is determined, the reference stroke skeleton data can be determined based on the determined reference text image and the preset reference character library, and each reference text image has corresponding reference stroke skeleton data, so the reference text image set has a corresponding reference stroke skeleton data set. It is worth understanding that the reference stroke skeleton data is the stroke skeleton data of the text in the reference text image.

[0093] S223: Determine a first reference character library according to the character image set and the reference stroke skeleton data set.

[0094] After determining the reference stroke skeleton data set, the first reference font library is determined according to each text image in the text image set and the corresponding reference stroke skeleton data, wherein a feature comparison operation can be adopted, for example, an elastic grid algorithm is adopted to calculate the difference value between each text image and the reference text image based on the reference stroke skeleton data, the difference value between all reference text images involved in each preset reference font library and the corresponding text image is comprehensively calculated, and the preset reference font library corresponding to the minimum difference value is screened out. The screened out preset reference font library is the reference font library that best matches all the text images in the text image set, that is, the optimal reference font library, which is defined as the first reference font library.

[0095] It is worth noting that the number of preset reference character libraries corresponding to the minimum difference value provided in the embodiment of the present application is only one, and the preset reference character library corresponding to the minimum difference value is the first reference character library.

[0096] The method for determining the optimal reference character library provided by the present embodiment, that is, determining the first reference character library, first determines the reference character image set corresponding to the character image set through the character image set and the preset reference character library set. Since the preset reference character library set includes the mapping relationship between each reference character image and the reference stroke skeleton data, the reference stroke skeleton data set can be determined according to the reference character image set and the preset reference character library set, and then the character image set and the reference stroke skeleton data set are calculated using a feature comparison algorithm, such as an elastic grid algorithm, so as to determine the first reference character library. The method for determining the first reference character library provided by the present embodiment can determine the character library that best matches the character image set from the preset reference character library set as the reference character library, thereby achieving accurate matching of the reference character library, which is conducive to improving the quality of the target character library.

[0097] S23: Determine target stroke trajectory data according to the text images in the text image set and the first reference character library.

[0098] The target stroke trajectory data is used to characterize the shape characteristics of the text image.

[0099] After the first reference character library is determined, target stroke trajectory data is determined according to each character image in the character image set and the first reference character library, wherein the target stroke trajectory data can represent the shape characteristics of each character image in the character image set.

[0100] It is worth understanding that strokes are the basic elements that constitute characters. Therefore, the target stroke trajectory data can be understood as a series of data that accurately represents each stroke of each character image in the character image set, such as the starting point, end point, inflection point of each stroke of the character image, and the position of each point in the entire character shape, thereby representing the shape characteristics of the character image.

[0101] In addition, the first reference character library includes a mapping relationship between reference character images and reference stroke skeleton data. Therefore, target stroke trajectory data can be determined through the character images in the character image set and the first reference character library. The determined target stroke trajectory data can represent the shape characteristics of the character images.

[0102] It is worth noting that the target stroke trajectory data refers to all the strokes constituting the text image.

[0103] In a possible design, the target stroke trajectory data is determined as follows: Figure 4 As shown, Figure 4 A schematic diagram of a process for determining target stroke trajectory data provided in an embodiment of the present application, the implementation method includes:

[0104] S231: Determine skeleton data according to the text image and a first preset image processing algorithm.

[0105] The skeleton data includes a feature point set.

[0106] The text images in the text image set are processed using a preset image processing algorithm to determine the skeleton data of the text in the text image. For example, the text images are processed using an image thinning processing algorithm to obtain the skeleton data of the text in the text image.

[0107] It can be understood that the skeleton data includes a plurality of data constituting the skeleton data. If each data is called a feature point, then the feature point set constitutes the skeleton data. In other words, the skeleton data includes the feature point set.

[0108] S232: According to a preset extraction algorithm, the feature point set is matched with a reference stroke skeleton data set to determine the stroke trajectory data.

[0109] After determining the skeleton data of the text image, that is, the feature point set, a preset extraction algorithm is used to match the feature point set with the reference stroke skeleton data set to obtain stroke trajectory data. It can be understood that the obtained stroke trajectory data is the stroke trajectory data of the text image in the text image set.

[0110] For example, a consistent point set drift algorithm (Coherent Point Drift, CPD for short) can be used to perform non-rigid point set registration on the feature point set and the reference stroke skeleton data set, and the point set registration result obtained is the stroke trajectory data.

[0111] It is worth noting that the stroke trajectory data refers to all the strokes that constitute the text image.

[0112] S233: Determine the target stroke trajectory data based on the stroke trajectory data and a preset filtering algorithm.

[0113] After determining the stroke trajectory data of the text image above, filter the stroke trajectory data through a preset filtering algorithm to filter out the stroke trajectory data with poor matching results determined in step S232. It can be understood that in step S232, a preset extraction algorithm is used to match the feature point set with the reference stroke skeleton data set, and the stroke trajectory data of the text image determined may include data such as the starting point, ending point, inflection point of the stroke, and the position of each point in the glyph. Therefore, it is necessary to filter out the data with poor matching.

[0114] For example, the specific process of the preset filtering algorithm adopted can be as follows: First, reproduce the text image through the dilation processing of the image according to the stroke trajectory data determined in step S232, and then compare the reproduced text image with the corresponding text image in the text image set, calculate the difference value after the comparison of the two, and determine the target stroke trajectory data from the stroke trajectory data according to the difference value. Specifically, the calculated difference values can be sorted in ascending order, and then a threshold is specified for truncation. For example, if the threshold is set to 70%, the stroke trajectory data corresponding to 30% of the difference values is considered to be the determined data with poor matching, so it is filtered out, thereby determining the stroke trajectory data with better matching and taking it as the target stroke trajectory data.

[0115] It should be noted that the target stroke trajectory data is for all strokes constituting the text image. As Figure 5 shown, Figure 5 is a schematic diagram of a kind of target stroke trajectory data provided by an embodiment of the present application. It can be understood that the expression form of the target stroke trajectory data can be a matrix, a graph, etc. Among them, the graph is a more vivid expression form. Figure 5 Taking the Chinese character "啊" as an example, the target stroke trajectory data of this glyph is shown.

[0116] The method for determining the target stroke trajectory data provided in this embodiment first determines the skeleton data through the text image and the first preset image processing algorithm, where the skeleton data includes a feature point set, and then according to the preset extraction algorithm, matches the feature point set with the reference stroke skeleton data set to determine the stroke trajectory data, and finally determines the target stroke trajectory data from the stroke trajectory data through the preset filtering algorithm to improve the accuracy of the data used in subsequent data training by the preset training model, which is beneficial to the target text image to maintain the writing style of the text images in the text image set.

[0117] S24: Determine the target text image based on the target stroke trajectory data and a preset processing algorithm, so as to generate a target font library according to the target text image.

[0118] After the target stroke trajectory data is determined, the target stroke trajectory data is operated by a preset processing algorithm to determine the target text image, and then the target character library is generated from the determined target text image. It can be understood that the target stroke trajectory data is the stroke trajectory data of the text image in the text image set. Therefore, the target stroke trajectory data is operated by a certain algorithm to determine the target text image corresponding to the text image. When the target text image is determined, the target character library can be generated according to the target text image.

[0119] It can be understood that the target character library includes each independent target character image.

[0120] In a possible design, the target text image is determined according to the target stroke trajectory data and the preset processing algorithm. Figure 6 As shown, Figure 6 A schematic diagram of a process for determining a target text image provided in this embodiment includes:

[0121] S241: Determine target stroke style data according to the target stroke trajectory data and a preset training model.

[0122] The target stroke style data includes target stroke coordinate data and target stroke center of gravity data.

[0123] The target stroke trajectory data is trained using a preset training model to determine target stroke style data, where the target stroke style data includes target stroke coordinate data and target stroke center of gravity data.

[0124] In order to obtain more accurate data describing the text image in the process of training data using the preset training model, the preset training model can use two models for data training for the stroke trajectory information and stroke center of gravity information describing the target text image. It can be understood that the two models are essentially the same, and the difference is the input and output data of the training model. For example, the preset training model can use an artificial neural network, and the input and output data for describing the stroke trajectory information are stroke point coordinate data, and the input and output data for describing the stroke center of gravity information are stroke center of gravity coordinate data. It is worth understanding that the stroke point coordinate data is the coordinate data representing the feature points on the stroke, and the stroke center of gravity coordinate data is the coordinate data representing the position of the stroke center of gravity.

[0125] It is worth noting that before data training, the target stroke trajectory data and the corresponding reference stroke skeleton data in the reference stroke skeleton data set are first formatted to obtain the target stroke point coordinate data and the corresponding reference stroke point coordinate data, as well as the target stroke center of gravity coordinate data and the corresponding reference stroke center of gravity coordinate data.

[0126] The specific steps of using the preset training model for data training are as follows:

[0127] For the preset training model that describes the stroke trajectory information, the same number of sampling points are evenly extracted from the target stroke point coordinate data and the reference stroke point coordinate data corresponding to the text image and the reference text image, and the numerical normalization is performed. The difference between the corresponding target stroke point coordinate data and the reference stroke point coordinate data is calculated, and the difference is used as the output of the preset training model, whose input is the normalized data of the corresponding reference stroke point coordinate data.

[0128] For the preset training model that describes the stroke center of gravity information, the normalized difference between the corresponding target stroke center of gravity coordinate data and the corresponding reference stroke center of gravity coordinate data is calculated, and the difference is used as the output of the preset training model, and its input is the corresponding reference stroke center of gravity coordinate data.

[0129] The target stroke trajectory data determined in step S23 and the corresponding reference stroke skeleton data are used as the training data of the above two preset training models, and the target stroke coordinate data and the target stroke center of gravity data can be obtained respectively, wherein the target stroke coordinate data is obtained by the preset training model describing the stroke trajectory information, and the target stroke center of gravity data is obtained by the preset training model describing the stroke center of gravity information. The target stroke coordinate data and the target stroke center of gravity data jointly determine the target stroke style data to accurately describe the overall writing style of the text image.

[0130] S242: Determine target stroke detail data according to the target stroke trajectory data.

[0131] The target stroke detail data includes target stroke width data and target stroke end contour feature data.

[0132] The target stroke detail data can be understood as data representing the detail information of the stroke, such as the stroke width information and the contour information of the stroke end. Therefore, the target stroke detail data includes the target stroke width data and the target stroke end contour feature data. The target stroke trajectory data can represent the shape characteristics of the text image, such as Figure 5 As shown, it can be seen that expanding the stroke width of the stroke skeleton data and modifying the stroke end contour can further accurately represent the shape characteristics of the text image.

[0133] For example, the target stroke width data, i.e., the stroke width value, can be determined as twice the maximum distance from the stroke starting point or end point to the stroke contour, and the data of the stroke starting point and end point are all from the target stroke trajectory data, so the target stroke width data is determined according to the target stroke trajectory data. Furthermore, by emitting a certain number of rays from the starting point or end point to the stroke contour closest to one side, the distance from the starting point or end point to the stroke contour can be calculated, and then the stroke contour shape in the starting point or end point area can be determined. Moreover, in the offline stage, all strokes involved in the text can be accurately classified, for example, Chinese is 339 categories, Japanese is 358 categories, then the average value of each type of stroke in the above-mentioned data characterizing the stroke contour shape can be calculated, and the obtained average value is the target stroke end contour feature data. The target stroke width data and the target stroke end contour feature data determine the target stroke detail data.

[0134] S243: Determine target stroke connection probability data according to the target stroke trajectory data and the first reference character library.

[0135] It is understandable that, in the offline stage, the components of the reference text image in the first reference character library can be accurately classified, for example, Chinese is 1777 categories and Japanese is 2075 categories. A category represents a component. In order to describe the characteristics of the connection of adjacent strokes within a component, it is necessary to calculate the probability of connecting adjacent strokes within each category, that is, each component. For example, for Chinese, there are 1777 categories, and each category represents the probability of connecting between the end point of the i-th stroke and the starting point of the i+1-th stroke within the category. Thus, through statistical analysis, the probability of connecting between the starting point and the end point of the target stroke and the end point of the adjacent previous stroke and the starting point of the adjacent next stroke in the component where the target stroke is located is obtained, and the data representing the probability of connecting is the target stroke connecting probability data.

[0136] S244: Determine target stroke position data according to the target stroke style data and the first reference character library.

[0137] The target stroke style data determined in step S241 is fitted with the corresponding reference stroke skeleton data in the first reference character library, and the fitting result is the target stroke position data to represent the position information of each stroke of the text image in the entire character shape.

[0138] It is understandable that, since the target stroke style data includes target stroke coordinate data and target stroke center of gravity data, the target stroke coordinate data is fitted with the reference stroke point coordinate data, and similarly, the target stroke center of gravity data is fitted with the reference stroke center of gravity coordinate data. The fitting results of the two are determined as the target stroke position data.

[0139] S245: Determine the target stroke closed contour path according to the target stroke detail data and the target stroke position data.

[0140] The target stroke detail data includes target stroke width data and target stroke end contour feature data. By performing operations on the two types of data respectively, the closed contour path of the target stroke can be determined.

[0141] Specifically, firstly, the stroke order of the text image can be determined through the correspondence between the text-component-stroke order, and the stroke contour information can be restored according to the determined stroke order. Then, based on the target stroke end contour feature data and the positions of the starting point and the end point represented by the target stroke position data as the center point, a certain number of rays are emitted on average within a range of 180°, wherein the length of the ray is the stroke end width of the current stroke type, and the end point of the ray is the final contour point. The stroke interruption is divided into a certain number of segments, and a ray is taken in each of the 90° directions to the left and right. The length of the ray is the width of a certain number of segments in the current stroke middle segment, and the end point of the ray is still a contour point. All contour points are connected in a preset certain order, and a complete stroke closed contour path can be obtained.

[0142] S246: Determine a single stroke image according to the target stroke closed contour path and a preset filling algorithm.

[0143] After the target stroke closed contour path is determined, the target stroke closed contour path is filled using a preset filling algorithm to obtain each single stroke image. The preset filling algorithm may be a winding filling algorithm (Winding Fill).

[0144] S247: Determine a target stroke image according to the single stroke image and the target stroke connection probability data.

[0145] After each single stroke image is determined, each single stroke image may be processed according to certain rules to obtain a target stroke image.

[0146] For example, according to the correspondence between text-component-stroke sequence within a component and based on the target stroke connection probability data, the adjacent strokes that need to be connected within the component can be smoothly connected to obtain the target stroke image.

[0147] It is worth noting that the target stroke connection probability data is determined based on the target stroke trajectory data, which takes into account the writing habits of the characters in the text image and reduces meaningless connected strokes. Therefore, the target stroke image determined based on a single stroke image and the target stroke connection probability data maintains the text style of the characters in the original written text image.

[0148] S248: Determine a target text image according to the target stroke image and a preset superposition method.

[0149] After the target stroke image is determined, the determined target stroke image is superimposed once using a preset superposition method, so that the entire shape of the target text can be obtained, that is, the target text image is determined. The preset superposition method can be any method that can perform image superposition, and this embodiment of the application does not limit this.

[0150] It can be understood that when superimposing the target stroke images, all target stroke images of the same target text image are superimposed.

[0151] The method for determining the target text image provided in the present embodiment first determines the target stroke style data according to the target stroke trajectory data and a preset training model, and determines the target stroke detail data according to the target stroke trajectory data, and then determines the target stroke connection probability data and the target stroke position data, as well as the target stroke closed contour path, and uses a preset filling algorithm to fill the target stroke closed contour path to determine a single stroke image, and then determines the target stroke image in combination with the target stroke connection probability data, and superimposes it by a preset superposition method, and finally determines the target text image, so that the determined target text image can maintain the text style of the original text image.

[0152] It is understandable that through Figure 6 The method for determining the target text image in the illustrated embodiment can determine all target text images that constitute a complete set of target character libraries. After all target text images are determined, a possible method for generating a target character library based on the target text images is to store all target text images directly into a set of character libraries, which is the target character library. The obtained target character library has the same text style as the same components in the text image set.

[0153] Another possible implementation method of generating a target character library from a target text image is as follows: Figure 7 As shown, Figure 7 A schematic diagram of a process for generating a target character library provided in an embodiment of the present application, the implementation method includes:

[0154] S71: Determine a modified text image according to the target text image and a second preset image processing algorithm.

[0155] The target text image is processed by a second preset image processing algorithm to correct the text image so that the stroke width of the target text image is closer to the stroke width of the text images in the text image set. The second preset image processing algorithm may be image erosion and / or image dilation processing.

[0156] For example, a difference value can be used to evaluate the width of the same strokes between a corrected text image and text images in a text image set. A technician in this field can determine a threshold of the difference value based on implementation requirements to control the degree of processing of the target text image by the second preset image processing algorithm, thereby determining the corrected text image.

[0157] S72: Based on a preset vector algorithm, a target font library is generated according to the corrected text image and the text image set.

[0158] After the corrected text image is determined, a preset vector algorithm is used to operate the corrected text image and the text images in the text image set to obtain the final target text image constituting the target character library. After all the final target text images are determined, all the final target text images constitute the target character library.

[0159] For example, the glyph outline can be vectorized to vectorize the corrected text image and the text images in the text image set, and the final target text image can be generated according to the standard format of the vector font library, and the vectorization of all the final target text images can be completed to form the target font library. Figure 8 As shown, Figure 8 A schematic diagram of the same text images in a standard font library and a target font library provided in an embodiment of the present application, the text images in the standard font library 4 are prepared according to the prior art, and the text images in the target font library 5 are prepared according to the font generation method provided in this embodiment, and both are vector font libraries.

[0160] It can be understood that the target character library includes each independent final target character image.

[0161] The character library generation method provided in the present embodiment obtains a character image set, wherein the obtained character image set includes at least one character image, and then determines a first reference character library based on the obtained character image set, wherein the first reference character library data presets a character library in the reference character library set, and after determining the first reference character library, determines target stroke trajectory data based on the character images in the character image set and the first reference character library, wherein the target stroke trajectory data can characterize the shape characteristics of the character image, and finally determines the target character image based on the target stroke trajectory data and a preset processing algorithm, and generates a target character library based on the target character image. The automatic generation of the entire character library can be realized through the character image. Compared with the prior art, the character library production efficiency is improved and the production cost is reduced because the generation process is simple. Moreover, the character library generation method provided in the present embodiment can more accurately maintain the style of the character images in the character image set, thereby improving the quality of the character library.

[0162] Fig. 9The structure diagram of a character library generation device provided in an embodiment of the present application is shown in FIG. The character library generation device provided in this embodiment is used to execute the character library generation method provided in the above embodiments, such as Fig. 9 As shown, the character library generating device 100 provided in this embodiment includes:

[0163] The acquisition module 101 is used to acquire a text image set, where the text image set includes at least one text image.

[0164] The first processing module 102 is configured to determine a first reference character library according to the character image set, where the first reference character library belongs to a preset reference character library set.

[0165] The second processing module 103 is used to determine target stroke trajectory data according to the character images in the character image set and the first reference character library, where the target stroke trajectory data is used to characterize shape characteristics of the character images.

[0166] The third processing module 104 is used to determine a target text image according to the target stroke trajectory data and a preset processing algorithm, so as to generate a target character library according to the target text image.

[0167] The character library generation device provided in this embodiment is similar to the above Figure 2 The implementation principle and effect of the method embodiment are similar and will not be repeated here.

[0168] In a possible design, the first processing module 102 is specifically configured to:

[0169] Determine a corresponding reference text image set according to the text image set and the preset reference character library set;

[0170] Determine a reference stroke skeleton data set according to a reference character image set and a preset reference character library set, wherein the preset reference character library set includes a mapping relationship between each reference character image and reference stroke skeleton data;

[0171] A first reference character library is determined according to the character image set and the reference stroke skeleton data set.

[0172] This embodiment is different from the above Figure 3 The implementation principle and effect of the method embodiment are similar and will not be repeated here.

[0173] In a possible design, the second processing module 103 is specifically configured to:

[0174] Determine skeleton data according to the text image and a first preset image processing algorithm, where the skeleton data includes a feature point set;

[0175] According to a preset extraction algorithm, the feature point set is matched with a reference stroke skeleton data set to determine the stroke trajectory data;

[0176] The target stroke trajectory data is determined according to the stroke trajectory data and a preset filtering algorithm.

[0177] This embodiment is different from the above Figure 4 The implementation principle and effect of the method embodiment are similar and will not be repeated here.

[0178] In a possible design, the third processing module 104 is specifically configured to:

[0179] Determine target stroke style data according to target stroke trajectory data and a preset training model, wherein the target stroke style data includes target stroke coordinate data and target stroke center of gravity data;

[0180] Determine target stroke detail data according to target stroke trajectory data, the target stroke detail data including target stroke width data and target stroke end contour feature data;

[0181] Determine target stroke connection probability data according to target stroke trajectory data and a first reference character library;

[0182] Determine target stroke position data according to the target stroke style data and the first reference character library;

[0183] Determine the target stroke closed contour path according to the target stroke detail data and the target stroke position data;

[0184] Determine a single stroke image according to a target stroke closed contour path and a preset filling algorithm;

[0185] Determine a target stroke image according to the single stroke image and target stroke connection probability data;

[0186] The target text image is determined according to the target stroke image and the preset superposition method.

[0187] This embodiment is different from the above Figure 6 The implementation principle and effect of the method embodiment are similar and will not be repeated here.

[0188] In a possible design, the third processing module 104 is further specifically configured to:

[0189] Determine a modified text image according to the target text image and a second preset image processing algorithm;

[0190] Based on a preset vector algorithm, a target font library is generated according to the corrected text image and the text image set.

[0191] This embodiment is different from the above Figure 7 The implementation principle and effect of the method embodiment are similar and will not be repeated here.

[0192] Fig.10This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.10 As shown, the electronic device 800 provided in this embodiment includes:

[0193] at least one processor 801; and

[0194] A memory 802 is communicatively connected to at least one processor 801; wherein,

[0195] The memory 802 stores instructions executable by at least one processor 801. The instructions are executed by at least one processor 801 so that at least one processor 801 can execute each step of the above-mentioned character library generation method. For details, please refer to the relevant description in the above-mentioned method embodiment.

[0196] In an exemplary embodiment, the present application provides a non-transitory computer-readable storage medium storing computer instructions, and the computer instructions are used to make a computer execute each step of the character library generation method in the above embodiments. For example, the readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device.

[0197] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This 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 common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.

[0198] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A method for generating a character library, characterized in that: include: Acquire a text image set, wherein the text image set includes at least one text image; Determine a first reference character library according to the character image set, the first reference character library belongs to a preset reference character library set, the preset reference character library set includes a mapping relationship between each reference character image and reference stroke skeleton data, and the first reference character library is a reference character library with the smallest difference from all the character images in the character image set among multiple preset reference character libraries in the preset reference character library set; Determine target stroke trajectory data according to the character images in the character image set and the first reference character library, wherein the target stroke trajectory data is used to characterize shape characteristics of the character images; Determine a target text image according to the target stroke trajectory data and a preset processing algorithm, so as to generate a target character library according to the target text image, wherein the target text image is a modified text image determined based on a second preset image processing algorithm; The determining a first reference character library according to the character image set comprises: Determine a corresponding reference character image set according to the character image set and the preset reference character library set; Determine a reference stroke skeleton data set according to the reference character image set and the preset reference character library set; The first reference character library is determined according to the character image set and the reference stroke skeleton data set.

2. The character library generation method according to claim 1, characterized in that: The step of determining target stroke trajectory data according to the character images in the character image set and the first reference character library includes: Determine skeleton data according to the text image and a first preset image processing algorithm, wherein the skeleton data includes a feature point set; According to a preset extraction algorithm, the feature point set is matched with the reference stroke skeleton data set to determine the stroke trajectory data; Target stroke trajectory data is determined according to the stroke trajectory data and a preset filtering algorithm.

3. The character library generation method according to claim 2, characterized in that: The step of determining a target text image according to the target stroke trajectory data and a preset processing algorithm includes: Determine target stroke style data according to the target stroke trajectory data and a preset training model, wherein the target stroke style data includes target stroke coordinate data and target stroke center of gravity data; Determine target stroke detail data according to the target stroke trajectory data, wherein the target stroke detail data includes target stroke width data and target stroke end contour feature data; Determine target stroke connection probability data according to the target stroke trajectory data and the first reference character library; Determine target stroke position data according to the target stroke style data and the first reference character library; Determine a target stroke closed contour path according to the target stroke detail data and the target stroke position data; Determine a single stroke image according to the target stroke closed contour path and a preset filling algorithm; Determine a target stroke image according to the single stroke image and the target stroke connection probability data; The target text image is determined according to the target stroke image and a preset superposition method.

4. The character library generation method according to claim 3, characterized in that: The step of generating a target character library according to the target character image comprises: Determining a modified text image according to the target text image and a second preset image processing algorithm; Based on a preset vector algorithm, a target character library is generated according to the modified text image and the text image set.

5. A character library generating device, characterized in that: include: An acquisition module, used to acquire a text image set, wherein the text image set includes at least one text image; A first processing module is configured to determine a first reference character library according to the character image set, wherein the first reference character library belongs to a preset reference character library set, the preset reference character library set includes a mapping relationship between each reference character image and reference stroke skeleton data, and the first reference character library is a reference character library with the smallest difference from all the character images in the character image set among multiple preset reference character libraries in the preset reference character library set; A second processing module, configured to determine target stroke trajectory data according to the character images in the character image set and the first reference character library, wherein the target stroke trajectory data is used to characterize shape characteristics of the character images; A third processing module is used to determine a target text image according to the target stroke trajectory data and a preset processing algorithm, so as to generate a target character library according to the target text image, wherein the target text image is a modified text image determined based on the second preset image processing algorithm; The first processing module is specifically used for: Determine a corresponding reference character image set according to the character image set and the preset reference character library set; Determine a reference stroke skeleton data set according to the reference character image set and the preset reference character library set; The first reference character library is determined according to the character image set and the reference stroke skeleton data set.

6. The character library generating device according to claim 5, characterized in that: The second processing module is specifically used for: Determine skeleton data according to the text image and a first preset image processing algorithm, wherein the skeleton data includes a feature point set; According to a preset extraction algorithm, the feature point set is matched with the reference stroke skeleton data set to determine the stroke trajectory data; Target stroke trajectory data is determined according to the stroke trajectory data and a preset filtering algorithm.

7. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed 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 character library generation method according to any one of claims 1 to 4.

8. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the character library generation method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Chinese word stock automatic generation method based on writing style modeling

    CN106384094A