A Chinese character font generation method based on font outline information

Through a Chinese character font generation method based on font outline information, using the font style migration network model and edge extraction module, the problems of low efficiency and unstable quality of Chinese character font generation in the existing technology are solved, and high-quality Chinese character font generation is achieved.

CN117830074BActive Publication Date: 2024-08-23GUANGZHOU ACADEMY OF FINE ARTS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311755529.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-20
Publication Date
2024-08-23
Estimated Expiration
2043-12-20

AI Technical Summary

Technical Problem

Existing Chinese character font generation technology is difficult to unify a huge vocabulary into the same style, resulting in low font generation efficiency and unstable quality. Chinese character structures are complex and font styles are diverse, making it difficult to meet the needs of glyph generation.

Method used

A Chinese character font generation method based on font outline information is adopted. By constructing a training set of source style and target style, a font style transfer network model is established. The edge extraction module and generator are used to generate target-style font images, and adversarial training is performed through the discriminator. , optimize network model parameters and improve font generation quality.

Benefits of technology

While reducing the number of training samples, the structure and style characteristics of Chinese characters are captured, and the generated Chinese characters have clear outlines, complete stroke characteristics, good style performance, high recognizability and authenticity, and improve the quality of Chinese character font generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117830074B
    Figure CN117830074B
Patent Text Reader

Abstract

The present invention provides a Chinese character font generation method based on font outline information, by constructing a source style font training set and a target style font training set, and then constructing a font style transfer network model, and using a loss function to train and optimize the font transfer network model, so that its generator and discriminator reach preset performance, which is conducive to improving the result of font generation. At the same time, an edge extraction module is set in the font style transfer network model, the edge extraction module receives the input source style font image and extracts the edge outline information of the font in the source style font image through a convolution operation and passes it into the generator, and then the generator splices these edge information with the source style font image, helping the generator to better understand the structure and edge details of the font, so that the overall structure and stroke edges of the generated font have good clarity, and the font generation quality is further optimized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Chinese character font generation, and in particular to a Chinese character font generation method based on font outline information. Background Art

[0002] The history of Chinese font development began around the end of the 1980s. It has gone through three periods: the first was the "writing and engraving period", the second was the "drawing and casting period", and the third was the "digital period". With the widespread application of artificial intelligence technology in recent years with its powerful data analysis and computing capabilities, the fourth period of Chinese font development, the "intelligent generation period", is coming. At present, the goal of the Chinese font generation model is to generate the remaining non-artificial fonts of the target font through training with a small number of glyph samples provided by designers. The generated glyphs are consistent with the fonts provided by designers in structure and style, so as to serve as a reference for subsequent design, which can improve the efficiency of font development to a certain extent.

[0003] However, due to the large vocabulary of Chinese characters, it is difficult to unify the huge vocabulary into the same style font, and the structure of Chinese characters is also relatively complex, and the font styles are also relatively diverse. Therefore, in the design and development of font Chinese character libraries, a large number of glyph training samples are required, and the quality of the generated glyphs is also relatively unstable, making it difficult to meet the requirements for glyph generation efficiency, glyph authenticity and clarity. Therefore, it is necessary to provide a Chinese character font generation method with high font generation efficiency, good glyph authenticity and clarity, so as to improve the generation quality of Chinese character fonts. Summary of the invention

[0004] In view of the technical problem that the quality of Chinese characters generated by the Chinese character font generation technology in the prior art is defective, the present invention provides a Chinese character font generation method based on font outline information to improve the generation quality of Chinese character fonts.

[0005] A Chinese character font generation method based on font outline information comprises the following steps: step S1: constructing a source style font training set and a target style font training set: selecting a number of simplified Chinese characters from the standard character set GB2312, and storing the simplified Chinese characters as a source style font file and a target style font file according to the pre-selected source style font and target style font, respectively, and then converting the source style font file into a source style font image for storage, to construct a source style font training set; converting the target style font file into a target style font image for storage, to construct a target style font training set; step S2: constructing a font style transfer network model: the font style transfer network model comprises an edge extraction module, a generator and a discriminator; wherein the edge extraction module is used to extract font outline information from a source style font image; the generator is used to convert a source style Chinese character font image into a target style font image according to an input source style font image and its body outline information; the discriminator is used to discriminate the generated The font authenticity of the font image generated by the discriminator; Step S3: Generation of target style font image: Inputting the source style font training set into the font style transfer network model, using the edge extraction module to extract the font outline information from the source Chinese character font image in the source style font training set and inputting it into the generator with the source Chinese character font image, the generator splices the source Chinese character font image and the corresponding font outline information together, and then generates the target style font image; Step S4: Training of the font style transfer network model: Pairing the target style font image generated in step S3 with the target style font image in the target style font training set, and inputting them into the discriminator, updating the network model parameters through the reverse transfer of the loss function, and cyclically training until the generator and the discriminator meet the preset performance standards, that is, completing the training of the font style transfer network model; Step S5: Automatic generation of target style font: Inputting a Chinese character image of any font style into the font style transfer network model, the Chinese character corresponding to the target style font can be obtained.

