Character color processing method, device, equipment and storage medium
By performing character block detection and segmentation processing on the image of the teaching aids, the binary information of characters is obtained and unified, the problem of inconsistent character colors is solved, and the reliability and aesthetics of character color processing are improved.
Patent Information
- Application Number
- CN202310429187.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-14
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2043-04-14
AI Technical Summary
In the prior art, the characters in the textbook title image are not uniform, resulting in poor aesthetics of the layout, and characters are easily lost during character segmentation, affecting the reliability of the color processing results.
By performing character block detection and segmentation processing on the question image data, binary information of each character is obtained, target binary information is determined based on preset threshold values, and character color values are unified based on this information to prevent character miss detection and binary information loss.
Ensure that the color values of all characters are processed uniformly, improving the reliability of character color processing, avoiding the appearance of unprocessed characters, and improving the aesthetics of typesetting and answering questions.
Smart Images

Figure CN116485920B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a character color processing method, apparatus, device, and storage medium. Background Art
[0002] In recent years, students have used a variety of supplementary teaching books. The questions recommended in the supplementary teaching books are selected from the question bank. Since the questions in the question bank come from many sources, the character colors in the question images are not uniform. When the question images with inconsistent character colors are used for typesetting, the aesthetics are poor, which will also affect students' answering efficiency and accuracy.
[0003] To improve the aesthetics of question image layout, related techniques first segment characters from the question image, then perform color processing on the segmented characters to uniformly colorize them. The question layout is then based on the color-processed characters. However, the character segmentation process is prone to character loss, resulting in a small number of characters remaining unprocessed after color processing, making the color processing results less reliable. Summary of the Invention
[0004] In order to solve the above technical problems, the present disclosure provides a character color processing method, device, equipment and storage medium.
[0005] In a first aspect, the present disclosure provides a character color processing method, the method comprising:
[0006] Performing character block detection on the title image data of the page to be processed to determine a target character block in the title image data, and performing character segmentation processing on the title image data to obtain a character segmentation map of the title image data, wherein each character in the target character block corresponds to first binary information, and the character segmentation map includes second binary information of each character;
[0007] determining target binarization information of each character based on the first binarization information of each character and the second binarization information of each character;
[0008] Based on the target binarization information of each character, the initial color value of each character in the question image data is processed to obtain the target color value of each character in the question image data.
[0009] In a second aspect, the present disclosure provides a character color processing device, the device comprising:
[0010] a detection module, configured to perform character block detection on the title image data of the to-be-processed page, and determine a target character block in the title image data, wherein each character in the target character block corresponds to the first binary information;
[0011] a segmentation module, configured to perform character segmentation processing on the question image data to obtain a character segmentation map of the question image data, wherein the character segmentation map includes second binarized information of each character;
[0012] a determination module, configured to determine target binarization information of each character based on the first binarization information of each character and the second binarization information of each character;
[0013] The color processing module is used to process the initial color value of each character in the question image data based on the target binarization information of each character to obtain the target color value of each character in the question image data.
[0014] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the device comprising:
[0015] processor;
[0016] a memory for storing executable instructions;
[0017] The processor is used to read executable instructions from the memory and execute the executable instructions to implement the method provided by the first aspect above.
[0018] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored, wherein the storage medium stores the computer program, and when the computer program is executed by a processor, the processor implements the method provided in the first aspect above.
[0019] The technical solution provided by the embodiments of the present disclosure has the following advantages over the prior art:
[0020] The present invention discloses a method, device, equipment, and storage medium for character color processing. The method performs character block detection on the title image data of the processing page, determines the target character block in the title image data, and performs character segmentation processing on the title image data to obtain a character segmentation map of the title image data, wherein each character in the target character block corresponds to first binary information, and the character segmentation map contains second binary information of each character; based on the first binary information of each character and the second binary information of each character, the target binary information of each character is determined; based on the target binary information of the character, the initial color value of each character in the title image data is processed to obtain the target color value of each character in the title image data. Therefore, when processing the character color, character block detection and character segmentation processing are performed on the title image data at the same time to prevent the problem of missing characters, obtain the binary information of all characters, and unify the color of the characters based on the binary information of each character. Characters that have not been color-unified will not appear, thereby ensuring the reliability of the character color processing results. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0022] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0023] Figure 1 A flowchart of a character color processing method provided by an embodiment of the present disclosure;
[0024] Figure 2 A logical diagram of a character color processing method provided by an embodiment of the present disclosure;
[0025] Figure 3 A schematic structural diagram of a character color processing device provided in an embodiment of the present disclosure;
[0026] Figure 4 A schematic structural diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0028] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0029] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc. mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0030] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0031] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0032] In the related art, the character color processing solution is generally based on the character segmentation model to segment the characters from the question image data, and then unify the colors of the segmented characters. However, the character segmentation method based on the character segmentation model is prone to the problem of character loss, resulting in a small number of characters still not being color processed after color processing. The related art also adopts an image binarization method to extract the binarization information of each character from the question image data, and unify the colors of the characters based on the binarization information of each character. However, the image binarization method is prone to the problem of image binarization failure, which makes it impossible to extract the binarization information of some characters in the question image data, resulting in the inability to unify the colors of some characters in the question image.
[0033] In summary, based on the character color processing method in the related art, it is easy to cause the color of some characters in the question image to be inconsistent, resulting in poor reliability of the character color processing result.
[0034] In order to improve the reliability of character color processing results, the following Figures 1 to 2 The character color processing method provided in the embodiments of the present disclosure is described. In the embodiments of the present disclosure, the character color processing method can be executed by an electronic device or a server. The electronic device may include a mobile phone, tablet computer, desktop computer, laptop computer, or other device with communication capabilities. The server may be a cloud server or server cluster, or other device with storage and computing capabilities. It should be noted that the following embodiments are explained exemplarily using an electronic device as the execution subject.
[0035] Figure 1 A flow chart of a character color processing method provided by an embodiment of the present disclosure is shown.
[0036] like Figure 1 As shown, the character color processing method may include the following steps.
[0037] S110. Perform character block detection on the title image data of the page to be processed, determine the target character block in the title image data, and perform character segmentation processing on the title image data to obtain a character segmentation map of the title image data, wherein each character in the target character block corresponds to the first binary information, and the character segmentation map contains the second binary information of each character.
[0038] In this embodiment, when unifying the color of characters in a supplementary teaching book, any page in the supplementary teaching book is obtained as a page to be processed, the page to be processed contains multiple questions, the question image data of the page to be processed is obtained, and then the color of each character in the question image data is unified.
[0039] In some embodiments, multiple connected domain blocks are removed from the question image data, and the remaining blocks are used as target character blocks, where each character in the target character block corresponds to the first binarized information. Optionally, the multiple connected domain blocks removed may include, but are not limited to, illustration blocks, noise blocks, and blocks with a large intersection with the illustration.
[0040] In other embodiments, single character detection is performed on the question image data, and the detected single character block is used as the target character block in the question image data, and each character in the target character block corresponds to the first binary information.
[0041] In the disclosed embodiment, before character segmentation is performed on the question image data, the question image data is preprocessed, for example, by scaling the question image data to a standard size or performing data normalization. Character segmentation is then performed on the preprocessed question image data to obtain a character segmentation map, in which each character in the character segmentation map corresponds to the second binary information. Alternatively, the question image data may be segmented using a pre-trained character segmentation model, an average segmentation algorithm, a color fill segmentation algorithm (CFS), or the like to obtain a character segmentation map.
[0042] Therefore, when processing the character color, character block detection and character segmentation processing are performed on the question image data at the same time to prevent the problem of missing characters and obtain binary information of all characters.
[0043] S120 : Determine target binarization information of each character based on the first binarization information of each character and the second binarization information of each character.
[0044] It is understandable that character block detection on the question image data may result in missed characters, and character segmentation processing on the question image data may result in loss of binarized information. Combining the first binarized information and the second binarized information of each character can minimize the loss of binarized information for some character strokes. For this reason, S120 specifically includes: adding the first binarized information and the second binarized information of each character to obtain target binarized information for each character.
[0045] The target binarization information is the binarization information of all characters in the title image.
[0046] Furthermore, the target binarization information of each character is compared with a preset binarization threshold, and characters with target binarization information greater than the preset binarization threshold are determined as character pixels, and characters with target binarization information less than the preset binarization threshold are determined as background pixels. Optionally, the preset binarization threshold can be 0, the target binarization information of the character pixel is 1, and the target binarization information of the background pixel is 0.
[0047] S130 : Based on the target binarization information of each character, the initial color value of each character in the question image data is processed to obtain the target color value of each character in the question image data.
[0048] In this embodiment, optionally, S130 specifically includes:
[0049] S1301: Obtain a preset background image and determine the color value of each pixel in the preset background image;
[0050] S1302 : Based on the target binarization information of each character and the color value of each pixel in the preset background image, the initial color value of each character in the question image data is processed to obtain the target color value of each character in the question image data.
[0051] Among them, S1302 specifically includes: multiplying the initial color value of each character by the target binarization information of each character to obtain a first product; adding the opposite of the target binarization information of each character to the target value, and multiplying the sum of the opposite number and the target value by the color value of each pixel in the preset background image to obtain a second product; calculating the sum of the first product and the second product to obtain the target color value of each character in the question image data.
[0052] Optionally, the target color value of each character can be determined as follows:
[0053] Img_out=Fcolor*MSK+Img_bg*(1-MSK)
[0054] Among them, Img_out is the target color value of each character, MSK is the target binarization information of each character, specifically the target binarization information of the character pixel is 1, and the target binarization information of the background pixel is 0, Fcolor is the initial color value of each character, and Img_bg is the color value of each pixel in the preset background image.
[0055] Using the above formula, each character's initial color value multiplied by the target binarization information 1 becomes the font color value. The character's initial color value multiplied by the target binarization information 0 becomes the background pixel value. (1 - target binarization information 1) multiplied by the background pixel value becomes 0, and (1 - target binarization information 0) multiplied by the background pixel value becomes the background pixel. Thus, the initial color of each character is added to the background image to form an image with both foreground and background, resulting in the target color value for each character.
[0056] The disclosed embodiment provides a character color processing method, which performs character block detection on the title image data of the processing page, determines the target character block in the title image data, and performs character segmentation processing on the title image data to obtain a character segmentation map of the title image data, wherein each character in the target character block corresponds to first binary information, and the character segmentation map contains second binary information of each character; based on the first binary information of each character and the second binary information of each character, the target binary information of each character is determined; based on the target binary information of the character, the initial color value of each character in the title image data is processed to obtain the target color value of each character in the title image data. Therefore, when processing the character color, character block detection and character segmentation processing are performed on the title image data at the same time to prevent the problem of missing characters, obtain the binary information of all characters, and unify the color of the characters based on the binary information of each character, so that characters that have not been unified in color will not appear, thereby ensuring the reliability of the character color processing results.
[0057] It is understandable that there may be illustrations of larger sizes in the title image data. In order to avoid the impact of illustrations on character color processing, the title image data is first preprocessed, for example, the title image data is scaled to a standard size or the data is normalized, and then the illustrations in the title image data are removed to obtain the title image data without illustrations, and then the characters in the title image data without illustrations are color processed.
[0058] In this embodiment, before S110, the method further includes: performing illustration removal processing on the title image data of the to-be-processed page to obtain the title image data after illustration removal;
[0059] Accordingly, S110 specifically includes: performing character block detection on the question image data after the illustrations are removed, determining the target character block in the question image data, and performing character segmentation processing on the question image data after the illustrations are removed to obtain a character segmentation map of the question image data.
[0060] Among them, the title image data of the processed page is subjected to illustration removal processing to obtain the title image data after the illustrations are removed, including: using a pre-trained illustration detection model to perform illustration detection processing on the title image data, determining multiple illustrations in the title image data, and removing the multiple illustrations from the title image data to obtain the title image data after the illustrations are removed.
[0061] The pre-trained illustration detection model may be a model of the YOLOv series, specifically a YOLOv7 model. In other embodiments, the pre-trained illustration detection model may also be a model such as SSD or mask-rcnn.
[0062] Therefore, before performing character block detection and character segmentation processing on the title image data, performing illustration removal processing on the title image data can avoid the impact of illustrations on character color processing, which is beneficial to improving the accuracy of character block detection and character segmentation processing.
[0063] In another embodiment of the present disclosure, character block detection is performed on the question image data in two ways to obtain the target character blocks in the question image data, and a character segmentation model is used to perform character segmentation processing on the question image data to obtain a character segmentation map of the question image.
[0064] In some embodiments of the present disclosure, the step of “performing character block detection on the title image data of the page to be processed to determine the target character block in the title image data” in S110 includes:
[0065] S1101, performing block removal processing on the question image data to obtain the first character detection block;
[0066] S1102, performing single character detection processing on the question image data to obtain a second character detection block;
[0067] S1103 : Merge the first character detection block and the second character detection block to obtain a target character block.
[0068] Among them, S1101 specifically includes: S1, binarizing the question image data to generate a question binary image; S2, performing connected domain analysis on the question binary image to obtain multiple connected domain blocks; S3, removing multiple target connected domain blocks from the question image data based on the block information of the multiple connected domain blocks, and using the remaining blocks as the first character detection blocks.
[0069] Specifically, the question image data is first binarized using methods such as OTSU binarization, fixed threshold binarization, and adaptive binarization to obtain a question binary image. Then, a connected domain analysis is performed on the question binary image to obtain multiple connected domain blocks, and the block information of each connected domain block is determined. Then, based on the block information of the multiple connected domain blocks, multiple target connected domain blocks are removed to obtain the first character test block.
[0070] Among them, "removing multiple target connected domain blocks from the title image data based on block information of multiple connected domain blocks" in S3 includes: when the block information is the block size of each connected domain block, determining from the title image data a first type of blocks whose block size is greater than or equal to a first size threshold, taking the first type of blocks as target connected domain blocks and removing them; and / or, when the block information is the block size of each connected domain block, removing from the title image data a second type of blocks whose block size is greater than or equal to a second size threshold, taking the second type of blocks as target connected domain blocks and removing them; and / or, when the block information is the intersection range of each connected domain block and the illustration, removing from the title image data a third type of blocks whose intersection block range is greater than or equal to a preset intersection range threshold, taking the third type of blocks as target connected domain blocks and removing them.
[0071] The block size of each connected domain block includes but is not limited to an average width Wr, an average height Hr, and an average width Wr*average height Hr.
[0072] Among them, the first type of blocks are illustration blocks in the title image data. Illustration blocks are much larger than characters, so illustration blocks need to be filtered.
[0073] In some embodiments, the block size is the average width Wr of the current block, and the first size threshold is the average block width Wavg*the illustration width threshold W1. If the average width Wr of the current block is greater than the average block width Wavg*the illustration width threshold W1, the current block belongs to the first type of block, and the first type of block is taken as the target connected domain block and removed.
[0074] In other embodiments, the block size is the average height Hr of the current block, and the first size threshold is the block average height Hr*the illustration height threshold W2. If the average height Hr of the current block is greater than the block average height Havg*the illustration height threshold W2, then the current block belongs to the first type of block, and the first type of block is taken as the target connected domain block and removed.
[0075] In some other embodiments, the block size is the average height Hr*average width Wr of the current block, and the first size threshold is the average height Havg*average width Wavg*illustration area threshold W3 of the block. If the average height Hr*average width Wr of the current block is greater than the average height Havg*average width Wavg*illustration area threshold W3 of the block, then the current block belongs to the first type of block, and the first type of block is used as the target connected domain block and is removed.
[0076] Among them, the second type of blocks are noise blocks in the question image data, specifically salt and pepper noise blocks. If the noise blocks are larger than the characters, the noise blocks need to be filtered.
[0077] Specifically, the block size is the average height Hr*average width Wr of the current block, and the second size threshold is the average height Hr*illustration area threshold W3 of the block. If the average height Hr*average width Wr of the current block is greater than the average height Havg*average width Wavg*illustration area threshold W3 of the block, the current block belongs to the second type of block, and the second type of block is taken as the target connected domain block and removed.
[0078] The third type of block is a noise block with a large intersection with the illustration. It can be understood that a larger intersection indicates that the block is also a title illustration and should be filtered out. Conversely, a smaller intersection indicates that the block is less likely to be a title illustration and should be retained.
[0079] The intersection range is determined based on the position of the pixel points where each connected domain block intersects with the illustration. The preset intersection range threshold is pre-selected and determined based on experience.
[0080] S1102 specifically includes: using a pre-trained single-character detection model to perform single-character detection processing on the question image data to obtain a second character detection block.
[0081] Specifically, before performing single character detection processing on the title image data, the title image data can be preprocessed, for example, the title image data can be scaled to a standard size, or the title image data can be normalized, and then the title image data can be input into a pre-trained single character detection model, and the single character detection model can be used to perform forward reasoning on the title image data to detect the position information of a single character in the title image data, and determine the second character detection block based on the position information of the single character.
[0082] Optionally, pre-trained single-character detection models include but are not limited to YOLOv5, SSD models, etc.
[0083] It is understandable that when using block removal processing or single character detection processing alone for character block detection, the problem of missed character detection is likely to occur. In order to comprehensively detect the characters, the block removal processing method and the single character detection processing method are combined for character detection, and the first character detection block and the second character detection block obtained by detection are merged to obtain the target character block of the question image data, thereby avoiding the problem of missed character detection and improving the reliability of the character detection results.
[0084] In some embodiments of the present disclosure, "performing character segmentation processing on the question image data to obtain a character segmentation map of the question image data" in S110 includes: using a pre-trained character segmentation model to perform character segmentation processing on the question image data to obtain a character segmentation map of the question image data.
[0085] Specifically, before performing character segmentation processing on the question image data, the question image data can be preprocessed, for example, the question image data can be scaled to a standard size, or the question image data can be normalized, and then the question image data can be input into a pre-trained character segmentation model, and the pre-trained character segmentation model can be used to perform forward reasoning on the question image data to determine the second binarization information of each character, and generate a character segmentation map based on the second binarization information of each character and the position of each character.
[0086] Optionally, pre-trained character segmentation models include but are not limited to U2net, other models in the U2net series, and PointRend models.
[0087] In other embodiments, the position information of each character can be detected from the question image data, and based on the position information of each character, multiple characters can be segmented from the question image data, and the binarization information of each character can be determined. Based on each character and the binarization information of each character, a character segmentation map of the question image data can be generated.
[0088] Furthermore, the first binarization information of each character and the second binarization information of each character are added together to obtain target binarization information of each character, so that color uniformity processing is performed using the target binarization information of each character.
[0089] In summary, we first use the traditional block removal method and the single-character model detection method to detect character blocks together, determine the first binary information of each character, and then use the character segmentation model to determine the second binary information of each character. Finally, we use the first binary information of each character and the second binary information of each character to perform character color processing together. Therefore, we avoid the appearance of characters that are not unified in color and ensure the reliability of the character color processing results.
[0090] In yet another embodiment of the present disclosure, a character color processing method is explained as a whole.
[0091] Figure 2 A logical schematic diagram of a character color processing method provided by an embodiment of the present disclosure is shown.
[0092] like Figure 2 As shown, the character color processing method may include the following steps.
[0093] S210: Input the title image data of the page to be processed.
[0094] S220 , performing illustration removal processing on the title image data of the page to be processed to obtain the title image data after illustration removal.
[0095] Specifically, a pre-trained illustration detection model is used to perform illustration detection processing on the title image data, multiple illustrations in the title image data are determined, and the multiple illustrations are removed from the title image data to obtain the title image data after illustration removal.
[0096] S230 , extracting target binarization information of each character from the title image data after the illustrations are removed.
[0097] Among them, S230 specifically includes: performing character block detection on the question image data after the illustrations are removed to determine the target character block, and performing character segmentation processing on the question image data after the illustrations are removed to obtain a character segmentation map, wherein each character in the target character block corresponds to the first binary information, and the character segmentation map contains the second binary information of each character; merging the first character detection block and the second character detection block to obtain the target character block.
[0098] Among them, character block detection is performed on the title image data after the illustrations are removed to determine the target character block, including: performing block removal processing on the title image data after the illustrations are removed to obtain a first character detection block; performing single character detection processing on the title image data after the illustrations are removed to obtain a second character detection block; and merging the first character detection block and the second character detection block to obtain a target character block.
[0099] The character segmentation process is performed on the question image data after the illustrations are removed to obtain a character segmentation map, including: using a pre-trained single character detection model to perform single character detection on the question image data to obtain a second character detection block.
[0100] The step of performing character segmentation processing on the question image data after the illustrations are removed to obtain a character segmentation map includes: using a pre-trained character segmentation model to perform character segmentation processing on the question image data after the illustrations are removed to obtain a character segmentation map.
[0101] S240 : Based on the target binarization information of each character, the initial color value of each character in the question image data is processed to obtain the target color value of each character in the question image data.
[0102] Among them, S240 specifically includes: obtaining a preset background image and determining the color value of each pixel in the preset background image; based on the target binarization information of each character and the color value of each pixel in the preset background image, processing the initial color value of each character in the question image data to obtain the target color value of each character in the question image data.
[0103] The embodiment of the present disclosure also provides a character color processing device for implementing the above character color processing method. Figure 3In the embodiments of the present disclosure, the character color processing device may be an electronic device or a server. The electronic device may include a mobile phone, tablet computer, desktop computer, laptop computer, or other device with communication capabilities. The server may be a cloud server or server cluster, or other device with storage and computing capabilities.
[0104] Figure 3 A structural schematic diagram of a character color processing device provided by an embodiment of the present disclosure is shown.
[0105] like Figure 3 As shown, the character color processing device 300 may include:
[0106] The detection module 310 is configured to perform character block detection on the title image data of the page to be processed, and determine a target character block in the title image data, wherein each character in the target character block corresponds to the first binary information;
[0107] a segmentation module 320 for performing character segmentation processing on the question image data to obtain a character segmentation map of the question image data, wherein the character segmentation map includes second binarized information of each character;
[0108] A determination module 330, configured to determine target binarization information of each character based on the first binarization information of each character and the second binarization information of each character;
[0109] The color processing module 340 is configured to process the initial color value of each character in the question image data based on the target binarization information of each character to obtain the target color value of each character in the question image data.
[0110] The disclosed embodiment provides a character color processing device, which performs character block detection on the title image data of the processing page, determines the target character block in the title image data, and performs character segmentation processing on the title image data to obtain a character segmentation map of the title image data, wherein each character in the target character block corresponds to first binary information, and the character segmentation map contains second binary information of each character; based on the first binary information of each character and the second binary information of each character, the target binary information of each character is determined; based on the target binary information of the character, the initial color value of each character in the title image data is processed to obtain the target color value of each character in the title image data. Therefore, when processing the character color, character block detection and character segmentation processing are performed on the title image data at the same time to prevent the problem of missing characters, obtain the binary information of all characters, and unify the color of the characters based on the binary information of each character, so that characters that have not been unified in color will not appear, thereby ensuring the reliability of the character color processing results.
[0111] In some optional embodiments, the detection module 310 includes:
[0112] a block removal unit, configured to perform block removal processing on the question image data to obtain a first character detection block;
[0113] a single character detection unit, configured to perform single character detection processing on the question image data to obtain a second character detection block;
[0114] The block merging unit is configured to merge the first character detection block and the second character detection block to obtain the target character block.
[0115] In some optional embodiments, the block removal unit is specifically configured to:
[0116] Binarizing the question image data to generate a question binary image;
[0117] Performing connected domain analysis on the binary image of the question to obtain multiple connected domain blocks;
[0118] According to the block information of the multiple connected domain blocks, multiple target connected domain blocks are removed from the question image data, and the remaining blocks are used as the first character detection blocks.
[0119] In some optional embodiments, the block removal unit is specifically configured to:
[0120] In a case where the block information is the block size of each connected domain block, determining a first type of blocks having a block size greater than or equal to a first size threshold from the subject image data, and removing the first type of blocks as the target connected domain blocks; and / or,
[0121] In a case where the block information is the block size of each connected domain block, removing the second type of blocks whose block size is greater than or equal to a second size threshold from the subject image data, and taking the second type of blocks as the target connected domain blocks and removing them; and / or,
[0122] In a case where the block information is the intersection range of each connected domain block and the illustration, third-type blocks whose intersection block range is greater than or equal to a preset intersection range threshold are removed from the title image data, and the third-type blocks are used as the target connected domain blocks and removed.
[0123] In some optional embodiments, the single character detection unit is specifically configured to:
[0124] The pre-trained single-character detection model is used to perform single-character detection processing on the question image data to obtain the second character detection block.
[0125] In some optional embodiments, the segmentation module 320 is specifically configured to:
[0126] The pre-trained character segmentation model is used to perform character segmentation processing on the question image data to obtain a character segmentation map of the question image data.
[0127] In some optional embodiments, the determination module 330 is specifically configured to:
[0128] The first binarization information of each character and the second binarization information of each character are added together to obtain target binarization information of each character.
[0129] In some optional embodiments, the color processing module 340 includes:
[0130] An acquisition unit, configured to acquire a preset background image and determine the color value of each pixel in the preset background image;
[0131] The color processing unit is used to process the initial color value of each character in the question image data based on the target binarization information of each character and the color value of each pixel in the preset background image to obtain the target color value of each character in the question image data.
[0132] In some optional embodiments, the color processing unit is specifically configured to:
[0133] Multiplying the initial color value of each character by the target binarization information of each character to obtain a first product;
[0134] Adding the opposite number of the target binary information of each character to the target value, and multiplying the sum of the opposite number and the target value by the color value of each pixel in the preset background image to obtain a second product;
[0135] The sum of the first product and the second product is calculated to obtain a target color value of each character in the question image data.
[0136] In some optional embodiments, the device further comprises:
[0137] An illustration removal module is used to perform illustration removal processing on the title image data of the page to be processed to obtain the title image data after the illustration is removed;
[0138] Accordingly, the detection module 310 is specifically configured to:
[0139] Performing character block detection on the title image data after the illustrations are removed to determine a target character block in the title image data;
[0140] Accordingly, the segmentation module 320 is specifically configured to:
[0141] Performing character segmentation processing on the title image data after the illustrations are removed to obtain a character segmentation map of the title image data.
[0142] In some optional embodiments, the illustration removal module is specifically configured to:
[0143] Using a pre-trained illustration detection model, the title image data is subjected to illustration detection processing to determine multiple illustrations in the title image data, and the multiple illustrations are removed from the title image data to obtain the title image data after the illustrations are removed.
[0144] It should be noted that Figure 3 The character color processing device 300 shown can execute Figures 1 to 2 The various steps in the method embodiment shown are implemented Figures 1 to 2 The various processes and effects in the illustrated method embodiment are not described in detail here.
[0145] The exemplary embodiments of the present disclosure further provide an electronic device including: at least one processor; and a memory communicatively connected to the at least one processor. The memory stores a computer program executable by the at least one processor, which, when executed by the at least one processor, causes the electronic device to perform a method according to an exemplary embodiment of the present disclosure.
[0146] Exemplary embodiments of the present disclosure also provide a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to perform the method according to an embodiment of the present disclosure.
[0147] Exemplary embodiments of the present disclosure further provide a computer program product, including a computer program, wherein when the computer program is executed by a processor of a computer, it is used to cause the computer to perform the method according to the embodiment of the present disclosure.
[0148] refer to Figure 4, a structural block diagram of an electronic device 400 that can serve as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure, and the electronic device 400 can be the above-mentioned electronic device. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0149] like Figure 4 As shown, the electronic device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.
[0150] Multiple components within electronic device 400 are connected to I / O interface 405, including an input unit 406, an output unit 407, a storage unit 408, and a communication unit 409. Input unit 406 can be any type of device capable of inputting information into electronic device 400. Input unit 406 can receive input numeric or character information and generate key input signals related to user settings and / or function control of the electronic device. Output unit 407 can be any type of device capable of presenting information and may include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. Storage unit 408 may include, but is not limited to, a magnetic disk or an optical disk. Communication unit 409 allows electronic device 400 to exchange information / data with other devices via computer networks such as the Internet and / or various telecommunication networks and may include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver and / or a chipset, such as a Bluetooth™ device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.
[0151] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above. For example, in some embodiments, the character color processing method may be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 400 via the ROM 402 and / or the communication unit 409. In some embodiments, the computing unit 401 may be configured to perform the character color processing method in any other appropriate manner (e.g., by means of firmware).
[0152] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0153] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0154] As used in this disclosure, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., a magnetic disk, an optical disk, a memory, a programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including machine-readable media that receive machine instructions as machine-readable signals. The term "machine-readable signal" refers to any signal used to provide machine instructions and / or data to a programmable processor.
[0155] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0156] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0157] Computer systems may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The client and server relationship arises through computer programs running on the respective computers and having a client-server relationship to each other.
[0158] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device that includes the element.
[0159] The above are merely specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not limited to these embodiments, but is to be construed in the broadest manner consistent with the principles and novel features disclosed herein.
Claims
1. A character color processing method, characterized in that: include: Performing character block detection on the title image data of the page to be processed to determine a target character block in the title image data, and performing character segmentation processing on the title image data to obtain a character segmentation map of the title image data, wherein each character in the target character block corresponds to first binary information, and the character segmentation map includes second binary information of each character; determining target binarization information of each character based on the first binarization information of each character and the second binarization information of each character; Based on the target binarization information of each character, the initial color value of each character in the question image data is processed to obtain the target color value of each character in the question image data.
2. The method according to claim 1, characterized in that The step of performing character block detection on the title image data of the page to be processed and determining the target character block in the title image data includes: Performing block removal processing on the question image data to obtain a first character detection block; Performing single character detection processing on the question image data to obtain a second character detection block; The first character detection block and the second character detection block are merged to obtain the target character block.
3. The method according to claim 2, characterized in that The step of performing block removal processing on the title image data to obtain a first character detection block includes: Binarizing the question image data to generate a binary question image; Performing connected domain analysis on the binary image of the question to obtain multiple connected domain blocks; According to the block information of the multiple connected domain blocks, multiple target connected domain blocks are removed from the question image data, and the remaining blocks are used as the first character detection blocks.
4. The method according to claim 3, characterized in that The removing of a plurality of target connected domain blocks from the subject image data according to the block information of the plurality of connected domain blocks comprises: In a case where the block information is the block size of each connected domain block, determining a first type of blocks having a block size greater than or equal to a first size threshold from the subject image data, and removing the first type of blocks as the target connected domain blocks; and / or, In a case where the block information is the block size of each connected domain block, removing the second type of blocks whose block size is greater than or equal to a second size threshold from the subject image data, and taking the second type of blocks as the target connected domain blocks and removing them; and / or, In a case where the block information is the intersection range of each connected domain block and the illustration, third-type blocks whose intersection block range is greater than or equal to a preset intersection range threshold are removed from the title image data, and the third-type blocks are used as the target connected domain blocks and removed.
5. The method according to claim 2, characterized in that The single character detection processing is performed on the title image data to obtain a second character detection block, including: The pre-trained single-character detection model is used to perform single-character detection processing on the question image data to obtain the second character detection block.
6. The method according to claim 1, characterized in that The step of performing character segmentation processing on the question image data to obtain a character segmentation map of the question image data includes: The pre-trained character segmentation model is used to perform character segmentation processing on the question image data to obtain a character segmentation map of the question image data.
7. The method according to claim 1, characterized in that The determining target binarization information of each character based on the first binarization information of each character and the second binarization information of each character includes: The first binarization information of each character and the second binarization information of each character are added together to obtain target binarization information of each character.
8. The method according to claim 1, characterized in that The processing of the initial color value of each character in the question image data based on the target binarization information of each character to obtain the target color value of each character in the question image data includes: Obtain a preset background image and determine the color value of each pixel in the preset background image; Based on the target binarization information of each character and the color value of each pixel in the preset background image, the initial color value of each character in the question image data is processed to obtain the target color value of each character in the question image data.
9. The method according to claim 8, characterized in that The processing of the initial color value of each character in the question image data based on the target binarization information of each character and the color value of each pixel in the preset background image to obtain the target color value of each character in the question image data includes: Multiplying the initial color value of each character by the target binarization information of each character to obtain a first product; Adding the opposite number of the target binary information of each character to the target value, and multiplying the sum of the opposite number and the target value by the color value of each pixel in the preset background image to obtain a second product; The sum of the first product and the second product is calculated to obtain a target color value of each character in the question image data.
10. The method according to any one of claims 1 to 9, characterized in that Before performing character block detection on the title image data of the page to be processed, determining the target character block in the title image data, and performing character segmentation processing on the title image data to obtain a character segmentation map of the title image data, the method further includes: Performing illustration removal processing on the title image data of the page to be processed to obtain the title image data after the illustration is removed; The step of performing character block detection on the title image data of the page to be processed, determining the target character block in the title image data, and performing character segmentation processing on the title image data to obtain a character segmentation map of the title image data includes: Character block detection is performed on the title image data after the illustrations are removed to determine the target character block in the title image data, and character segmentation processing is performed on the title image data after the illustrations are removed to obtain a character segmentation map of the title image data.
11. The method according to claim 10, characterized in that The step of performing illustration removal processing on the title image data of the page to be processed to obtain the title image data after illustration removal includes: Using a pre-trained illustration detection model, the title image data is subjected to illustration detection processing to determine multiple illustrations in the title image data, and the multiple illustrations are removed from the title image data to obtain the title image data after the illustrations are removed.
12. A character color processing device, characterized in that: include: a detection module, configured to perform character block detection on the title image data of the to-be-processed page, and determine a target character block in the title image data, wherein each character in the target character block corresponds to the first binary information; a segmentation module, configured to perform character segmentation processing on the question image data to obtain a character segmentation map of the question image data, wherein the character segmentation map includes second binarized information of each character; a determination module, configured to determine target binarization information of each character based on the first binarization information of each character and the second binarization information of each character; The color processing module is used to process the initial color value of each character in the question image data based on the target binarization information of each character to obtain the target color value of each character in the question image data.
13. An electronic device, characterized in that: include: processor; a memory for storing executable instructions; The processor is configured to read the executable instructions from the memory and execute the executable instructions to implement the method according to any one of claims 1 to 11.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Metal surface character defect detection method, system and device and storage medium
CN113450316A
Image processing apparatus, method, and storage medium
US20150181077A1