Method, device, computer equipment and storage medium for synthesizing images containing text

By using the text annotation information of the template image and the differential evolution algorithm, multiple synthetic images are generated, which solves the problems of high manpower and material resources consumption and low accuracy when training text detection algorithms, and achieves efficient sample generation and improved detection accuracy.

CN115620319BActive Publication Date: 2025-10-03HANGZHOU HIKVISION SYST TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211410464.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-11
Publication Date
2025-10-03
Estimated Expiration
2042-11-11

AI Technical Summary

Technical Problem

Existing technologies require a large number of real image samples when training text detection algorithms, resulting in high consumption of manpower and material resources and low detection accuracy.

Method used

Through the text annotation information of the template image, the text filling parameters are predicted, and multiple synthetic images of the same type as the template image are generated. The differential evolution algorithm is used to optimize the text filling parameters, reduce manual annotation, and improve the authenticity and efficiency of the synthetic images.

Benefits of technology

The training sample size of the text detection algorithm is increased, the amount of manual annotation is reduced, and manpower and material resources are saved. The generated synthetic images are highly similar to the template images, meeting the needs of algorithm training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115620319B_ABST
    Figure CN115620319B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a method, apparatus, computer equipment and storage medium for synthesizing an image containing text. Based on the text annotation information of a template image, the text filling parameters of the template image are predicted, the text annotation information is used to indicate the original text and first attribute information of at least one field included in the template image, and the text filling parameters are used to indicate the content filling format of each field in the template image; synthetic text corresponding to each field in the template image is generated; according to the first attribute information and the text filling parameters, the synthetic text of each field is used in turn to replace the corresponding original text in the template image to obtain multiple synthetic images. In this method, the text filling parameters of the template image can be predicted by simply annotating the template image, which reduces the amount of manual annotation. Secondly, multiple synthetic images of the same type as the template image are generated by replacing the original text with synthetic text, thereby improving the efficiency of synthesizing images containing text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to a method, apparatus, computer device, and storage medium for synthesizing an image containing text. Background Art

[0002] In scenarios involving text detection, content recognition, and content analysis of images, trained text detection algorithms can effectively identify the text content in images, saving manpower and material resources.

[0003] To ensure recognition accuracy, a large number of sample images are needed to train the text detection algorithm in the early stage, and each character must appear a certain number of times in the sample images. Otherwise, the text detection algorithm may have low text detection accuracy after it is actually launched.

[0004] Based on this, there is an urgent need for a method that can simulate and generate image materials containing text to generate a large number of sample images to meet the training requirements of text detection algorithms for images containing text. Summary of the Invention

[0005] The embodiments of the present application provide a method, apparatus, computer device, and storage medium for synthesizing images containing text, which can quickly generate multiple synthetic images of the same type as the template image based on the text annotation information and text filling parameters of the template image.

[0006] In a first aspect, the present application provides a method for synthesizing an image containing text, the method comprising:

[0007] Predicting text filling parameters of the template image based on text annotation information of the template image; the text annotation information is used to indicate the original text and first attribute information of at least one field included in the template image, and the text filling parameters are used to indicate the content filling format of each field in the template image;

[0008] Generate synthetic text corresponding to each field in the template image;

[0009] According to the first attribute information and the text filling parameter, the corresponding original text is replaced in sequence with the synthesized text of each field in the template image to obtain a plurality of synthesized images.

[0010] In a second aspect, the present application provides a device for synthesizing an image containing text, the device comprising:

[0011] a parameter prediction module, configured to predict text filling parameters of the template image based on text annotation information of the template image; the text annotation information is configured to indicate original text and first attribute information of at least one field included in the template image, and the text filling parameters are configured to indicate a content filling format for each field in the template image;

[0012] A text generation module is used to generate synthetic text corresponding to each field in the template image;

[0013] The content replacement module is used to replace the corresponding original text with the synthetic text of each field in the template image in turn according to the first attribute information and the text filling parameter to obtain multiple synthetic images.

[0014] In a third aspect, the present application provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method for synthesizing an image containing text shown in the first aspect are implemented.

[0015] In a fourth aspect, the present application provides a computer storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for synthesizing an image containing text shown in the first aspect above.

[0016] In a fifth aspect, the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, it implements the steps of the method for synthesizing an image containing text shown in the first aspect above.

[0017] The technical solutions provided by the embodiments of the present application can achieve at least the following beneficial effects:

[0018] The present application provides a method, apparatus, computer device, and storage medium for synthesizing an image containing text. Based on the text annotation information of a template image, the method predicts the text filling parameters of the template image and generates synthesized text corresponding to each field in the template image. The text annotation information indicates the original text and first attribute information of at least one field included in the template image, and the text filling parameters indicate the content filling format of each field in the template image. Based on the first attribute information and the text filling parameters, the synthesized text of each field in the template image is sequentially replaced with the corresponding original text, resulting in multiple synthesized images. This method, firstly, considers that text parameters in images are relatively complex, manual annotation relies on experience, and has low annotation accuracy. Therefore, for any template image, the present application only requires simple annotation of the original text and first attribute information in the template image to predict the template image's text filling parameters based on the text annotation information. Thus, by predicting the template image's text filling parameters, rather than manually annotating the text filling parameters in the template image, the accuracy of the text filling parameters can be improved and the manual annotation effort can be reduced, saving significant manpower and material resources. Secondly, after determining the relevant parameters / information of the template image, multiple synthetic images of the same type as the template image can be generated by replacing the original text of each field in the template image with the synthetic text of each field, thereby improving the efficiency of synthesizing images containing text, so as to generate as many synthetic images as possible in a short time and meet the sample size requirements of algorithm training. Furthermore, since the multiple images are all based on the format of the template image and obtained by replacing the text content, the multiple synthetic images and the template image contain the same number of fields, and except for the text content, the first attribute information and text filling parameters of the multiple synthetic images and the template image are the same. In this way, the text content and format between the synthetic image and the real template image are more similar, thereby improving the authenticity of the synthetic image. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 This is a flowchart of a method for synthesizing an image containing text, shown in an exemplary embodiment of the present application;

[0020] Figure 2 1 is a schematic diagram of an area offset of a text filling area shown in an exemplary embodiment of the present application;

[0021] Figure 3 This is a flow chart of predicting text filling parameters according to an exemplary embodiment of the present application;

[0022] Figure 4 This is a schematic diagram of a process for obtaining an optimal field solution, shown in an exemplary embodiment of the present application;

