Handwriting sample image annotation method, device, computer equipment and storage medium

CN109522898BActive Publication Date: 2024-10-15PING AN TECH (SHENZHEN) CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN201811084479.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-09-18
Publication Date
2024-10-15
Estimated Expiration
2038-09-18

AI Technical Summary

Technical Problem

The annotation efficiency of existing handwritten samples is low, and the accuracy and completeness of the annotated content are not high, mainly due to the heavy workload and energy consumption caused by manual collection and annotation.

Method used

By obtaining the handwriting sample image to be annotated for image preprocessing, a binary image is generated, and the position information of the handwritten text is determined based on the pixel value. The annotation information is automatically generated based on the preset naming method and combination method, and is saved in the database to reduce Manual annotation steps.

Benefits of technology

It improves the efficiency and accuracy of handwritten sample annotation, reduces the need for manual annotation, realizes automated annotation information generation, and enhances the completeness and customizability of annotation content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN109522898B_ABST
    Figure CN109522898B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, computer equipment and storage medium for labeling handwriting sample images. The method comprises: obtaining a handwriting sample image to be labeled and the text content of the handwriting text contained in the handwriting sample image; performing image preprocessing on the handwriting sample image to obtain a binary image corresponding to the handwriting sample image, and obtaining the image size of the binary image; determining the target pixel corresponding to the handwritten text in the binary image according to the pixel value of each pixel in the binary image, and obtaining the relative position information of the handwritten text in the handwriting sample image according to the target pixel; setting the image name of the handwriting sample image; combining the image name, text content, relative position information, and image size to obtain the labeling information of the handwriting sample image to be labeled. The technical solution of the present invention improves the sample labeling efficiency, as well as the completeness and accuracy of the labeling content.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a handwriting sample image annotation method, device, computer equipment and storage medium. Background Art

[0002] In the research on handwritten text recognition, a large number of handwritten samples need to be prepared to support the model training of the handwritten text recognition model.

[0003] However, current handwriting samples are often collected manually. Due to the wide variety of handwriting samples, the workload of manually collecting handwriting samples is large. After manually collecting a large number of handwriting samples, it is still necessary to spend a lot of time and energy to manually annotate the sample content of the collected handwriting samples, resulting in low efficiency in labeling handwriting samples and low efficiency in generating handwriting samples for model training and testing. At the same time, manual labeling cannot guarantee the accuracy and completeness of the labeled content. Summary of the invention

[0004] The embodiments of the present invention provide a handwriting sample image annotation method, apparatus, computer equipment and storage medium to solve the current problems of low annotation efficiency of handwriting samples and low accuracy and completeness of annotation content.

[0005] A handwriting sample image annotation method, comprising:

[0006] Obtaining a handwriting sample image to be annotated and text content of the handwriting text contained in the handwriting sample image to be annotated;

[0007] Performing image preprocessing on the handwriting sample image to be labeled, obtaining a binary image corresponding to the handwriting sample image to be labeled, and acquiring the image size of the binary image;

[0008] Determine the target pixel point corresponding to the handwritten text in the binary image according to the pixel value of each pixel point in the binary image, and determine the relative position information of the handwritten text to be marked in the handwriting sample image according to the position coordinates of the target pixel point in the binary image;

[0009] According to a preset naming method, set the image name of the handwriting sample image to be annotated;

[0010] Combining the picture name, the text content, the relative position information, and the picture size according to a preset first combination method to obtain annotation information of the handwriting sample picture to be annotated;

[0011] The handwriting sample image to be annotated and the annotation information are correspondingly saved in a preset handwriting sample database.

[0012] A handwriting sample image annotation device, comprising:

[0013] An acquisition module, used to acquire a handwriting sample image to be annotated and text content of a handwriting text contained in the handwriting sample image to be annotated;

[0014] A preprocessing module, used to perform image preprocessing on the handwriting sample image to be labeled, obtain a binary image corresponding to the handwriting sample image to be labeled, and obtain the image size of the binary image;

[0015] A position determination module, used to determine the target pixel point corresponding to the handwritten text in the binary image according to the pixel value of each pixel point in the binary image, and determine the relative position information of the handwritten text in the handwritten sample image to be annotated according to the position coordinates of the target pixel point in the binary image;

[0016] A name setting module, used to set the image name of the handwriting sample image to be annotated according to a preset naming method;

[0017] A first combining module, used to combine the picture name, the text content, the relative position information, and the picture size according to a preset first combining method to obtain the annotation information of the handwriting sample picture to be annotated;

[0018] The saving module is used to save the handwriting sample image to be annotated and the annotation information correspondingly into a preset handwriting sample database.