[0006] Preferably, step S1 specifically includes: step S01: selecting 500 simplified Chinese characters from the standard character set GB2312, the simplified Chinese characters including but not limited to single characters and compound characters, the compound characters including Chinese characters with left-right structure, top-bottom structure, fully surrounded structure and semi-enclosed structure; step S02: storing the 500 simplified Chinese characters obtained in step S01 as characters in a certain order, and selecting a source style font and a target style font, and storing the 500 characters as a source style font file and a target style font file according to the selected source style font and target style font; step S03: converting the source style font file and the target style font file into black-text images with a white background through Python code, and then storing and constructing a source style font training set of 500 characters and a target style font training set of 500 characters.

[0007] Preferably, the format of the characters is TXT format, and the formats of the source style font file and the target style font file are TTF format or OTF format.

[0008] Preferably, the step S3 specifically includes: step S301: inputting the source style Chinese character images in the source style font training set into the edge extraction module and the generator of the font style transfer network model respectively; step S302: using the edge extraction module to extract the font contour information of the source style font image in the input source style font training set, and storing them as single-channel grayscale font contour images respectively and inputting them into the generator, and the generator splices the source style font image and the corresponding font contour image together; step S303: the generator encodes the spliced ​​source style font image and the corresponding font contour image to obtain the image and contour information of the corresponding Chinese character, and decodes and generates the target style font image according to the encoded information and the corresponding font contour information extracted by the edge extraction module in step S302.

[0009] Preferably, step S4 is specifically as follows: step S401: pairing the target style font image in the target style font training set with the target style font image generated in step S3 to obtain two groups of true and false Chinese character images; step S402: inputting the two groups of true and false Chinese character images obtained in step 401 into the discriminator, so that it performs authenticity identification on each group of true and false Chinese character images, and performs adversarial training through a binary cross entropy loss function, back-propagates the discriminator, updates the discriminator parameters, and obtains a discriminator that meets the preset performance standards; step S403: according to the authenticity identification and classification results of the discriminator on the true and false Chinese character images, uses a generator loss function to calculate the loss value of the true and false Chinese character images in the generator, back-propagates the generator, updates the generator parameters, and obtains a generator that meets the preset performance standards.

[0010] Preferably, the binary cross entropy loss function is used to measure the authenticity classification effect of the discriminator on the input true and false Chinese character images, and the binary cross entropy loss function is specifically:

[0011] Among them, G is the generator, D is the discriminator, N is the preset batch size, and x i represents the set of source style Chinese character images and their corresponding font outline images; G(x i ) is the fake Chinese character image generated by the generator, y i It is a real Chinese character image.

[0012] Preferably, the generator loss function is specifically:

[0013] L G-ESGAN (G,D)=λ adv ·L adv (G,D)+λL1 ·L L1 (G);

[0014] Among them, G is the generator, D is the discriminator, and L adv (G,D) is the adversarial loss function, L L1 (G) is the L1 loss function λ adv and λ L1 is the weight parameter of the adversarial loss function and the L1 loss function; the adversarial loss function is specifically:

[0015]

[0016] Where N is the preset batch size, y i is the real Chinese character image, G(x i ) is a fake Chinese character image generated by the generator; the adversarial loss function L adv (G, D) is used to simultaneously improve the discriminator's ability to judge and the authenticity of the fonts generated by the generator; the L1 loss function is specifically:

[0017]

[0018] Among them, λ is a regularization parameter, and the L1 loss function is used to obtain the difference between the fake Chinese character image generated by the generator and the real Chinese character image.