[0023] Figure 5This is a schematic diagram of a field similarity calculation process shown in an exemplary embodiment of the present application;

[0024] Figure 6 This is a schematic diagram of a field similarity calculation process shown in an exemplary embodiment of the present application;

[0025] Figure 7 This is a schematic diagram of an individual variation processing flow chart shown in an exemplary embodiment of the present application;

[0026] Figure 8 is a structural diagram of an image synthesis device containing text, shown in an exemplary embodiment of the present application;

[0027] Figure 9 It is a structural diagram of a computer device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION

[0028] In order to make the purpose, technical solutions and advantages of this application more clear, the technical solutions of this application will be further described in detail below with reference to the accompanying drawings and embodiments.

[0029] Before explaining the method for synthesizing an image containing text provided in an embodiment of the present application, the application scenario of the embodiment of the present application is first introduced.

[0030] When performing text detection on images, in order to improve detection accuracy and detection speed, pre-trained text detection algorithms or neural network models with text detection functions are usually used to replace manual image recognition to obtain text information in the image.

[0031] However, before the text detection algorithm is put into use, it needs to be trained with a large number of sample images to improve the detection accuracy of the algorithm.

[0032] Based on this, the present application provides a method for synthesizing images containing text. Based on a small number of real images, the text annotation information of the pre-annotated template image is used to predict the text filling parameters of the template image, and then for the template image, text replacement is used to generate multiple virtual synthetic images similar to the template image to meet the training sample size requirements of the image text detection algorithm.

[0033] In an exemplary embodiment, the method for synthesizing an image containing text provided in the present application can be applied in a computer device or in a system consisting of at least two computer devices to implement the above method through information interaction between the devices.

[0034] In some embodiments, the computer device may be a terminal or a server. The terminal may be, but is not limited to, various personal computers, laptops, smartphones, tablet computers, portable wearable devices, etc.; the server may be, but is not limited to, at least one independent server, a distributed server, a cloud server, a server cluster, etc.

[0035] It should be noted that the embodiment of the present application provides a method for synthesizing an image containing text, and its execution subject can be any computer device or an image synthesis device containing text. The device can be implemented as part or all of the processor in the computer device through software, hardware, or a combination of software and hardware.

[0036] Next, the technical solutions of the embodiments of the present application and how the technical solutions of the embodiments of the present application solve the above-mentioned technical problems will be described in detail with reference to the accompanying drawings. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments; it is obvious that the described embodiments are only part of the embodiments of the present application, not all of them.

[0037] In an exemplary embodiment, Figure 1 As shown, an embodiment of the present application provides a method for synthesizing an image containing text, which is applied to a computer device. The method may include the following steps:

[0038] Step 110: Based on the text annotation information of the template image, predict the text filling parameters of the template image; the text annotation information is used to indicate the original text and first attribute information of at least one field included in the template image, and the text filling parameters are used to indicate the content filling format of each field in the template image.

[0039] It should be understood that a field is a variable associated with an object or class, and is used to describe a certain feature of the object / class. In the embodiment of the present application, a template image may include at least one field, and the content of each field is different.

[0040] As an example, the template image includes five fields, "A", "B", "C", "D" and "E", each field corresponds to a different original text to describe the characteristics / content of the field through the original text.

[0041] For example, the original text of the "A" field is "aa", the original text of the "B" field is "bb", the original text of the "C" field is "cc", the original text of the "D" field is "dd", and the original text of the "E" field is "ee".

[0042] Optionally, for a template image, the original text may be recognized by optical character recognition (OCR) technology. The implementation process may refer to related existing technologies and will not be described in detail here.

[0043] It should be noted that the above example only takes the template image including multiple fields as an example. In actual applications, the template image may also include only one field. The embodiment of the present application does not limit the number of fields included in the template image.

[0044] In some embodiments, for the template image, the first attribute information includes the text filling area and font color of each field, and the text filling parameters include the font type, font size and area offset of each field.

[0045] The first attribute information is information that is manually pre-marked. For example, a dotted frame is used to mark the text filling area of ​​each field, and the font color of each field is black.

[0046] It's worth emphasizing that the text fill area represents the maximum fillable area for each field. For the same field, different images contain different numbers of characters in the field information. Therefore, the actual area occupied by the original text within the annotated text fill area is different.

[0047] Based on this, it is necessary to further determine the text real area corresponding to the original text of each field in the template image. In a possible implementation, the text real area can be determined by using the text filling area and the area offset.

[0048] The area offset is used to describe information such as the rotation angle, translation amount, and size adjustment amount of the actual text area of ​​the original text of a field relative to the annotated text filling area.

[0049] As an example, see Figure 2 The text filling area can be represented by rect, rect = (x, y, w, h), where x and y are the horizontal and vertical coordinate values ​​of the upper left corner of the text filling area, and w and h are the width and height values ​​of the text filling area.

[0050] The region offset can be expressed as the offset scale of the four edge points of the text filling region. Specifically, region offset deviation = {(tlx, tly), (trx, try), (dlx, dly), (drx, dry)}; where (tlx, tly), (trx, try), (dlx, dly), (drx, dry) represent the offset scales of the top left, top right, bottom left, and bottom right points, respectively.

[0051] Among them, tlx is a coefficient, the actual offset pixel point is tlx*w, the actual offset pixel point of tly is tly*h, and the pixel point calculation method of other edge points is similar to this, which is not repeated here.

[0052] From the above introduction, it should be understood that for a template image, the fields, their original text, the field fill area, and the font color are all easy to annotate, requiring little manual experience and being easy to implement in practice. However, the font type, font size, and area offset of each field in the template image have specific formatting requirements, making manual annotation more difficult.

[0053] Therefore, for the template image, this application only needs to simply mark the original text, text filling area and font color of each field to obtain text annotation information. Then, based on the text annotation information, a corresponding computer algorithm is used to predict the text filling parameters in the template image that are more complex and difficult to directly mark.

[0054] The technical concept for predicting text filling parameters in this application is as follows: based on the original text of each field in the template image, a target image identical to the original text of each field in the template image is generated by combining a preset plurality of font types, a preset plurality of font colors, a preset plurality of font sizes, and a preset region offset adjustment step length and adjustment amount. Simultaneously, a standard field image for each field is obtained from the template image. Furthermore, by calculating the similarity between each field's standard field image and multiple target images, the target image with the highest similarity is determined for each field in the template image. Finally, the text filling parameters of the template image are determined by combining the parameters of the target image with the highest similarity corresponding to each field.