[0019] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the above-mentioned handwriting sample image annotation method are implemented.

[0020] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the above-mentioned handwriting sample image annotation method.

[0021] In the above-mentioned handwriting sample image annotation method, device, computer equipment and storage medium, the image preprocessing is performed on the acquired handwriting sample image to be annotated to obtain a binary image and its image size, and the relative position information of the handwritten text in the handwriting sample image to be annotated is determined according to the pixel value of each pixel in the binary image, and the image name of the handwriting sample image to be annotated is set according to a preset naming method, and then the image size, image name, text content and relative position information of the handwritten text are combined according to a preset first combination method to obtain the annotation information of the handwriting sample image to be annotated, thereby realizing automatic generation of annotation information without manual annotation, improving sample annotation efficiency, and further improving the generation efficiency of the handwriting sample database used for model training and testing. At the same time, the content of the annotation information is automatically combined and generated according to attribute information such as image size, image name, text content and relative position information of the handwritten text, and the annotation information can comprehensively and meticulously describe the content of the handwriting sample image, and its annotation format can be customized, thereby effectively improving the completeness and accuracy of the annotation content. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0023] Figure 1 is a flow chart of a method for labeling a handwriting sample image in one embodiment of the present invention;

[0024] Figure 2 is a schematic diagram of a specific handwriting sample image in a handwriting sample image annotation method in one embodiment of the present invention;

[0025] Figure 3 is a flow chart of step S2 in a handwriting sample image annotation method in one embodiment of the present invention;

[0026] Figure 4 A flow chart of generating annotation information by adopting another annotation method in a handwriting sample image annotation method according to an embodiment of the present invention;

[0027] Figure 5 is a flow chart of generating a handwriting sample image to be annotated in a handwriting sample image annotating method in one embodiment of the present invention;

[0028] Figure 6 is a flow chart of expanding a handwriting sample image to be annotated in a handwriting sample image annotating method in one embodiment of the present invention;

[0029] Figure 7 is a schematic diagram of a handwriting sample image annotation device in one embodiment of the present invention;

[0030] Figure 8 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION

[0031] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0032] The handwriting sample image annotation method provided in the present application can be applied on the server side, and the server side can be implemented with an independent server or a server cluster composed of multiple servers.

[0033] In one embodiment, if Figure 1 As shown, a handwriting sample image annotation method is provided, which is described in detail as follows:

[0034] S1: Obtain a handwriting sample image to be labeled and text content of the handwriting text contained in the handwriting sample image to be labeled.

[0035] In this embodiment, the handwriting samples used for handwriting text recognition model training can be pre-saved in a preset handwriting sample data set, which stores a number of handwriting samples, each of which includes a sample image containing handwriting text and the text content of the handwriting text.

[0036] Specifically, the server obtains a handwriting sample from a preset handwriting sample data set, uses a sample image contained in the handwriting sample as the handwriting sample image to be labeled, and determines the text content of the handwriting text corresponding to the sample image as the text content of the handwriting text contained in the handwriting sample image to be labeled.

[0037] S2: performing image preprocessing on the handwriting sample image to be labeled, obtaining a binary image corresponding to the handwriting sample image to be labeled, and obtaining the image size of the binary image.

[0038] Specifically, the handwriting sample image to be labeled is subjected to preprocessing processes such as denoising, graying and binarization, and the handwriting sample image to be labeled is converted into a binary image containing only black and white colors, that is, the pixel value of the pixel point in the binary image is 0 or 255.

[0039] The handwritten text contained in the handwriting sample image is displayed in black in the binary image, and other positions of the handwriting sample image are displayed in white, or the handwritten text contained in the handwriting sample image is displayed in white in the binary image, and other positions of the handwriting sample image are displayed in black.

[0040] Get the image size of the binary image, which may include the length and width of the binary image, wherein the length of the binary image is the number of pixels occupied by the binary image in the horizontal direction, and the width of the binary image is the number of pixels occupied by the binary image in the vertical direction.

[0041] It can be understood that the image size of the binary image is the image size of the handwriting sample image to be labeled.

[0042] S3: Determine the target pixel corresponding to the handwritten text in the binary image according to the pixel value of each pixel in the binary image, and determine the relative position information of the handwritten text in the handwritten sample image to be labeled according to the position coordinates of the target pixel in the binary image.

[0043] Specifically, the server obtains the pixel value of each pixel in the binary image based on the binary image obtained in step S2. Since the handwritten text is displayed in black or white in the binary image, that is, the pixel value of the pixel corresponding to the handwritten text is 0 or 255, the pixel corresponding to the handwritten text in the binary image can be determined based on the pixel value of each pixel in the binary image, and the pixel corresponding to the handwritten text can be marked as the target pixel.