[0019] Preferably, step S41 is also included between step S4 and step S5: testing of the font style transfer model: randomly selecting a number of Chinese characters other than the Chinese characters selected in step S1 from the standard character set GB2312, and storing them as source style font files in a pre-selected source style font, and then converting the source style font files into source style font images for storage to construct a test data set and input them into the font style transfer model and other font generation models for comparative experiments, and performing qualitative and quantitative evaluations on the generated corresponding style font images based on preset evaluation indicators to rate the font generation quality of the font style transfer model.

[0020] Preferably, the preset evaluation indicators include structural accuracy, stroke restoration, contour clarity, style matching and visual aesthetics for qualitative evaluation and structural similarity index, feature-based similarity index, peak signal-to-noise ratio and root mean square error for quantitative evaluation.

[0021] The beneficial effects of the present invention are as follows: the present invention provides a Chinese character font generation method based on font outline information, by constructing a source style font training set and a target style font training set, and then constructing a font style transfer network model, and using a loss function to train and optimize the font transfer network model, so that its generator and discriminator reach preset performance, which is conducive to improving the result of font generation. At the same time, an edge extraction module is set in the font style transfer network model, the edge extraction module accepts the input source style font image and extracts the edge outline information of the font in the source style font image through a convolution operation and passes it into the generator, and then the generator splices these edge information with the source style font image, helping the generator to better understand the structure and edge details of the font, and can capture the structure and style characteristics of Chinese characters while reducing the number of character samples necessary for training. The generated Chinese character character outline and stroke features are clear, the structural integrity and style performance are good, and it has high recognizability and authenticity. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A schematic flow chart of a method for generating a Chinese character font based on font outline information provided by the present invention;

[0023] Figure 2 Specific reference diagram for 500 simplified Chinese characters in this embodiment;

[0024] Figure 3 A schematic diagram of the flow of generating Chinese characters by the font style transfer model provided by the present invention;

[0025] Figure 4 A schematic diagram of the working of the edge extraction module provided by the present invention;

[0026] Figure 5 This is a schematic diagram comparing the Song font generation effects of the model of the present invention and the open source model;

[0027] Figure 6 A schematic diagram comparing the round font generation effects of the model of the present invention and the open source model;

[0028] Figure 7 A schematic diagram comparing the decorative font generation effects of the model of the present invention and the open source model;

[0029] Figure 8 A schematic diagram showing the comparison of the Kaiti font generation effects of the model of the present invention and the open source model;

[0030] Fig. 9 A schematic diagram comparing the effects of the Fangsong font generation of the model of the present invention and the open source model;

[0031] Fig.10 It is a schematic diagram comparing the boldface generation effects of the model of the present invention and the open source model;

[0032] Fig.11 The figure is a schematic diagram comparing the handwriting generation effects of the model of the present invention and the open source model.

[0033] Figure ID

[0034] 1. Edge extraction module; 2. Generator; 3. Discriminator; 4. Source style font image; 5. Target style font image; 6. Target style font image. DETAILED DESCRIPTION

[0035] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.

[0036] refer to Figure 1 As shown, the present invention provides a Chinese character font generation method based on font outline information, comprising the following steps:

[0037] Step S1: constructing a source style font training set and a target style font training set. Select a number of simplified Chinese characters from the standard character set GB2312, and store the simplified Chinese characters as a source style font file and a target style font file according to the pre-selected source style font and target style font, respectively, and then convert the source style font file into a source style font image 4 for storage to construct a source style font training set; convert the target style font file into a target style font image 6 for storage to construct a target style font training set.

[0038] Specifically, step S1 includes:

[0039] S01: Select 500 simplified Chinese characters from the standard character set GB2312, the simplified Chinese characters include but are not limited to single characters or compound characters, the compound characters include left-right structure, top-bottom structure, fully enclosed structure, and semi-enclosed structure Chinese characters; the standard character set GB2312 is also known as the "Chinese Character Coded Character Set for Information Interchange Basic Set", covering 6763 commonly used Chinese characters and characters, and the fonts included can meet the daily use needs of most Chinese characters. Reference Figure 2As shown, the 500 simplified Chinese characters selected from the standard character set GB2312 in this embodiment are selected based on the 50 characters used to determine the font style of the Founder character library. These Chinese characters not only include the 32 strokes of Chinese characters, and the morphological changes of each stroke in different positions, but also include the basic structural forms of Chinese characters, such as: left-right structure, up-down structure, full-surrounding structure, semi-surrounding structure, etc. At the same time, these Chinese characters also include most of the single-character, compound characters and most of the radicals of Chinese characters. These 500 characters are used as the font sample training samples, and the sample quantity is small, which is conducive to improving the development efficiency of the font generation model. At the same time, the strokes and structural composition of commonly used Chinese characters can be obtained, which is conducive to improving the similarity between the subsequent generated fonts and samples and improving the quality of the generated fonts.

