CN113312444A - Word stock construction method and device, electronic equipment and storage medium - Google Patents

Word stock construction method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113312444A
CN113312444A CN202110694439.9A CN202110694439A CN113312444A CN 113312444 A CN113312444 A CN 113312444A CN 202110694439 A CN202110694439 A CN 202110694439A CN 113312444 A CN113312444 A CN 113312444A
Authority
CN
China
Prior art keywords
font
chinese character
component
target chinese
complexity
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110694439.9A
Other languages
Chinese (zh)
Other versions
CN113312444B (en
Inventor
郦悦华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202110694439.9A priority Critical patent/CN113312444B/en
Publication of CN113312444A publication Critical patent/CN113312444A/en
Application granted granted Critical
Publication of CN113312444B publication Critical patent/CN113312444B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/31Indexing; Data structures therefor; Storage structures
    • G06F16/316Indexing structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Abstract

According to the word stock construction method, the word stock construction device, the electronic equipment and the storage medium, the first output data is obtained by inputting the obtained first input data into the first neural network model, the first component under the corresponding first font is obtained from the Chinese word stock according to the first font attribute value set of the component of the target Chinese character, and the second input data is obtained. Inputting the second input data into a second neural network model to obtain second output data; generating a target Chinese character under the first font according to the component under the first font and the second output data, and obtaining third input data; and inputting the third input data into a third neural network model to obtain a second position parameter value of the target Chinese character in the character forming space, and finally obtaining the target Chinese character. According to the method and the device, selection of Chinese character components, relative position adjustment and position arrangement of whole characters are achieved through three neural network models, so that the time for constructing the character library is shortened, and the efficiency is improved.

Description

Word stock construction method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for building a word stock, an electronic device, and a storage medium.
Background
At present, with the development of network technology, the personalized requirements of users on the font of Chinese characters are continuously increased, so that the construction of a Chinese character font library becomes more important.
In the prior art, in order to meet the personalized requirements of users on Chinese characters, designers usually manually adjust the stroke position and the stroke form of each Chinese character, so as to construct a character library with different fonts.
However, the process of constructing the Chinese character library by the method is long in time consumption, low in efficiency and high in labor cost.
Disclosure of Invention
The application provides a method and a device for constructing a character library, electronic equipment and a storage medium, which are used for solving the problem that the construction of the Chinese character library in the prior art is long in time consumption.
In a first aspect, the present application provides a word stock construction method, including:
obtaining first input data, the first input data comprising: the method comprises the following steps of averaging the font attribute value sets of the components of the target Chinese character, wherein the components correspond to the font attribute value sets one by one, and each font attribute value set comprises attribute values of font attributes under various fonts; wherein different attribute values of the font attribute are used for representing different fonts;
inputting the first input data into a first neural network model to obtain first output data, wherein the first output data comprises: the first font attribute value set of the component of the target Chinese character, the ratio of the weight of the component to the area of the component circumscribed rectangle and the shape parameter of the component circumscribed rectangle; wherein the first set of font property values comprises a first property value of the font property;
according to the first font attribute value set of the member of the target Chinese character, obtaining a first member under a corresponding first font from a Chinese character library, and obtaining second input data, wherein the second input data comprises: a second attribute value of a font attribute of the first member in the first font, a ratio of a weight of the first member to an area of a circumscribed rectangle of the first member, and a shape parameter of the circumscribed rectangle of the first member;
inputting the second input data into a second neural network model to obtain second output data, wherein the second output data comprises structural relation parameters among the first components and shape parameters of circumscribed rectangles of the first components;
generating a target Chinese character under the first font according to the member under the first font and the second output data, and obtaining third input data, wherein the third input data comprises shape parameters of a circumscribed rectangle of the target Chinese character under the first font, the shape parameters of the target Chinese character, first position parameter values of the target Chinese character in a character forming space and the ratio of the weight of the target Chinese character to the area of the circumscribed rectangle of the target Chinese character;
inputting the third input data into a third neural network model to obtain a second position parameter value of the target Chinese character in a character forming space; and obtaining the target Chinese character under the first font in the character forming space based on the second position parameter value of the target Chinese character in the character forming space and the target Chinese character under the first font.
In one possible implementation, the font property includes at least one of: complexity parameters of different directions, maximum complexity parameters of different directions, and center of gravity parameters of different directions.
In one possible implementation, the font property includes complexity parameters in different directions; the complexity parameter comprises complexity; the method further comprises the following steps:
for each direction, based on each component of the target Chinese character under each font, the complexity of each component of the target Chinese character in different directions under various fonts is obtained by executing the following processing:
acquiring a pixel array of the member; counting the number of pixels of the pixel array along the direction, the number of pixels corresponding to a component circumscribed rectangle in the pixel array, and the number of pixels corresponding to the component in the pixel array; and calculating the ratio of the pixel number corresponding to the member to a product result as the complexity of the member in the direction under the font, wherein the product result is the result of multiplying the pixel number of the pixel array along the first direction by the pixel number corresponding to a member circumscribed rectangle in the pixel array.
In one possible implementation, the complexity parameter includes a complexity ratio; the method further comprises the following steps:
and aiming at the complexity of each component of the target Chinese character in each font in each direction, calculating the ratio of the complexity to the complexity of the components in other directions in the font to obtain the complexity ratio of each component of the target Chinese character in various fonts.
In one possible implementation manner, for each direction, based on each component of the target Chinese character in each font, the following processing is performed to obtain the maximum complexity of each component of the target Chinese character in different directions in multiple fonts:
acquiring coordinates of each pixel in a pixel array of the member; calculating the sum of the coordinates of the pixels corresponding to the member in each group of pixels in the direction to obtain the sum of the coordinates corresponding to each group of pixels in the direction; and taking the maximum value of the sum of the coordinates corresponding to each group of pixels in the direction as the maximum complexity of the component in the direction under the font.
In one possible implementation, the maximum complexity parameter includes a maximum complexity ratio; the method further comprises the following steps:
and aiming at the maximum complexity of each component of the target Chinese character in each font in each direction, calculating the ratio of the maximum complexity to the maximum complexity of the components in other directions in the font to obtain the maximum complexity ratio of each component of the target Chinese character in various fonts.
In one possible implementation, the font property includes center of gravity parameters in different directions; the center of gravity parameter comprises a center of gravity; the method further comprises the following steps:
for each direction, based on each component of the target Chinese character under each font, obtaining the gravity center of each component of the target Chinese character under different directions of various fonts by executing the following processing:
obtaining coordinates of each pixel point in the pixel array of the component; counting the number of pixels corresponding to a component circumscribed rectangle in the pixel array; calculating the sum of coordinates of pixels corresponding to the members aiming at the pixel points in the direction; and calculating the ratio of the sum of the coordinates of the pixels corresponding to the member to the number of pixels corresponding to a member circumscribed rectangle in the pixel array as the gravity center of the member in the direction under the font.
In one possible implementation, the center of gravity parameter includes a center of gravity ratio; the method further comprises the following steps:
and calculating the ratio of the gravity center of each component of the target Chinese character in each direction under each font to the gravity centers of the components in other directions under the fonts to obtain the gravity center ratio of each component of the target Chinese character in various fonts.
In a possible implementation manner, the shape parameters of the component further include shape parameters of the component in different areas in different scanning directions; the method further comprises the following steps:
acquiring a pixel array of the member; for each scanning direction, determining groups of pixels in a current scanning area of the pixel array along the scanning direction; scanning the pixels of each group along the scanning direction, and determining a first scanned first pixel in each group of pixels, wherein the first pixel belongs to a pixel corresponding to a component; calculating the sum of coordinates of first pixels corresponding to each group of pixels to obtain a first summation result; and calculating the reciprocal of the mean square value of the first summation result as the morphological parameter of the component in the scanning direction in the area.
In one possible implementation manner, the first position parameter value includes a ratio of a left full degree of the target chinese character to a sum of full degrees of the target chinese character in left and right directions and a ratio of an upper full degree of the target chinese character to a sum of full degrees of the target chinese character in up and down directions; the second position parameter value comprises a parameter value of a gravity center parameter of the target Chinese character in a character forming space.
In a second aspect, the present application provides a word stock construction apparatus, the apparatus comprising:
a first acquisition unit configured to acquire first input data, the first input data including: the method comprises the following steps of averaging the font attribute value sets of the components of the target Chinese character, wherein the components correspond to the font attribute value sets one by one, and each font attribute value set comprises attribute values of font attributes under various fonts; wherein different attribute values of the font attribute are used for representing different fonts;
a first generating unit, configured to input the first input data into a first neural network model, and obtain first output data, where the first output data includes: the first font attribute value set of the component of the target Chinese character, the ratio of the weight of the component to the area of the component circumscribed rectangle and the shape parameter of the component circumscribed rectangle; wherein the first set of font property values comprises a first property value of the font property;
a second obtaining unit, configured to obtain a first component in a corresponding first font from a chinese character library according to the first font attribute value set of the component of the target chinese character, and obtain second input data, where the second input data includes: a second attribute value of a font attribute of the first member in the first font, a ratio of a weight of the first member to an area of a circumscribed rectangle of the first member, and a shape parameter of the circumscribed rectangle of the first member;
a second generating unit, configured to input the second input data into a second neural network model to obtain second output data, where the second output data includes structural relationship parameters between the first members and shape parameters of a circumscribed rectangle of the first members;
a third obtaining unit, configured to generate a target chinese character in the first font according to the component in the first font and the second output data, and obtain third input data, where the third input data includes a shape parameter of a circumscribed rectangle of the target chinese character in the first font, a shape parameter of the target chinese character, a first position parameter value of the target chinese character in a character forming space, and a ratio of a weight of the target chinese character to an area of the circumscribed rectangle of the target chinese character;
a third generating unit, configured to input the third input data into a third neural network model, and obtain a second position parameter value of the target chinese character in a character forming space; and obtaining the target Chinese character under the first font in the character forming space based on the second position parameter value of the target Chinese character in the character forming space and the target Chinese character under the first font.
In one possible implementation, the font property includes at least one of: complexity parameters of different directions, maximum complexity parameters of different directions, and center of gravity parameters of different directions.
In one possible implementation, the font property includes complexity parameters in different directions; the complexity parameter comprises complexity; the device further comprises:
the first calculation unit is used for obtaining the complexity of each component of the target Chinese character in different directions under various fonts by executing the following processing according to each component of the target Chinese character under each font for each direction:
acquiring a pixel array of the member; counting the number of pixels of the pixel array along the direction, the number of pixels corresponding to a component circumscribed rectangle in the pixel array, and the number of pixels corresponding to the component in the pixel array; and calculating the ratio of the pixel number corresponding to the member to a product result as the complexity of the member in the direction under the font, wherein the product result is the result of multiplying the pixel number of the pixel array along the first direction by the pixel number corresponding to a member circumscribed rectangle in the pixel array.
In one possible implementation, the complexity parameter includes a complexity ratio; the device further comprises:
and the second calculating unit is used for calculating the ratio of the complexity of each component of the target Chinese character in each direction under each font to the complexity of the components in other directions under the fonts to obtain the complexity ratio of each component of the target Chinese character in various fonts.
In one possible implementation, the font property includes maximum complexity parameters for different directions; the device further comprises:
and a third calculation unit, configured to obtain, for each direction, the maximum complexity of each component of the target chinese character in different directions in multiple fonts by performing the following processing based on each component of the target chinese character in each font:
acquiring coordinates of each pixel in a pixel array of the member; calculating the sum of the coordinates of the pixels corresponding to the member in each group of pixels in the direction to obtain the sum of the coordinates corresponding to each group of pixels in the direction;
and taking the maximum value of the sum of the coordinates corresponding to each group of pixels in the direction as the maximum complexity of the component in the direction under the font.
In one possible implementation, the maximum complexity parameter includes a maximum complexity ratio; the device further comprises:
and the fourth calculating unit is used for calculating the ratio of the maximum complexity of each component of the target Chinese character in each direction under each font to the maximum complexity of the components in other directions under the fonts, and obtaining the maximum complexity ratio of each component of the target Chinese character under various fonts.
In one possible implementation, the font property includes center of gravity parameters in different directions; the center of gravity parameter comprises a center of gravity; the device further comprises:
a fifth calculation unit, configured to obtain, for each direction, a center of gravity of each component of the target chinese character in different directions in the plurality of fonts by performing the following processing based on each component of the target chinese character in each font:
obtaining coordinates of each pixel point in the pixel array of the component; counting the number of pixels corresponding to a component circumscribed rectangle in the pixel array; calculating the sum of coordinates of pixels corresponding to the members aiming at the pixel points in the direction; and calculating the ratio of the sum of the coordinates of the pixels corresponding to the member to the number of pixels corresponding to a member circumscribed rectangle in the pixel array as the gravity center of the member in the direction under the font.
In one possible implementation, the center of gravity parameter includes a center of gravity ratio; the device further comprises:
and the sixth calculating unit is used for calculating the ratio of the gravity center of each component of the target Chinese character in each direction under each font to the gravity centers of the components in other directions under the fonts to obtain the gravity center ratio of each component of the target Chinese character under various fonts.
In a possible implementation manner, the shape parameters of the component further include shape parameters of the component in different areas in different scanning directions; the device further comprises:
a seventh calculation unit for acquiring a pixel array of the member; for each scanning direction, determining groups of pixels in a current scanning area of the pixel array along the scanning direction; scanning the pixels of each group along the scanning direction, and determining a first scanned first pixel in each group of pixels, wherein the first pixel belongs to a pixel corresponding to a component; calculating the sum of coordinates of first pixels corresponding to each group of pixels to obtain a first summation result; and calculating the reciprocal of the mean square value of the first summation result as the morphological parameter of the component in the scanning direction in the area.
In one possible implementation manner, the first position parameter value includes a ratio of a left full degree of the target chinese character to a sum of full degrees of the target chinese character in left and right directions and a ratio of an upper full degree of the target chinese character to a sum of full degrees of the target chinese character in up and down directions; the second position parameter value comprises a parameter value of a gravity center parameter of the target Chinese character in a character forming space.
In a third aspect, the present application provides an electronic device, comprising: a memory, a processor;
a memory; a memory for storing the processor-executable instructions;
wherein the processor is configured to perform the method according to any one of the first aspect according to the executable instructions.
In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon computer-executable instructions for implementing the method according to any one of the first aspect when executed by a processor.
In a fifth aspect, the present application provides a computer program product comprising a computer program that, when executed by a processor, implements the method according to any of the first aspects.
According to the word stock construction method, the word stock construction device, the electronic equipment and the storage medium, the first output data is obtained by inputting the obtained first input data into the first neural network model, the first component under the corresponding first font is obtained from the Chinese word stock according to the first font attribute value set of the component of the target Chinese character, and the second input data is obtained. Inputting the second input data into a second neural network model to obtain second output data; generating a target Chinese character under the first font according to the component under the first font and the second output data, and obtaining third input data; inputting the third input data into a third neural network model to obtain a second position parameter value of the target Chinese character in the character forming space; and obtaining the target Chinese character under the first font in the character forming space based on the second position parameter value of the target Chinese character in the character forming space and the target Chinese character under the first font. According to the method and the device, three neural network models are built, the selection of Chinese character components, the adjustment of relative positions and the arrangement of the positions of whole characters are realized, and then the construction of a character library is realized, so that the construction time of the character library is shortened, and the efficiency is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic flow chart of a word stock construction method according to an embodiment of the present application;
FIG. 2 is a diagram illustrating a selection process of Chinese character components according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a first model training process according to an embodiment of the present disclosure;
fig. 4 is a schematic flowchart of a complexity obtaining method according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a component pixel array according to an embodiment of the present disclosure;
fig. 6 is a schematic flowchart of a method for obtaining a maximum complexity parameter according to an embodiment of the present application;
fig. 7 is a schematic flowchart of a method for acquiring a barycentric parameter according to an embodiment of the present application;
fig. 8 is a schematic flowchart of a morphological parameter obtaining method according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of a word stock construction apparatus according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of another word stock construction device provided in an embodiment of the present application;
fig. 11 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
With the above figures, there are shown specific embodiments of the present application, which will be described in more detail below. These drawings and written description are not intended to limit the scope of the inventive concepts in any manner, but rather to illustrate the inventive concepts to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
At present, with the continuous development of network technology, people mostly adopt a network office mode, and with the continuous popularization of network office, the personalized requirements of users on fonts also increase. Currently, in order to meet the personalized requirements of users for fonts, designers are usually required to manually construct a Chinese character library. For example, a component of a target font chinese character is manually selected in the character library, and in the character formation space, the shape and size of the selected component are manually adjusted, and the position of the chinese character component is adjusted, so as to obtain a final target font chinese character.
However, the construction of the Chinese character library by the method takes a long time and needs much manpower, and the design efficiency of the Chinese character library is low.
The method and the device for constructing the word stock, the electronic equipment and the storage medium aim to solve the technical problems in the prior art.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 1 is a schematic flow chart of a word stock construction method according to an embodiment of the present application. As shown in fig. 1, the method comprises the steps of:
s101, acquiring first input data, wherein the first input data comprises: the average value of the font attribute value sets of the components of the target Chinese character corresponds to the font attribute value sets one by one, and each font attribute value set comprises attribute values of font attributes under various fonts; wherein different attribute values of the font attribute are used to characterize different fonts.
For example, when designing a target chinese character, an average value of the font property sets of the respective components in the target chinese character is first obtained. For example, when a Chinese character "" is to be designed, it is first determined that the Chinese character may be composed of two components, left and right, each of which includes a plurality of different fonts in a component library of the Chinese character. Fig. 2 is a schematic diagram of a selection process of a chinese character component according to an embodiment of the present application. Wherein, for the left member of the Chinese character "", three different types of fonts can be included in the word stock, and the member of one font is selected as the left member of the final target Chinese character "". Thus, when the first input data of the member is acquired, the average value of the set of attribute values of the font attributes in the different fonts of the member can be used as the first input data of the member.
S102, inputting the first input data into a first neural network model to obtain first output data, wherein the first output data comprises: the first font attribute value set of the member of the target Chinese character, the ratio of the weight of the member to the area of the circumscribed rectangle of the member and the shape parameter of the circumscribed rectangle of the member; wherein the first set of font property values includes a first property value of the font property.
Illustratively, after first input data of each component in the target Chinese character is acquired, the first input data is used as input data of the first neural network model, and first output data is obtained. The first neural network model can be used for selecting a component of the target Chinese character under the target font from the Chinese character construction library.
Specifically, the first neural network model may output first output data, where the first output data includes a first font property set of the member of the target chinese character (i.e., a first property value of the font property), a ratio of the member weight to an area of a member bounding rectangle, and a shape parameter of the member bounding rectangle. Wherein, the first font represents the font of the target Chinese character which needs to be designed finally. The component circumscribed rectangle is the minimum circumscribed rectangle frame of the component, and the ratio of the weight of the component to the area of the component circumscribed rectangle is the ratio of the number of pixels of the component in the component to the number of all pixels in the component circumscribed rectangle. Optionally, the shape parameter of the member bounding rectangle may be characterized by the width and height of the member bounding rectangle.
The first neural network model in this step is obtained by training with the neural network model, using the font attribute value set of the member of the sample Chinese character, the font attribute value of the predetermined font of the member of the sample Chinese character, the ratio of the weight of the member to the area of the circumscribed rectangle of the member, and the shape parameter of the circumscribed rectangle of the member as training samples. As shown in fig. 3, fig. 3 is a schematic structural diagram of a first model training process according to an embodiment of the present disclosure. In the figure, the average value of the font attribute value sets of the components of the sample Chinese characters can be determined from the Chinese character library and used as an input parameter in the model training process. And taking the attribute value of the font under the designed preset font in the font library, the ratio of the weight of the member to the area of the circumscribed rectangle of the member and the shape parameter of the circumscribed rectangle of the member as output parameters in the model training process for training. The connection parameters are transfer parameters among neurons in each layer in the forward propagation or backward propagation process of the model.
Optionally, in order to prevent the overfitting phenomenon of the model during the training process, when the neural network model is trained, the training sample may be divided into a training set and a verification set, and the training set is used for training the model; taking the verification set as an input parameter of the model, obtaining an error of the model, and stopping training if the error is smaller than a preset value; otherwise, continuing to train the model.
S103, according to the first font attribute value set of the component of the target Chinese character, obtaining a first component under a corresponding first font from a Chinese character library, and obtaining second input data, wherein the second input data comprises: a second attribute value of the font attribute of the first member in the first font, a ratio of the weight of the first member to the area of the circumscribed rectangle of the first member, and a shape parameter of the circumscribed rectangle of the first member.
Illustratively, after the first font attribute value set of the target Chinese character is obtained, a first component of the target Chinese character in the first font can be selected from the Chinese character library according to each attribute value in the first font attribute value set.
Optionally, the user may select, in the chinese character component library, a component having the smallest error with the first output data according to the first output data, as the component of the target chinese character in the first font. Wherein, the first font is a target font which needs to be designed finally.
After determining the first member of the target Chinese character in the first font, the second attribute value of the font of the first member in the first font, the ratio of the weight of the first member to the area of the circumscribed rectangle of the first member, and the shape parameter of the circumscribed rectangle of the first member may be obtained.
Optionally, the second attribute value of the font of the first component in the first font, the ratio of the weight of the first component to the area of the circumscribed rectangle of the first component, and the shape parameter of the circumscribed rectangle of the first component may be equal to or different from the values in the first output data (i.e. when there is an error).
And S104, inputting the second input data into the second neural network model to obtain second output data, wherein the second output data comprises structural relation parameters among the first components and shape parameters of the circumscribed rectangle of the first components.
Exemplarily, the second input data obtained in step S103 is used as an input of a second neural network model, and then an output of the second neural network model is obtained, where the second neural network model is used to determine a relative position relationship between the first components of the target chinese character selected in the above steps in the first font, and adaptively adjust the size of the components while determining the relative position relationship. The second output data includes structural relationship parameters between the first members and shape parameters of the circumscribed rectangle of the first members. Alternatively, the structural relationship parameter between the first members may be determined by the geometric center of the respective circumscribed rectangle of each first member in the same coordinate system. Alternatively, the shape parameter between the first members may be determined by the center of gravity of the member bounding rectangle and the width and height of the member bounding rectangle.
In this step, the second neural network model indicates the font property value of the predetermined font of the component of the sample Chinese character, the shape parameter of the circumscribed rectangle of the component of the sample Chinese character under the predetermined font, and the structural relationship parameter between the components of the sample Chinese character as training samples, and the training samples are obtained by adopting the neural network model.
Optionally, when the number of hidden layer nodes in the neural network model is determined in the model training process, the number may be determined by using the following empirical model calculation method. For example, the initial values of the hidden layer nodes in the model can be determined by the following formulas.
m=log2n
Wherein m is the initial number of the hidden layer nodes, and n is the number of the input layer nodes.
Optionally, in the process of model training, the hidden layer neuron may adopt an S-type transfer function logsig, so as to ensure the nonlinear mapping capability of the neural network.
Optionally, in the process of model training, the output layer neuron may adopt a linear function purelin to perform value domain expansion on the neural network output.
Optionally, a bayesian learning algorithm may be further combined in the model training process. When the training samples are insufficient, the prediction performance of the trained neural network can be effectively improved.
And S105, generating the target Chinese character under the first font according to the member under the first font and the second output data, and obtaining third input data, wherein the third input data comprises the shape parameter of the circumscribed rectangle of the target Chinese character under the first font, the shape parameter of the target Chinese character, the first position parameter value of the target Chinese character in the character forming space and the ratio of the weight of the target Chinese character to the area of the circumscribed rectangle of the target Chinese character.
Illustratively, after the second output data is obtained, according to the second output data and the components in the first font, the components in the first font are resized and laid out in the relative positions, that is, the components in the first font are resized and then spliced together to obtain the target Chinese character in the first font. And analyzing the target Chinese character in the first font to obtain the shape parameter of the circumscribed rectangle of the target Chinese character in the first font, the shape parameter of the target Chinese character, the first position parameter value of the target Chinese character in the character forming space and the ratio of the weight of the target Chinese character to the area of the circumscribed rectangle of the target Chinese character, and taking the parameters as third input data.
Optionally, the first position parameter value of the target chinese character in the character-forming space may be represented by a ratio of the left full degree of the target chinese character to the sum of the left full degrees of the target chinese character in the left-right direction and a ratio of the upper full degree of the target chinese character to the sum of the upper full degrees of the target chinese character in the up-down direction. When the left full-virtual degree of the target Chinese character is scanned from the left frame of the component external rectangle to the right frame, the number of the scanned pixel points of the first component in each row of pixel points and the number of the scanned pixel points included between the left frame of the component external rectangle are squared and then inverted to obtain the calculation result of the row, and the calculation results of each row are summed to obtain the left full-virtual degree of the target Chinese character.
S106, inputting the third input data into a third neural network model to obtain a second position parameter value of the target Chinese character in a character forming space; and obtaining the target Chinese character under the first font in the character forming space based on the second position parameter value of the target Chinese character in the character forming space and the target Chinese character under the first font.
Illustratively, in step S, the third neural network model is used to adjust the position of the chinese character generated in step S105 in the word formation space, so as to obtain the target chinese character located under the first font in the word formation space.
Specifically, the third input data obtained in step S105 is input into the third neural network model as an input parameter, the second position parameter of the target chinese character in the character-forming space is obtained through the third neural network model, and the position of the target chinese character in the character-forming space is adjusted according to the second position parameter. Wherein, the second position parameter can be characterized by the gravity center of the Chinese character in the character forming space.
The third neural network model is obtained by training the shape parameter of the circumscribed rectangle of the sample Chinese character, the shape parameter of the sample Chinese character, the first position parameter value of the sample Chinese character in the character forming space, the ratio of the weight of the sample Chinese character to the area of the circumscribed rectangle of the sample Chinese character, and the second position parameter value of the sample Chinese character in the character forming space as training samples.
Optionally, the second position parameter value of the target Chinese character in the character forming space can be represented by the parameter value of the center-of-gravity parameter of the target Chinese character in the character forming space.
Optionally, in the three neural network models, a BP (Back Propagation) neural network may be used.
Optionally, in order to avoid saturation of output data due to an excessively large absolute value of input data of the neural network model, the input data of the model may be normalized before the input data, for example, the input data may be normalized as follows.
Figure BDA0003127506190000111
Wherein x ismaxIs the maximum value, x, in the input dataminIs the minimum value, x, in the input dataiFor the i-th parameter, x, in the input data before normalizationi' is the ith parameter in the normalized input data.
In the embodiment, through the three neural network models, the selection and the relative position adjustment of the components under the first font of the target Chinese character are realized, and the position of the obtained whole character (namely the target Chinese character) in the character forming space is determined, so that the time for constructing the character library of the target Chinese character in the character forming space is shortened, and the efficiency is improved.
In the embodiment shown in FIG. 1, the font properties include at least one of: complexity parameters of different directions, maximum complexity parameters of different directions, and center of gravity parameters of different directions.
When the complexity parameters in different directions are obtained, the complexity parameters include complexity, and the complexity can be obtained through the following steps. As shown in fig. 4, fig. 4 is a schematic flowchart of a complexity obtaining method provided in an embodiment of the present application, where the method includes:
s201, acquiring a pixel array of the component.
Illustratively, the pixel array of the building block includes pixel points in a bounding rectangle of the building block and pixel points corresponding to the building block itself. Fig. 5 is a schematic diagram of a component pixel array according to an embodiment of the present disclosure. The component can be divided into pixel points arranged in an array, wherein the number of the pixel points corresponding to the component is the number of the black small square frames in the graph, and the number of the pixel points in the component external rectangular frame is the sum of the numbers of the black small square frames and the white small square frames in the largest rectangular frame.
S202, counting the number of pixels of the pixel array along a certain direction, the number of pixels corresponding to a circumscribed rectangle of a member in the pixel array, and the number of pixels corresponding to the member in the pixel array.
Illustratively, the number of pixel points in a certain direction in the pixel array is counted, for example, in fig. 5, the number of pixel points in the X-axis direction, that is, the number of rows of pixels included in the bounding rectangle of the member, may be included. The number of pixel points in the Y-axis direction, i.e., the number of columns of pixels included in the component bounding rectangle, may also be included. And sequentially counting the number of pixels corresponding to the component circumscribed rectangle in the pixel array and the number of pixels corresponding to the component in the pixel array.
S203, calculating the ratio of the pixel number corresponding to the member to the multiplication result, wherein the ratio is used as the complexity of the member in a certain direction under the font, and the multiplication result is the result of multiplying the pixel number of the pixel array in the certain direction by the pixel number corresponding to a member circumscribed rectangle in the pixel array.
Illustratively, after the product of the number of pixels of the pixel along a certain direction and the number of pixels corresponding to the bounding rectangle of the member in the pixel array is calculated, the ratio of the number of pixels corresponding to the member to the product result is taken as the complexity of the member in a certain direction under the font. Then, for each direction, based on each component of the target Chinese character under each font, the complexity of each component of the target Chinese character under various fonts and different directions is obtained by executing the steps S201 to S203. Wherein the complexity of different directions may include the complexity of the component X direction and the complexity of the component Y direction.
Optionally, the complexity parameter further includes a complexity ratio. Specifically, after the complexity of each component of the target Chinese character in each direction in a certain font is obtained, the ratio of the complexity to the complexity of the components in other directions in the font is calculated, so that the complexity ratio of each component of the target Chinese character in various fonts can be obtained. For example, the ratio may be the ratio of the complexity of the component in the X-direction to the complexity of the component in the Y-direction.
In this embodiment, when obtaining the font property, the complexity parameter of the component may be used as the font property value of the component, so that the model obtained by training has higher prediction accuracy.
In some embodiments, when obtaining the font property, a maximum complexity parameter is included in the font property, and the maximum complexity parameter includes a maximum complexity. Aiming at each direction, based on each component of the target Chinese character under each font, the maximum complexity of each component of the target Chinese character in different directions under various fonts is obtained, and the method mainly comprises the following steps. As shown in fig. 6, fig. 6 is a schematic flowchart of a method for acquiring a maximum complexity parameter according to an embodiment of the present application.
S301, coordinates of each pixel in the pixel array of the component are acquired.
For example, for a building block, coordinates may be added to the pixel array to obtain the pixel coordinates of each pixel in the bounding rectangle of the building block. For example, the coordinates of the geometric center in the small rectangular frame corresponding to each pixel point may be regarded as the coordinates of the pixel point.
S302, calculating the sum of the coordinates of the pixels corresponding to the member in each group of pixels in a certain direction, and obtaining the sum of the coordinates corresponding to each group of pixels in the certain direction.
For example, for each group of pixels in the X direction of the member, the pixels in the circumscribed rectangle of the member may be divided into a group of pixels by rows, and for each row of pixels, the sum of the coordinates of the pixel points of the member in the X direction is calculated, so as to obtain the sum of the coordinates corresponding to each group of pixels in a certain direction. For example, for each group of pixels in the Y direction of the member, the pixels in the circumscribed rectangle of the member may be divided into a group of pixels by columns, and for each row of pixels, the sum of the coordinates of the pixels of the member in the Y direction is calculated, so as to obtain the sum of the coordinates corresponding to each group of pixels in a certain direction.
S303, taking the maximum value in the sum of the coordinates corresponding to each group of pixels in a certain direction as the maximum complexity of the component in the certain direction under the font.
Illustratively, the sizes of the sums of the coordinates corresponding to each group of pixel points in a certain direction are compared, and the maximum value is selected as the maximum complexity of the component in the certain direction under the font.
Optionally, the maximum complexity may include an X-direction maximum complexity and a Y-direction maximum complexity.
Optionally, the maximum complexity parameter includes a maximum complexity ratio. Specifically, when calculating the maximum complexity ratio, the following method may be adopted: and aiming at the maximum complexity of each component of the target Chinese character in each font in each direction, calculating the ratio of the maximum complexity to the maximum complexity of the components in other directions under the font to obtain the maximum complexity ratio of each component of the target Chinese character in various fonts. For example, the maximum complexity ratio may be 6) the ratio of the X-direction maximum complexity to the Y-direction maximum complexity.
In this embodiment, when obtaining the font property, the maximum complexity parameter of the component may be used as the font property value of the component, so as to improve the prediction accuracy of the model.
In some embodiments, when obtaining the font property, the font property includes a center-of-gravity parameter that the font property includes different directions; the center of gravity parameter comprises the center of gravity; aiming at each direction, based on each component of the target Chinese character under each font, the following processing is executed to obtain the gravity centers of the components of the target Chinese character under various fonts in different directions, and the method mainly comprises the following steps. As shown in fig. 7, fig. 7 is a schematic flowchart of a method for acquiring a barycentric parameter according to an embodiment of the present application.
S401, coordinates of each pixel point in the pixel array of the component are obtained.
Exemplarily, this step is similar to the principle of step S301 in fig. 6, and is not described here again.
S402, counting the number of pixels corresponding to a component circumscribed rectangle in the pixel array.
Exemplarily, this step is similar to the principle of step S301 in fig. 4, and is not described here again.
And S403, calculating the sum of the coordinates of the pixels corresponding to the members aiming at the pixels in a certain direction.
For example, in this step, for a pixel point in a certain direction, a coordinate sum of the pixel point corresponding to the member in the certain direction is calculated, for example, in the X direction, a coordinate sum of the pixel point corresponding to the member in the X direction is calculated.
S404, calculating the ratio of the sum of the coordinates of the pixels corresponding to the member to the number of pixels corresponding to the circumscribed rectangle of the member in the pixel array as the gravity center of the member in a certain direction under the character style.
Illustratively, in this step, the ratio of the sum of the coordinates of the pixels acquired in step S403 to the pixels for use in the bounding rectangle of the member is taken as the center of gravity in a certain direction, that is, when the ratio of the sum of the coordinates in the X direction to the pixels for use in the bounding rectangle of the member is taken, the center of gravity obtained at this time is the center of gravity in the X direction.
Optionally, the barycentric parameter includes a barycentric ratio. Specifically, when calculating the barycenter ratio, the ratio of the barycenter of each component of the target chinese character in each direction to the barycenter of the component in the other direction in each font may be calculated, so as to obtain the barycenter ratio of each component of the target chinese character in the plurality of fonts.
In some embodiments, when the font property is obtained, the font property includes the morphological parameters of the component in different regions in different scanning directions. Fig. 8 is a flowchart illustrating a morphological parameter obtaining method according to an embodiment of the present application. The method comprises the following steps:
s501, a pixel array of the component is acquired, and for each scanning direction, groups of pixels along the scanning direction in a current scanning area of the pixel array are determined.
Illustratively, the scan direction of the member may include: scanning from the upper frame to the lower frame of the external rectangle of the component, scanning from the lower frame to the upper frame of the external rectangle of the component, scanning from the left frame to the right frame of the external rectangle of the component, and scanning from the right frame to the left frame of the external rectangle of the component. And the scan region of the member circumscribing rectangle can be divided into an upper portion, a middle portion, and a lower portion. Or may also include a left portion, a middle portion, and a right portion. Specifically, based on each scanning area, each scanning direction of each area may be scanned according to the scanning direction of the component, so as to obtain each group of pixels along the scanning direction in the current scanning area of the pixel array. Further, the member configuration parameters are divided into: a member upper form, a member lower form, a member upper left form, a member upper right form, a member lower left form, a member lower right form, a member middle left form, a member middle right form, a member left form, a member right form, a member left upper form, a member left lower form, a member right upper form, a member right lower form, a member middle upper form, a member middle lower form.
S502, scanning each group of pixels along the scanning direction, and determining the first scanned first pixel in each group of pixels, wherein the first pixel belongs to the pixels corresponding to the members.
Illustratively, when each group of pixels is scanned in a scanning direction, a corresponding first pixel of a member scanned first in each group of pixels in the scanning direction is acquired.
S503, calculating the sum of coordinates of the first pixels corresponding to the pixels in each group to obtain a first summation result, and calculating the reciprocal of the mean square value of the first summation result to be used as the form parameter of the component in the region in the scanning direction.
For example, the coordinates of the first pixel are determined, a first summation result is obtained after summation, and the reciprocal of the mean square value of the first summation result is taken as the morphological parameter of the component in the area under the scanning direction. When the upper frame of the component circumscribed rectangle scans to the lower frame or the lower frame scans to the upper frame, the coordinate of the first pixel is the sum of the coordinates in the Y direction. When the left frame or the right frame of the circumscribed rectangle of the component scans to the right frame or the left frame, the coordinate of the first pixel is the sum of the coordinates in the X direction.
In the embodiment, by acquiring the form parameters of the components in different areas in different scanning directions, the differences among the components in different fonts can be better distinguished, so that the accuracy of the trained model is higher.
The word stock construction method is exemplified below with reference to specific examples.
For the first neural network model, when the target Chinese character includes two components, the input parameters include: the total number of parameters for the component 1 category and the component 2 category is 50, and each parameter includes: the structural member comprises a structural member X-direction complexity, a structural member Y-direction complexity, a ratio of the X-direction complexity to the Y-direction complexity, an X-direction maximum complexity, a Y-direction maximum complexity, a ratio of the X-direction maximum complexity to the Y-direction maximum complexity, a structural member external rectangular frame internal center of gravity X, a structural member external rectangular frame internal center of gravity Y, a structural member external rectangular frame internal center of gravity X to Y ratio, a structural member upper portion form, a structural member lower portion form, a structural member upper portion left form, a structural member upper portion right form, a structural member lower portion left form, a structural member lower portion right form, a structural member middle left portion form, a structural member middle right portion form, a structural member left portion upper portion form, a structural member left portion lower portion form, a structural member right portion upper portion form, a structural member middle upper portion form and a structural member middle lower portion form.
For the first neural network model, the output parameters are the parameter basis for selecting the word-forming component, and the total output parameters of the component 1 and the component 2 are 30, specifically including:
the width of the external rectangle of the component, the height of the external rectangle of the component, the gravity center X of the external rectangle of the component, the gravity center Y of the external rectangle of the component, the ratio of the weight of the component to the area of the external rectangle, the upper form of the component, the lower form of the component, the left form of the component, the right form of the component, the left and right structural components further comprise: a member upper left form, a member upper right form, a member lower left form, a member lower right form, a member middle left form, a member middle right form; the upper and lower structural members further include: a member left upper form, a member left lower form, a member right upper form, a member right lower form, a member middle upper form, and a member middle lower form.
For the second neural network model, when the target kanji includes two components, the input parameters include: the method comprises the following steps of determining the width of a component circumscribed rectangle, the height of the component circumscribed rectangle, the complexity of the component in the X direction, the ratio of the complexity of the component in the X direction to the complexity of the component in the Y direction, the maximum complexity of the X direction, the ratio of the maximum complexity of the X direction to the maximum complexity of the Y direction, the gravity center X in a component circumscribed rectangle frame, the gravity center Y in a component circumscribed rectangle frame, the ratio of the weight of the component to the space area of a character, the upper form of the component, the lower form of the component, the left form of the component and the right form of the component; the left and right structural left member further includes: the right member of the left-right structure of the upper member right form, the lower member right form, and the middle member right form further comprises: a member upper left configuration, a member lower left configuration, a member middle left configuration; the upper and lower structural upper members further comprise: a member left lower form, a member right lower form, a member middle lower form; the lower structural member further includes: a left upper member configuration, a right upper member configuration, and an intermediate upper member configuration.
For the output parameters of the second neural network model, the output parameters are the parameter basis for selecting the word-forming component, and the total number of the parameters of the component 1 and the component 2 is 8, which specifically includes: the gravity center X of the circumscribed rectangle of the component, the gravity center Y of the circumscribed rectangle of the component, the geometric center X of the circumscribed rectangle of the component and the geometric center Y of the circumscribed rectangle of the component.
For the third neural network model, when the target chinese character includes two components, the input parameters are factors that affect the position in the character-forming space of the chinese character, and the input parameters include: the total of 25 parameters for the component 1 class and the component 2 class include: the character comprises a character body, a character outer-connected rectangle width, a character outer-connected rectangle height, a character outer-connected rectangle inner center of gravity X, a character outer-connected rectangle inner center of gravity Y, a character X direction complexity, a character Y direction complexity, a character weight to outer-connected rectangle area ratio, a character left full-deficiency ratio to left and right full-deficiency sum ratio, a character upper full-deficiency ratio to up and down full-deficiency sum ratio, a character upper form, a character lower form, a character upper left form, a character upper right form, a character lower left form, a character lower right form, a character middle left form, a character middle right form, a character left form, a character right form, a character left upper form, a character left lower form, a character middle upper form, a character middle lower form.
For the third neural network model, the output parameters are the basis for determining the position of the Chinese character in the character forming space, and specifically include the gravity center X of the Chinese character in the character forming space and the gravity center Y of the Chinese character in the character forming space.
In the above embodiment, the font property of the component in each neural network model may be the same or different, and is not limited herein.
Fig. 9 is a schematic structural diagram of a word stock construction device according to an embodiment of the present application, and as shown in fig. 9, the device includes:
a first obtaining unit 61 configured to obtain first input data, the first input data including: the average value of the font attribute value sets of the components of the target Chinese character corresponds to the font attribute value sets one by one, and each font attribute value set comprises attribute values of font attributes under various fonts; wherein different attribute values of the font attribute are used for representing different fonts;
a first generating unit 62, configured to input first input data into the first neural network model, and obtain first output data, where the first output data includes: the first font attribute value set of the member of the target Chinese character, the ratio of the weight of the member to the area of the circumscribed rectangle of the member and the shape parameter of the circumscribed rectangle of the member; wherein the first font property value set comprises a first property value of the font property;
a second obtaining unit 63, configured to obtain, according to the first font attribute value set of the component of the target chinese character, a first component in a corresponding first font from the chinese character library, and obtain second input data, where the second input data includes: a second attribute value of the font attribute of the first member in the first font, a ratio of the weight of the first member to the area of the circumscribed rectangle of the first member, and a shape parameter of the circumscribed rectangle of the first member;
a second generating unit 64, configured to input second input data into the second neural network model to obtain second output data, where the second output data includes structural relationship parameters between the first members and shape parameters of circumscribed rectangles of the first members;
a third obtaining unit 65, configured to generate a target chinese character in the first font according to the component in the first font and the second output data, and obtain third input data, where the third input data includes a shape parameter of a circumscribed rectangle of the target chinese character in the first font, a shape parameter of the target chinese character, a first position parameter value of the target chinese character in a character formation space, and a ratio of a weight of the target chinese character to an area of the circumscribed rectangle of the target chinese character;
a third generating unit 66, configured to input third input data into the third neural network model, so as to obtain a second position parameter value of the target chinese character in the character forming space; and obtaining the target Chinese character under the first font in the character forming space based on the second position parameter value of the target Chinese character in the character forming space and the target Chinese character under the first font.
The apparatus provided in this embodiment is used to implement the technical solution provided by the above method, and the implementation principle and the technical effect are similar and will not be described again.
Fig. 10 is a schematic structural diagram of another word stock construction device according to an embodiment of the present application. As shown in FIG. 10, in some embodiments, font properties include at least one of: complexity parameters of different directions, maximum complexity parameters of different directions, and center of gravity parameters of different directions.
In some embodiments, the font properties include complexity parameters in different directions; the complexity parameter includes complexity; the device still includes:
a first calculating unit 67, configured to obtain, for each direction, the complexity of each component of the target chinese character in different directions in multiple fonts by performing the following processing based on each component of the target chinese character in each font:
acquiring a pixel array of a member; counting the number of pixels of the pixel array along the direction, the number of pixels corresponding to a component circumscribed rectangle in the pixel array and the number of pixels corresponding to the component in the pixel array; and calculating the ratio of the pixel number corresponding to the member to the multiplication result as the complexity of the member in the lower direction of the font, wherein the multiplication result is the result of multiplying the pixel number of the pixel array along the first direction by the pixel number corresponding to the circumscribed rectangle of the member in the pixel array.
In some embodiments, the complexity parameter comprises a complexity ratio; the device still includes:
and the second calculating unit 68 is used for calculating the complexity of each component of the target Chinese character in each direction under each font and the ratio of the complexity to the complexity of the components under the fonts in other directions to obtain the complexity ratio of each component of the target Chinese character in various fonts.
In some embodiments, the font property includes a maximum complexity parameter for different directions; the device still includes:
a third calculating unit 69, configured to obtain, for each direction, the maximum complexity of each component of the target chinese character in different directions in the plurality of fonts by performing the following processing based on each component of the target chinese character in each font:
acquiring coordinates of each pixel in a pixel array of a component; calculating the sum of the coordinates of the pixels corresponding to the member in each group of pixels in the direction to obtain the sum of the coordinates corresponding to each group of pixels in the direction; and taking the maximum value of the sum of the coordinates corresponding to each group of pixels in the direction as the maximum complexity of the component in the direction below the font.
In some embodiments, the apparatus further comprises:
and a fourth calculating unit 70, configured to calculate, for the maximum complexity of each component of the target chinese character in each font in each direction, a ratio of the maximum complexity to the maximum complexity of the components in other directions under the font, so as to obtain a maximum complexity ratio of each component of the target chinese character in multiple fonts.
In some embodiments, the apparatus further comprises:
a fifth calculation unit 71, configured to obtain, for each direction, the center of gravity of each component of the target chinese character in different directions in the plurality of fonts by performing the following processing based on each component of the target chinese character in each font:
obtaining coordinates of each pixel point in a pixel array of the component; counting the number of pixels corresponding to a component circumscribed rectangle in the pixel array; calculating the sum of coordinates of pixels corresponding to the members aiming at the pixels in the direction; and calculating the ratio of the sum of the coordinates of the pixels corresponding to the member to the number of pixels corresponding to the circumscribed rectangle of the member in the pixel array as the gravity center of the member in the lower direction of the font.
In some embodiments, the barycentric parameter includes a barycentric ratio; the device still includes:
and a sixth calculating unit 72, configured to calculate, for the gravity center of each component of the target chinese character in each font in each direction, a ratio of the gravity center to the gravity centers of the components in other directions, and obtain a gravity center ratio of each component of the target chinese character in the plurality of fonts.
In some embodiments, the component shape parameters further include morphological parameters of the component at different regions in different scan directions; the device still includes:
a seventh calculation unit 73 for acquiring a pixel array of the member; for each scanning direction, determining groups of pixels along the scanning direction in a current scanning area of the pixel array; scanning each group of pixels along the scanning direction, and determining a first scanned first pixel in each group of pixels, wherein the first pixel belongs to the pixels corresponding to the members; calculating the sum of coordinates of first pixels corresponding to each group of pixels to obtain a first summation result; and calculating the reciprocal of the mean square value of the first summation result as the morphological parameter of the region of the component in the scanning direction.
In some embodiments, the first position parameter value comprises a ratio of the left full degree of the target Chinese character to the sum of the left full degrees and the right full degrees and a ratio of the upper full degree of the target Chinese character to the sum of the upper full degrees and the lower full degrees; the second position parameter value comprises the parameter value of the gravity center parameter of the target Chinese character in the character forming space.
The apparatus provided in this embodiment is used to implement the technical solution provided by the above method, and the implementation principle and the technical effect are similar and will not be described again.
Fig. 11 is a schematic structural diagram of an electronic device provided in an embodiment of the present application, and as shown in fig. 11, the electronic device includes:
a processor (processor)291, the electronic device further including a memory (memory) 292; a Communication Interface 293 and bus 294 may also be included. The processor 291, the memory 292, and the communication interface 293 may communicate with each other via the bus 294. Communication interface 293 may be used for the transmission of information. Processor 291 may call logic instructions in memory 294 to perform the methods of the embodiments described above.
Further, the logic instructions in the memory 292 may be implemented in software functional units and stored in a computer readable storage medium when sold or used as a stand-alone product.
The memory 292 is a computer-readable storage medium for storing software programs, computer-executable programs, such as program instructions/modules corresponding to the methods in the embodiments of the present application. The processor 291 executes the functional application and data processing by executing the software program, instructions and modules stored in the memory 292, so as to implement the method in the above method embodiments.
The memory 292 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal device, and the like. Further, the memory 292 may include a high speed random access memory and may also include a non-volatile memory.
The present application provides a computer readable storage medium having stored thereon computer executable instructions for performing the method of any one of the first aspect when executed by a processor.
A computer program product comprising a computer program that, when executed by a processor, implements a method as in any one of the first aspects.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements 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 application is limited only by the appended claims.