[0044] For example, if the pixel value of the pixel corresponding to the handwritten text is 0, the pixel with the pixel value of 0 in the binary image is marked as the target pixel.

[0045] The position coordinates of the target pixel points in the binary image are obtained, and according to the position coordinates, the smallest rectangular area containing all the target pixel points in the binary image is used as the regional image of the handwritten text in the handwritten sample image to be annotated. The size of the regional image can be represented by the number of pixels contained in the length and width of the regional image respectively.

[0046] The position coordinates of the target pixel point in the upper left corner of the region image in the binary image and the size of the region image are used as the relative position information of the handwritten text to be annotated in the handwritten sample image.

[0047] It should be noted that the relative position information of the handwritten text in the handwritten sample image to be annotated can also be identified by the position coordinates of the target pixel point in the upper left corner and the target pixel point in the lower right corner of the regional image. The specific selection can be made according to the needs of the actual application and is not limited here.

[0048] For example, in Figure 2 In the handwriting sample image to be annotated shown, the dotted box area is the regional image, point A is the target pixel point in the upper left corner of the regional image, and point B is the target pixel point in the lower right corner of the regional image. Therefore, the position coordinates of point A and the size of the dotted box area can be used as relative position information, or the position coordinates of point A and the position coordinates of point B can be used as relative position information.

[0049] S4: According to a preset naming method, set the image name of the handwriting sample image to be annotated.

[0050] Specifically, the preset naming method can be a combination of storage path and identification ID. The storage path for storing the handwriting sample image to be labeled is obtained, and a unique identification ID is created for the handwriting sample image to be labeled. The "storage path-identification ID" naming method is used to name the handwriting sample image to be labeled, and the image name of the handwriting sample image to be labeled is obtained.

[0051] The identification ID may be created by randomly selecting an unused random number from a preset random number set as the identification ID.

[0052] It should be noted that the preset naming method can also be the naming method of "storage path-marked date-identification ID-picture format", but it is not limited to this. It can be set according to the needs of actual application and is not limited here.

[0053] S5: combining the picture name, text content, relative position information, and picture size according to a preset first combination method to obtain annotation information of the handwriting sample picture to be annotated.

[0054] Specifically, the text content obtained in step S1, the image size obtained in step S2, the relative position information obtained in step S3, and the image name set in step S4 are connected according to a first combination method to form the annotation information of the handwriting sample image to be annotated.

[0055] Among them, the first combination method can specifically be a combination method of "{picture size / picture name / text content / relative position information}", or a combination method of "{picture name-picture size-text content-relative position information}", or other combination methods, which can be specifically set according to the needs of actual application and are not limited here.

[0056] For example, Figure 2 The annotation information of the handwritten sample image to be annotated can be:

[0057] {bolepianti_C000008_20161202_235745.png / 280*70 / is for reference only, the author is responsible for the content. / (3,3),270*64}

[0058] Among them, "bolepianti_C000008_20161202_235745.png" is the image name of the handwriting sample image, which contains the relative storage path of the handwriting sample image "bolepianti_C000008", the marked date "20161202", the identification ID of the handwriting sample image "235745", and the image format of the handwriting sample image "png"; "280*70" is the image size of the handwriting sample image, that is, the length is 280 pixels and the width is 70 pixels. pixel point; "For reference only, the author is responsible for the content." is the text content of the handwritten text; "(3, 3), 270*64" is the relative position information of the handwritten text in the handwriting sample image; "(3, 3)" represents the position coordinates of the pixel point A in the upper left corner of the regional image where the handwritten text is located in the handwriting sample image, that is, the position 3 pixels to the right and 3 pixels below the upper left corner of the handwriting sample image as the coordinate origin; "270*64" represents the size of the regional image, that is, the pixel area occupied by the handwritten text is 270 pixels long and 64 pixels wide.

[0059] S6: Save the handwriting sample image to be annotated and the annotation information correspondingly into a preset handwriting sample database.

[0060] Specifically, the handwriting sample image to be annotated obtained in step S1 and the annotation information obtained in step S6 are correspondingly saved in a preset handwriting sample database.

[0061] Among them, the preset handwriting sample database is used for training and tuning the handwriting text recognition model. When the handwriting sample images in the handwriting sample database are used for subsequent model training of the handwriting text recognition model, the annotation information of the handwriting sample images is parsed according to the format of the annotation information, and the attribute information of the handwritten text contained in the handwriting sample images can be obtained completely and accurately, thereby effectively supporting model training.