[0040] Step S02: The 500 simplified Chinese characters obtained in step S01 are stored as characters in a certain order, and a source style font and a target style font are selected, and the 500 characters are stored as a source style font file and a target style font file according to the selected source style font and the target style font; wherein, in this embodiment, the format of the characters is TXT format, and the format of the source style font file and the target style font file is TTF format or OTF format.

[0041] Step S03: The source style font file and the target style font file are respectively converted into black text images with a white background through Python code, and then stored and constructed to obtain a source style font training set of 500 characters and a target style font training set of 500 characters.

[0042] In this embodiment, the black-text image with white background is a 256px*256px RGB image with black-text on white background. In this embodiment, there are 7 sets of font training sets of 500 Chinese characters in different font styles, including 1 Songti, 1 Heiti, 1 Kaiti, 1 Fangsongti, 1 Yuanti, 1 Shufati and 1 Decorationti. The 7 sets of font data sets can be used as source style font training sets or target style font training sets in pairs.

[0043] refer to Figure 3 and Figure 4 As shown, step S2: construct a font style transfer network model: the font style transfer network model includes an edge extraction module 1, a generator 2 and a discriminator 3; the edge extraction module 1 is used to extract the font contour information in the source style font image 4; wherein, the generator 2 is used to convert the source style Chinese font image into a target style font image according to the input source style font image 4 and its body contour information; the discriminator 3 is used to discriminate the font authenticity of the font image generated by the generator 2.

[0044] Step S3: Generation of target style font image 5: Input the source style font training set into the font style transfer network model, use the edge extraction module 1 to extract the font outline information from the source Chinese character font image in the source style font training set and input it into the generator 2 together with the source Chinese character font image, the generator 2 splices the source Chinese character font image and the corresponding font outline information together to generate the target style font image 5.

[0045] Among them, reference Figure 3 , Figure 4 As shown, the edge extraction module 1 is implemented by a PyTorch module named "Edge_conv". The design idea of ​​this module adopts convolution operation. Edge_conv emphasizes the edge information in the font image by applying a specific 3x3 Laplacian kernel convolution in the forward propagation. At the same time, it has certain edge detection functions and module flexibility, which is used to detect the edges of the input Chinese character font image and enhance the edge part. This module can be easily integrated into the deep learning model architecture as a processing step before font generation, which helps to improve the accuracy of subsequent generation tasks. The edge extraction module 1 accepts the input source style font image 4 and extracts the edge contour information of the font in the source style font image 4 through convolution operation and passes it into the generator 2. Then the generator 2 splices these edge information with the source style font image 4 to help the generator 2 better understand the structure and edge details of the font and generate the target style image 5.

[0046] The step S3 specifically includes: step S301: inputting the source style Chinese character images in the source style font training set into the edge extraction module 1 and the generator 2 of the font style transfer network model respectively.

[0047] Step S302: Use edge extraction module 1 to extract font outline information of source style font image 4 in the input source style font training set, and store it as single-channel grayscale font outline images to input generator 2, and generator 2 splices the source style font image 4 and the corresponding font outline image together.

[0048] Step S303: The generator 2 includes an encoder and a decoder. The generator 2 encodes the spliced ​​source style font image 4 and the corresponding font outline image to obtain the image and outline information of the corresponding Chinese character, and decodes and generates the target style font image 5 according to the encoded information and the corresponding font outline information extracted by the edge extraction module 1 in step S302.

[0049] refer to Figure 3 , Figure 4As shown, step S4: training of the font style transfer network model: pairing the target style font image 5 generated in step S3 with the target style font image 6 in the target style font training set, and inputting them into the discriminator 3, updating the network model parameters through reverse transfer of the loss function, and repeating the training until the generator 2 and the discriminator 3 meet the preset performance standards, that is, completing the training of the font style transfer network model.