[0055] Based on this technical concept, an embodiment of the present application provides an adaptive template configuration parameter generation method based on a differential evolution algorithm to predict the text filling parameters of a template image based on text annotation information pre-annotated in the template image.

[0056] Next, the implementation process of obtaining text filling parameters by using an adaptive template configuration parameter generation method based on a differential evolution algorithm is described in detail.

[0057] In the exemplary embodiments of the present application, Figure 3 As shown, the implementation process of the above step 110 may include the following steps:

[0058] Step 410: Generate an initial population corresponding to the template image; the initial population includes multiple initial individuals, and each initial individual corresponds to a filling parameter solution of the template image, and each filling parameter solution includes a field parameter solution corresponding to each field in the template image.

[0059] The field parameter solution of each field is used to indicate the content filling format of the field.

[0060] In one possible implementation, the implementation process of the above-mentioned step 410 can be: for the text annotation information of at least one field included in the template image, based on preset multiple font types, preset multiple font sizes, and preset multiple area offset adjustment methods, randomly generate multiple filling parameter solutions for the template image; and construct an initial population of the template image based on the randomly generated multiple filling parameter solutions.

[0061] It should be understood that one template image corresponds to one initial population, and different template images correspond to different initial populations. It is necessary to use a preset random solution generation algorithm based on the text annotation information of each template image to generate the initial population of each template image in real time.

[0062] Theoretically, if the randomly generated initial individuals in the initial population have exhausted all filling parameter solutions, an optimal individual solution can be determined directly based on multiple initial individuals in the initial population; thus, the text filling parameters of the template image can be determined based on the field parameter solutions of each field in the optimal individual solution.

[0063] However, considering the large number of initial individuals generated and the large amount of similarity calculations required to obtain the optimal field parameter solution, this application adopts the idea of ​​a differential evolution algorithm. When generating the initial population, there is no need to generate initial individuals corresponding to all combinations based on a preset number of font types, a preset number of font sizes, and a preset number of regional offset adjustments. Instead, only a preset number of initial individuals need to be generated. In the subsequent process, if the optimal field solution for each field in the template image cannot be selected from the initial population, the initial population is evolved to generate better individuals, thereby selecting the optimal field solution for each field from the evolved individuals.

[0064] The number of initial individuals in the initial population may be any preset value, such as 10, 100, 200, etc., and this embodiment of the present application does not impose any limitation on this.

[0065] In this way, adopting the idea of ​​evolution can not only greatly reduce the amount of filling parameter solutions generated, but also speed up the acquisition of the optimal field solution, thereby improving the acquisition rate and parameter accuracy of the text filling parameters of the template image.

[0066] As an example, using the template image above, the initial individual's corresponding fill parameter solutions include the field parameter solutions for "A," "B," "C," "D," and "E." In other words, each initial individual's fill parameter solution includes five field parameter solutions.

[0067] Since the text filling parameters that need to be predicted include three values: font type, font size, and area offset, each field parameter solution includes three parameter values, namely font parameter, font size parameter, and offset parameter.

[0068] Step 420: Obtain the optimal field solution corresponding to each field in the template image from the field parameter solutions included in the multiple initial individuals.

[0069] It should be understood that if the initial number of individuals is 10, and taking the above template image as an example, the filling parameter solution corresponding to each initial individual includes 5 field parameter solutions, then the purpose of step 420 is to obtain the optimal field solution corresponding to each field (A, B, C, D, E) in the template image from the 50 (i.e., 10*5) field parameter solutions in the initial population.

[0070] In one possible implementation, Figure 4 As shown, the implementation process of step 420 includes the following steps:

[0071] Step 421: Calculate the field similarity between each field in the template image and the field parameter solutions included in the multiple initial individuals to obtain multiple field similarities corresponding to each field.

[0072] For any field in the template image, there is a corresponding field parameter solution in each initial individual. Therefore, the number of field similarities corresponding to each field calculated in step 421 is the same as the number of initial individuals in the initial population.

[0073] As an example, if there are 10 initial individuals in the initial population, then for a field in the template image, after performing the operation of step 421 , 10 field similarities corresponding to the field can be obtained.

[0074] In some embodiments, such as Figure 5 As shown, the implementation process of step 421 may include the following steps:

[0075] Step 4211: Generate target images of field parameter solutions corresponding to the target field in multiple initial individuals.

[0076] The target field is any field in the template image, and the target field corresponds to a field parameter solution in an initial individual.

[0077] That is, for each field included in the template image, steps 4211 to 4213 need to be executed to determine the field similarity between each field and the corresponding field parameter solutions in multiple initial individuals, and obtain multiple field similarities corresponding to each field.

[0078] For the target field, each initial individual corresponds to a field parameter solution, and each field parameter solution includes font parameters, font size parameters, and offset parameters. Therefore, for the target field, the number of target images that need to be generated is the same as the number of initial individuals.

[0079] Specifically, the implementation process of generating the target image can be: based on the text filling area of ​​the target field in the template image, generate the initial image corresponding to each field parameter solution; based on the font parameters and font size parameters in each field parameter solution, add the original text of the target field on the corresponding initial image to obtain the intermediate image corresponding to each field parameter solution; based on the offset parameters in each field parameter solution, perform a projection transformation on the corresponding intermediate image to obtain the target image corresponding to each field parameter solution.

[0080] It should be noted that, in order to facilitate the comparison of similarity, the pixel values ​​of the original text in the initial image and the intermediate image are different.

[0081] As an example, an image with all pixel values ​​0 can be generated based on the text-filled area as the initial image. Then, based on the original text, font parameters, and font size parameters of the target field, text information is added to the initial image and the pixel values ​​of the text are set to 1 to distinguish it from the background, resulting in an intermediate image.

[0082] For the same original text, due to different font parameters and / or font size parameters, the corresponding real text area is different. In order to ensure that the text information can be completely filled into the annotated text filling area and avoid pixel overflow, the intermediate image needs to be projected to obtain the target image.

[0083] Among them, projection transformation is the process of transforming the coordinates of one map projection point into the coordinates of another map projection point, which may involve scaling processing, translation processing, rotation processing, etc., which will not be repeated here.

[0084] Step 4212: Obtain the standard field image of the target field from the template image.

[0085] Specifically, according to the text-filled area of ​​each field manually marked in the template image, the standard field image corresponding to each field is intercepted from the template image.

[0086] That is, for a template image, the number of corresponding standard field images is the same as the number of fields included in the template image.