[0062] In this embodiment, by performing image preprocessing on the acquired handwriting sample image to be annotated, a binary image and its image size are obtained, and the relative position information of the handwritten text in the handwriting sample image to be annotated is determined according to the pixel value of each pixel in the binary image, and the image name of the handwriting sample image to be annotated is set according to a preset naming method, and then according to a preset first combination method, the image size, image name, text content of the handwritten text and the relative position information are combined to obtain the annotation information of the handwriting sample image to be annotated, thereby realizing automatic generation of annotation information without manual annotation, improving sample annotation efficiency, and further improving the generation efficiency of a handwriting sample database for model training and testing. At the same time, the content of the annotation information is automatically combined and generated according to attribute information such as image size, image name, text content of the handwritten text and relative position information. The annotation information can comprehensively and meticulously describe the content of the handwriting sample image, and its annotation format can be customized, thereby effectively improving the completeness and accuracy of the annotation content.

[0063] In one embodiment, if Figure 3 As shown, in step S2, the handwriting sample image is preprocessed to obtain a binary image corresponding to the handwriting sample image, which specifically includes the following steps:

[0064] S21: Obtain the RGB component value of each pixel in the handwriting sample image to be labeled, and perform grayscale processing on the handwriting sample image to be labeled according to the RGB component value to obtain a grayscale image.

[0065] Specifically, the grayscale processing is performed using the RGB model, which is a commonly used method for expressing color information. It uses the brightness of the three primary colors of red, green, and blue to quantitatively represent the color. The RGB model is also called the additive color mixing model. It is a method of mixing colors by superimposing the three RGB colors on each other, and is therefore suitable for display by light emitters such as monitors.

[0066] In the RGB model, if R=G=B, the color representation has only one grayscale color, where the value of R=G=B is the pixel value of the pixel after grayscale processing, that is, the grayscale value, and its pixel value range is 0-255. Therefore, after grayscale processing using the RGB model, for each pixel in the obtained grayed image, only one byte is needed to store the pixel value of the pixel.

[0067] Grayscale processing methods include but are not limited to component method, maximum value method, average value method or weighted average method.

[0068] In a specific embodiment, the handwritten sample image to be annotated is grayed using formula (1) to obtain a grayed image:

[0069]

[0070] Among them, P(x, y) is the pixel value of the pixel point (x, y) in the handwritten sample image to be labeled after grayscale processing, R(x, y) is the color component of the pixel point (x, y) in the R channel, G(x, y) is the color component of the pixel point (x, y) in the G channel, B(x, y) is the color component of the pixel point (x, y) in the B channel, a, b, c are the preset weight parameters corresponding to the R channel, G channel, and B channel respectively, δ is the preset adjustment factor, and the preset weight parameters a, b, c and the adjustment factor δ can be set according to the needs of the actual application, and there is no limitation here.

[0071] S22: performing binarization processing on the grayed image according to a preset grayscale threshold to obtain a binarized image.

[0072] Specifically, according to the pixel value of each pixel in the grayed image obtained in step S21, each pixel in the grayed image is traversed according to the preset grayscale threshold, the pixel value of each pixel is compared with the grayscale threshold, and the pixel value of the pixel is modified according to the comparison result, the pixel value of the pixel whose pixel value is greater than the grayscale threshold is modified to the grayscale maximum value, and the pixel value of the pixel whose pixel value is less than the grayscale threshold is modified to the grayscale minimum value, thereby completing the binarization process, wherein the maximum grayscale value is 255 and the minimum grayscale value is 0.

[0073] Furthermore, the grayscale threshold selection method may include a fixed threshold or an adaptive threshold. Depending on the grayscale threshold selection method, different binarization algorithms may be used to binarize the grayed image. Specific binarization algorithms include but are not limited to: bimodal method, P parameter method, iterative method, Otsu algorithm (OTSU), etc.

[0074] In this embodiment, according to the RGB component value of each pixel in the handwriting sample image to be labeled, the handwriting sample image to be labeled is grayed to obtain a grayed image, and according to a preset grayscale threshold, the grayed image is binarized to obtain a binarized image, thereby realizing the binarization of the handwriting sample image to be labeled, providing a basis for the subsequent determination of the relative position information of the handwritten text in the handwriting sample image to be labeled. In addition, the grayscale processing is performed using formula (1), and the binarization process is completed by comparing the pixel value with the fixed grayscale threshold. The algorithm is simple and has high execution efficiency. When faced with a large number of handwriting sample images to be labeled, the sample labeling efficiency can be improved, thereby improving the generation efficiency of the handwriting sample database used for model training and testing.