Claims (14)

1. A method for building a word stock is characterized by comprising the following steps:
obtaining first input data, the first input data comprising: the method comprises the following steps of averaging the font attribute value sets of the components of the target Chinese character, wherein the components correspond to the font attribute value sets one by one, and each font attribute value set comprises attribute values of font attributes under various fonts; wherein different attribute values of the font attribute are used for representing different fonts;
inputting the first input data into a first neural network model to obtain first output data, wherein the first output data comprises: the first font attribute value set of the component of the target Chinese character, the ratio of the weight of the component to the area of the component circumscribed rectangle and the shape parameter of the component circumscribed rectangle; wherein the first set of font property values comprises a first property value of the font property;
according to the first font attribute value set of the member of the target Chinese character, obtaining a first member under a corresponding first font from a Chinese character library, and obtaining second input data, wherein the second input data comprises: a second attribute value of a font attribute of the first member in the first font, a ratio of a weight of the first member to an area of a circumscribed rectangle of the first member, and a shape parameter of the circumscribed rectangle of the first member;
inputting the second input data into a second neural network model to obtain second output data, wherein the second output data comprises structural relation parameters among the first components and shape parameters of circumscribed rectangles of the first components;
generating a target Chinese character under the first font according to the member under the first font and the second output data, and obtaining third input data, wherein the third input data comprises shape parameters of a circumscribed rectangle of the target Chinese character under the first font, the shape parameters of the target Chinese character, first position parameter values of the target Chinese character in a character forming space and the ratio of the weight of the target Chinese character to the area of the circumscribed rectangle of the target Chinese character;
inputting the third input data into a third neural network model to obtain a second position parameter value of the target Chinese character in a character forming space; and obtaining the target Chinese character under the first font in the character forming space based on the second position parameter value of the target Chinese character in the character forming space and the target Chinese character under the first font.
2. The method of claim 1, wherein the font properties comprise at least one of: complexity parameters of different directions, maximum complexity parameters of different directions, and center of gravity parameters of different directions.
3. The method of claim 2, wherein the font property comprises complexity parameters for different directions; the complexity parameter comprises complexity; the method further comprises the following steps:
for each direction, based on each component of the target Chinese character under each font, the complexity of each component of the target Chinese character in different directions under various fonts is obtained by executing the following processing:
acquiring a pixel array of the member; counting the number of pixels of the pixel array along the direction, the number of pixels corresponding to a component circumscribed rectangle in the pixel array, and the number of pixels corresponding to the component in the pixel array; and calculating the ratio of the pixel number corresponding to the member to a product result as the complexity of the member in the direction under the font, wherein the product result is the result of multiplying the pixel number of the pixel array along the first direction by the pixel number corresponding to a member circumscribed rectangle in the pixel array.
4. The method of claim 3, wherein the complexity parameter comprises a complexity ratio; the method further comprises the following steps:
and aiming at the complexity of each component of the target Chinese character in each font in each direction, calculating the ratio of the complexity to the complexity of the components in other directions in the font to obtain the complexity ratio of each component of the target Chinese character in various fonts.
5. The method of claim 2, wherein the font property comprises a maximum complexity parameter for different directions; the method further comprises the following steps:
for each direction, based on each component of the target Chinese character under each font, the following processing is executed to obtain the maximum complexity of each component of the target Chinese character under various fonts in different directions:
acquiring coordinates of each pixel in a pixel array of the member; calculating the sum of the coordinates of the pixels corresponding to the member in each group of pixels in the direction to obtain the sum of the coordinates corresponding to each group of pixels in the direction; and taking the maximum value of the sum of the coordinates corresponding to each group of pixels in the direction as the maximum complexity of the component in the direction under the font.
6. The method of claim 5, wherein the maximum complexity parameter comprises a maximum complexity ratio; the method further comprises the following steps:
and aiming at the maximum complexity of each component of the target Chinese character in each font in each direction, calculating the ratio of the maximum complexity to the maximum complexity of the components in other directions in the font to obtain the maximum complexity ratio of each component of the target Chinese character in various fonts.
7. The method of claim 2, wherein the font property comprises a center of gravity parameter for different directions; the center of gravity parameter comprises a center of gravity; the method further comprises the following steps:
for each direction, based on each component of the target Chinese character under each font, obtaining the gravity center of each component of the target Chinese character under different directions of various fonts by executing the following processing:
obtaining coordinates of each pixel point in the pixel array of the component; counting the number of pixels corresponding to a component circumscribed rectangle in the pixel array; calculating the sum of coordinates of pixels corresponding to the members aiming at the pixel points in the direction; and calculating the ratio of the sum of the coordinates of the pixels corresponding to the member to the number of pixels corresponding to a member circumscribed rectangle in the pixel array as the gravity center of the member in the direction under the font.
8. The method of claim 7, wherein the center of gravity parameters include a center of gravity ratio; the method further comprises the following steps:
and calculating the ratio of the gravity center of each component of the target Chinese character in each direction under each font to the gravity centers of the components in other directions under the fonts to obtain the gravity center ratio of each component of the target Chinese character in various fonts.
9. The method of claim 2, wherein the component shape parameters further include morphological parameters of the component at different regions in different scan directions; the method further comprises the following steps:
acquiring a pixel array of the member; for each scanning direction, determining groups of pixels in a current scanning area of the pixel array along the scanning direction; scanning the pixels of each group along the scanning direction, and determining a first scanned first pixel in each group of pixels, wherein the first pixel belongs to a pixel corresponding to a component; calculating the sum of coordinates of first pixels corresponding to each group of pixels to obtain a first summation result; and calculating the reciprocal of the mean square value of the first summation result as the morphological parameter of the component in the scanning direction in the area.
10. The method of claim 1, wherein the first position parameter values include a ratio of left full ambiguity to sum of left full ambiguity and a ratio of upper full ambiguity to sum of up full ambiguity and down full ambiguity of the target Chinese character; the second position parameter value comprises a parameter value of a gravity center parameter of the target Chinese character in a character forming space.
11. A font library construction apparatus, comprising:
a first acquisition unit configured to acquire first input data, the first input data including: the method comprises the following steps of averaging the font attribute value sets of the components of the target Chinese character, wherein the components correspond to the font attribute value sets one by one, and each font attribute value set comprises attribute values of font attributes under various fonts; wherein different attribute values of the font attribute are used for representing different fonts;
a first generating unit, configured to input the first input data into a first neural network model, and obtain first output data, where the first output data includes: the first font attribute value set of the component of the target Chinese character, the ratio of the weight of the component to the area of the component circumscribed rectangle and the shape parameter of the component circumscribed rectangle; wherein the first set of font property values comprises a first property value of the font property;
a second obtaining unit, configured to obtain a first component in a corresponding first font from a chinese character library according to the first font attribute value set of the component of the target chinese character, and obtain second input data, where the second input data includes: a second attribute value of a font attribute of the first member in the first font, a ratio of a weight of the first member to an area of a circumscribed rectangle of the first member, and a shape parameter of the circumscribed rectangle of the first member;
a second generating unit, configured to input the second input data into a second neural network model to obtain second output data, where the second output data includes structural relationship parameters between the first members and shape parameters of a circumscribed rectangle of the first members;
a third obtaining unit, configured to generate a target chinese character in the first font according to the component in the first font and the second output data, and obtain third input data, where the third input data includes a shape parameter of a circumscribed rectangle of the target chinese character in the first font, a shape parameter of the target chinese character, a first position parameter value of the target chinese character in a character forming space, and a ratio of a weight of the target chinese character to an area of the circumscribed rectangle of the target chinese character;
a third generating unit, configured to input the third input data into a third neural network model, and obtain a second position parameter value of the target chinese character in a character forming space; and obtaining the target Chinese character under the first font in the character forming space based on the second position parameter value of the target Chinese character in the character forming space and the target Chinese character under the first font.
12. An electronic device, comprising: a memory, a processor;
a memory; a memory for storing the processor-executable instructions;
wherein the processor is configured to perform the method according to the executable instructions of any one of claims 1-10.
13. A computer-readable storage medium having computer-executable instructions stored thereon, which when executed by a processor, perform the method of any one of claims 1-10.
14. A computer program product, characterized in that the computer program product comprises a computer program which, when being executed by a processor, carries out the method of any one of claims 1-10.
CN202110694439.9A 2021-06-22 2021-06-22 Word stock construction method and device, electronic equipment and storage medium Active CN113312444B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110694439.9A CN113312444B (en) 2021-06-22 2021-06-22 Word stock construction method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110694439.9A CN113312444B (en) 2021-06-22 2021-06-22 Word stock construction method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113312444A true CN113312444A (en) 2021-08-27
CN113312444B CN113312444B (en) 2023-11-24

