Image Processing Method, Apparatus, Device, and Storage Medium
By determining the alternative colors and similar colors sets of text macroblocks in image processing, obtaining the target color frequency and encoding, the problem of increasing data volume in image transmission is solved, and efficient data transmission is achieved under low bandwidth.
Patent Information
- Application Number
- CN202010591981.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-24
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2040-06-24
AI Technical Summary
In low bandwidth scenarios, the prior art sets different quantization parameters for the text image area and non-text image area in the image, resulting in an increase in the code stream of the text image area, which in turn leads to an increase in the amount of data in the image during transmission, which cannot adapt to the requirements of low bandwidth.
The text macroblock is determined from the macroblock of the frame image to be processed, N alternative colors are determined for each text macroblock, P similar color sets are formed, and the frequency of the target color and other colors is obtained. Each text macroblock is encoded by summing the first sum value, reducing the length of the data stream of the same color.
On the premise of ensuring text clarity, the amount of data in the image during transmission is reduced, the amount of data is increased, and the transmission requirements of low bandwidth are adapted.
Smart Images

Figure CN111932643B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing, and in particular, to an image processing method, apparatus, device, and storage medium. Background Art
[0002] Generally, in the transmission of JPEG format images, the types of images are not distinguished. In a low-bandwidth scenario, the same Discrete Cosine Transform (DCT) algorithm and quantization are used for lossy compression of all images. Since text images contain more high-frequency components, and DCT transformation and quantization will cause the loss of high-frequency components, the text in the text images will become blurred.
[0003] Currently, different quantization parameters can be set for the text image regions and non-text image regions in the image (the quantization parameter for the text image region is small, and the quantization parameter for the non-image region is large) to improve the image quality of the text image regions in the image. However, this may cause an increase in the bitstream of the text image regions in the image, and further cause an increase in the data volume during the transmission of the image, making it unable to meet the requirements of low bandwidth. Summary of the Invention
[0004] Embodiments of the present disclosure provide an image processing method, apparatus, device, and storage medium, which can solve the problem that setting different quantization parameters for the text image regions and non-text image regions in the image may cause an increase in the bitstream of the text image regions in the image, and further cause an increase in the data volume during the transmission of the image, making it unable to meet the requirements of low bandwidth. The technical solutions are as follows:
[0005] According to a first aspect of the embodiments of the present disclosure, an image processing method is provided, and the method includes:
[0006] Determine text macroblocks from at least one macroblock of a to-be-processed frame image;
[0007] For each text macroblock, determine N candidate colors from the text macroblock, where N is an integer greater than 1;
[0008] Determine P similarity sets from the N candidate colors, where P is an integer greater than or equal to 1, the similarity set is a set of similar colors, and the similar colors are colors with a difference in pixel values less than a preset difference threshold;
[0009] Obtain a target color corresponding to each similarity set, where the target color is the color with the highest frequency in the similarity set;
[0010] Determine the frequencies of the P target colors in each text macroblock and the frequencies of I other colors except the P similarity sets;
[0011] Sum the frequencies corresponding to each same color among the P target colors and I other colors in all text macroblocks to obtain a first sum value for each same color frequency.
[0012] Encode each text macroblock according to the first sum value.
[0013] The image processing method provided by the embodiments of the present disclosure can determine text macroblocks from at least one macroblock of a to-be-processed frame image; for each text macroblock, determine N candidate colors from the text macroblock; determine P similarity sets from the N candidate colors; obtain the target color corresponding to each similarity set; determine the frequency of the P target colors and the frequency of I other colors except the P similarity sets in each text macroblock; sum the frequencies corresponding to each same color among the P target colors and I other colors in all text macroblocks to obtain a first sum value for each same color frequency; encode each text macroblock according to the first sum value, so that the probability of the appearance of the color in each macroblock becomes larger, and further the length of the data code stream of each same color after encoding becomes shorter, and finally the data volume of the encoded text macroblock during transmission is reduced. In the scenario of ensuring text clarity, the data volume of the to-be-processed frame image after encoding during transmission is reduced, avoiding the problem that the code stream of the text image area in the image may increase using the prior art, and further resulting in an increase in the data volume of the image during transmission and being unable to meet the requirements of low bandwidth.
[0014] In one embodiment, the encoding each text macroblock according to the includes:
[0015] Encode each same color among the P target colors and I other colors in each text macroblock according to the first sum value.
[0016] By encoding each same color among the P target colors and I other colors in each text macroblock according to the first sum value, the probability of the appearance of each same color is increased, and further the length of the data code stream of the same color after encoding becomes shorter, reducing the data volume of the image during transmission.
[0017] In one embodiment, the determining N candidate colors from the text macroblock includes:
[0018] Count the frequency of each color in the text macroblock;
[0019] Sort each color in descending order of frequency;
[0020] Determine the colors ranked in the top N as the candidate colors of the text macroblock.
[0021] In one embodiment, the obtaining of the target color corresponding to each similarity set includes:
[0022] Taking the color with the highest frequency in each similarity set as the target color corresponding to each similarity set.
[0023] By determining the target color, the number of color types in the text macroblock can be reduced.
[0024] In one embodiment, the determining of the frequency of the target color includes:
[0025] Calculating the second sum value of the frequencies of all colors in the similarity set;
[0026] Taking the second sum value as the frequency of the target color.
[0027] By taking the second sum value of the frequencies of all colors in the similarity set as the frequency of the target color, the frequency of the target color can be increased, so that the probability of the target color appearing is increased. Furthermore, the length of the data bitstream after encoding of the target color is shortened, and the data volume during the transmission of the image is reduced.
[0028] In one embodiment, the method further includes:
[0029] Encoding the non-text macroblocks in the to-be-processed frame image.
[0030] By encoding the non-text macroblocks, the security of the to-be-processed frame image during transmission is improved.
[0031] According to a second aspect of the embodiments of the present disclosure, there is provided an image processing apparatus, including:
[0032] A text macroblock determination module, configured to determine text macroblocks from at least one macroblock of a to-be-processed frame image;
[0033] An alternative color determination module, configured to determine N alternative colors from the text macroblock for each text macroblock, where N is an integer greater than 1;
[0034] A similarity set determination module, configured to determine P similarity sets from the N alternative colors, where P is an integer greater than or equal to 1, the similarity set is a set of similar colors, and the similar colors are colors with a difference in pixel values less than a preset difference threshold;
[0035] A target color obtaining module, configured to obtain the target color corresponding to each similarity set, where the target color is the color with the highest frequency in the similarity set;
[0036] A color frequency determination module, configured to determine the frequencies of P target colors in each text macroblock and the frequencies of I other colors except the P similarity sets;
[0037] A first sum determination module, configured to sum the frequencies corresponding to each same color among the P target colors and the I other colors in all text macroblocks, to obtain a first sum of the frequencies of each same color;
[0038] A text macroblock encoding module, configured to encode each text macroblock according to the first sum.
[0039] In one embodiment, the text macroblock encoding module is configured to:
[0040] Encode each same color among the P target colors and the I other colors in each text macroblock according to the first sum.
[0041] In one embodiment, the alternative color determination module is configured to:
[0042] Count the frequencies of each color in the text macroblock;
[0043] Sort each of the colors in descending order of frequency;
[0044] Determine that the colors ranked in the first N are the alternative colors of the text macroblock.
[0045] In one embodiment, the target color acquisition module is configured to:
[0046] Use the color with the highest frequency in each similarity set as the target color corresponding to each similarity set.
[0047] In one embodiment, the color frequency determination module is configured to:
[0048] Calculate a second sum of the frequencies of all colors in the similarity set;
[0049] Use the second sum as the frequency of the target color.
[0050] In one embodiment, the apparatus further includes:
[0051] A non-text macroblock encoding module, configured to encode non-text macroblocks in the to-be-processed frame image.
[0052] According to a third aspect of the embodiments of the present disclosure, there is provided an image processing device, including a processor and a memory, where at least one computer instruction is stored in the memory, and the instruction is loaded and executed by the processor to implement the steps performed in the image processing method according to any one of the first aspect.
[0053] According to a fourth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium storing at least one computer instruction, which is loaded and executed by a processor to implement the steps performed in the image processing method according to any one of the first aspects.
[0054] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and should not limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure and used together with the specification to explain the principles of the present disclosure.
[0056] Figure 1 is a flowchart of an image processing method provided by an embodiment of the present disclosure Figure 1 ;
[0057] Figure 2 is a flowchart of an image processing method provided by an embodiment of the present disclosure Figure 2 ;
[0058] Figure 3 is a schematic diagram of the logical process of an image processing method provided by an embodiment of the present disclosure;
[0059] Figure 4 is the structure of an image processing apparatus provided by an embodiment of the present disclosure Figure 1 ;
[0060] Figure 5 is the structure of an image processing apparatus provided by an embodiment of the present disclosure Figure 2 ;
[0061] Figure 6 is a structural diagram of an image processing device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0062] Here, the exemplary embodiments will be described in detail, and the examples are shown in the accompanying drawings. When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. On the contrary, they are only examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0063] Figure 1 is a flowchart of an image processing method provided by an embodiment of the present disclosure Figure 1 . As Figure 1 shown, the method includes:
[0064] S101. Determine text macroblocks from at least one macroblock of the frame image to be processed.
[0065] Exemplarily, after obtaining the frame image to be processed, perform macroblock partitioning on the frame image to be processed to generate at least one macroblock. Then, according to the rendering instruction of the frame image to be processed, obtain the first rendering position information of the text image area and the second rendering position information of the non-text image area in the frame image to be processed.
[0066] Among them, the rendering instruction includes data such as rendering content and rendering position information. According to the rendering content in the rendering instruction, it can be determined whether the frame image to be processed is a text image or a non-text image. According to the position information, the position information of the text image, that is, the "first rendering position information", and the position information of the non-text image, that is, the "second rendering position information", can be determined.
[0067] For each macroblock, determine whether the macroblock is a text macroblock according to the first rendering position information. If the coordinate range of the macroblock includes the first rendering position information, the macroblock is a text macroblock; if the coordinate range of the macroblock does not include the first rendering position information, the macroblock is a non-text macroblock.
[0068] Further, if there are text macroblocks in the frame image to be processed, the frame image to be processed is a text image; otherwise, the frame image to be processed is a non-text image.
[0069] S102. For each text macroblock, determine N alternative colors from the text macroblock, where N is an integer greater than 1.
[0070] In this step, first count the frequency of each color in the text macroblock; then sort each color in descending order of frequency; determine the top N colors as the alternative colors of the text macroblock. Exemplarily, the value of N is positively correlated with the number of color types in the text macroblock, that is, the larger the number of color types in the text macroblock, the larger the value of N.
[0071] S103. Determine P similarity sets from the N alternative colors, where P is an integer greater than or equal to 1. The similarity set is a set of similar colors, and the similar colors are colors with a pixel value difference less than a preset difference threshold.
[0072] Exemplarily, each similarity set includes at least two similar colors, and the pixel value difference between every two colors in each similarity set is less than the preset difference threshold.
[0073] S104. Obtain the target color corresponding to each similarity set, and the target color is the color with the highest frequency in the similarity set.
[0074] Exemplarily, for each similar set, determine the color with the highest frequency in the similar set, and use the color with the highest frequency in the similar set as the target color corresponding to each similar set, and then use the target color as the final color of the similar set.
[0075] S105. Determine the frequencies of the P target colors in each text macro-block and the frequencies of the I other colors except for the P similar sets.
[0076] Exemplarily, for each text macro-block, calculate the second sum value of the frequencies of all colors in each similar set in the text macro-block; and use the second sum value as the frequency of the target color of the similar set. Then, determine the frequencies of the I other colors except for the P similar sets in the text macro-block according to the frequencies of each color in the text macro-block statistically obtained in S102.
[0077] S106. Sum up the frequencies corresponding to each same color among the P target colors and the I other colors in all text macro-blocks to obtain the first sum value of the frequency of each same color.
[0078] For example, sum up the frequencies corresponding to green among the P target colors and the I other colors in all text macro-blocks to obtain the first sum value of the frequency of green. Another example, sum up the frequencies corresponding to red among the P target colors and the I other colors in all text macro-blocks to obtain the first sum value of the frequency of red. The calculation processes for other same colors are similar to those of red and green, and are not elaborated here in this embodiment.
[0079] S107. Encode each text macro-block according to the first sum value.
[0080] For each macro-block, if there is green among the P target colors and the I other colors in the text macro-block, encode the green in the text macro-block according to the first sum value of the frequency of green. If there is red among the P target colors and the I other colors in the text macro-block, encode the red in the text macro-block according to the first sum value of the frequency of red. In the same way, encode the same colors among the P target colors and the I other colors in the text macro-block according to the first sum value of each same color.
[0081] In this embodiment, Huffman coding is used to encode each text macro-block. Huffman coding, also known as Hoffman coding. In computer data processing, Huffman coding uses a variable-length coding table to encode source symbols (such as a letter in a file), where the variable-length coding table is obtained by a method of evaluating the occurrence probability of source symbols. Letters with a high occurrence probability use shorter codes, while those with a low occurrence probability use longer codes, which reduces the average length and expected value of the encoded string, thereby achieving the purpose of lossless data compression.
[0082] In this step, Huffman coding is performed on the same colors in each text macroblock through the first sum value of each same color frequency, so that the probability of occurrence of each same color in each macroblock increases, and further the length of the data bitstream of each same color after Huffman coding becomes shorter, and the data volume of the text macroblock after final coding during transmission can be reduced in the scenario where the text clarity can be guaranteed.
[0083] Exemplarily, after each text macroblock is encoded according to the first sum value, the non-text macroblocks in the to-be-processed frame image are encoded. The encoding method of the non-text macroblocks can use any encoding method, and this embodiment does not limit it here.
[0084] The image processing method provided by the embodiments of the present disclosure can determine text macroblocks from at least one macroblock of a to-be-processed frame image; for each text macroblock, determine N candidate colors from the text macroblock; determine P similarity sets from the N candidate colors; obtain the target color corresponding to each similarity set; determine the frequency of the P target colors in each text macroblock and the frequency of I other colors except the P similarity sets; sum the frequencies corresponding to each same color among the P target colors and the I other colors in all text macroblocks to obtain the first sum value of each same color frequency; encode each text macroblock according to the first sum value, so that the probability of occurrence of the colors in each macroblock becomes larger, and further the length of the data bitstream of each same color after encoding becomes shorter, and the data volume of the text macroblock after final encoding during transmission is reduced, and in the scenario where the text clarity is guaranteed, the data volume of the to-be-processed frame image after encoding during transmission is reduced, avoiding the problem that the bitstream of the text image area in the image may increase using the prior art, and further resulting in an increase in the data volume during image transmission and being unable to meet the requirements of low bandwidth.
[0085] Next, in combination with Figure 2 Examples, the image processing method provided by the embodiments of the present disclosure will be further described in detail. Figure 2 is the flow of an image processing method provided by the embodiments of the present disclosure Figure 2 As Figure 2 shown, the method includes:
[0086] S201. Obtain a picture (to-be-processed frame image), and obtain the first rendering position information of the text image area and the second rendering position information of the non-text image area in the picture from the operating system.
[0087] Specifically, during rendering, the operating system sends rendering instructions to the driver. In specific implementation, a virtual driver can be used to receive the rendering instructions and then forward the received instructions to the actual device driver; alternatively, a listening program can be set up to intercept the instructions sent by the operating system to the driver.
[0088] Among them, the rendering instructions contain data such as the rendering content and position information. According to the rendering content in the rendering instructions, it can be determined whether the image to be rendered is a text image or a non-text image. According to the position information, the position information of the text image, that is, the "first rendering position information", and the position information of the non-text image, that is, the "second rendering position information", can be determined.
[0089] S202. Divide the picture into M×N non-overlapping macro blocks.
[0090] It should be noted that M×N is related to the screen resolution and the macro block size.
[0091] For example, if the screen resolution is 1920×1080 and the macro block size is 5×5, then the picture can be divided into 384×216 non-overlapping macro blocks.
[0092] S203. Perform the following processing for each macro block: According to the obtained first rendering position information and second rendering position information, determine whether the current macro block contains a text image area; if so, mark the macro block as a text macro block and execute step S204.
[0093] For example, if the pixel point range included in the currently processed macro block is [0, 0], [0, 16], [16, 16], [16, 0], and the first rendering position information obtained from the rendering instructions is [5, 5], it can be known that the macro block includes a text image area. Then, the macro block can be marked as a text macro block.
[0094] S204. Count the frequencies of the appearances of each color (pixel value) in the text macro block, and sort the colors from high to low according to the frequencies; from the sorted colors, determine I colors with high frequencies and mark these I colors as candidate colors.
[0095] For example: The resolution of a picture is (1, 8), that is, 8 columns in one row; the specific pixel values are (1, 1, 1, 2, 2, 2, 3, 3); then, after counting and arranging, it is 1:3, 2:3, 3:2. If 2 candidate colors are determined from this picture, then the color with pixel value 1 and the color with pixel value 2 are the candidate colors of this picture.
[0096] S205. Determine whether there are colors with a difference (pixel value difference) less than J among the candidate colors; if so, execute S206, if not, add the candidate colors and the frequencies of the candidate colors to the global variable.
[0097] S206. Among the alternative colors, determine P colors with a difference less than J, and determine these P colors as similar colors; determine the color with the highest frequency among the similar colors, and denote the color with the highest frequency as color X; calculate the sum of the frequencies of each color among the similar colors, and use the sum of the frequencies as the frequency of the combined color. The pixel value of the combined color Q is the pixel value of color X; add the other colors and their frequencies except the similar colors in the text macroblock, and the combined color Q and its frequency to the global variable.
[0098] S207. Determine whether all the macroblocks in the current picture have been processed; if so, execute step S208. If not, return to execute S203.
[0099] S208. Use Huffman coding to generate a Huffman code table according to the colors and frequencies stored in the global variable.
[0100] It should be noted that Huffman coding is a standard algorithm. Please refer to the instructions on the Internet.
[0101] S209. Encode all the text macroblocks using the Huffman code table; encode the other macroblocks in the picture except the text macroblocks.
[0102] It should be noted that for encoding the other macroblocks except the text macroblocks, any encoding method can be used, and the present invention does not make any restrictions.
[0103] S210. Send the generated code stream and the Huffman code table to the receiving end.
[0104] It can be seen that the present invention combines similar colors and only retains the combined color and the other colors except the similar colors in each text macroblock. Compared with JPEG, the method of the present invention can reduce the types of colors in the macroblock and greatly reduce the amount of data to be compressed; at the same time, performing Huffman coding on the colors of different text blocks can effectively reduce the code stream.
[0105] The schematic diagram of the logical process of the image processing method provided by the embodiments of the present disclosure is as Figure 3 shown.
[0106] Figure 4 is the structure of an image processing device provided by the embodiments of the present disclosure Figure 1 , as Figure 4 shown. The device 40 includes:
[0107] A text macroblock determination module 401, configured to determine text macroblocks from at least one macroblock of a to-be-processed frame image;
[0108] An alternative color determination module 402, configured to determine N alternative colors for each text macro block, where N is an integer greater than 1;
[0109] A similarity set determination module 403, configured to determine P similarity sets from the N alternative colors, where P is an integer greater than or equal to 1, the similarity set is a set of similar colors, and the similar colors are colors with a difference in pixel values less than a preset difference threshold;
[0110] A target color acquisition module 404, configured to acquire the target color corresponding to each similarity set, where the target color is the color with the highest frequency in the similarity set;
[0111] A color frequency determination module 405, configured to determine the frequencies of the P target colors in each text macro block and the frequencies of I other colors except the P similarity sets;
[0112] A first sum value determination module 406, configured to sum the frequencies corresponding to each same color among the P target colors and the I other colors in all text macro blocks to obtain a first sum value of the frequency of each same color;
[0113] A text macro block encoding module 407, configured to encode each text macro block according to the first sum value.
[0114] In one embodiment, the text macro block encoding module 407 is configured to:
[0115] Encode each same color among the P target colors and the I other colors in each text macro block according to the first sum value.
[0116] In one embodiment, the alternative color determination module 402 is configured to:
[0117] Count the frequency of each color in the text macro block;
[0118] Sort each color in descending order of frequency;
[0119] Determine the colors ranked in the first N as the alternative colors of the text macro block.
[0120] In one embodiment, the target color acquisition module 404 is configured to:
[0121] Use the color with the highest frequency in each similarity set as the target color corresponding to each similarity set.
[0122] In one embodiment, the color frequency determination module 405 is configured to:
[0123] Calculate a second sum value of the frequencies of all colors in the similarity set;
[0124] Use the second sum value as the frequency of the target color.
[0125] In one embodiment, as Figure 5 shown, the apparatus 40 further includes:
[0126] A non-text macroblock encoding module 408 for encoding non-text macroblocks in the to-be-processed frame image.
[0127] The image processing apparatus provided by the embodiments of the present disclosure can determine text macroblocks from at least one macroblock of the to-be-processed frame image; for each text macroblock, determine N candidate colors from the text macroblock; determine P similarity sets from the N candidate colors; obtain the target color corresponding to each similarity set; determine the frequency of the P target colors in each text macroblock and the frequency of I other colors except the P similarity sets; sum the frequencies corresponding to each same color among the P target colors and the I other colors in all text macroblocks to obtain a first sum value of the frequency of each same color; encode each text macroblock according to the first sum value, so that the probability of the color appearance in each macroblock becomes larger, and further the length of the data stream of each same color after encoding becomes shorter, and finally the data volume of the encoded text macroblock during transmission is reduced. In the scenario of ensuring text clarity, the data volume of the to-be-processed frame image after encoding during transmission is reduced, avoiding the problem that the data stream of the text image area in the image may increase when using the prior art, and further causing an increase in the data volume of the image during transmission and being unable to meet the requirements of low bandwidth.
[0128] Figure 6 is a structural diagram of an image processing device provided by the embodiments of the present disclosure. As Figure 6 shown, the image processing device 60 includes a processor 601 and a memory 602. At least one computer instruction is stored in the memory 602, and the instruction is loaded and executed by the processor 601 to Figures 1 to 3 perform the steps executed in the image processing method described in the corresponding embodiment.
[0129] Based on the above Figures 1 to 3 corresponding embodiment of the image processing method described, the embodiments of the present disclosure further provide a computer-readable storage medium. For example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc. Computer instructions are stored on the storage medium for performing the above Figures 1 to 3 corresponding embodiment of the image processing method described, which will not be elaborated here.
[0130] Those of ordinary skill in the art can understand that all or part of the steps to implement the above embodiments can be completed by hardware or can be completed by instructing the relevant hardware through a program. The program can be stored in a computer-readable storage medium. The storage medium mentioned above can be a read-only memory, a magnetic disk, an optical disk, or the like.
[0131] After considering the specification and practicing the disclosure herein, those skilled in the art will readily conceive of other embodiments of the present disclosure. This application is intended to cover any variations, uses, or adaptations of the present disclosure, which follow the general principles of the present disclosure and include known common general knowledge or conventional technical means in the technical field not disclosed by the present disclosure. The specification and embodiments are only regarded as exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.
Claims
1. An image processing method, characterized in that, Including: Determine text macroblocks from at least one macroblock of the frame image to be processed; For each text macroblock, determine N alternative colors from the text macroblock, where N is an integer greater than 1; Determine P similarity sets from the N alternative colors, where P is an integer greater than or equal to 1, and the similarity set is a set of similar colors, and the similar colors are colors with a pixel value difference less than a preset difference threshold; Obtain the target color corresponding to each similarity set, where the target color is the color with the highest frequency in the similarity set; Determine the frequencies of the P target colors in each text macroblock and the frequencies of I other colors except the P similarity sets; Sum the frequencies corresponding to each same color among the P target colors and the I other colors in all text macroblocks to obtain the first sum value of each same color frequency; Encode each text macroblock according to the first sum value.
2. The method according to claim 1, wherein The encoding each text macroblock according to the first sum value includes: Encode each same color among the P target colors and the I other colors in each text macroblock according to the first sum value.
3. The method according to claim 1, wherein The determining N alternative colors from the text macroblock includes: Count the frequency of each color in the text macroblock; Sort each color in descending order of frequency; Determine the colors ranked in the first N as the alternative colors of the text macroblock.
4. The method according to claim 1, characterized in that, Determining the frequency of the target color includes: Calculate the second sum value of the frequencies of all colors in the similarity set; Take the second sum value as the frequency of the target color.
5. The method according to any one of claims 1 to 4, characterized in that The method further includes: Encode non-text macroblocks in the frame image to be processed.
6. An image processing apparatus, characterized in that, Including: A text macroblock determination module for determining text macroblocks from at least one macroblock of the frame image to be processed; An alternative color determination module for, for each text macroblock, determining N alternative colors from the text macroblock, where N is an integer greater than 1; A similarity set determination module for determining P similarity sets from the N alternative colors, where P is an integer greater than or equal to 1, and the similarity set is a set of similar colors, and the similar colors are colors with a pixel value difference less than a preset difference threshold; A target color acquisition module for obtaining the target color corresponding to each similarity set, where the target color is the color with the highest frequency in the similarity set; A color frequency determination module for determining the frequencies of the P target colors in each text macroblock and the frequencies of I other colors except the P similarity sets; A first sum value determination module for summing the frequencies corresponding to each same color among the P target colors and the I other colors in all text macroblocks to obtain the first sum value of each same color frequency; A text macroblock encoding module for encoding each text macroblock according to the first sum value.
7. The device according to claim 6, characterized in that, The text macroblock encoding module is used for: Encoding each same color among the P target colors and the I other colors in each text macroblock according to the first sum value.
8. An image processing apparatus, characterized in that, The device includes a processor and a memory, and at least one computer instruction is stored in the memory, and the instruction is loaded and executed by the processor to implement the steps performed in the image processing method according to any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that, At least one computer instruction is stored in the storage medium, and the instruction is loaded and executed by the processor to implement the steps performed in the image processing method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Character block encoding method and apparatus
CN108391132A
Coding and decoding method and device
CN111277829A