[0075] In one embodiment, if Figure 4As shown, after step S4 and before step S6, the handwriting sample image annotation method further includes a processing process of generating annotation information by adopting another annotation method, which specifically includes the following steps:

[0076] S71: Obtaining a character code corresponding to each character in the text content from a preset data dictionary, wherein the data dictionary contains standard characters and the character code of each standard character.

[0077] The preset data dictionary contains standard characters and the character code corresponding to each standard character. The character code is generated by a preset encoding method and is used to uniquely identify the standard character. The standard characters include but are not limited to Chinese characters, Arabic numerals, letters, punctuation marks, etc.

[0078] It should be noted that the preset encoding method can be Unicode encoding, random number encoding, or other customized encoding methods, which can be set according to the needs of actual application and are not limited here.

[0079] Specifically, according to the text content of the handwritten text contained in the handwriting sample image to be annotated, the character code corresponding to each character in the text content is queried from a preset data dictionary.

[0080] S72: combining the image name, the character code corresponding to each character in the text content, the relative position information, and the image size according to a preset second combination method to obtain annotation information of the handwriting sample image to be annotated.

[0081] Specifically, the image size obtained in step S2, the relative position information obtained in step S3, the image name set in step S4, and the character code corresponding to each character in the text content of the handwritten text obtained in step S71 are connected according to the second combination method to form the annotation information of the handwritten sample image to be annotated.

[0082] Among them, the second combination method can specifically be a combination method of "{picture size / picture name / character encoding / relative position information}", or a combination method of "{picture name-picture size-character encoding-relative position information}", or other combination methods, which can be set according to the needs of actual application and are not limited here.

[0083] For example, Figure 2 The annotation information of the handwritten sample image to be annotated can be:

[0084] {bolepianti_C000008_20161202_235745.png / 280*70 / 10607,11373,20999,20925,20929,20924,12343,23044,87584,45891 / (3,3),270*64}

[0085] Among them, "bolepianti_C000008_20161202_235745.png" is the image name of the handwriting sample image, which contains the relative storage path of the handwriting sample image "bolepianti_C000008", the marked date "20161202", the identification ID of the handwriting sample image "235745", and the image format of the handwriting sample image "png"; "280*70" is the image size of the handwriting sample image, that is, the length is 280 pixels and the width is 70 pixels; "10607, 11373, 20999, 20925, 20929, 20924, 12343, 23044, 87584, 45891" is the text content of the handwritten text, "For reference only, the author is responsible for the content." Each of the 10 characters in the "(3, 3), 270*64" is the character code corresponding to the handwritten text in the handwriting sample image. "(3, 3)" indicates the position coordinates of the pixel point A in the upper left corner of the regional image where the handwritten text is located in the handwriting sample image, that is, the position 3 pixels to the right and 3 pixels below the upper left corner of the handwriting sample image as the coordinate origin. "270*64" indicates the size of the regional image, that is, the length of the pixel area occupied by the handwritten text is 270 pixels and the width is 64 pixels.

[0086] In this embodiment, the character code corresponding to each character in the text content of the handwritten text is obtained from a preset data dictionary, and the image name, the character code corresponding to each character in the text content, the relative position information and the image size are combined according to a preset second combination method to obtain the annotation information of the handwritten sample image to be annotated, thereby realizing the use of character codes instead of characters in the annotation information. When the handwritten text recognition model is trained using the handwritten sample images in the handwriting sample database, it is more efficient to directly use the character codes parsed from the annotation information to compare the training results. At the same time, when the character codes need to be restored to characters, the preset data dictionary must be used for accurate restoration, which also improves the data security of the annotation information in the handwriting sample database to a certain extent.

[0087] In one embodiment, if Figure 5 As shown, before step S1, the handwriting sample image annotation method also includes a process of generating a handwriting sample image to be annotated, which specifically includes the following steps:

[0088] S81: Obtain a corpus text from a preset text corpus, and set a handwriting font attribute of the corpus text.

[0089] In this embodiment, the preset text corpus is a pre-set database for storing corpus texts. Furthermore, the corpus texts can be classified and saved in the text corpus according to a preset classification method, that is, the corpus texts are classified and stored in the text corpus according to their categories.

[0090] Among them, the corpus text can be a character, a sentence, a word, or a paragraph, etc. The preset classification method can be classification by field, for example, chemistry, literature and other different fields, or classification by text attributes, for example, news, novels and other different attributes. The specific classification method can be set according to the needs of actual application.

[0091] Specifically, the server obtains at least one corpus text in the text category from a preset text corpus according to the text category required for the handwritten text recognition model training, and sets the handwritten font attribute of the corpus text.