[0087] Taking the above template image as an example, if the target field is the "A" field, the obtained standard field image is a regional image composed of all pixel points corresponding to "aa".

[0088] It should be noted that steps 4211 and 4212 can be executed simultaneously or sequentially. When executed sequentially, multiple target images corresponding to the target field can be generated first, and then the standard field image of the target field can be obtained; or the standard field image of the target field can be obtained first, and then multiple target images corresponding to the target field can be generated. The embodiments of the present application do not limit this.

[0089] Step 4213: Determine the field similarity between the target field and the corresponding multiple field parameter solutions based on the accumulated amount of overlapping pixels between the standard field image and the target images of each field parameter solution.

[0090] In this step, for the target field, it corresponds to one standard field image and multiple target images, and the similarity between the standard field image and each target image needs to be calculated in sequence. Therefore, after the similarity calculation, one field corresponds to multiple field similarities.

[0091] It should be noted that the original text of the target field may include at least one character. When calculating the field similarity between the standard field image and a certain target image in the present application, the accumulated amount of overlapping pixels of each character in the target field is calculated to determine the field similarity between the target field and the field parameter solution corresponding to the target image.

[0092] Taking the above template image as an example again, if the target field is the "occupation" field, then as Figure 6 shown, the standard field image is the region image composed of all pixel points corresponding to the two characters "writer" in the template image. Assuming that the initial population corresponds to 10 initial individuals, then there are field parameter solutions for the "occupation" field in the filling parameter solutions corresponding to each initial individual. According to the 10 field parameter solutions of the "occupation" field, 10 target images can be generated.

[0093] It should be understood that among these 10 target images, at least one parameter in the font type, font size, and regional offset of the two characters "writer" is different.

[0094] Continue to refer to Figure 6 , for the standard field image of the "writer" field and the first target image, calculate the number of overlapping pixels of the first character "zuo" in the standard image and the character "zuo" in the target image, and at the same time, calculate the number of overlapping pixels of the second character "jia" in the standard image and the character "jia" in the target image; then sum the number of overlapping pixels of the first character and the number of overlapping pixels of the second character to obtain the accumulated amount of overlapping pixels between the standard field image and the target image under the "occupation" field.

[0095] Optionally, since the target image is also generated based on the text-filled area, the image sizes of the standard field image and the target image are the same, so the standard field image and the target image can be superimposed, and then the number of overlapping pixels of each character in the superimposed image can be counted to obtain the cumulative amount of overlapping pixels between the standard field image and each target image.

[0096] Among them, the greater the accumulated amount of overlapping pixels, the higher the field similarity between the standard field image and the target image.

[0097] Therefore, after the accumulated amount of overlapping pixels is calculated, the field similarity between each field in the template image and the corresponding multiple field parameter solutions can be determined based on the preset conversion relationship between the pixel amount and the similarity.

[0098] Step 422: According to the multiple field similarities corresponding to each field, a candidate field solution for each field is obtained from the field parameter solutions corresponding to each field in multiple initial individuals.

[0099] Among them, each field in the template image corresponds to multiple field similarities, and each field similarity corresponds to a field parameter solution.

[0100] In an embodiment of the present application, for any field, multiple field similarities are sorted from large to small based on the field similarity between the field and multiple field parameter solutions; and then the candidate field solution of the field is determined based on a preset number of field parameter solutions ranked at the front in terms of similarity.

[0101] As an example, the preset number may be 1, and a field parameter solution in the initial population that has the highest field similarity with each field is determined as a candidate field solution corresponding to each field.

[0102] As another example, the preset number can also be 2, 3, 4, etc., that is, for each field in the template image, at least two field parameter solutions with high similarity between each field are determined from the initial population, and then the candidate field solution is determined from the at least two field parameter solutions corresponding to each field.

[0103] It should be noted that if the number of initial individuals in the initial population is large, almost all possible parameter combinations have been listed; or based on the initial population, the candidate field solutions of each field determined can already well describe the true parameters of each field in the template image, then the candidate field solutions are directly determined as the optimal field solutions without executing the following steps 423 and 424.

[0104] Optionally, a similarity threshold can be set in advance. If the field similarity between each field in the template image and its corresponding candidate field solution in the multiple initial individuals included in the initial population meets the similarity threshold, the candidate field solution of each field is directly determined as the optimal field solution corresponding to each field.

[0105] The similarity threshold is any pre-set value, such as 90%, 95%, 98%, etc., and this embodiment of the present application does not impose any limitation on this.

[0106] If the number of randomly generated initial individuals is limited, the candidate field solutions for each field may not accurately describe the actual format of the original text in each field in the template image. Therefore, it is necessary to evolve the initial population one or more times through the following step 423 to obtain the optimal field solution for each field from the evolved target individuals.

[0107] Step 423: Based on the candidate field solutions of each field, multiple initial individuals are mutated until the individual mutation processing results meet the preset population evolution end conditions, thereby obtaining multiple target individuals.

[0108] It should be understood that by performing a mutation process on multiple initial individuals once, the initial population has evolved once; by continuing to perform mutation processes on the evolved individuals, the initial population has evolved twice. Similarly, one population evolution is performed by performing a mutation process on each individual in the population after the previous evolution.

[0109] In this step, the target individual can be an individual after one population evolution or multiple population evolutions, depending on whether the individual mutation processing result meets the preset population evolution end condition.

[0110] The preset population evolution termination conditions include any of the following:

[0111] (1) The number of individual mutations reaches the preset number of population evolutions;

[0112] Specifically, during the individual variation processing, the number of individual variations in the population is counted; if the number of individual variations reaches the preset number of population evolutions, the population evolution operation is terminated to obtain multiple target individuals.

[0113] As an example, the number of population evolutions may be any preset value, such as 5 rounds, 10 rounds, 50 rounds, and the like.

[0114] (2) The candidate field solutions of each field do not change within the preset number of mutation processing times.

[0115] Specifically, a candidate field solution for each field is obtained after each mutation process; if the candidate field solution for each field does not change within a preset number of mutation processes, the population evolution operation is terminated to obtain multiple target individuals.

[0116] As an example, the preset number of mutation processing times may be any value less than the number of population evolution times, such as 3 times, 5 times, 10 times, etc.

[0117] That is, under this condition, if the candidate field solutions of each field can no longer be further optimized within the number of mutation processing times, the evolution operation can be terminated early.

[0118] Optionally, the population evolution operation may be terminated in advance when the candidate field solutions of a preset proportion of fields do not change within a preset number of mutation processing times.