[0050] Among them, step S4 is specifically as follows: step S401: pairing the target style font image 6 in the target style font training set with the class target style font image 5 generated in step S3 to obtain two groups of true and false Chinese character images; that is, a group of true Chinese character font images composed of the target style font images 6 and a group of false Chinese character images composed of the class target style font images 5 paired one by one with them.

[0051] Step S402: Input the two groups of true and false Chinese characters obtained in step 401 into the discriminator 3, so that it can identify the authenticity of each group of true and false Chinese character images, and perform adversarial training through the binary cross entropy loss function, back-propagate the discriminator 3, update the parameters of the discriminator 3, and obtain the discriminator 3 that meets the preset performance standards, that is, the binary classification discriminator 3 that can correctly distinguish the authenticity of the image.

[0052] Step S403: Based on the authenticity identification and classification results of the true and false Chinese character images by the discriminator 3, a generator 2 loss function is used to calculate the loss value of the true and false Chinese character images in the generator 2, back-propagates the generator 2, updates the parameters of the generator 2, and obtains a generator 2 that meets the preset performance standards.

[0053] Among them, in step S402, the binary cross entropy loss function is specifically:

[0054]

[0055] Among them, G is the generator 2, D is the discriminator 3, N is the preset batch size, x i represents the set of source style Chinese character images and their corresponding font outline images; G(x i ) is the fake Chinese character image generated by generator 2, y i is a real Chinese character image. The binary cross entropy loss function is used to measure the authenticity classification effect of the discriminator 3 on the input true and false Chinese character images. The binary cross entropy loss function helps the discriminator 3 learn to distinguish the real image from the generated image and improve the adversarial performance. i )) becomes smaller, that is, it becomes more difficult for discriminator 3 to classify the generated image as real, and the binary cross entropy loss becomes smaller.

[0056] In step S403, the loss function of generator 2 is specifically:

[0057] LG-ESGAN (G,D)=λ adv ·L adv (G,D)+λ L1 ·L L1 (G)

[0058] Among them, G is the generator 2, D is the discriminator 3, L adv (G,D) is the adversarial loss function, L L1 is the L1 loss function λ adv and λ L1 is the weight parameter of the adversarial loss function and the L1 loss function; these two loss functions work together to help generator 2 generate outputs that are similar to real images and have good adversarial properties. During the training process, by adjusting the weight parameters and learning rate, generator 2 and discriminator 3 can achieve a better balance. When both the adversarial loss and the L1 loss are small, the overall loss of generator 2 becomes smaller, indicating that generator 2 has achieved a good balance in adversarial training.

[0059] Specifically, the adversarial loss function is:

[0060]

[0061] Where N is the preset batch size, y i is the real Chinese character image, G(x i ) is a fake Chinese character image generated by generator 2; the adversarial loss function L adv (G, D) is used to simultaneously improve the judgment ability of discriminator 3 and the authenticity of the fonts generated by generator 2; the adversarial loss function encourages generator 2 to fool discriminator 3, making it unable to distinguish the generated images from the real images. Generator 2 learns to generate more realistic images by minimizing the adversarial loss. i )) becomes larger and the adversarial loss becomes smaller, indicating that Generator 2 successfully deceives Discriminator 3.

[0062] The L1 loss function is specifically:

[0063]

[0064] Where λ is a regularization parameter, and the L1 loss function is used to obtain the difference between the fake Chinese character image generated by generator 2 and the real Chinese character image. The L1 loss function encourages the image generated by generator 2 to be as similar as possible to the real image at the pixel level, which helps to retain more details and structural information. i )-y i When ||1 ​​becomes smaller, the L1 loss becomes smaller, which means that the generated image is closer to the real image.

[0065] Although the edge extraction module 1 does not have a dedicated supervision loss, its output affects the loss of the loss function of the generator 2, especially the calculation of the L1 loss, helping the generator 2 to better understand the font structure and edge details. Through continuous iteration and training, the generator 2 of the font style transfer model will learn to generate realistic images. The edge extraction module 1 will extract the edge information of the input image through forward propagation, and then splice this edge information with the feature maps of other layers to help the generator 2 learn how to better use the edge information. The discriminator 3 also gradually improves its performance to better evaluate the generated images and extract the edge information of the images. The game between the two sides will eventually lead to the generation of higher quality target Chinese fonts and complete the training of the font style transfer model.