Family

ID=77379760

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110694439.9A Active CN113312444B (en) 2021-06-22 2021-06-22 Word stock construction method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113312444B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110211203A (en) * 2019-06-10 2019-09-06 大连民族大学 The method of the Chinese character style of confrontation network is generated based on condition
CN110533737A (en) * 2019-08-19 2019-12-03 大连民族大学 The method generated based on structure guidance Chinese character style
CN112784531A (en) * 2019-11-05 2021-05-11 北京大学 Chinese font and word stock generation method based on deep learning and part splicing
CN112862025A (en) * 2021-03-08 2021-05-28 成都字嗅科技有限公司 Chinese character stroke filling method, system, terminal and medium based on computer

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110211203A (en) * 2019-06-10 2019-09-06 大连民族大学 The method of the Chinese character style of confrontation network is generated based on condition
CN110533737A (en) * 2019-08-19 2019-12-03 大连民族大学 The method generated based on structure guidance Chinese character style
CN112784531A (en) * 2019-11-05 2021-05-11 北京大学 Chinese font and word stock generation method based on deep learning and part splicing
CN112862025A (en) * 2021-03-08 2021-05-28 成都字嗅科技有限公司 Chinese character stroke filling method, system, terminal and medium based on computer

Also Published As

Publication number Publication date
CN113312444B (en) 2023-11-24