[0119] Taking the above template image as an example, if the candidate field solutions of at least 3 fields among the 5 fields do not change within the preset number of mutations, the population evolution operation can also be terminated early.

[0120] Further, if Figure 7 As shown, when performing mutation processing on multiple initial individuals in the above step 423, the implementation process may include the following steps:

[0121] Step 4231: Using a preset first mutation strategy, mutate the candidate field solutions of each field in the field parameter solutions included in multiple initial individuals to obtain a first mutation vector corresponding to the candidate field solution.

[0122] It should be noted that, among the multiple initial individuals, the filling parameter solution corresponding to each initial individual includes the field parameter solution corresponding to each field in the template image. In other words, an initial individual contains multiple field parameter solutions, and the number of its field parameter solutions is the same as the number of fields contained in the template image.

[0123] For the field parameter solution contained in an initial individual, there may be the following situations:

[0124] (1) The field parameter solutions of the initial individual include the candidate field solutions of each field in the template image, that is, the field parameter solutions in the initial individual are all candidate field solutions;

[0125] (2) The field parameter solutions of the initial individual contain candidate field solutions for at least one field in the template image, as well as non-candidate field solutions for other fields. That is, the field parameter solutions in the initial individual include both candidate field solutions and non-candidate field solutions.

[0126] (3) The field parameter solutions of the initial individuals do not contain candidate field solutions for any field in the template image, that is, the field parameter solutions in the initial individuals are all non-candidate field solutions.

[0127] Based on this, for the above situation (1), the initial individual is mutated through step 4231; for the above situation (2), the initial individual is mutated through steps 4231 and 4232; for the above situation (3), the initial individual is mutated through step 4232.

[0128] Furthermore, considering that the font size, font type, and region offset of different fields in a document image may be the same, the rand / 1 mutation strategy can be selected for the candidate field solutions in the initial individual. That is, the first mutation strategy in step 4231 can be the rand / 1 mutation strategy.

[0129] Specifically, for multiple fields in the template image, three initial individuals Xp1(g), Xp2(g) and Xp3(g) are randomly selected from the initial individuals where the candidate field solutions of each field are located, and the first mutation vector H of the candidate field solution is calculated by the following formula (1): i1 (g):

[0130] H i1 (g)=Xp1(g)+F*(Xp2(g)-Xp3(g)) (1)

[0131] Where F is the scaling factor parameter, which is generally between 0 and 2; for example, set F to 0.5.

[0132] Step 4232: Using the preset second mutation strategy, mutate the non-candidate field solutions of each field in the field parameter solutions included in the multiple initial individuals to obtain a second mutation vector corresponding to each non-candidate field solution.

[0133] The second mutation strategy may be a best / 1 mutation strategy.

[0134] Specifically, for any field in the template image, two initial individuals Xp4(g) and Xp5(g) are randomly selected from the initial population, and the second mutation vector H of the non-candidate field solution is calculated by the following formula (2): i2 (g):

[0135] H i2 (g)=Xbest(g)+F-(Xp4(g)-Xp5(g)) (2)

[0136] Where Xbest(g) is the candidate field solution for the field, and F is the scaling factor parameter, which generally takes a value between 0 and 2; for example, set F to 0.5.

[0137] Step 4233: For any initial individual in the initial population, the first mutation vector is cross-replaced with the corresponding candidate field solution, and / or the second mutation vector is cross-replaced with the corresponding non-candidate field solution to obtain multiple target individuals.

[0138] Among them, during the cross-replacement processing, the font size, font type and area offset deviation = {(tlx, tly), (trx, try), (dlx, dly), (drx, dry)} in the target individual are generated with a cross-probability between 0 and 1 to replace the field parameter solution in the initial individual.

[0139] It should be noted that the above 10 values ​​(font size, font type, tlx, tly, trx, try, dlx, dly, drx, dry) are calculated separately for crossover probability and replaced.

[0140] Optionally, a fixed replacement value random(j) is randomly selected from the above 10 values, and the parameter corresponding to the fixed replacement value random(j) will definitely be replaced. In this way, crossover can be guaranteed in the evolution result.

[0141] Step 424: Based on the target individual, determine the optimal field solution corresponding to each field in the template image.

[0142] It should be noted that the process of selecting the optimal field solution for each field from the target individual is similar to the process of selecting candidate field solutions for each field from the initial individual, both of which are achieved by calculating field similarity. Therefore, the implementation process of step 424 can be referred to above, steps 421 and 422, and will not be repeated here.

[0143] Step 430: Determine text filling parameters of the template image according to the optimal field solutions corresponding to the fields in the template image.

[0144] Specifically, the font type, font size, and area offset of each field in the template image are determined from the optimal field solution corresponding to each field, thereby obtaining the text filling parameters of the template image.

[0145] In the above-mentioned scheme for predicting text filling parameters, considering that text parameter information is relatively complex, manual annotation relies on experience, and has low annotation accuracy, for any template image, this application only needs to simply annotate the original text and first attribute information in the template image, and then predict the text filling parameters of the template image based on the text annotation information. In this way, by predicting the text filling parameters of the template image instead of manually annotating the text filling parameters in the template image, not only can the accuracy of the text filling parameters be improved, but the amount of manual annotation can also be reduced, saving a lot of manpower and material resources.

[0146] Furthermore, after determining the text filling parameters of the template image through the above steps 410 to 430 , multiple virtual images can be synthesized based on the template image according to the text filling parameters.

[0147] Step 120: Generate synthetic text corresponding to each field in the template image.

[0148] In one possible implementation, the implementation process of step 120 may be: determining the second attribute information of each field in the template image; obtaining the text synthesis strategy corresponding to each field based on the second attribute information of each field; and generating the synthesized text corresponding to each field in the template image according to the text synthesis strategy of each field.

[0149] Among them, the second attribute information is used for the fillable text of each field. The second attribute information may include field keywords or field feature information, such as name, surname, address / residence, license plate, mobile phone number, ID card number, date, etc.

[0150] In some embodiments, the text synthesis strategy includes the text content of the field and the content synthesis method; the content synthesis method can be a random combination.

[0151] As an example, for the second attribute information listed above, the text synthesis strategy of the field may include any of the following:

[0152] (1) Generate a random string of a certain length, and adjust the probability of each character appearing in the synthesized text according to the character frequency of the current synthesized text to ensure that the frequency distribution of each character in the synthesized text is relatively uniform.