[0066] Step S41: Testing of the font style transfer model: randomly select several Chinese characters excluding the Chinese characters selected in step S1 from the standard character set GB2312, and store them as source style font files in the pre-selected source style fonts, and then convert the source style font files into source style font images 4 for storage, build a test data set and input them into the font style transfer model and other font generation models for comparative experiments, and perform qualitative and quantitative evaluations on the generated corresponding style font images based on preset evaluation indicators, and rate the font generation quality of the font style transfer model, that is, it can also be judged whether the performance standards of the generator and the discriminator meet the requirements.

[0067] Specifically, the test data set inputs the trained font style transfer model and the zi2zi model and CycleGAN model, which are representative and well-opened in the field of font generation, and conducts comparative experiments under the same experimental environment. The fonts in the source style font image 4 are optimized to generate target-like style font images 5 including seven target font styles: Songti, Yuanti, Zhuangzhuangti, Kaiti, Fangsongti, Heiti and Handwriting, and the generated corresponding style font images are qualitatively and quantitatively evaluated based on preset evaluation indicators. The font style transfer model, zi2zi model and CycleGAN model respectively optimize the source style font in the source style font image 4 to generate seven target font styles: Songti, Yuanti, Zhuangzhuangti, Kaiti, Fangsongti, Heiti and Handwriting. The results are compared as follows: Figures 5 to 11 shown.

[0068] Among them, the preset evaluation indicators of the qualitative evaluation are structural accuracy, stroke restoration, contour clarity, style matching and visual aesthetics; preferably, a number of researchers and practitioners in font design-related professions can be selected to compare the model-generated image with the target image and score them according to the preset evaluation indicators, and finally the scores are summarized to obtain the subjective evaluation of the model generation quality by professionals in the field.

[0069] The preset evaluation indicators of the quantitative evaluation are the structural similarity index, the feature-based similarity index, the peak signal-to-noise ratio and the root mean square error. After the source style font image 4 generates the target-style font image 5 of the seven target font styles of Songti, Yuanti, Zhuangti, Kaiti, Fangsongti, Heiti and Handwriting, the image calculation software can be used to calculate the structural similarity index, feature-based similarity index, peak signal-to-noise ratio and root mean square error of the target-style font image 5 and the target style font image 6, and then judge the quality of model font generation. Among them, the larger the value of the structural similarity index, the feature-based similarity index and the peak signal-to-noise ratio, the higher the similarity between the image generated by the model and the target image; the smaller the value of the root mean square error, the smaller the difference between the image generated by the model and the target image and the higher the similarity.

[0070] refer to Figure 4 As shown, step S5: automatic generation of target style font: inputting Chinese character images of any font style into the font style transfer network model, the Chinese characters corresponding to the target style font can be obtained. After the font style transfer network model is trained, it has the ability to generate the target style font of its target style font training set, and inputting the font style image of any Chinese character can obtain the Chinese character image corresponding to the target style font.

[0071] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the implementation of the present invention. It can be understood that the described examples are only part of the examples of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present invention.

Claims