[0092] Among them, the handwriting font attributes include handwriting font type, font color, font depth, and font size. The server can set the handwriting font attributes of the corpus text by randomly selecting a certain number of handwriting font types, font colors, font depths, and font sizes, and then combining them, or by cyclically selecting each font type, font color, font depth, and font size, and then combining them, or by allowing the user to customize the handwriting font attributes through human-computer interaction. It can be understood that a corpus text can correspond to one handwriting font attribute, or it can correspond to multiple different handwriting font attributes.

[0093] S82: Draw the corpus text on a preset canvas according to the handwriting font attributes of the corpus text, and obtain a handwriting sample image to be annotated and text content of the handwriting text contained in the handwriting sample image to be annotated.

[0094] Specifically, the server draws a corpus text on a preset canvas according to the handwriting font attributes determined in step S81 in the manner of drawing a corpus text on a canvas, and uses the obtained image as a handwriting sample image to be annotated, and uses the corpus text as the text content of the handwriting text contained in the handwriting sample image to be annotated.

[0095] It should be noted that the preset canvas includes a canvas of preset size and preset color. The server can directly use the preset canvas function component to draw a canvas of specified size and color, and then use the preset text drawing function component to draw the corpus text in the canvas according to the handwritten font attributes.

[0096] For example, you can use the imagecreate() function in the GD2 function library to create a canvas, the imagecolorallocate() function to set the color of the canvas, and the gdImageStringFT() function to draw the corpus text.

[0097] Furthermore, when drawing the corpus text on the canvas, the position of the corpus text on the canvas can also be set. For example, the position coordinates of the corpus text can be passed as parameters to the gdImageStringFT() function to draw the corpus text at the specified position on the canvas.

[0098] Preferably, the corpus text is drawn at the center of the canvas.

[0099] In this embodiment, by obtaining a corpus text from a preset text corpus and setting the handwriting font attributes of the corpus text, and then drawing the corpus text on a preset canvas according to the handwriting font attributes of the corpus text, a handwriting sample image to be annotated and the text content of the handwriting text contained in the handwriting sample image to be annotated are obtained, thereby realizing automatic generation of handwriting sample images, eliminating the need for manual collection of handwriting samples, thereby reducing the cost of collecting handwriting samples and improving the efficiency of collecting handwriting samples.

[0100] In one embodiment, if Figure 6 As shown, after step S82, the handwriting sample image annotation method further includes an expansion process of the handwriting sample image to be annotated, specifically including the following steps:

[0101] S83: Processing the handwriting sample image to be labeled according to a preset image effect processing method to obtain a new handwriting sample image to be labeled and text content of the handwriting text contained in the new handwriting sample image to be labeled.

[0102] Specifically, the server processes the handwriting sample image to be labeled generated in step S82 according to a preset image effect processing method, and uses the new image obtained after processing as a new handwriting sample image to be labeled. At the same time, the text content of the handwritten text contained in the handwriting sample image to be labeled generated in step S82 is directly used as the text content of the handwriting text contained in the new handwriting sample image to be labeled.

[0103] The preset image effect processing method is to transform the graphic effect of the handwriting sample image to be annotated, or to transform the font of the handwritten text in the handwriting sample image to be annotated.

[0104] For example, the image effect processing method can be to use a random Gaussian blur algorithm to blur the handwritten text in the handwriting sample image to be labeled, or to use a random angle tilt method to adjust the angle of the handwritten text in the handwriting sample image to be labeled, or to add a watermark, a border, a background pattern, or change the background color of the canvas to the handwriting sample image to be labeled.

[0105] It should be noted that the image effect processing method can be specifically set according to the needs of the actual application and is not limited here.

[0106] In this embodiment, the handwriting sample picture to be labeled is processed by a preset picture effect processing method to obtain a new picture, and the new picture is used as a new handwriting sample picture to be labeled, thereby achieving effective expansion of the handwriting sample pictures to be labeled, thereby further improving the collection efficiency of handwriting samples.

[0107] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0108] In one embodiment, a handwriting sample image annotation device is provided, and the handwriting sample image annotation device corresponds to the handwriting sample image annotation method in the above embodiment. Figure 7 As shown, the handwriting sample image annotation device includes an acquisition module 71, a preprocessing module 72, a position determination module 73, a name setting module 74, a first combination module 75 and a storage module 76. The functional modules are described in detail as follows:

[0109] An acquisition module 71 is used to acquire a handwriting sample image to be annotated and text content of the handwriting text contained in the handwriting sample image to be annotated;