[0153] (2) For the "address / residence" field, a synthetic text for this field is generated by randomly combining multiple address information in the address database;

[0154] (3) When the enumeration string is generated, a random string is returned from the enumeration string set;

[0155] (4) For the “license plate” field, a synthetic text for this field is generated by random combination based on the license plate style and available character strings;

[0156] (5) For the "number" field, a random combination of digits 0-9 is used to generate a string of data, and the last digit is randomly replaced with a preset character to generate the synthetic text corresponding to the field; or, a random combination of digits 0-9 is used to generate an array of preset digits to obtain the synthetic text of the field.

[0157] (6) For the "date" field, generate a date and time string in a common format to obtain the synthetic text of the field.

[0158] It should be understood that the purpose of step 120 is to generate virtual text content for each field according to the second attribute information of each field in the template image to obtain a synthesized text for each field. The content of the synthesized text is different from the content of the original text.

[0159] Based on this, after determining the text filling parameters and generating the corresponding synthetic text, it is only necessary to replace the original text in the template image with the synthetic text of at least one field according to the text filling parameters to obtain the synthetic image.

[0160] Step 130: According to the first attribute information and the text filling parameter, the corresponding original text is replaced in sequence with the synthesized text of each field in the template image to obtain multiple synthesized images.

[0161] The first attribute information includes the text filling area and font color of each field; the text filling parameters include at least one of the font type, font size and area offset of each field.

[0162] In one possible implementation, step 130 may be implemented by: generating a first field image corresponding to each field based on the text filling area of ​​each field; adding the field's synthetic text to the corresponding first field image based on the font color, font type, and font size of each field to obtain a second field image corresponding to each field; performing a projective transformation on the second field image corresponding to each field based on the area offset of each field to obtain a third field image corresponding to each field; and filling the character pixel values ​​in the third field image corresponding to each field into the text filling area of ​​each field in the template image.

[0163] It should be understood that the process of generating the third field image in step 130 is similar to the implementation process of generating the target image corresponding to the field parameter solution of the target field in the above step 4211. Therefore, the specific implementation process can be referred to the explanation and limitation of the above step 4211 and will not be repeated here.

[0164] In addition, when implementing step 130, the original text of all fields in the template image can be replaced to generate a composite image; the original text of at least one field in the template image can also be replaced to generate a composite image. This embodiment of the present application does not limit this.

[0165] In an embodiment of the present application, a computer device predicts text filling parameters for a template image based on text annotation information of a template image, and generates synthetic text corresponding to each field in the template image. The text annotation information indicates the original text and first attribute information of at least one field included in the template image, and the text filling parameters indicate the content filling format of each field in the template image. Then, based on the first attribute information and the text filling parameters, the corresponding original text in each field of the template image is replaced in sequence with the synthetic text of each field, resulting in multiple synthetic images. In this method, first, simply annotating the original text and first attribute information in the template image allows the text filling parameters of the template image to be predicted based on the text annotation information, thereby improving the accuracy of the text filling parameters and reducing the amount of manual annotation. Secondly, after determining the relevant parameters / information of the template image, the original text of each field in the template image is replaced with the synthetic text of each field, thereby generating multiple synthetic images of the same type as the template image. This improves the efficiency of synthesizing images containing text, allowing the generation of as many synthetic images as possible in a short period of time to meet the sample size requirements for algorithm training. Furthermore, because the multiple images are created by replacing the text content based on the template image's format, the multiple synthesized images and the template image contain the same number of fields. Besides the text content, the first attribute information and text filling parameters are identical. This makes the text content and formatting of the synthesized images more similar to the actual template image, thereby enhancing the authenticity of the synthesized images.

[0166] Based on the same technical concept, the embodiments of the present application also provide a device for synthesizing text-containing images corresponding to the aforementioned method for synthesizing text-containing images. The implementation solutions provided by this device in solving the technical problems are similar to those described in the aforementioned method embodiments. Therefore, the specific functional limitations of one or more embodiments of the device for synthesizing text-containing images provided below can be found in the definitions of the relevant steps in the aforementioned method for synthesizing text-containing images, and will not be repeated here.

[0167] In an exemplary embodiment, Figure 8 As shown, the embodiment of the present application further provides an apparatus for synthesizing an image containing text, the apparatus 900 including:

[0168] Parameter prediction module 910, configured to predict text filling parameters of the template image based on text annotation information of the template image; the text annotation information is used to indicate the original text and first attribute information of at least one field included in the template image, and the text filling parameters are used to indicate the content filling format of each field in the template image;

[0169] A text generation module 920 is used to generate synthetic text corresponding to each field in the template image;

[0170] The content replacement module 930 is configured to replace the corresponding original text with the synthesized text of each field in the template image in sequence according to the first attribute information and the text filling parameter, thereby obtaining a plurality of synthesized images.

[0171] In a possible implementation, the first attribute information includes the text filling area and font color of each field; the text filling parameters include at least one of the font type, font size, and area offset of each field.

[0172] In a possible implementation, the parameter acquisition module 910 includes:

[0173] An initialization submodule is used to generate an initial population corresponding to the template image; the initial population includes multiple initial individuals, and each initial individual corresponds to a filling parameter solution of the template image, and each filling parameter solution includes a field parameter solution corresponding to each field in the template image;

[0174] The field solution acquisition submodule is used to obtain the optimal field solution corresponding to each field in the template image from the field parameter solutions contained in multiple initial individuals;

[0175] The parameter determination submodule is used to determine the text filling parameters of the template image according to the optimal field solutions corresponding to each field in the template image.

[0176] In a possible implementation, the field solution acquisition submodule includes:

[0177] A similarity calculation unit is used to calculate the field similarity between each field in the template image and the field parameter solutions contained in the multiple initial individuals, and obtain multiple field similarities corresponding to each field;

[0178] a candidate solution obtaining unit, configured to obtain a candidate field solution for each field from field parameter solutions corresponding to each field in a plurality of initial individuals according to a plurality of field similarities corresponding to each field;

[0179] A mutation processing unit is used to perform mutation processing on multiple initial individuals based on the candidate field solutions of each field until the individual mutation processing results meet the preset population evolution end conditions, thereby obtaining multiple target individuals;

[0180] The field solution determination unit is used to determine the optimal field solution corresponding to each field in the template image based on the target individual.

[0181] In a possible implementation, the similarity calculation unit includes:

[0182] An image generation subunit is used to generate a target image of a field parameter solution corresponding to each target field in a plurality of initial individuals; the target field is any field in the template image, and the target field corresponds to one field parameter solution in one initial individual;