1. A Chinese character font generation method based on font outline information, characterized in that: The steps include: Step S1: constructing a source style font training set and a target style font training set: selecting a number of simplified Chinese characters from the standard character set GB2312, and storing the simplified Chinese characters as a source style font file and a target style font file according to the pre-selected source style font and target style font, respectively, and then converting the source style font file into a source style font image for storage, to construct a source style font training set; Convert the target style font file into a target style font image for storage, and construct a target style font training set; Step S2: constructing a font style transfer network model: the font style transfer network model comprises an edge extraction module, a generator and a discriminator; wherein the edge extraction module is used to extract font outline information in a source style font image; the generator is used to convert a source style Chinese character font image into a target style font image according to the input source style font image and its body outline information; the discriminator is used to discriminate the font authenticity of the font image generated by the generator; Step S3: Generation of target-style font image: Input the source-style font training set into the font style transfer network model, use the edge extraction module to extract font outline information from the source Chinese font image in the source-style font training set, and input the font outline information into the generator together with the source Chinese font image, and then generate the target-style font image; Step S4: training the font style transfer network model: pairing the target style font image generated in step S3 with the target style font image in the target style font training set, and inputting them into the discriminator, updating the network model parameters through reverse transfer of the loss function, and cyclically training until the generator and the discriminator meet the preset performance standards, that is, completing the training of the font style transfer network model; Step S5: Automatically generate target style fonts: input Chinese character images of any font style into the font style transfer network model to obtain Chinese characters corresponding to the target style fonts; Wherein, step S1 specifically includes: Step S01: selecting 500 simplified Chinese characters from the standard character set GB2312, wherein the simplified Chinese characters include single characters and compound characters, and the compound characters include characters of left-right structure, top-bottom structure, full-enclosed structure, and semi-enclosed structure; Step S02: The 500 simplified Chinese characters obtained in step S01 are stored as characters in a certain order, and a source style font and a target style font are selected, and the 500 characters are stored as a source style font file and a target style font file according to the selected source style font and the target style font; wherein the format of the characters is TXT format, and the format of the source style font file and the target style font file is TTF format or OTF format; Step S03: converting the source style font file and the target style font file into black text images with a white background through Python code, and then storing and constructing a source style font training set of 500 characters and a target style font training set of 500 characters respectively; The step S3 specifically includes: Step S301: inputting the source style Chinese character images in the source style font training set into the edge extraction module and the generator of the font style transfer network model respectively; Step S302: extracting font outline information of the source style font image in the input source style font training set using an edge extraction module, and storing the information as single-channel grayscale font outline images respectively and inputting them into a generator, and the generator splices the source style font image and the corresponding font outline image together; Step S303: the generator encodes the spliced ​​source style font image and the corresponding font outline image to obtain the image and outline information of the corresponding Chinese character, and decodes and generates a target style font image based on the encoded information and the corresponding font outline information extracted by the edge extraction module in step S302; The step S4 is specifically as follows: Step S401: Pairing the target style font image in the target style font training set with the target style font image generated in step S3 to obtain two groups of true and false Chinese character images; Step S402: input the two groups of true and false Chinese character images obtained in step 401 into the discriminator, so that it can distinguish the authenticity of each group of true and false Chinese character images, and perform adversarial training through a binary cross entropy loss function, back-propagate the discriminator, update the discriminator parameters, and obtain a discriminator that meets the preset performance standards; Step S403: according to the authenticity identification and classification result of the discriminator on the true and false Chinese character images, a generator loss function is used to calculate the loss value of the true and false Chinese character images in the generator, the generator is back-propagated, and the generator parameters are updated to obtain a generator that meets the preset performance standard; The binary cross entropy loss function is used to measure the effect of the discriminator on the true and false classification of the input true and false Chinese character images. The binary cross entropy loss function is specifically: Among them, G is the generator, D is the discriminator, N is the preset batch size, and x i represents the set of source style Chinese character images and their corresponding font outline images; G(x i ) is the fake Chinese character image generated by the generator, y i is a real Chinese character image; the generator loss function is specifically: L G-ESGAN (G,D)=λ adv ·L adv (G,D)+λ L1 ·L L1 (G) Among them, G is the generator, D is the discriminator, and L adv (G,D) is the adversarial loss function, L L1 (G) is the L1 loss function, λ adv and λ L1 is the weight parameter of the adversarial loss function and the L1 loss function; The adversarial loss function is specifically: The adversarial loss function L adv (G, D) is used to simultaneously improve the discriminator's ability to judge and the authenticity of the fonts generated by the generator; The L1 loss function is specifically: Among them, λ is a regularization parameter, and the L1 loss function is used to obtain the difference between the fake Chinese character image generated by the generator and the real Chinese character image.

2. A Chinese character font generation method based on font outline information according to claim 1, characterized in that: The step S41 is also included between step S4 and step S5: testing of the font style transfer model: randomly selecting a number of Chinese characters other than the Chinese characters selected in step S1 from the standard character set GB2312, and storing them as source style font files in a pre-selected source style font, and then converting the source style font files into source style font images for storage to construct a test data set and inputting them into the font style transfer model and other font generation models for comparative experiments, and performing qualitative and quantitative evaluations on the generated corresponding style font image results based on preset evaluation indicators to rate the font generation quality of the font style transfer model.

3. The method for generating Chinese character fonts based on font outline information according to claim 2, characterized in that: The preset evaluation indicators include structural accuracy, stroke restoration, contour clarity, style matching and visual aesthetics for qualitative evaluation and structural similarity index, feature-based similarity index, peak signal-to-noise ratio and root mean square error for quantitative evaluation.