[0110] A preprocessing module 72 is used to perform image preprocessing on the handwriting sample image to be labeled, obtain a binary image corresponding to the handwriting sample image to be labeled, and obtain the image size of the binary image;

[0111] A position determination module 73 is used to determine the target pixel point corresponding to the handwritten text in the binary image according to the pixel value of each pixel point in the binary image, and determine the relative position information of the handwritten text in the handwritten sample image to be annotated according to the position coordinates of the target pixel point in the binary image;

[0112] A name setting module 74, used to set the image name of the handwriting sample image to be annotated according to a preset naming method;

[0113] A first combining module 75, configured to combine the picture name, the text content, the relative position information, and the picture size in accordance with a preset first combining method to obtain the annotation information of the handwriting sample picture to be annotated;

[0114] The saving module 76 is used to save the handwriting sample image to be annotated and the annotation information in a preset handwriting sample database.

[0115] Furthermore, the preprocessing module 72 includes:

[0116] A graying submodule, used to obtain the RGB component value of each pixel in the handwriting sample image to be labeled, and grayscale the handwriting sample image to be labeled according to the RGB component value to obtain a grayed image;

[0117] The binarization submodule is used to perform binarization processing on the grayed image according to a preset grayscale threshold to obtain a binarized image.

[0118] Furthermore, the handwriting sample image annotation device also includes:

[0119] A coding conversion module, used for obtaining the character coding corresponding to each character in the text content from a preset data dictionary, wherein the data dictionary contains standard characters and the character coding of each of the standard characters;

[0120] The second combination module is used to combine the picture name, the character code corresponding to each character in the text content, the relative position information, and the picture size according to a preset second combination method to obtain the annotation information of the handwriting sample picture to be annotated.

[0121] Furthermore, the handwriting sample image annotation device also includes:

[0122] A corpus acquisition module, used to acquire corpus text from a preset text corpus and set handwriting font attributes of the corpus text;

[0123] The image generation module is used to draw the corpus text on a preset canvas according to the handwriting font attributes, and obtain the handwriting sample image to be annotated and the text content of the handwriting text contained in the handwriting sample image to be annotated.

[0124] Furthermore, the handwriting sample image annotation device also includes:

[0125] The sample expansion module is used to process the handwriting sample picture to be labeled according to a preset picture effect processing method to obtain a new handwriting sample picture to be labeled and the text content of the handwriting text contained in the new handwriting sample picture to be labeled.

[0126] For the specific limitations of the handwriting sample image annotation device, please refer to the limitations of the handwriting sample image annotation method above, which will not be repeated here. Each module in the above-mentioned handwriting sample image annotation device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0127] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store handwriting sample images and the text content contained therein. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a handwriting sample image annotation method is implemented.

[0128] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the handwriting sample image annotation method of the above embodiment are implemented, such as Figure 1 Alternatively, when the processor executes the computer program, the functions of each module / unit of the handwriting sample image annotation device in the above embodiment are realized, for example Figure 7 The functions of modules 71 to 76 are shown in Figure 1. To avoid repetition, they will not be described here.

[0129] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the handwriting sample image annotation method in the above method embodiment is implemented, or when the computer program is executed by a processor, the functions of each module / unit in the handwriting sample image annotation device in the above device embodiment are implemented. To avoid repetition, it will not be described here.

[0130] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. 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. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0131] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0132] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A handwriting sample image annotation method, characterized in that: The handwriting sample image annotation method comprises: Obtaining a handwriting sample image to be annotated and text content of the handwriting text contained in the handwriting sample image to be annotated; Performing image preprocessing on the handwriting sample image to be labeled, obtaining a binary image corresponding to the handwriting sample image to be labeled, and acquiring the image size of the binary image; Determining the target pixel corresponding to the handwritten text in the binary image according to the pixel value of each pixel in the binary image, and determining the relative position information of the handwritten text in the handwriting sample image to be labeled according to the position coordinates of the target pixel in the binary image, including: obtaining the position coordinates of the target pixel in the binary image, obtaining the regional image of the handwritten text in the handwriting sample image to be labeled according to the position coordinates, and determining the relative position information of the handwriting sample image according to the position coordinates of the regional image in the binary image and the size of the regional image; According to a preset naming method, set the image name of the handwriting sample image to be annotated; Combining the picture name, the text content, the relative position information, and the picture size according to a preset first combination method to obtain annotation information of the handwriting sample picture to be annotated; The handwriting sample image to be annotated and the annotation information are correspondingly saved in a preset handwriting sample database.