[0183] An image acquisition subunit, used for acquiring a standard field image of a target field from a template image;

[0184] The calculation subunit is used to determine the field similarity between the target field and the corresponding multiple field parameter solutions based on the accumulated amount of overlapping pixels between the standard field image and the target image of each field parameter solution.

[0185] In one possible implementation, the field parameter solution includes font parameters, font size parameters, and offset parameters;

[0186] The image generation subunit is specifically used to:

[0187] Generate the initial image corresponding to the parameter solution of each field according to the text filling area of ​​the target field in the template image;

[0188] Based on the font parameters and font size parameters in the parameter solutions for each field, the original text of the target field is added to the corresponding initial image to obtain the intermediate image corresponding to the parameter solutions for each field; the pixel values ​​of the original text in the initial image and the intermediate image are different;

[0189] According to the offset parameters in the parameter solutions of each field, the corresponding intermediate image is projected and transformed to obtain the target image corresponding to the parameter solution of each field.

[0190] In a possible implementation, the variation processing unit includes:

[0191] A first processing subunit is configured to adopt a preset first mutation strategy to perform mutation processing on candidate field solutions of each field in the field parameter solutions included in the multiple initial individuals, and obtain a first mutation vector corresponding to each candidate field solution;

[0192] The second processing subunit is configured to adopt a preset second mutation strategy to perform mutation processing on non-candidate field solutions of each field among the field parameter solutions included in the multiple initial individuals, thereby obtaining a second mutation vector corresponding to each non-candidate field solution;

[0193] The cross-replacement subunit is used to cross-replace the first mutation vector in the initial individual with the corresponding field parameter solution, and / or cross-replace the second mutation vector in the initial individual with the corresponding field parameter solution for any initial individual in the initial population, to obtain multiple target individuals.

[0194] In a possible implementation, the population evolution termination condition includes any of the following:

[0195] The number of individual mutations reaches the preset number of population evolutions;

[0196] The candidate field solutions for each field remain unchanged within the preset number of mutation processes.

[0197] In a possible implementation, the content replacement module 930 includes:

[0198] An image generation submodule, configured to generate a first field image corresponding to each field according to the text filling area of ​​each field;

[0199] A text adding submodule is used to add the synthetic text of the field to the corresponding first field image according to the font color, font type and font size of each field to obtain a second field image corresponding to each field;

[0200] An image processing submodule is used to perform a projection transformation on the second field image corresponding to each field according to the area offset of each field, so as to obtain a third field image corresponding to each field;

[0201] The replacement submodule is used to fill the character pixel values ​​in the third field image corresponding to each field into the text filling area of ​​each field in the template image.

[0202] In one possible implementation, the text generation module 920 includes:

[0203] an attribute determination submodule, configured to determine second attribute information of each field in the template image;

[0204] The strategy acquisition submodule is used to acquire the text synthesis strategy corresponding to each field according to the second attribute information of each field; the text synthesis strategy includes the text content of the field and the content synthesis method;

[0205] The text generation submodule is used to generate synthetic text corresponding to each field in the template image according to the text synthesis strategy of each field.

[0206] It should be noted that each module in the above-mentioned text-containing image synthesis device can be implemented in whole or in part through software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each of the above modules.

[0207] In an exemplary embodiment, the present application also provides a computer device. The computer device can be used to implement the image synthesis method containing text in the above embodiment. Figure 9 As shown, the computer device includes one or more processors 1010 , a memory 1020 , a system bus 1030 , and a communication interface 1040 , and the processor 1010 , the memory 1020 , and the communication interface 1040 are connected via the system bus 1030 .

[0208] The processor may be a central processing unit (CPU) or other forms of processing units with data processing capabilities and / or instruction execution capabilities, and may control other components in a computer device to perform desired functions.

[0209] Optionally, the processor is equipped with application software related to data processing.

[0210] The memory may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. As an example, the non-volatile memory may include read-only memory (ROM), a hard disk, a flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor may execute the program instructions to implement the text-containing image synthesis method and / or other desired functions in the various embodiments shown above.

[0211] The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner. The wireless manner can be achieved through WIFI, operator network, NFC (near field communication) or other technologies.

[0212] In some embodiments, the computer device may further include an input device and an output device (not shown), which are interconnected via a bus system and / or other connection mechanisms (not shown). The input device may be a touch screen layer covering a display screen, a key, trackball, or touchpad provided on the computer device housing, or an external keyboard, touchpad, or mouse. The output device may output various information to the external device. Examples include a display / screen, speakers, a communication network, and remote output devices connected thereto.

[0213] Of course, to simplify, Figure 9 Only some of the components in the computer device that are related to the embodiments of the present application are shown. In addition, the computer device may also include any other appropriate components depending on the specific application.

[0214] In an exemplary embodiment, the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor in a computer device, the method for synthesizing an image containing text provided in the above embodiment can be implemented.

[0215] In an exemplary embodiment, the present application also provides a computer program product, including a computer program. When the computer program is executed by a processor in a computer device, it can implement the image synthesis method containing text provided in the above embodiment.

[0216] The above specific implementation methods further explain in detail the purpose, technical solutions and beneficial effects of the embodiments of the present application. It should be understood that the above are only specific implementation methods of the embodiments of the present application and are not intended to limit the scope of protection of the embodiments of the present application. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of the embodiments of the present application should be included in the scope of protection of the embodiments of the present application.

Claims

1. A method for synthesizing an image containing text, characterized in that: include: Predicting text filling parameters of the template image based on text annotation information of the template image; The text annotation information is used to indicate the original text and first attribute information of at least one field included in the template image, and the text filling parameter is used to indicate the content filling format of each field in the template image; Generating synthetic texts corresponding to the fields in the template image; According to the first attribute information and the text filling parameter, in the template image, the corresponding original text is replaced in sequence with the synthesized text of each field to obtain a plurality of synthesized images; The predicting of text filling parameters of the template image based on the text annotation information of the template image includes: generating an initial population corresponding to the template image; the initial population including a plurality of initial individuals, each of which corresponds to a filling parameter solution of the template image, each of which includes a field parameter solution corresponding to each of the fields in the template image; Obtaining, from the field parameter solutions included in the multiple initial individuals, the optimal field solutions corresponding to the respective fields in the template image; determining text filling parameters of the template image according to the optimal field solutions corresponding to the fields in the template image; The step of obtaining, from the field parameter solutions included in the plurality of initial individuals, the optimal field solution corresponding to each of the fields in the template image, comprises: Generate a target image of field parameter solutions corresponding to target fields in the multiple initial individuals; the target field is any field in the template image, and the target field corresponds to one field parameter solution in one of the initial individuals; Acquire a standard field image of the target field from the template image; determining, based on the accumulated amount of overlapping pixels between the standard field image and the target images of the field parameter solutions, the field similarity between the target field and the corresponding plurality of field parameter solutions; Obtaining, according to the multiple field similarities corresponding to each of the fields, candidate field solutions for each of the fields from the field parameter solutions corresponding to the multiple initial individuals; Based on the candidate field solutions of each field, the multiple initial individuals are mutated until the individual mutation processing results meet the preset population evolution end conditions, thereby obtaining multiple target individuals; Based on the target individual, optimal field solutions corresponding to the fields in the template image are determined.

