CN111612871A - Handwritten sample generation method and device, computer equipment and storage medium - Google Patents
Handwritten sample generation method and device, computer equipment and storage medium Download PDFInfo
- Publication number
- CN111612871A CN111612871A CN202010273099.8A CN202010273099A CN111612871A CN 111612871 A CN111612871 A CN 111612871A CN 202010273099 A CN202010273099 A CN 202010273099A CN 111612871 A CN111612871 A CN 111612871A
- Authority
- CN
- China
- Prior art keywords
- target
- text
- handwritten text
- target handwritten
- information
- 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.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 56
- 238000012545 processing Methods 0.000 claims abstract description 56
- 238000009877 rendering Methods 0.000 claims abstract description 18
- 230000008569 process Effects 0.000 claims abstract description 8
- 238000004590 computer program Methods 0.000 claims description 33
- 230000009466 transformation Effects 0.000 claims description 26
- 238000001914 filtration Methods 0.000 claims description 19
- 239000006002 Pepper Substances 0.000 claims description 12
- 238000005286 illumination Methods 0.000 claims description 9
- 238000010586 diagram Methods 0.000 description 8
- 235000002566 Capsicum Nutrition 0.000 description 6
- 241000722363 Piper Species 0.000 description 6
- 235000016761 Piper aduncum Nutrition 0.000 description 6
- 235000017804 Piper guineense Nutrition 0.000 description 6
- 235000008184 Piper nigrum Nutrition 0.000 description 6
- 230000000694 effects Effects 0.000 description 6
- 150000003839 salts Chemical class 0.000 description 6
- 230000008859 change Effects 0.000 description 4
- 238000013507 mapping Methods 0.000 description 4
- 238000006243 chemical reaction Methods 0.000 description 3
- 238000005516 engineering process Methods 0.000 description 3
- 230000000007 visual effect Effects 0.000 description 3
- 238000004422 calculation algorithm Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000013515 script Methods 0.000 description 2
- 230000001360 synchronised effect Effects 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 238000012549 training Methods 0.000 description 2
- 230000000903 blocking effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000009792 diffusion process Methods 0.000 description 1
- 230000002708 enhancing effect Effects 0.000 description 1
- 230000003628 erosive effect Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000002285 radioactive effect Effects 0.000 description 1
- 230000009467 reduction Effects 0.000 description 1
- 238000004088 simulation Methods 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 230000037303 wrinkles Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T11/00—2D [Two Dimensional] image generation
- G06T11/60—Editing figures and text; Combining figures or text
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/35—Clustering; Classification
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T5/00—Image enhancement or restoration
- G06T5/90—Dynamic range modification of images or parts thereof
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- Controls And Circuits For Display Device (AREA)
Abstract
The application relates to a handwritten sample generation method, a handwritten sample generation device, computer equipment and a storage medium. The method comprises the following steps: obtaining corpus information of a sample to be generated; selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library according to the text information carried in the corpus information; acquiring a corresponding target background picture according to text information carried in the corpus information; performing data enhancement processing on at least one first target handwritten text to obtain at least one corresponding second target handwritten text; and rendering at least one second target handwritten text into a target background picture to obtain a handwritten sample. Therefore, texts in the obtained handwriting samples are more various and vivid, the handwritten texts are more real and delicate in expression, the handwriting rules of real people are more met, the whole process does not need manual participation, and a large number of first handwriting samples with rich varieties can be generated quickly and effectively.
Description
Technical Field
The present application relates to the field of image processing technologies, and in particular, to a method and an apparatus for generating a handwritten sample, a computer device, and a storage medium.
Background
With the continuous development and popularization of computer technology and various printing technologies, documents needing to be handwritten are replaced by various printed documents more and more. However, in various occasions or when character recognition is carried out, the method needs to be realized by a handwritten text, and the handwritten text has an irreplaceable position. Traditionally, handwritten samples have been obtained by manual collection or simple computer mapping and size conversion.
However, hand-written samples obtained by manual collection or simple computer mapping and size conversion are generally rough, and vivid and high-quality hand-written samples cannot be obtained.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a method, an apparatus, a computer device and a storage medium for generating a handwritten sample.
A method of handwriting sample generation, the method comprising:
obtaining corpus information of a sample to be generated;
selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library according to the text information carried in the corpus information;
acquiring a corresponding target background picture according to the text information carried in the corpus information;
performing data enhancement processing on the at least one first target handwritten text to obtain at least one corresponding second target handwritten text;
rendering the at least one second target handwritten text to the target background picture to obtain a handwritten sample.
In one embodiment, the text information includes at least one text to be generated;
the selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library comprises:
searching at least one target handwritten text set corresponding to the at least one text to be generated from the handwritten text library;
and randomly selecting a target handwritten text from the at least one target handwritten text set to obtain the at least one first target handwritten text.
In one embodiment, the obtaining a corresponding target background picture according to text information carried in the corpus information includes:
obtaining a classification corresponding to the text information;
obtaining a background class corresponding to the category according to the category corresponding to the text information;
and randomly selecting the background class to obtain a target background picture.
In one embodiment, before performing data enhancement processing on the at least one first target handwritten text to obtain at least one corresponding second target handwritten text, the method includes:
and taking a preset word size in the text information as a reference, and adjusting the size of the at least one first target handwritten text under the constraint condition that the preset word size is in an inverse proportional relation with the depth of the target background picture to obtain the updated at least one first target handwritten text.
In one embodiment, the adjusting, with reference to a preset font size in the text information and under a constraint condition that the preset font size is in an inverse proportional relationship with the depth of the target background picture, the size of the at least one first target handwritten text to obtain the updated at least one first target handwritten text includes:
and randomly adjusting the size of the at least one first target handwritten text within a preset range to obtain the updated at least one first target handwritten text.
In one embodiment, the performing data enhancement processing on the at least one first target handwritten text to obtain at least one corresponding second target handwritten text includes:
and performing Gaussian blur, salt-and-pepper noise, elastic transformation and/or local area data enhancement processing on at least one first target handwritten text to obtain at least one second target handwritten text.
In one embodiment, the performing data enhancement processing on the at least one first target handwritten text to obtain at least one corresponding second target handwritten text further includes:
and performing curvature transformation on the position of the at least one first target handwritten text to obtain at least one updated second target handwritten text.
In one embodiment, the local area data enhancement processing includes:
for the at least one first target handwritten text, performing data enhancement processing on a local area of each first target handwritten text to obtain at least one third target handwritten text; wherein the local area is a random area on the first target handwritten text;
and filtering the at least one third target handwritten text on the boundary of the local area to obtain the at least one second target handwritten text.
In one embodiment, the filtering on the boundary of the local area to obtain the at least one second target handwritten text includes:
expanding the local area by taking the boundary of the local area as a reference to obtain a universal local area;
and in the pan local area, counting pixel gradients, and filtering according to the pixel gradients to obtain the at least one second target handwritten text.
In one embodiment, the performing data enhancement processing on the local area of each first target handwritten text further includes:
and (3) shielding, smearing, corroding and/or adjusting the illumination brightness at a certain probability in a local area of each first target handwritten text to obtain the at least one second target handwritten text.
In one embodiment, the rendering the at least one second target handwritten text into the target background picture to obtain a handwritten sample includes:
and carrying out overall data enhancement processing on the handwriting sample to obtain a handwriting sample of the updater.
A handwritten sample generation apparatus, said apparatus comprising:
the corpus information acquisition module is used for acquiring corpus information of a sample to be generated;
the first target handwritten text acquisition module is used for selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library according to the text information carried in the corpus information;
the background picture acquisition module is used for acquiring a corresponding target background picture according to the text information carried in the corpus information;
the second target handwritten text determination module is used for performing data enhancement processing on the at least one first target handwritten text to obtain at least one corresponding second target handwritten text;
and the handwriting sample generation module is used for rendering the at least one second target handwritten text into the target background picture to obtain a handwriting sample.
A computer device comprising a memory storing a computer program and a processor implementing the steps of any of the methods described above when the processor executes the computer program.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of any of the above.
According to the handwritten sample generation method, the handwritten sample generation device, the computer equipment and the storage medium, the corpus information of a sample to be generated is obtained; selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library according to the text information carried in the corpus information; acquiring a corresponding target background picture according to text information carried in the corpus information; performing data enhancement processing on at least one first target handwritten text to obtain at least one corresponding second target handwritten text; and rendering at least one second target handwritten text into a target background picture to obtain a handwritten sample. The first target handwritten text is selected from a preset handwritten text library, abundant text samples exist in the preset handwritten text library, so that the first target handwritten text is more diversified, and after the first target handwritten text is obtained, at least one second target handwritten text which is more in line with the real person handwriting style can be obtained by performing data enhancement processing on at least one first target handwritten text. The target background picture is determined according to the text information carried in the corpus information and better conforms to the corresponding style of the corpus information. After at least one second target handwritten text which is more accordant with the real person handwriting style and a target background picture which is more accordant with the corresponding style of the corpus information are obtained, the at least one second target handwritten text is rendered into the target background picture to obtain a handwriting sample, the text in the handwriting sample is more various and vivid, meanwhile, the background picture in the handwriting sample is more accordant with the corresponding style of the corpus information, the handwriting text is more real and delicate in expression and more accordant with the real person handwriting rule, the whole process does not need manual participation, and a large number of first handwriting samples with rich varieties can be generated quickly and effectively.
Drawings
FIG. 1 is a flow diagram illustrating a method for generating handwritten samples in one embodiment;
FIG. 2 is a schematic flow chart diagram illustrating one possible implementation of step S200 in one embodiment;
FIG. 3 is a schematic flow chart diagram illustrating one possible implementation of step S300 in one embodiment;
FIG. 4 is a flow diagram of local area data enhancement processing in one embodiment;
FIG. 5 is a schematic flow chart illustrating one possible implementation of step S420 in one embodiment;
FIG. 6 is a block diagram of a handwritten sample generation apparatus in one embodiment;
FIG. 7 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It will be understood that the terms "first," "second," and the like as used in this application may be used herein to describe various conditional relationships, but these conditional relationships are not limited by these terms. These terms are only used to distinguish one conditional relationship from another.
In one embodiment, as shown in fig. 1, there is provided a handwriting sample generation method, including the steps of:
and S100, obtaining the corpus information of the sample to be generated.
And S200, selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library according to the text information carried in the corpus information.
And step S300, acquiring a corresponding target background picture according to the text information carried in the corpus information.
Step S400, data enhancement processing is carried out on at least one first target handwritten text to obtain at least one corresponding second target handwritten text.
Step S500, rendering at least one second target handwritten text to a target background picture to obtain a handwritten sample.
The text information refers to the content, font size and other attribute information of the text contained in the handwriting sample to be generated and related to the text to be generated. The corpus information includes text information and configuration information corresponding to the text information. The background picture refers to a background picture corresponding to a handwritten sample to be generated, for example, the background picture corresponding to an ancient poem may be a paper with a groove, the background picture corresponding to a chinese name and a number may be some bills, and the background corresponding to a part of a place name and a name may be a natural scene. The handwritten text library comprises a file handwritten font library and a single character font library, wherein the file handwritten font library is a handwritten font library made according to corresponding fonts (such as a song style, a regular style, an clerical script and the like); the single character font library is a handwritten font library which is obtained by handwriting and collecting and processing a real person according to a certain format (font, word size and the like). Data enhancement refers to processing of data according with a real handwriting style, and comprises Gaussian blur, salt and pepper noise, elastic transformation and the like.
Specifically, after the corpus information of the sample to be generated is acquired, at least one target handwritten text is selected from a preset handwritten text library according to text information carried in the corpus information, and a corresponding target background picture is acquired according to the text information carried in the corpus information. For example, the text information indicates that the handwritten sample to be generated is a signature of a specific bill, the signature is "three sheets", two first target handwritten texts exist, which are "three sheets" and "three" respectively, and the background picture is a picture corresponding to the specific bill. Further, in order to obtain a more real and detailed handwriting sample, data enhancement processing is performed on at least one first target handwritten text, for example, gaussian blur, salt and pepper noise, elastic transformation, local area data enhancement processing, and the like are performed on the at least one first target handwritten text, so that the first target handwritten text better conforms to the effect of real person handwriting, at least one corresponding second target handwritten text is obtained, and the at least one second target handwritten text obtained through the data enhancement processing is rendered into a target background picture, so that the handwriting sample is obtained.
The handwritten sample generation method obtains the corpus information of a sample to be generated; selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library according to the text information carried in the corpus information; acquiring a corresponding target background picture according to text information carried in the corpus information; performing data enhancement processing on at least one first target handwritten text to obtain at least one corresponding second target handwritten text; and rendering at least one second target handwritten text into a target background picture to obtain a handwritten sample. The first target handwritten text is selected from a preset handwritten text library, abundant text samples exist in the preset handwritten text library, so that the first target handwritten text is more diversified, and after the first target handwritten text is obtained, at least one second target handwritten text which is more in line with the real person handwriting style can be obtained by performing data enhancement processing on at least one first target handwritten text. The target background picture is determined according to the text information carried in the corpus information and better conforms to the corresponding style of the corpus information. After at least one second target handwritten text which is more accordant with the real person handwriting style and a target background picture which is more accordant with the corresponding style of the corpus information are obtained, the at least one second target handwritten text is rendered into the target background picture to obtain a handwriting sample, the text in the handwriting sample is more various and vivid, meanwhile, the background picture in the handwriting sample is more accordant with the corresponding style of the corpus information, the handwriting text is more real and delicate in expression and more accordant with the real person handwriting rule, the whole process does not need manual participation, and a large number of first handwriting samples with rich varieties can be generated quickly and effectively.
In one embodiment, as shown in fig. 2, the method is a flowchart of an implementable manner of step S200, where selecting, according to text information carried in corpus information, at least one first target handwritten text corresponding to the text information from a preset handwritten text library, and the selecting includes:
step S210, at least one target handwritten text set corresponding to at least one text to be generated is searched from the handwritten text library.
Step S220, randomly selecting a target handwritten text from at least one target handwritten text set to obtain at least one first target handwritten text.
The text information comprises at least one text to be generated. The text to be generated refers to the text content of the generated handwriting sample, for example, the handwriting sample to be generated is a signature of a specific bill, the signature is "three by one", and the text information to be generated includes two texts to be generated, which are "one by one" and "three" respectively.
Specifically, since the specific form of the handwritten text is influenced by the environment, paper, pen ink and the like during writing, even if the same person has a main pen, the written characters can be in different states, so that the same character in a general handwritten font library corresponds to a plurality of texts, the plurality of texts are used as one text set, on the basis, when the target handwritten text is obtained, for each text to be generated, a target handwritten text set corresponding to the text to be generated is searched from the handwritten text library, one text is randomly selected from the target handwritten text set as a first target handwritten text, and finally at least one first target handwritten text corresponding to at least one text to be generated is obtained. The mode of randomly selecting the first target handwritten text from the target handwritten text set of the handwritten font library can make the first handwritten sample generated by applying the text in the handwritten font library richer and more diverse.
It should be noted that the handwritten text library includes a document handwritten font library and a single character font library, where texts in the single character handwritten font library exist in the form of pictures, and generally correspond to a set, the single character font library is originally handwritten, and originally functions as a training and testing set for identifying handwritten single characters, each single character has a certain number of sets, and here, the single character library can be used as the single character font library, and any text in the set is randomly extracted each time according to sample information to be generated. The file handwritten font library is a standard handwritten font library file made according to corresponding fonts (such as sons, regular scripts, clerks and the like), exists in a file form, generally has no corresponding set, can be regarded as a special case of the set, and can be directly called without random selection when the file is used for handwriting the text in the font library. When the target handwritten text extracted from the file handwritten font library is applied to the generation of a subsequent handwritten sample, a given character size needs to be generated, and then subsequent processing is carried out, while the text in the single character font library exists in a picture form, when the target handwritten text is applied to the generation of the subsequent handwritten sample, the size conversion and the shading removal operation need to be carried out according to the given character size, and then the subsequent processing is carried out.
In the above embodiment, at least one target handwritten text set corresponding to at least one text to be generated is searched from the handwritten text library; and randomly selecting a target handwritten text from at least one target handwritten text set to obtain at least one first target handwritten text. The mode of randomly selecting the first target handwritten text from the target handwritten text set of the handwritten font library can enable the first handwritten sample generated by applying the text in the handwritten font library to be richer and more diverse. The single character font library can effectively relieve the problems of insufficiency, unicity and the like of the file handwritten font library, and the combination application of the single character font library and the file handwritten font library can form various handwritten samples with different styles according to different combinations.
In one embodiment, as shown in fig. 3, the flowchart is an implementable flowchart of step S300, where obtaining a corresponding target background picture according to text information carried in corpus information includes:
step S310, obtaining the classification corresponding to the text information.
Step S320, obtaining a background class corresponding to the category according to the category corresponding to the text information.
And step S330, randomly selecting the background class to obtain a target background picture.
Specifically, according to the text information carried in the corpus information, a classification corresponding to the text information is obtained, for example, the classification may be ancient poems, bills, landscapes, and the like. And further determining a background class according to the classification corresponding to the text information, wherein the background class can be an ancient poetry background class, a bill background class, a landscape background class and the like, and randomly selecting a picture in the determined background class as a target background picture.
In the above embodiment, the classification corresponding to the text information is obtained; obtaining a background class corresponding to the category according to the corresponding category of the text information; and randomly selecting from the background class to obtain a target background picture. The target background picture is obtained by randomly selecting from the background class and is used for generating the handwriting sample, so that various handwriting samples with different background styles can be formed, and the form of the generated handwriting sample is enriched.
In one embodiment, the method before step S400 may be implemented, where before performing data enhancement processing on at least one first target handwritten text to obtain at least one corresponding second target handwritten text, the method includes:
and taking a preset word size in the text information as a reference, and adjusting the size of at least one first target handwritten text under the constraint condition that the preset word size is in an inverse proportional relation with the depth of the target background picture to obtain the updated at least one first target handwritten text.
Specifically, due to the principle of visual similarity, the larger the depth of the region in the target background picture in which the at least one first target handwritten text is placed is, the smaller the font size of the same font size is rendered, and the smaller the depth of the region in the target background picture in which the at least one first target handwritten text is placed is, the larger the font size of the same font size is rendered. Based on this fact, to determine the size of the first target handwritten text, it is necessary to obtain average depth information of an area in the target background picture where at least one target handwritten text is placed, obtain a depth value at each pixel point in the area, and calculate an average depth according to the depth value at each pixel point in the area. And then, taking the preset font size in the text information as a reference, and multiplying the preset font size by the ratio of the preset numerical value to the average depth to obtain the size of at least one target handwritten text. For example, if the preset font size is 10, the height of the corresponding text is about 3.5mm, when the 10 font is displayed on a normal background, the text height is 3.5mm, and when the 10 font is displayed on a background picture with a varying depth, the text height hf is alpha/dave, where alpha is a scaling coefficient, the size of the coefficient is determined according to the influence of the depth of the background picture on the display of the text size, and is generally a smaller value, for example, a value between 0.01 and 0.1, and dave is the average depth of the target handwritten text region in the target background picture. And finally, obtaining the updated at least one first target handwritten text by changing the width of the text in proportion to the height of the text.
Optionally, the size of the at least one first target handwritten text is randomly adjusted within a preset range, so that the updated at least one first target handwritten text is obtained.
The preset range is determined according to specific requirements, and generally, a certain enlargement or reduction may be performed on the basis of the size of the first target handwritten text, and the specific range is not limited.
Specifically, after at least one first target handwritten text is obtained, the size of the at least one first target handwritten text is randomly adjusted within a preset range, and the at least one first target handwritten text with the changed size is obtained. Because the size of the text in the handwriting sample obtained by real person handwriting is manually controlled, the size of the text is not consistent with the size generated by a machine, and the size of each text generally can be changed differently, the size of at least one first target handwritten text can be adjusted, so that the at least one first target handwritten text can better accord with the effect of real person handwriting and is more vivid.
In the above embodiment, the preset font size in the text information is used as a reference, and the size of the at least one first target handwritten text is adjusted under the constraint condition that the preset font size is in an inverse proportional relation with the depth of the target background picture, so as to obtain the updated at least one first target handwritten text. The size of the at least one first target handwritten text can be consistent with the depth expression of the target background picture corresponding to the size of the at least one first target handwritten text, so that the at least one first target handwritten text is more consistent with the visual effect and is more lifelike when being displayed on the picture.
In one embodiment, the method in step S400 may be implemented, where performing data enhancement processing on at least one first target handwritten text to obtain at least one corresponding second target handwritten text includes:
and performing Gaussian blur, salt-and-pepper noise, elastic transformation and/or local area data enhancement processing on the at least one first target handwritten text to obtain at least one second target handwritten text.
Specifically, performing gaussian blurring, salt and pepper noise, elastic transformation and/or local area data enhancement on at least one first target handwritten text simulates the instability of real person handwriting or the condition that the handwritten text in the real environment is possibly corroded and polluted.
Optionally, curvature transformation is performed on the position of the at least one first target handwritten text to obtain at least one updated second target handwritten text.
The method is characterized in that curvature transformation is carried out on the position of at least one target handwritten text, randomness adjustment of character spacing and line spacing in real person handwriting can be simulated, and the specific curvature transformation comprises the following steps: acquiring at least one bounding box corresponding to at least one target handwritten text; and adjusting the position of at least one bounding box according to the change of the curve by taking the starting point of the preset curve as a reference.
The bounding box in the present application refers to a shape that approximately replaces a target handwritten text region with a geometric shape that is slightly larger in area and simple in characteristics. The predetermined curve is a wavy line having a change in curvature.
Specifically, a curve y ═ f (x) is randomly generated, the ordinate (abscissa) of at least one bounding box is fixed from the starting point of the curve, the abscissa (ordinate) of the bounding box position is adjusted according to the change of the curve, and at least one second target handwritten text subjected to curvature transformation is obtained
In the above embodiment, at least one target handwritten text with a determined size is placed in the target background picture, and curvature transformation is performed on the position of the at least one target handwritten text placed in the target background picture to obtain the first handwritten sample. The arrangement of the texts in the handwriting sample obtained by real person handwriting is manually controlled, and the texts in each line or each column are not strictly on one reference line, so that the arrangement position of the texts in the handwriting sample is adjusted to further ensure that the generated handwriting sample is more real, and the obtained first handwriting sample is more in line with the effect of real person handwriting and is more vivid.
In the above embodiment, at least one first target handwritten text is subjected to gaussian blurring, salt-and-pepper noise, elastic transformation, and/or local area data enhancement processing, so as to obtain at least one second target handwritten text. The instability of real person handwriting or the condition that the handwritten text in the real environment is possibly corroded and polluted can be simulated, so that the at least one first target handwritten text is more consistent with the visual effect and more vivid when displayed on the picture.
In one embodiment, as shown in fig. 4, a schematic flow chart of a local area data enhancement process includes:
step S410, for at least one first target handwritten text, performing data enhancement processing on a local area of each first target handwritten text to obtain at least one third target handwritten text; the local area is a random area on the first target handwritten text.
Step S420, filtering the at least one third target handwritten text on the boundary of the local area to obtain at least one second target handwritten text.
Specifically, a local area W H (W is the width of the area, H is the height of the area, and W and H are random variables) smaller than or equal to a corresponding first target handwritten text is randomly selected, when the area size of a surrounding box surrounding city corresponding to the first target handwritten text is W H (W is the width of the area surrounding the box, and H is the height of the area surrounding the box), and the position of the first target handwritten text is (I, J), a local area R (I, J, W, H), (I < I + W-W, J < J + H, W < W, H, I, J, W, H are random variables) is selected, and data enhancement processing (shielding, smearing, corroding, adjusting illumination brightness and the like with a certain probability) is performed on the local area so as to simulate noises such as ink leakage, pause and the like in a handwritten sample obtained by true human handwriting. Optionally, the local area and the area surrounded by the bounding box are processed in a rectangular state, which is an exemplary illustration, and in the actual processing process, the specific shape of the local area and the area surrounded by the bounding box is not limited.
Optionally, shielding, smearing, corroding and/or adjusting the illumination brightness with a certain probability are performed on a local area of each first target handwritten text to obtain at least one second target handwritten text.
In the above exemplary embodiment, for at least one first target handwritten text, performing data enhancement processing on a local area of each first target handwritten text to obtain at least one third target handwritten text; wherein, the local area is a random area on the first target handwritten text; and filtering the at least one third target handwritten text on the boundary of the local area to obtain at least one second target handwritten text. The method can better simulate the noises such as ink leakage, pause and the like in the handwriting sample obtained by the real person, so that the first target handwriting text is more in line with the handwriting effect of the real person and is more vivid.
In one embodiment, as shown in fig. 5, it is a flowchart of an implementable method of step S420, including:
in step S421, the local region is expanded based on the boundary of the local region to obtain a global local region.
Step S422, in the universal local area, the pixel gradient is counted, and filtering is performed according to the pixel gradient to obtain at least one second target handwritten text.
Specifically, the local region is expanded with the boundary of the local region as a reference, and a global local region having an area larger than the corresponding local region and surrounding the local region is obtained. And in the pan local area, counting pixel gradients, filtering according to the pixel gradients, tiling the gradient values into each pixel in the range, and performing mean-like filtering to obtain at least one second target handwritten text.
In the above embodiment, the local region is expanded by using the boundary of the local region as a reference, so as to obtain a global local region; and in the pan local area, counting pixel gradients, and filtering according to the pixel gradients to obtain at least one second target handwritten text. The sharpness of the local area after local enhancement processing can be reduced, the pixels of the local area are smoother, noises such as ink leakage and pause in a handwriting sample obtained by handwriting of a real person can be better simulated, the first handwriting sample is more in accordance with the handwriting effect of the real person, and the first handwriting sample is more vivid.
In one embodiment, the method after step S500 may be implemented, wherein rendering at least one second target handwritten text into a target background picture, and obtaining a handwriting sample includes:
and carrying out overall data enhancement processing on the handwriting sample to obtain the handwriting sample of the updater.
Specifically, after at least one second target handwritten text is rendered into the target background picture to obtain a handwritten sample, data enhancement, such as blocking, lighting, and the like, is performed on the whole obtained handwritten sample (which is not limited to the area containing the second target handwritten text) to simulate different conditions of the background picture.
In the above embodiment, the handwriting sample is subjected to data enhancement to simulate different conditions of the background picture, such as wrinkles, stains and the like, so that the handwriting sample is more in line with the effect of real person handwriting and is more vivid.
In a specific embodiment, the handwriting sample generation method may be generated as follows:
step 1, acquiring required linguistic data (linguistic data information), such as ancient poems, celebrity names, worship and other contents needing handwriting, and also can be the amount, name and the like of bills. And 2, selecting a certain probability to be generated by the conventional handwritten font or to be formed by selecting and splicing individual Chinese characters from a single character handwriting library. And 3, selecting a reasonable background according to the linguistic data, wherein the background possibly appearing in ancient poems is paper with a grain, the background possibly appearing in Chinese names and numbers is a bill, and the background possibly appearing in place names and famous languages is a natural scene. Depth estimation is performed on the selected background through an algorithm to facilitate generation of text more realistic. And 4, performing certain data enhancement on the text part, such as blurring, deformation, salt and pepper noise addition, elastic transformation, occlusion addition and the like, and rendering and pasting the text part to a designated area on the background picture. And 5, performing integral data enhancement, integral Gaussian blur, illumination brightness adjustment and the like on the image with the problem to form final sample data.
Specifically, regarding step 1, a corpus needs to be generated, which is described by taking a chinese corpus as an example, and the chinese corpus aggregates different types of chinese corpora, such as an ancient poetry thesaurus, a worship blessing thesaurus, a chinese surname thesaurus, a chinese place name thesaurus, a celebrity name thesaurus, and the like in different dynasties.
As for step 2, specifically, it may be: if the handwritten font is generated, whether the character exists in the handwritten font library or not needs to be judged, and if the character does not exist in the handwritten font library, a new font library needs to be replaced. Here, the reason why the method of generating characters by gan is not suitable is that gan cannot stably ensure that the generated handwriting is correctly written, and the text in the font library can be rendered on the background image directly by using a rendering processing tool such as pygame. If the single character font library is used for generation, the following operations are required to be carried out on the single character: the size of the randomly selected single-word sample is calibrated to a specified size, for example, the word size is required to be 12 pixels high, and the picture resize is required to be 12 x (w/(12/h)). Then, single character cutout is carried out, and a character area and a background area need to be distinguished; after the background and text regions are judged, 100% transparency is added to the background portion, so that the background region no longer exists in the generated sample. And after certain data enhancement is carried out on the text area, the text area is pasted into a prepared background picture, and the position of the text in the background picture is recorded. Given that handwritten fonts may not be regularly lined, a certain offset of position is required here.
The single character library refers to an image without a color background formed by a single handwritten font. Optionally, a handwriting library corresponding to chinese: CASIA Online and Offline Chinese Handwriting Databases http:// www.nlpr.ia.ac.cn/Databases/Handwriting/Home. html, English corresponding Handwriting libraries: emnisthttps:// www.nist.gov/itl/products-and-services/emnist-dataset. These data sets originally function as training and testing sets for recognizing handwritten individual characters, each individual character having a certain number of different handwritten sets of black and white characters. The method is used as a single-character font library, and any one element in the character set is randomly extracted to be used as the current rendering font according to the corpus each time, so that the defects and the singularity of the handwriting font library are effectively reduced. Thousands of handwritten text sets of different styles can be formed according to different combinations.
For step 3, because the backgrounds of different corpora have certain differences, the background class of the corpora can be determined according to the classification when preparing the corpora, and then a random background is selected from the background class. In order to make the result more realistic, we record the depth information of the background, and perform mapping according to the depth information, for example, when the same block is rendered by mapping, the deeper part will contain relatively smaller writing, and even because of the drastic change of depth, certain deformation conforming to the rule will be generated. Alternatively, assuming that d (i, j) represents the depth of the pixel point (i, j), a certain rectangular region R is selected as Rect (i, j, w, h), and the font height hf is alpha/dave, where dave is the average depth of the rectangular region R, alpha is a coefficient, and the rendering start position of the word is in any region in R.
Regarding step 4, considering the irregularity of the handwritten text, a method of taking random numbers for each parameter generated by the text under certain constraint conditions is adopted here. For example, for the generation of the font size, the position of the font (horizontal row, vertical row, whether curvature exists) is somewhat random. And adding certain data enhancement such as Gaussian blur, salt and pepper noise, elastic transformation and unclear simulation handwriting to the generated characters. Alternatively, elastic transformation may also be used. The elastic transformation is local radioactive transformation, so that the canvas can generate random distortion, diffusion and other deformations, and the irregularity of the handwriting in the real environment can be well simulated. The method can well simulate possible noises such as ink leakage, pause and the like of the handwriting. In addition, local regions are selected with certain probability for local data enhancement.
The algorithm for font curvature generation is as follows: and generating a curve at the position y ═ f (x), and then starting from the starting point of the curve to render one by one. The bounding box of each word is recorded, and the corresponding curve position of the farthest x-axis coordinate + space size of the bounding box of the word is the rendering coordinate of the next word.
For data enhancement of each word, the data enhancement steps are generated locally herein as follows: firstly, randomly selecting any area W H smaller than the font size, namely if the character size W H and the character position (I, J), selecting an area R (I, J, W, H), and according to the constraint I < I < I + W-W, J < J < J + H-H, W < W, H < H and random variables I, J, W, H. And shielding, smearing and corroding the area with certain probability, adjusting the illumination brightness and the like. Then, in order to make the part not excessively abrupt in the whole, 672C text is fused on the w × h boundary, i.e. the gradient of the pixel is calculated, and then the gradient value is tiled into each pixel in a certain range, and the operation of mean-like filtering is performed. Thereby enhancing the authenticity of the generated text.
Regarding step 5, after the text is rendered on the background, data enhancement such as shading, lighting, etc. is performed on the text and the background to simulate different conditions of the paper instead of the single-word condition. The data enhancement of step 5 is an operation performed on the entire picture, and the font generation area is not emphasized. Simulating old folds of paper and so on for a range of possible variations. Finally, the generated text samples are obtained, different random combinations are performed, different transformation and deformation are performed on the character body, and the state of thousands of handwritten characters can be simulated. Thereby generating millions of handwritten text data.
In one embodiment, as shown in fig. 6, there is provided a handwriting sample generation apparatus including: a corpus information obtaining module 601, a first target handwritten text obtaining module 602, a background picture obtaining module 603, a second target handwritten text determining module 604 and a handwritten sample generating module 605, wherein:
the corpus information acquiring module 601 is configured to acquire corpus information of a sample to be generated;
a first target handwritten text acquisition module 602, configured to select, according to text information carried in the corpus information, at least one first target handwritten text corresponding to the text information from a preset handwritten text library;
a background picture obtaining module 603, configured to obtain a corresponding target background picture according to the text information carried in the corpus information;
a second target handwritten text determination module 604, configured to perform data enhancement processing on at least one first target handwritten text to obtain at least one corresponding second target handwritten text;
and a handwriting sample generating module 605, configured to render at least one second target handwritten text into the target background picture, so as to obtain a handwriting sample.
In one embodiment, the text information comprises at least one text to be generated; the first target handwritten text acquisition module 602 is further configured to search at least one target handwritten text set corresponding to at least one text to be generated from the handwritten text library; and randomly selecting a target handwritten text from at least one target handwritten text set to obtain at least one first target handwritten text.
In one embodiment, the background picture obtaining module 603 is further configured to obtain a classification corresponding to the text information; obtaining a background class corresponding to the category according to the corresponding category of the text information; and randomly selecting from the background class to obtain a target background picture.
In one embodiment, the apparatus further includes a size adjustment module, configured to adjust a size of the at least one first target handwritten text under a constraint condition that a preset font size in the text information is used as a reference and the depth of the target background picture is in an inverse proportional relationship, so as to obtain the updated at least one first target handwritten text.
In one embodiment, the size adjustment module is further configured to randomly adjust the size of the at least one first target handwritten text within a preset range, so as to obtain the updated at least one first target handwritten text.
In one embodiment, the second target handwritten text determination module 604 is further configured to perform gaussian blurring, salt and pepper noise, elastic transformation, and/or local area data enhancement on at least one first target handwritten text to obtain at least one second target handwritten text.
In one embodiment, the second target handwritten text determination module 604 is further configured to perform curvature transformation on the position of the at least one first target handwritten text, so as to obtain at least one updated second target handwritten text.
In one embodiment, the second target handwritten text determination module 604 is further configured to perform, on at least one first target handwritten text, data enhancement processing on a local area of each first target handwritten text to obtain at least one third target handwritten text; wherein, the local area is a random area on the first target handwritten text; and filtering the at least one third target handwritten text on the boundary of the local area to obtain at least one second target handwritten text.
In one embodiment, the second target handwritten text determination module 604 is further configured to expand the local area by using the boundary of the local area as a reference, so as to obtain a global local area; and in the pan local area, counting pixel gradients, and filtering according to the pixel gradients to obtain at least one second target handwritten text.
In one embodiment, the second target handwritten text determination module 604 is further configured to perform occlusion, smearing, erosion, and/or illumination brightness adjustment on a local area of each first target handwritten text with a certain probability to obtain at least one second target handwritten text.
In one embodiment, the apparatus further includes a handwriting sample updating module, configured to perform overall data enhancement processing on the handwriting sample to obtain an updated handwriting sample of the hand.
For specific limitations of the handwriting sample generation apparatus, reference may be made to the above limitations of the handwriting sample generation method, which are not described herein again. The modules in the handwritten sample generation apparatus may be implemented in whole or in part by software, hardware, and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 7. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of handwriting sample generation. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
obtaining corpus information of a sample to be generated;
selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library according to the text information carried in the corpus information;
acquiring a corresponding target background picture according to text information carried in the corpus information;
performing data enhancement processing on at least one first target handwritten text to obtain at least one corresponding second target handwritten text;
and rendering at least one second target handwritten text into a target background picture to obtain a handwritten sample.
In one embodiment, the text information comprises at least one text to be generated; the processor, when executing the computer program, further performs the steps of: searching at least one target handwritten text set corresponding to at least one text to be generated from a handwritten text library; and randomly selecting a target handwritten text from at least one target handwritten text set to obtain at least one first target handwritten text.
In one embodiment, the processor, when executing the computer program, further performs the steps of: obtaining a classification corresponding to the text information; obtaining a background class corresponding to the category according to the corresponding category of the text information; and randomly selecting from the background class to obtain a target background picture.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and taking a preset word size in the text information as a reference, and adjusting the size of at least one first target handwritten text under the constraint condition that the preset word size is in an inverse proportional relation with the depth of the target background picture to obtain the updated at least one first target handwritten text.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and randomly adjusting the size of the at least one first target handwritten text within a preset range to obtain the updated at least one first target handwritten text.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and performing Gaussian blur, salt-and-pepper noise, elastic transformation and/or local area data enhancement processing on the at least one first target handwritten text to obtain at least one second target handwritten text.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and performing curvature transformation on the position of the at least one first target handwritten text to obtain at least one updated second target handwritten text.
In one embodiment, the processor, when executing the computer program, further performs the steps of: for at least one first target handwritten text, performing data enhancement processing on a local area of each first target handwritten text to obtain at least one third target handwritten text; wherein, the local area is a random area on the first target handwritten text; and filtering the at least one third target handwritten text on the boundary of the local area to obtain at least one second target handwritten text.
In one embodiment, the processor, when executing the computer program, further performs the steps of: expanding the local area by taking the boundary of the local area as a reference to obtain a universal local area; and in the pan local area, counting pixel gradients, and filtering according to the pixel gradients to obtain at least one second target handwritten text.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and (3) shielding, smearing, corroding and/or adjusting the illumination brightness at a certain probability in a local area of each first target handwritten text to obtain at least one second target handwritten text.
In one embodiment, the processor, when executing the computer program, further performs the steps of: and carrying out overall data enhancement processing on the handwriting sample to obtain the handwriting sample of the updater.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
obtaining corpus information of a sample to be generated;
selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library according to the text information carried in the corpus information;
acquiring a corresponding target background picture according to text information carried in the corpus information;
performing data enhancement processing on at least one first target handwritten text to obtain at least one corresponding second target handwritten text;
and rendering at least one second target handwritten text into a target background picture to obtain a handwritten sample.
In one embodiment, the text information comprises at least one text to be generated; the computer program when executed by the processor further realizes the steps of: searching at least one target handwritten text set corresponding to at least one text to be generated from a handwritten text library; and randomly selecting a target handwritten text from at least one target handwritten text set to obtain at least one first target handwritten text.
In one embodiment, the computer program when executed by the processor further performs the steps of: obtaining a classification corresponding to the text information; obtaining a background class corresponding to the category according to the corresponding category of the text information; and randomly selecting from the background class to obtain a target background picture.
In one embodiment, the computer program when executed by the processor further performs the steps of: and taking a preset word size in the text information as a reference, and adjusting the size of at least one first target handwritten text under the constraint condition that the preset word size is in an inverse proportional relation with the depth of the target background picture to obtain the updated at least one first target handwritten text.
In one embodiment, the computer program when executed by the processor further performs the steps of: and randomly adjusting the size of the at least one first target handwritten text within a preset range to obtain the updated at least one first target handwritten text.
In one embodiment, the computer program when executed by the processor further performs the steps of: and performing Gaussian blur, salt-and-pepper noise, elastic transformation and/or local area data enhancement processing on the at least one first target handwritten text to obtain at least one second target handwritten text.
In one embodiment, the computer program when executed by the processor further performs the steps of: and performing curvature transformation on the position of the at least one first target handwritten text to obtain at least one updated second target handwritten text.
In one embodiment, the computer program when executed by the processor further performs the steps of: for at least one first target handwritten text, performing data enhancement processing on a local area of each first target handwritten text to obtain at least one third target handwritten text; wherein, the local area is a random area on the first target handwritten text; and filtering the at least one third target handwritten text on the boundary of the local area to obtain at least one second target handwritten text.
In one embodiment, the computer program when executed by the processor further performs the steps of: expanding the local area by taking the boundary of the local area as a reference to obtain a universal local area; and in the pan local area, counting pixel gradients, and filtering according to the pixel gradients to obtain at least one second target handwritten text.
In one embodiment, the computer program when executed by the processor further performs the steps of: and (3) shielding, smearing, corroding and/or adjusting the illumination brightness at a certain probability in a local area of each first target handwritten text to obtain at least one second target handwritten text.
In one embodiment, the computer program when executed by the processor further performs the steps of: and carrying out overall data enhancement processing on the handwriting sample to obtain the handwriting sample of the updater.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (14)
1. A method for generating handwritten samples, the method comprising:
obtaining corpus information of a sample to be generated;
selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library according to the text information carried in the corpus information;
acquiring a corresponding target background picture according to the text information carried in the corpus information;
performing data enhancement processing on the at least one first target handwritten text to obtain at least one corresponding second target handwritten text;
rendering the at least one second target handwritten text to the target background picture to obtain a handwritten sample.
2. The method according to claim 1, wherein the text information comprises at least one text to be generated;
the selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library comprises:
searching at least one target handwritten text set corresponding to the at least one text to be generated from the handwritten text library;
and randomly selecting a target handwritten text from the at least one target handwritten text set to obtain the at least one first target handwritten text.
3. The method according to claim 1, wherein obtaining a corresponding target background picture according to text information carried in the corpus information comprises:
obtaining a classification corresponding to the text information;
obtaining a background class corresponding to the category according to the category corresponding to the text information;
and randomly selecting the background class to obtain a target background picture.
4. The method of claim 1, wherein before performing data enhancement processing on the at least one first target handwritten text to obtain at least one corresponding second target handwritten text, the method comprises:
and taking a preset word size in the text information as a reference, and adjusting the size of the at least one first target handwritten text under the constraint condition that the preset word size is in an inverse proportional relation with the depth of the target background picture to obtain the updated at least one first target handwritten text.
5. The method according to claim 4, wherein the adjusting the size of the at least one first target handwritten text under a constraint condition that a preset font size in the text information is taken as a reference and the target background picture is in an inverse proportional relation with a depth of the target background picture, and after obtaining the updated at least one first target handwritten text, comprises:
and randomly adjusting the size of the at least one first target handwritten text within a preset range to obtain the updated at least one first target handwritten text.
6. The method of claim 1, wherein the performing data enhancement processing on the at least one first target handwritten text to obtain at least one corresponding second target handwritten text comprises:
and performing Gaussian blur, salt-and-pepper noise, elastic transformation and/or local area data enhancement processing on at least one first target handwritten text to obtain at least one second target handwritten text.
7. The method of claim 6, wherein the performing data enhancement processing on the at least one first target handwritten text to obtain at least one corresponding second target handwritten text, further comprises:
and performing curvature transformation on the position of the at least one first target handwritten text to obtain at least one updated second target handwritten text.
8. The method of claim 6, wherein the local area data enhancement process comprises:
for the at least one first target handwritten text, performing data enhancement processing on a local area of each first target handwritten text to obtain at least one third target handwritten text; wherein the local area is a random area on the first target handwritten text;
and filtering the at least one third target handwritten text on the boundary of the local area to obtain the at least one second target handwritten text.
9. The method of claim 8, wherein the filtering on the boundary of the local area to obtain the at least one second target handwritten text comprises:
expanding the local area by taking the boundary of the local area as a reference to obtain a universal local area;
and in the pan local area, counting pixel gradients, and filtering according to the pixel gradients to obtain the at least one second target handwritten text.
10. The method of any of claim 8, wherein performing data enhancement processing on the local area of each first target handwritten text further comprises:
and (3) shielding, smearing, corroding and/or adjusting the illumination brightness at a certain probability in a local area of each first target handwritten text to obtain the at least one second target handwritten text.
11. The method of claim 1, wherein rendering the at least one second target handwritten text into the target background picture after obtaining the handwritten sample comprises:
and carrying out overall data enhancement processing on the handwriting sample to obtain a handwriting sample of the updater.
12. An apparatus for generating handwritten samples, said apparatus comprising:
the corpus information acquisition module is used for acquiring corpus information of a sample to be generated;
the first target handwritten text acquisition module is used for selecting at least one first target handwritten text corresponding to the text information from a preset handwritten text library according to the text information carried in the corpus information;
the background picture acquisition module is used for acquiring a corresponding target background picture according to the text information carried in the corpus information;
the second target handwritten text determination module is used for performing data enhancement processing on the at least one first target handwritten text to obtain at least one corresponding second target handwritten text;
and the handwriting sample generation module is used for rendering the at least one second target handwritten text into the target background picture to obtain a handwriting sample.
13. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 11 when executing the computer program.
14. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 11.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010273099.8A CN111612871A (en) | 2020-04-09 | 2020-04-09 | Handwritten sample generation method and device, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010273099.8A CN111612871A (en) | 2020-04-09 | 2020-04-09 | Handwritten sample generation method and device, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111612871A true CN111612871A (en) | 2020-09-01 |
Family
ID=72199350
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010273099.8A Pending CN111612871A (en) | 2020-04-09 | 2020-04-09 | Handwritten sample generation method and device, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111612871A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112990205A (en) * | 2021-05-11 | 2021-06-18 | 创新奇智(北京)科技有限公司 | Method and device for generating handwritten character sample, electronic equipment and storage medium |
CN113065432A (en) * | 2021-03-23 | 2021-07-02 | 内蒙古工业大学 | Handwritten Mongolian recognition method based on data enhancement and ECA-Net |
CN113095167A (en) * | 2021-03-25 | 2021-07-09 | 北京有竹居网络技术有限公司 | Image acquisition method, device and equipment |
CN114202762A (en) * | 2022-02-18 | 2022-03-18 | 城云科技(中国)有限公司 | Handwritten sample generation method and device and application |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110078191A1 (en) * | 2009-09-28 | 2011-03-31 | Xerox Corporation | Handwritten document categorizer and method of training |
CN109493400A (en) * | 2018-09-18 | 2019-03-19 | 平安科技(深圳)有限公司 | Handwriting samples generation method, device, computer equipment and storage medium |
CN109522975A (en) * | 2018-09-18 | 2019-03-26 | 平安科技(深圳)有限公司 | Handwriting samples generation method, device, computer equipment and storage medium |
CN110136225A (en) * | 2019-03-29 | 2019-08-16 | 北京旷视科技有限公司 | Generate the method, apparatus and computer storage medium of the sample of written printed data |
CN110347302A (en) * | 2018-04-04 | 2019-10-18 | 广州阿里巴巴文学信息技术有限公司 | A kind of display methods and device of e-book |
-
2020
- 2020-04-09 CN CN202010273099.8A patent/CN111612871A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110078191A1 (en) * | 2009-09-28 | 2011-03-31 | Xerox Corporation | Handwritten document categorizer and method of training |
CN110347302A (en) * | 2018-04-04 | 2019-10-18 | 广州阿里巴巴文学信息技术有限公司 | A kind of display methods and device of e-book |
CN109493400A (en) * | 2018-09-18 | 2019-03-19 | 平安科技(深圳)有限公司 | Handwriting samples generation method, device, computer equipment and storage medium |
CN109522975A (en) * | 2018-09-18 | 2019-03-26 | 平安科技(深圳)有限公司 | Handwriting samples generation method, device, computer equipment and storage medium |
CN110136225A (en) * | 2019-03-29 | 2019-08-16 | 北京旷视科技有限公司 | Generate the method, apparatus and computer storage medium of the sample of written printed data |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113065432A (en) * | 2021-03-23 | 2021-07-02 | 内蒙古工业大学 | Handwritten Mongolian recognition method based on data enhancement and ECA-Net |
CN113095167A (en) * | 2021-03-25 | 2021-07-09 | 北京有竹居网络技术有限公司 | Image acquisition method, device and equipment |
CN112990205A (en) * | 2021-05-11 | 2021-06-18 | 创新奇智(北京)科技有限公司 | Method and device for generating handwritten character sample, electronic equipment and storage medium |
CN112990205B (en) * | 2021-05-11 | 2021-11-02 | 创新奇智(北京)科技有限公司 | Method and device for generating handwritten character sample, electronic equipment and storage medium |
CN114202762A (en) * | 2022-02-18 | 2022-03-18 | 城云科技(中国)有限公司 | Handwritten sample generation method and device and application |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111612871A (en) | Handwritten sample generation method and device, computer equipment and storage medium | |
CN110163285B (en) | Ticket recognition training sample synthesis method and computer storage medium | |
JP4418044B2 (en) | Method for displaying characters in a digital font, method for defining characters in a digital font, and method for generating characters in a digital font | |
EP1832986A2 (en) | Automated document layout design | |
US20020076111A1 (en) | Method and apparatus for formatting OCR text | |
US8515176B1 (en) | Identification of text-block frames | |
JPH076214A (en) | Method for change of character at inside od image | |
CN106202086B (en) | Picture processing and obtaining method, device and system | |
JP2010279038A (en) | Method and system for electronic image real-time personalization | |
CN111310758A (en) | Text detection method and device, computer equipment and storage medium | |
CN111507330A (en) | Exercise recognition method and device, electronic equipment and storage medium | |
CN111563563B (en) | Method for enhancing combined data of handwriting recognition | |
US9734132B1 (en) | Alignment and reflow of displayed character images | |
CN112417899A (en) | Character translation method, device, computer equipment and storage medium | |
CN110136225B (en) | Method, apparatus and computer storage medium for generating a sample of written print data | |
JPH05242300A (en) | Method for processing document image | |
CN111680635A (en) | Text recognition method and device, electronic equipment and storage medium | |
CN113673294B (en) | Method, device, computer equipment and storage medium for extracting document key information | |
US10216993B2 (en) | Intelligent document elements harvest and presentation system and method | |
US11715317B1 (en) | Automatic generation of training data for hand-printed text recognition | |
CN113936187A (en) | Text image synthesis method and device, storage medium and electronic equipment | |
CN112465931B (en) | Image text erasing method, related equipment and readable storage medium | |
CN113591845A (en) | Multi-topic identification method and device and computer equipment | |
Lakhanpal et al. | Refining Text-to-Image Generation: Towards Accurate Training-Free Glyph-Enhanced Image Generation | |
CN114898375A (en) | Character detection model training method and component, text recognition method and component |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200901 |