2. The handwriting sample image annotation method according to claim 1, characterized in that: The performing image preprocessing on the handwriting sample picture to be labeled to obtain a binary image corresponding to the handwriting sample picture to be labeled comprises: Obtaining the RGB component value of each pixel in the handwriting sample image to be labeled, and graying the handwriting sample image to be labeled according to the RGB component value to obtain a grayed image; According to a preset grayscale threshold, the grayed image is binarized to obtain a binarized image.

3. The handwriting sample image annotation method according to claim 1, characterized in that: After setting the picture name of the handwriting sample picture to be annotated according to the preset naming method, and before saving the handwriting sample picture to be annotated and the annotation information correspondingly in a preset handwriting sample database, the handwriting sample picture annotation method further includes: Obtaining a character code corresponding to each character in the text content from a preset data dictionary, wherein the data dictionary contains standard characters and the character code of each of the standard characters; According to a preset second combination method, the image name, the character code corresponding to each character in the text content, the relative position information, and the image size are combined to obtain the annotation information of the handwriting sample image to be annotated.

4. The handwriting sample image labeling method according to any one of claims 1 to 3, characterized in that: Before obtaining the handwriting sample image to be annotated and the text content of the handwritten text contained in the handwriting sample image to be annotated, the handwriting sample image annotating method further includes: Acquire a corpus text from a preset text corpus, and set a handwriting font attribute of the corpus text; According to the handwriting font attributes, the corpus text is drawn on a preset canvas to obtain the handwriting sample image to be annotated and the text content of the handwriting text contained in the handwriting sample image to be annotated.

5. The handwriting sample image annotation method according to claim 4, characterized in that: After drawing the corpus text on a preset canvas according to the handwriting font attributes and obtaining the handwriting sample image to be annotated and the text content of the handwriting text contained in the handwriting sample image to be annotated, the handwriting sample image annotation method further includes: The handwriting sample picture to be labeled is processed according to a preset picture effect processing method to obtain a new handwriting sample picture to be labeled and text content of the handwriting text contained in the new handwriting sample picture to be labeled.

6. A handwriting sample image annotation device, characterized in that: The handwriting sample image annotation device comprises: An acquisition module, used to acquire a handwriting sample image to be annotated and text content of a handwriting text contained in the handwriting sample image to be annotated; A preprocessing module, used to perform image preprocessing on the handwriting sample image to be labeled, obtain a binary image corresponding to the handwriting sample image to be labeled, and obtain the image size of the binary image; A position determination module, used to determine the target pixel point corresponding to the handwritten text in the binary image according to the pixel value of each pixel point in the binary image, and determine the relative position information of the handwritten text in the handwriting sample image to be labeled according to the position coordinates of the target pixel point in the binary image, including: obtaining the position coordinates of the target pixel point in the binary image, obtaining the regional image of the handwritten text in the handwriting sample image to be labeled according to the position coordinates, and determining the relative position information of the handwriting sample image according to the position coordinates of the regional image in the binary image and the size of the regional image; A name setting module, used to set the image name of the handwriting sample image to be annotated according to a preset naming method; A first combining module, used to combine the picture name, the text content, the relative position information, and the picture size according to a preset first combining method to obtain the annotation information of the handwriting sample picture to be annotated; The saving module is used to save the handwriting sample image to be annotated and the annotation information correspondingly into a preset handwriting sample database.

7. The handwriting sample image labeling device according to claim 6, characterized in that: The preprocessing module comprises: A graying submodule, used to obtain the RGB component value of each pixel in the handwriting sample image to be labeled, and grayscale the handwriting sample image to be labeled according to the RGB component value to obtain a grayed image; The binarization submodule is used to perform binarization processing on the grayed image according to a preset grayscale threshold to obtain a binarized image.

8. The handwriting sample image labeling device according to claim 6, characterized in that: The handwriting sample image annotation device also includes: A coding conversion module, used for obtaining the character coding corresponding to each character in the text content from a preset data dictionary, wherein the data dictionary contains standard characters and the character coding of each of the standard characters; The second combination module is used to combine the picture name, the character code corresponding to each character in the text content, the relative position information, and the picture size according to a preset second combination method to obtain the annotation information of the handwriting sample picture to be annotated.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the handwriting sample image labeling method according to any one of claims 1 to 5 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the handwriting sample image annotation method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Verification method and device based on handwritten character recognition

    CN106951832A

  • Image processing method and image processing device

    CN107590491A

  • Automatic generation method for handwritten Chinese font library based on deep neutral network

    CN107644006A

  • Method, system and equipment for recognizing handwritten Chinese characters

    CN108364037A

  • Picture processing method, electronic device and storage medium

    CN108446697A