2. The method according to claim 1, characterized in that The field parameter solution includes font parameters, font size parameters and offset parameters; Generating a target image of a field parameter solution corresponding to each of the target field in the plurality of initial individuals includes: generating an initial image corresponding to each of the field parameter solutions according to a text-filled area of ​​the target field in the template image; adding the original text of the target field to the corresponding initial image according to the font parameters and font size parameters in each field parameter solution to obtain an intermediate image corresponding to each field parameter solution; the original text has different pixel values ​​in the initial image and the intermediate image; According to the offset parameters in each of the field parameter solutions, a projection transformation is performed on the corresponding intermediate image to obtain a target image corresponding to each of the field parameter solutions.

3. The method according to claim 1, characterized in that The replacing corresponding original texts in the template image with the synthesized texts of the fields in sequence according to the first attribute information and the text filling parameter includes: generating a first field image corresponding to each of the fields according to the text filling area of ​​each of the fields; adding the synthesized text of the field to the corresponding first field image according to the font color, font type and font size of each field, to obtain a second field image corresponding to each field; performing a projection transformation on the second field image corresponding to each field according to the area offset of each field, so as to obtain a third field image corresponding to each field; The character pixel values ​​in the third field image corresponding to each field are filled into the text filling area of ​​each field in the template image.

4. The method according to any one of claims 1 to 3, characterized in that Generating synthetic text corresponding to each of the fields in the template image includes: determining second attribute information of each of the fields in the template image; According to the second attribute information of each field, a text synthesis strategy corresponding to each field is obtained; the text synthesis strategy includes the text content of the field and the content synthesis method; According to each of the text synthesis strategies, synthetic texts corresponding to each of the fields in the template image are generated.

5. An image synthesis device containing text, characterized in that: include: A parameter prediction module, configured to predict text filling parameters of the template image based on text annotation information of the template image; The text annotation information is used to indicate the original text and first attribute information of at least one field included in the template image, and the text filling parameter is used to indicate the content filling format of each field in the template image; A text generation module, configured to generate synthetic text corresponding to each of the fields in the template image; a content replacement module, configured to replace the corresponding original text in the template image with the synthesized text of each field in turn according to the first attribute information and the text filling parameter, to obtain a plurality of synthesized images; The parameter prediction module includes: an initialization submodule, configured to generate an initial population corresponding to the template image; the initial population comprising a plurality of initial individuals, each of which corresponds to a filling parameter solution for the template image, each of which comprises a field parameter solution corresponding to each of the fields in the template image; A field solution acquisition submodule, configured to acquire, from the field parameter solutions contained in the plurality of initial individuals, the optimal field solution corresponding to each of the fields in the template image; a parameter determination submodule, configured to determine text filling parameters of the template image according to the optimal field solutions corresponding to the fields in the template image; The field solution acquisition submodule includes: An image generation subunit is configured to generate a target image of field parameter solutions corresponding to target fields in the plurality of initial individuals; the target field is any field in the template image, and the target field corresponds to one field parameter solution in one of the initial individuals; an image acquisition subunit, configured to acquire a standard field image of the target field from the template image; a calculation subunit, configured to determine the field similarity between the target field and the corresponding plurality of field parameter solutions based on the accumulated amount of overlapping pixels between the standard field image and the target image of each field parameter solution; a candidate solution acquiring unit, configured to acquire, based on a plurality of field similarities corresponding to each of the fields, a candidate field solution for each of the fields from the field parameter solutions corresponding to the plurality of initial individuals; a mutation processing unit, configured to perform mutation processing on the plurality of initial individuals based on the candidate field solutions of the respective fields, until the individual mutation processing results meet a preset population evolution end condition, thereby obtaining a plurality of target individuals; The field solution determining unit is used to determine the optimal field solution corresponding to each of the fields in the template image based on the target individual.

6. The device according to claim 5, characterized in that The field parameter solution includes font parameters, font size parameters and offset parameters; The image generation subunit is specifically used to: generating an initial image corresponding to each of the field parameter solutions according to a text-filled area of ​​the target field in the template image; adding the original text of the target field to the corresponding initial image according to the font parameters and font size parameters in each field parameter solution to obtain an intermediate image corresponding to each field parameter solution; the original text has different pixel values ​​in the initial image and the intermediate image; Performing a projection transformation on the corresponding intermediate image according to the offset parameters in each of the field parameter solutions to obtain a target image corresponding to each of the field parameter solutions; The content replacement module includes: An image generation submodule, configured to generate a first field image corresponding to each field according to the text filling area of ​​each field; a text adding submodule, configured to add the synthesized text of the field to the corresponding first field image according to the font color, font type and font size of each field, to obtain a second field image corresponding to each field; An image processing submodule, configured to perform a projection transformation on the second field image corresponding to each field according to the area offset of each field, so as to obtain a third field image corresponding to each field; a replacement submodule, configured to fill the character pixel values ​​in the third field image corresponding to each field into the text filling area of ​​each field in the template image; The text generation module includes: an attribute determination submodule, configured to determine second attribute information of each field in the template image; A strategy acquisition submodule, configured to acquire a text synthesis strategy corresponding to each of the fields according to the second attribute information of each field; the text synthesis strategy includes the text content of the field and the content synthesis method; The text generation submodule is used to generate synthetic texts corresponding to the respective fields in the template image according to the respective text synthesis strategies.

7. A computer device, characterized in that: The device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the text-containing image synthesis method according to any one of claims 1 to 4 when executing the computer program.

8. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for synthesizing an image containing text according to any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Structured document information labeling method and device and electronic equipment

    CN111695518A