Similar Documents

Publication Publication Date Title
CN112733794B (en) Method, device and equipment for correcting sight of face image and storage medium
CN110930454A (en) Six-degree-of-freedom pose estimation algorithm based on boundary box outer key point positioning
US20230177695A1 (en) Instance segmentation method and system for enhanced image, and device and medium
CN110135325A (en) Crowd's number method of counting and system based on dimension self-adaption network
US20230072627A1 (en) Gaze correction method and apparatus for face image, device, computer-readable storage medium, and computer program product face image
CN112819947A (en) Three-dimensional face reconstruction method and device, electronic equipment and storage medium
CN110941999B (en) Method for adaptively calculating size of Gaussian kernel in crowd counting system
TW202038191A (en) Method, device and electronic equipment for living detection and storage medium thereof
CN111274999B (en) Data processing method, image processing device and electronic equipment
US20230298237A1 (en) Data processing method, apparatus, and device and storage medium
CN109635714A (en) The antidote and device of file scanned image
CN110210490A (en) Image processing method, device, computer equipment and storage medium
CN104851133A (en) Image self-adaptive grid generation variational method
CN112614140A (en) Method and related device for training color spot detection model
CN109993202A (en) A kind of line chirotype shape similarity judgment method, electronic equipment and storage medium
CN115393872A (en) Method, device and equipment for training text classification model and storage medium
CN105701760A (en) Histogram real-time generation method of geographic raster data optional polygon area
CN110807409A (en) Crowd density detection model training method and crowd density detection method
CN113312444B (en) Word stock construction method and device, electronic equipment and storage medium
Wu et al. A hybrid image retargeting approach via combining seam carving and grid warping
CN113610864B (en) Image processing method, device, electronic equipment and computer readable storage medium
CN111611883B (en) Table layout analysis method, system and equipment based on minimum cell clustering
CN113706583A (en) Image processing method, image processing device, computer equipment and storage medium
CN114266899A (en) Image target parallel detection method based on multi-core DSP
CN111382834B (en) Confidence degree comparison method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant