CN112383779A - Image encoding method and device, image decoding method and device, and processor - Google Patents

Image encoding method and device, image decoding method and device, and processor Download PDF

Info

Publication number
CN112383779A
CN112383779A CN202011211046.XA CN202011211046A CN112383779A CN 112383779 A CN112383779 A CN 112383779A CN 202011211046 A CN202011211046 A CN 202011211046A CN 112383779 A CN112383779 A CN 112383779A
Authority
CN
China
Prior art keywords
color
image
basic
index map
macro block
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011211046.XA
Other languages
Chinese (zh)
Inventor
唐春平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xian Wanxiang Electronics Technology Co Ltd
Original Assignee
Xian Wanxiang Electronics Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xian Wanxiang Electronics Technology Co Ltd filed Critical Xian Wanxiang Electronics Technology Co Ltd
Priority to CN202011211046.XA priority Critical patent/CN112383779A/en
Publication of CN112383779A publication Critical patent/CN112383779A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/20Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using video object coding
    • H04N19/23Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using video object coding with coding of regions that are present throughout a whole video segment, e.g. sprites, background or mosaic

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention discloses an image coding method and device, an image decoding method and device and a processor. Wherein, the method comprises the following steps: determining a target macro block comprising a text in an image to be coded; determining a basic color of a text of a target macro block; setting indexes for the basic color and the non-basic color of the target macro block, and generating a color index map of the target macro block; generating a background image of the image to be coded according to the color index map; and respectively coding the mapping table of the basic color, the color index map and the background image. The invention solves the technical problems of poor definition of characters or large code stream of image coding in the prior art when the images fused by the characters and the images are coded.

Description

Image encoding method and device, image decoding method and device, and processor
Technical Field
The present invention relates to the field of image encoding, and in particular, to an image encoding method and apparatus, an image decoding method and apparatus, and a processor.
Background
In image coding, text-picture fused images are very common. For the coding of such images, one way is to code the images as ordinary text blocks, but since the whole image macro block is wide in color distribution, the code stream obtained by coding is large; another method is to encode the image as a normal picture, but this encoding method may result in insufficient character sharpness in the encoded image.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the invention provides an image coding method and device, an image decoding method and device and a processor, which are used for at least solving the technical problems that the definition of characters is poor or the code stream of image coding is large when the images fused by the characters and the images in the related technology are coded.
According to an aspect of an embodiment of the present invention, there is provided an image encoding method including: determining a target macro block comprising a text in an image to be coded; determining a basic color of the text of the target macro block; setting indexes for the basic color and the non-basic color of the target macro block, and generating a color index map of the target macro block; generating a background image of the image to be coded according to the color index map; and respectively coding the mapping table of the basic color, the color index map and the background image.
Optionally, determining a target macro block including a text in an image to be encoded includes: determining color histograms of all macroblocks of the encoded image; determining the proportion of pixels of different colors within the preset number in the color histogram to pixels of different colors, wherein macro blocks exceeding the preset proportion are the target macro blocks; wherein the category color corresponds to a color value interval.
Optionally, determining the basic color of the text of the target macro block includes: taking the class color within the preset number as the basic color; or, a color other than the category color within the preset number and identical to the basic color of the upper unit macro block and/or the left unit macro block of the target macro block is used as the basic color.
Optionally, setting indexes for the base color and the non-base color of the target macroblock, and generating the color index map of the target macroblock includes: determining index numbers of the basic colors and the non-basic colors, wherein when the basic colors are multiple, each basic color corresponds to one index number, and the non-basic colors are the same index number; and comparing the colors of the pixels in the target macro block with the index numbers one by one to generate a color index map of the target macro block.
Optionally, after comparing the color of the pixel in the target macro block with the index number one by one to generate the color index map of the target macro block, the method further includes: and correcting the isolated keycolour in the color index map into a non-keycolour, wherein the isolated keycolour is formed by that eight pixels adjacent to the periphery are all the non-keycolour.
Optionally, generating the background image of the image to be encoded according to the color index map includes: filling the basic color into a non-basic color in an interpolation mode according to the color index map to obtain a background image of the target macro block; and carrying out the same processing on all target macro blocks in the image to be coded to obtain a background image of the image to be coded.
Optionally, the encoding the mapping table of the basic color, the color index map, and the background image respectively includes: coding the mapping table of the basic color in a first coding mode; encoding the color index map by a second encoding mode; and coding the background image by a third coding mode.
According to another aspect of the embodiments of the present invention, there is also provided an image decoding method, including: decoding a received code stream to obtain a mapping table of a basic color, a color index map and a background image, wherein the code stream comprises a first code stream for coding the mapping table of the basic color, a second code stream for coding the color index map and a third code stream for coding the background image; finding out the corresponding pixel position of the basic color on the background image according to the color index map; determining the basic color according to the basic color mapping table; modifying the background image according to the basic color and the pixel position to obtain an original image corresponding to the received code stream; wherein the background image includes a plurality of macro blocks, the base color is determined according to a color of a text of the macro block of the original image, and the color index map is generated by setting an index for the base color and the non-base color of the macro block of the original image.
According to another aspect of the embodiments of the present invention, there is also provided an image encoding apparatus including: the first determining module is used for determining a target macro block comprising a text in an image to be coded; the second determining module is used for determining the basic color of the text of the target macro block; a first generating module, configured to set indexes for a base color and a non-base color of the target macroblock, and generate a color index map of the target macroblock; the second generation module is used for generating a background image of the image to be coded according to the color index map; and the coding module is used for coding the mapping table of the basic color, the color index map and the background image respectively.
According to another aspect of the embodiments of the present invention, there is also provided an image decoding apparatus including: the decoding module is used for decoding a received code stream to obtain a mapping table of a basic color, a color index map and a background image, wherein the code stream comprises a first code stream for coding the mapping table of the basic color, a second code stream for coding the color index map and a third code stream for coding the background image; the index module is used for finding out the corresponding pixel position of the basic color on the background image according to the color index map; the determining module is used for determining the basic color according to the basic color mapping table; a modifying module, configured to modify the background image according to the basic color and the pixel position, so as to obtain an original image corresponding to the received code stream; wherein the background image includes a plurality of macro blocks, the base color is determined according to a color of a text of the macro block of the original image, and the color index map is generated by setting an index for the base color and the non-base color of the macro block of the original image.
According to another aspect of the embodiments of the present invention, there is also provided a processor configured to execute a program, where the program executes to perform the image encoding method or the image decoding method described in any one of the above.
According to another aspect of the embodiments of the present invention, there is also provided a computer storage medium, where the computer storage medium includes a stored program, and when the program runs, the apparatus on which the computer storage medium is located is controlled to execute the image encoding method or the image decoding method in any one of the above.
In the embodiment of the invention, the target macro block which comprises the text in the image to be coded is determined; determining a basic color of a text of a target macro block; setting indexes for the basic color and the non-basic color of the target macro block, and generating a color index map of the target macro block; generating a background image of the image to be coded according to the color index map; the mapping table of the basic color, the color index map and the background image are respectively coded by determining the basic color of the text of the image to be coded, and a color index map for generating a background image, encoding the mapping table of the basic color, the color index map and the background image, respectively, when decoding, the position and color of the text in the background image can be restored through the mapping table of the basic color and the color index map, thereby achieving the purposes of effectively and rapidly coding the image to be coded with the text and ensuring that the code stream is not too large, thereby realizing the technical effects of improving the efficiency and the accuracy of text coding and ensuring higher definition of the text after the picture to be coded is decoded under the condition of ensuring that the code stream is not overlarge, and the technical problems that the definition of characters is poor or the code stream of image coding is large when the images fused by the characters and the images are coded in the related technology are solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a flow chart of a method of image encoding according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method of image decoding according to an embodiment of the present invention;
FIG. 3 is a schematic illustration of a textual image according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a color distribution histogram according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of an image encoding apparatus according to an embodiment of the present invention;
fig. 6 is a schematic diagram of an image decoding apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In accordance with an embodiment of the present invention, there is provided a method embodiment of an image encoding method, it being noted that the steps illustrated in the flowchart of the figure may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different than here.
Fig. 1 is a flowchart of an image encoding method according to an embodiment of the present invention, as shown in fig. 1, the method including the steps of:
step S102, determining a target macro block including a text in an image to be coded;
step S104, determining the basic color of the text of the target macro block;
step S106, setting indexes for the basic color and the non-basic color of the target macro block, and generating a color index map of the target macro block;
step S108, generating a background image of the image to be coded according to the color index map;
step S110, encoding the mapping table of the basic color, the color index map and the background image, respectively.
Through the steps, determining a target macro block comprising a text in the image to be coded; determining a basic color of a text of a target macro block; setting indexes for the basic color and the non-basic color of the target macro block, and generating a color index map of the target macro block; generating a background image of the image to be coded according to the color index map; the mapping table of the basic color, the color index map and the background image are respectively coded by determining the basic color of the text of the image to be coded, and a color index map for generating a background image, encoding the mapping table of the basic color, the color index map and the background image, respectively, when decoding, the position and color of the text in the background image can be restored through the mapping table of the basic color and the color index map, thereby achieving the purposes of effectively and rapidly coding the image to be coded with the text and ensuring that the code stream is not too large, thereby realizing the technical effects of improving the efficiency and the accuracy of text coding and ensuring higher definition of the text after the picture to be coded is decoded under the condition of ensuring that the code stream is not overlarge, and the technical problems that the definition of characters is poor or the code stream of image coding is large when the images fused by the characters and the images are coded in the related technology are solved.
The image to be coded includes text, the color of the text is a main color of one or more colors, the image to be coded also includes a background other than the text, the background generally includes more colors than the colors of the text, the distribution of the colors is not irregular, therefore, the text and the background can be separated by colors, for example, as shown in fig. 3.
The image to be coded comprises a plurality of data macro blocks, and the image to be coded can be coded according to the macro blocks during coding. The macro blocks of the part containing the text in the macro blocks are target macro blocks, and the text and the background in the image to be coded are separated by separating the text and the background in the target macro blocks.
When the text in the target macro block is separated, the basic color of the text of the target macro block is determined, and the basic color is also the main color of the text and can be one or more. The colors in the target macroblock other than the base color are all non-base colors, i.e., colors considered as the background.
It should be noted that the basic color may represent multiple colors in a certain color numerical range, and since the multiple colors in the color numerical range are similar, one color to be changed may be selected as a color corresponding to the color numerical range, and specifically, the representative color and the corresponding color numerical range may be corresponded by a mapping table, so that the color numerical range corresponding to the representative color may be determined according to the mapping table, and thus, the specific color thereof may be determined. The non-base color is all colors except the base color.
And setting indexes for the basic color and the non-basic color of the target macro block to generate a color index map of the target macro block, wherein the color index map comprises all pixel points of the target macro block and the basic color or the non-basic color corresponding to the pixel points. The color index map may be modified to improve the accuracy of the color index map.
According to the color index map, pixels corresponding to the basic colors are removed, the removed parts can be filled according to non-basic colors around the removed basic colors, and a background image of the image to be coded is generated, so that non-basic color distortion caused by truncation of high-frequency components in the picture coding process is reduced, the quality of image coding is improved, and the definition and accuracy of the decoded image are improved.
The mapping table of the basic color, the color index map and the background image are respectively coded, the mapping table of the basic color, the color index map and the background image belong to different data types, and the suitable coding modes of the mapping table, the color index map and the background image are different, so that the mapping table of the basic color, the color index map and the background image can be respectively coded in different modes, the coding accuracy and efficiency are ensured, and the image coding accuracy and efficiency are improved.
Optionally, determining a target macro block including a text in an image to be encoded includes: determining color histograms of all macroblocks of the encoded image; determining the proportion of pixels of different colors within the preset number in the color histogram to pixels of different colors, and determining macro blocks exceeding the preset proportion as target macro blocks; wherein, the category color corresponds to a color value interval.
Determining color histograms of all macro blocks of a coded image, determining the percentage of multiple single colors in a certain macro block according to the color histograms, determining 1 or more colors with the percentage of the single colors in all the colors being larger than a certain preset proportion as basic colors of a current target macro block, wherein the number of the multiple basic colors is not more than the preset number, and the macro blocks with the types exceeding the preset proportion are target macro blocks. For example, macroblocks of several colors within a preset number occupying most of the entire image, for example, more than 80% of the entire image are target macroblocks.
Optionally, determining the basic color of the text of the target macro block includes: the variety colors within the preset number are used as basic colors; or, the color other than the category color within the preset number and the same as the basic color of the upper unit macro block and/or the left unit macro block of the target macro block is used as the basic color.
The method comprises the following steps of taking the colors within the preset number as basic colors, determining that the percentage of each color in all the colors exceeds the preset proportion, and determining that the number of the color types meeting the conditions is within the preset number, namely determining 1 or more colors of which the percentage of the single color in all the colors is larger than a certain preset proportion as the basic colors of the current target macro block.
Besides the category colors within the preset number, the category colors do not satisfy that the percentage of all colors exceeds the preset proportion, but the colors are the same as the basic colors of the upper unit macro block and/or the left unit macro block of the target macro block, and can be used as the basic colors. For example, if the target macroblock has a color with a ratio ranking of three, but the color in the left unit macroblock and/or the upper unit macroblock of the macroblock is selected as the basic color, the color may be preferentially selected as the basic color in the current target macroblock
Optionally, setting indexes for the base color and the non-base color of the target macroblock, and generating the color index map of the target macroblock includes: determining index numbers of basic colors and non-basic colors, wherein under the condition that the basic colors are multiple, each basic color corresponds to one index number, and the non-basic colors are the same index number; and comparing the colors of the pixels in the target macro block with the index numbers one by one to generate a color index map of the target macro block.
For example, if 3 key colors are determined in the current target macroblock, the index number of the non-key color is set to 0, and the key color index is set to 1/2/3; if two base colors are determined in the current target macroblock, the indices of all non-base colors except the base color are set to 0 and the index of the base color is set to 1/2.
For each pixel of the target macro block, if the color of the pixel belongs to the basic color, determining the corresponding basic color index value of the pixel, and marking the corresponding basic color index value of the pixel at the corresponding position; if not, directly marking the index value of the non-basic color. In this way, the color index map of the current target macro block can be obtained.
Optionally, after comparing the color of the pixel in the target macro block with the index number one by one to generate the color index map of the target macro block, the method further includes: and correcting the isolated keycolour in the color index map into the non-keycolour, wherein the isolated keycolour is that eight pixels adjacent to the periphery are all the non-keycolour.
After the color index map of the target macro block is generated, the color index map can be corrected, specifically, for an isolated basic color, the surrounding 8 pixels are not the basic color, and are corrected to be a non-basic color index, so that the corrected color index map is obtained, and the accuracy of the color index map is improved.
Similarly, an isolated non-base color can be modified to a base color, and since the possibility of single pixel independence is very small and generally does not exist, the accuracy of the color index map can be improved by modifying the non-base color.
Optionally, generating the background image of the image to be encoded according to the color index map includes: filling the basic color into a non-basic color in an interpolation mode according to the color index map to obtain a background image of the target macro block; and performing the same processing on all target macro blocks in the image to be coded to obtain a background image of the image to be coded.
The method aims to split a picture part according to a color index map, namely, all non-basic colors are found out, and then the positions of the basic colors are filled in a linear interpolation mode, so that a complete background image is obtained. The linear interpolation is performed to reduce non-keycolour distortion caused by truncating high frequency components during picture coding.
Optionally, the encoding the mapping table of the basic color, the color index map, and the background image respectively includes: coding a mapping table of the basic color in a first coding mode; coding the color index map by a second coding mode; and encoding the background image by a third encoding mode.
The first encoding method is an encoding method suitable for a mapping table of a base color, and may be the prior art, for example, a huffman encoding may be used for the mapping table of the base color; the second encoding method is an encoding method suitable for the color index map, and may be a conventional encoding method, for example, the color index map may use step size encoding; the third encoding method may be an encoding method suitable for the background image, and may be a conventional encoding method, for example, jpeg encoding may be used for the background image. The first, second and third encoding methods may be the same or different. And respectively coding the mapping table of the basic color, the color index map and the background image in different modes, thereby ensuring the coding accuracy and efficiency and providing the image coding accuracy and efficiency.
In accordance with an embodiment of the present invention, there is provided a method embodiment of an image decoding method, it is noted that the steps illustrated in the flowchart of the figure may be performed in a computer system, such as a set of computer-executable instructions, and that while a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
Fig. 2 is a flowchart of an image decoding method according to an embodiment of the present invention, and as shown in fig. 2, according to another aspect of the embodiment of the present invention, there is also provided an image decoding method including the steps of:
step S202, decoding the received code stream to obtain a mapping table of the basic color, a color index map and a background image, wherein the code stream comprises a first code stream for coding the mapping table of the basic color, a second code stream for coding the color index map and a third code stream for coding the background image;
step S204, finding out the corresponding pixel position of the basic color on the background image according to the color index map;
step S206, determining the basic color according to the basic color mapping table;
step S208, modifying the background image according to the basic color and the pixel position to obtain an original image corresponding to the received code stream;
the background image comprises a plurality of macro blocks, the basic color is determined according to the color of the text of the macro blocks of the original image, and the color index map is generated by setting indexes on the basic color and the non-basic color of the macro blocks of the original image.
Decoding the received code stream to obtain a mapping table of the basic color, a color index map and a background image, wherein the code stream comprises a first code stream for coding the mapping table of the basic color, a second code stream for coding the color index map and a third code stream for coding the background image; finding out the corresponding pixel position of the basic color on the background image according to the color index image; determining a basic color according to a basic color mapping table; modifying the background image according to the basic color and the pixel position to obtain an original image corresponding to the received code stream; the background image comprises a plurality of macro blocks, the basic color is determined according to the color of the macro block text of the original image, the color index map is generated by setting indexes on the basic color and non-basic color of the macro block of the original image, the background image is generated by determining the basic color of the text of the image to be coded and the color index map, the mapping table of the basic color, the color index map and the background image are respectively coded, the position and the color of the text in the background image can be restored through the mapping table of the basic color and the color index map during decoding, the purpose of effectively and quickly coding the image to be coded with the text and ensuring that the code stream is not overlarge is achieved, the efficiency and the accuracy of text coding are improved under the condition that the code stream is not overlarge, and the technical effect that the definition of the text after the image to be coded is decoded is higher is achieved, and the technical problems that the definition of characters is poor or the code stream of image coding is large when the images fused by the characters and the images are coded in the related technology are solved.
The received code stream may be encoded data of an image to be encoded, where the code stream includes a first code stream for encoding a mapping table of a basic color, a second code stream for encoding a color index map, and a third code stream for encoding a background image, and when the received code stream is decoded, the first code stream, the second code stream, and the third code stream may be decoded in different decoding manners to obtain a mapping table of the basic color, the color index map, and the background image, where the mapping table of the basic color may use a first decoding manner corresponding to the first encoding manner, the color index map may use a second decoding manner corresponding to the second encoding manner, the background image may use a decoding manner corresponding to the third encoding manner, and the decoding manner is determined specifically according to the encoding manner.
After obtaining the mapping table of the basic color, the color index map and the background image, the color value of the basic color, that is, the basic color itself, can be determined according to the mapping table of the basic color, the corresponding pixel position of the basic color on the background image can be found out according to the color index map, the basic color is filled in the corresponding pixel position, and the background image is modified, so that the image before encoding can be obtained.
It should be noted that this embodiment also provides an alternative implementation, which is described in detail below.
The embodiment provides a method for coding a character picture fused image, which has the main principle that the image is regarded as an image with a character layer covering a picture layer, and the character layer and the picture layer are coded respectively; and fusing the character layer and the picture layer after decoding at a decoding end to obtain a final image. By this coding method, the definition of characters can be maintained under the condition of controlling a certain code rate.
Fig. 3 is a schematic diagram of an image with text according to an embodiment of the present invention, and as shown in fig. 3, the embodiment is directed to an image in which characters and pictures are combined. In the present embodiment, the encoding principle for such an image is: such an image is encoded as an image in which a text layer covers a picture layer. The basic processing flow is as follows: firstly, generating a color index map and a basic color mapping table according to a current target image, wherein non-basic colors and basic colors are marked in the index map, and then splitting a background image part from the whole target image according to the color index map, as shown in FIG. 3; then, the color index map, the color mapping table and the background image are coded and then sent to a decoding end, and the decoding end decodes the color index map, the color mapping table and the background image; the decoding mode of the receiving end is as follows: and decoding the coded data of the color index map, the color mapping table and the picture part, and determining to fill the color of the background image according to the decoded color index map and the decoded color mapping table, namely filling the color of the character part in the current background image so as to obtain a final decoded image.
It needs to be emphatically explained that: the term "characters" in this embodiment is not intended to be literally understood characters (numbers, letters, etc.) but refers to all graphic information suitable for filling in a single or a few colors.
The encoding process for the combined image of the characters and the picture provided by the embodiment is as follows:
step 11, counting a color distribution histogram of each target macro block;
before this step, an image with combined text and picture is screened out from the whole frame image by default in some way, for example, after the whole frame image is divided into macro blocks in a preset way, the macro blocks with combined text and picture are identified, and then the macro blocks (target macro blocks) meeting the conditions are encoded in the way provided by this embodiment.
In actual implementation, it may also be determined which macroblocks belong to the target macroblock according to the color histogram, and therefore, step 101 may be further modified as follows: after dividing a frame of image into macro blocks, respectively counting the color histograms of the macro blocks, and then determining all macro blocks with concentrated colors (the macro blocks are characterized in that a few colors occupy most of the area of the whole image, such as more than 80%, and the like) as target macro blocks meeting the conditions; one or more base colors are then determined for each target macroblock in subsequent processing based on the determined color histogram of the target macroblock. In this step, if the macroblock does not belong to the macroblock with concentrated colors, the macroblock is not the target macroblock processed by the present invention, and the macroblocks may be encoded according to the existing appropriate method.
Color histograms are color features that are widely adopted in image analysis processing. It describes the proportion of different colors in the whole image, and does not care about the spatial position of each color, i.e. cannot describe the object or object in the image. In this embodiment, the proportion of different colors in one target macro block is mainly determined by a color histogram. Fig. 4 is a schematic diagram of a color distribution histogram according to an embodiment of the present invention, an exemplary color distribution histogram, as shown in fig. 4.
Step 12, determining one or more basic colors for each target macro block according to the color histogram of each target macro block, and classifying other colors as non-basic colors;
the maximum number of the basic colors determined by each target macro block and the maximum number of the basic colors parameter may be set as required, for example, set to 3, that is, each target macro block may determine at most 3 basic colors, and if the number of the basic colors that can be determined to satisfy the condition is less than 3, 1 or 2 colors that satisfy the condition are used as the basic colors of the current target macro block.
In this embodiment, each basic color corresponds to a color value range, not a certain value point. In addition, each basic color sets a corresponding representative color value. For example, if the color values 5-10 are set as belonging to the same basic color, one color value is selected as the representative color value of the basic color, for example, the color value 8 is selected as the representative color value of the basic color.
In actual implementation, the basic color of each target macro block may be determined according to a specific standard, for example, the percentage of a single color in each target macro block may be determined according to a color histogram corresponding to each target macro block, and 1 to 3 colors whose percentage of a single color is greater than a certain preset threshold are determined as the basic color of the current target macro block. Of course, there is a certain deviation in the basic color determined in this way, and therefore, a target macroblock may be analyzed in combination with the basic color of its left unit macroblock (macroblock on the left side of the current macroblock) and the basic color of its upper unit macroblock (macroblock above the current macroblock). For example, if the percentage of a color in the target macroblock is not ranked in the top three, but the color in the left unit macroblock and/or the top unit macroblock of the macroblock is selected as the base color, the color may be preferentially selected as the base color in the current target macroblock.
Once the base color is determined for each target macroblock, the other colors are uniformly classified as non-base colors.
In the present embodiment, the basic color is considered as the color of the character, and the non-basic color is considered as the color of the background image.
Step 13, determining the index number of the basic color and the non-basic color of each target macro block;
after determining the basic color and the non-basic color of the current target macro block, determining the index numbers of the basic color and the non-basic color. For example, if 3 key colors are determined in the current target macroblock, the index number of the non-key color is set to 0, and the key color index is set to 1/2/3; if two base colors are determined in the current target macroblock, the indices of all non-base colors except the base color are set to 0 and the index of the base color is set to 1/2.
Step 14, comparing the determined basic color index numbers pixel by pixel in the current target macro block to obtain a color index map of the current target macro block;
for each pixel, if the pixel belongs to the basic color, determining which basic color index value corresponds to the pixel, and marking the corresponding basic color index value at the corresponding position; if not, directly marking the index value of the non-basic color. In this way, the color index map of the current target macro block can be obtained.
Step 15, correcting the color index map: for an isolated basic color, the surrounding 8 pixels are not the basic color, and the basic color is corrected into a non-basic color index, so that a corrected color index map is obtained;
the isolated base color is not a character component in general, does not affect the viewing effect of the user on the characters, and is not used as the characters for coding, so that the isolated base color can be corrected into a non-base color, thereby being a picture component. In actual implementation, the index value corresponding to the isolated basic color is modified into the index value of the non-basic color directly in the color index map, so that the modified color index value can be obtained.
Step 16, according to the corrected color index map, determining the position of the basic color from the current target macro block, and modifying the color value of the basic color in the current target macro block;
specifically, the basic color of the interval can be modified according to two non-basic color adjacent to the basic color interval in the same line in a linear interpolation mode to obtain a background image;
the purpose of this step is to split the picture part according to the color index map, i.e. to find out all non-basic colors, and then fill the positions of the basic colors in a linear interpolation manner, thereby obtaining a complete background image.
In this step, linear interpolation is performed for the purpose of reducing non-keycolour distortion caused by truncation of high-frequency components during picture coding.
Step 17, coding the basic color mapping table, the color index map and the background image respectively;
the basic color mapping table is used for representing colors corresponding to each basic color in the basic current color index map, and an exemplary basic color mapping table is as follows, assuming that there are 3 basic colors in the current color index map:
1:Y1U1V1
2:Y2U2V2
3:Y3U3V3
an exemplary color index map is shown below. For simplicity and illustrative purposes, assume macroblock size 6 × 6:
0 1 1 2 3 0
0 1 1 2 0 0
0 0 0 2 3 0
0 1 1 2 3 0
1 2 3 2 0 0
0 0 0 0 0 0
the basic color mapping table, the color index map and the background image may be encoded by using an appropriate encoding method, for example, the basic color mapping table may use huffman coding, the color index map may use step coding, the background image may use jpeg coding, and the like.
And step 18, taking the data obtained by coding as a final code stream file, and sending the obtained code stream file to a decoding end.
The decoding process for the combined image of the characters and the picture provided by the embodiment is as follows:
step 21, analyzing the received code stream to obtain a basic color mapping table, a color index map and a background image;
and step 22, correcting the color value of the basic color position of the background image according to the index map and the basic color mapping table, thereby obtaining a final target image.
Specifically, the arrangement position of the basic color on the picture image can be obtained according to the index map, then the representative color corresponding to the current basic color is found from the basic color mapping table, and then the corresponding representative color is filled in the corresponding position in the background image. And filling the representative colors of the basic colors in corresponding positions in the background image one by one according to the mode to obtain the final target decoding image.
Code rate control:
in this embodiment, the requirement of code rate control can be realized by adjusting the maximum number of basic colors and the quantization parameter of picture coding. For example, the larger the maximum number of the base colors is, the larger the code stream is, and conversely, the smaller the code stream is, and thus, an appropriate maximum number of the base colors can be selected. The larger the quantization parameter of the picture coding is, the smaller the coding code stream is, and the smaller the quantization parameter is, the larger the coding code stream is.
Fig. 5 is a schematic diagram of an image encoding apparatus according to an embodiment of the present invention, and as shown in fig. 5, according to another aspect of the embodiment of the present invention, there is also provided an image encoding apparatus including: a first determining module 502, a second determining module 504, a first generating module 506, a second generating module 508 and an encoding module 510, which are described in detail below.
A first determining module 502, configured to determine a target macro block including a text in an image to be encoded; a second determining module 504, connected to the first determining module 502, for determining a basic color of a text of a target macro block; a first generating module 506, connected to the second determining module 504, configured to set an index for the basic color and the non-basic color of the target macroblock, and generate a color index map of the target macroblock; a second generating module 508, connected to the first generating module 506, for generating a background image of the image to be encoded according to the color index map; and an encoding module 510, connected to the second generating module 508, for encoding the mapping table of the basic color, the color index map and the background image, respectively.
By the device, a first determining module 502 is adopted to determine a target macro block comprising a text in an image to be coded; the second determination module 504 determines the base color of the text of the target macroblock; the first generation module 506 sets indexes for the basic color and the non-basic color of the target macro block to generate a color index map of the target macro block; the second generating module 508 generates a background image of the image to be encoded according to the color index map; the encoding module 510 encodes the mapping table of the basic color, the color index map and the background image respectively, generating a background image by determining the basic color of the text of the image to be coded and the color index map, coding the mapping table of the basic color, the color index map and the background image respectively, when decoding, the position and color of the text in the background image can be restored through the mapping table of the basic color and the color index map, thereby achieving the purposes of effectively and rapidly coding the image to be coded with the text and ensuring that the code stream is not too large, thereby realizing the technical effects of improving the efficiency and the accuracy of text coding and ensuring higher definition of the text after the picture to be coded is decoded under the condition of ensuring that the code stream is not overlarge, and the technical problems that the definition of characters is poor or the code stream of image coding is large when the images fused by the characters and the images are coded in the related technology are solved.
Fig. 6 is a schematic diagram of an image decoding apparatus according to an embodiment of the present invention, and as shown in fig. 6, according to another aspect of the embodiment of the present invention, there is also provided an image decoding apparatus including: a decoding module 62, an indexing module 64, a determining module 66 and a modifying module 68, the apparatus of which is described in detail below.
A decoding module 62, configured to decode the received code stream to obtain a mapping table of the basic color, a color index map, and a background image, where the code stream includes a first code stream for encoding the mapping table of the basic color, a second code stream for encoding the color index map, and a third code stream for encoding the background image; an index module 64 connected to the decoding module 62 for finding the corresponding pixel position of the basic color on the background image according to the color index map; a determining module 66, connected to the indexing module 64, for determining the basic color according to the basic color mapping table; a modifying module 68 connected to the determining module 66, configured to modify the background image according to the basic color and the pixel position, so as to obtain an original image corresponding to the received code stream; the background image comprises a plurality of macro blocks, the basic color is determined according to the color of the text of the macro blocks of the original image, and the color index map is generated by setting indexes on the basic color and the non-basic color of the macro blocks of the original image.
By the device, the decoding module 62 is adopted to decode the received code stream to obtain a mapping table of the basic color, a color index map and a background image, wherein the code stream comprises a first code stream for coding the mapping table of the basic color, a second code stream for coding the color index map and a third code stream for coding the background image; the indexing module 64 finds the corresponding pixel position of the basic color on the background image according to the color index map; the determination module 66 determines the basic color according to the basic color mapping table; the modifying module 68 modifies the background image according to the basic color and the pixel position to obtain an original image corresponding to the received code stream; the background image comprises a plurality of macro blocks, the basic color is determined according to the color of the macro block text of the original image, the color index map is generated by setting indexes on the basic color and non-basic color of the macro block of the original image, the background image is generated by determining the basic color of the text of the image to be coded and the color index map, the mapping table of the basic color, the color index map and the background image are respectively coded, the position and the color of the text in the background image can be restored through the mapping table of the basic color and the color index map during decoding, the purpose of effectively and quickly coding the image to be coded with the text and ensuring that the code stream is not overlarge is achieved, the technical effects of improving the efficiency and the accuracy of text coding and ensuring that the definition of the text after the image to be coded is decoded is higher are achieved under the condition that the code stream is not overlarge, and the technical problems that the definition of characters is poor or the code stream of image coding is large when the images fused by the characters and the images are coded in the related technology are solved.
According to another aspect of the embodiments of the present invention, there is also provided a processor for executing a program, where the program executes to perform the image encoding method or the image decoding method of any one of the above.
According to another aspect of the embodiments of the present invention, there is also provided a computer storage medium including a stored program, wherein when the program runs, an apparatus in which the computer storage medium is located is controlled to execute the image encoding method or the image decoding method of any one of the above.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable computer storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a computer storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to perform all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned computer storage media include: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (11)

1. An image encoding method, comprising:
determining a target macro block comprising a text in an image to be coded;
determining a basic color of the text of the target macro block;
setting indexes for the basic color and the non-basic color of the target macro block, and generating a color index map of the target macro block;
generating a background image of the image to be coded according to the color index map;
and respectively coding the mapping table of the basic color, the color index map and the background image.
2. The method of claim 1, wherein determining a target macroblock in the image to be encoded that includes text comprises:
determining color histograms of all macroblocks of the encoded image;
determining the proportion of pixels of different colors within the preset number in the color histogram to pixels of different colors, wherein macro blocks exceeding the preset proportion are the target macro blocks;
wherein the category color corresponds to a color value interval.
3. The method of claim 2, wherein determining the base color of the text of the target macroblock comprises:
taking the class color within the preset number as the basic color;
or, a color other than the category color within the preset number and identical to the basic color of the upper unit macro block and/or the left unit macro block of the target macro block is used as the basic color.
4. The method of claim 1, wherein indexes are set for the base color and non-base colors of the target macroblock, and wherein generating the color index map of the target macroblock comprises:
determining index numbers of the basic colors and the non-basic colors, wherein when the basic colors are multiple, each basic color corresponds to one index number, and the non-basic colors are the same index number;
and comparing the colors of the pixels in the target macro block with the index numbers one by one to generate a color index map of the target macro block.
5. The method according to claim 4, wherein after comparing the color of the pixel in the target macroblock with the index number one by one to generate the color index map of the target macroblock, further comprising:
and correcting the isolated keycolour in the color index map into a non-keycolour, wherein the isolated keycolour is formed by that eight pixels adjacent to the periphery are all the non-keycolour.
6. The method of claim 1, wherein generating the background image of the image to be encoded according to the color index map comprises:
filling the basic color into a non-basic color in an interpolation mode according to the color index map to obtain a background image of the target macro block;
and carrying out the same processing on all target macro blocks in the image to be coded to obtain a background image of the image to be coded.
7. The method of claim 1, wherein encoding the mapping table of the base color, the color index map, and the background image respectively comprises:
coding the mapping table of the basic color in a first coding mode;
encoding the color index map by a second encoding mode;
and coding the background image by a third coding mode.
8. An image decoding method, comprising:
decoding a received code stream to obtain a mapping table of a basic color, a color index map and a background image, wherein the code stream comprises a first code stream for coding the mapping table of the basic color, a second code stream for coding the color index map and a third code stream for coding the background image;
finding out the corresponding pixel position of the basic color on the background image according to the color index map;
determining the basic color according to the basic color mapping table;
modifying the background image according to the basic color and the pixel position to obtain an original image corresponding to the received code stream;
wherein the background image includes a plurality of macro blocks, the base color is determined according to a color of a text of the macro block of the original image, and the color index map is generated by setting an index for the base color and the non-base color of the macro block of the original image.
9. An image encoding device characterized by comprising:
the first determining module is used for determining a target macro block comprising a text in an image to be coded;
the second determining module is used for determining the basic color of the text of the target macro block;
a first generating module, configured to set indexes for a base color and a non-base color of the target macroblock, and generate a color index map of the target macroblock;
the second generation module is used for generating a background image of the image to be coded according to the color index map;
and the coding module is used for coding the mapping table of the basic color, the color index map and the background image respectively.
10. An image decoding apparatus, comprising:
the decoding module is used for decoding a received code stream to obtain a mapping table of a basic color, a color index map and a background image, wherein the code stream comprises a first code stream for coding the mapping table of the basic color, a second code stream for coding the color index map and a third code stream for coding the background image;
the index module is used for finding out the corresponding pixel position of the basic color on the background image according to the color index map;
the determining module is used for determining the basic color according to the basic color mapping table;
a modifying module, configured to modify the background image according to the basic color and the pixel position, so as to obtain an original image corresponding to the received code stream;
wherein the background image includes a plurality of macro blocks, the base color is determined according to a color of a text of the macro block of the original image, and the color index map is generated by setting an index for the base color and the non-base color of the macro block of the original image.
11. A processor, characterized in that the processor is configured to run a program, wherein the program is configured to perform the image encoding method according to any one of claims 1 to 7 or the image decoding method according to claim 8 when running.
CN202011211046.XA 2020-11-03 2020-11-03 Image encoding method and device, image decoding method and device, and processor Pending CN112383779A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011211046.XA CN112383779A (en) 2020-11-03 2020-11-03 Image encoding method and device, image decoding method and device, and processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011211046.XA CN112383779A (en) 2020-11-03 2020-11-03 Image encoding method and device, image decoding method and device, and processor

Publications (1)

Publication Number Publication Date
CN112383779A true CN112383779A (en) 2021-02-19

Family

ID=74578201

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011211046.XA Pending CN112383779A (en) 2020-11-03 2020-11-03 Image encoding method and device, image decoding method and device, and processor

Country Status (1)

Country Link
CN (1) CN112383779A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113507604A (en) * 2021-06-15 2021-10-15 上海辰珅科技有限公司 Image encoding method and device, and image decoding method and device
CN114496410A (en) * 2021-12-29 2022-05-13 四川天邑康和通信股份有限公司 HDMI wire core extrusion process

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101217668A (en) * 2008-01-14 2008-07-09 浙江大学 A mixed image compression method based on block classification
US20080304762A1 (en) * 2007-06-06 2008-12-11 Canon Kabushiki Kaisha Image processing apparatus and method
CN101790023A (en) * 2009-01-22 2010-07-28 夏普株式会社 Method for compressing image, image compressing device and image processing system
CN101816177A (en) * 2007-09-13 2010-08-25 微软公司 Textual image coding
CN103839252A (en) * 2012-11-27 2014-06-04 京瓷办公信息系统株式会社 Image processing device
US20150030066A1 (en) * 2013-07-23 2015-01-29 Futurewei Technologies, Inc. Screen content coding systems and methods
CN106686384A (en) * 2016-11-29 2017-05-17 苏睿 Character block compression method, device, image compression method and device
CN106851294A (en) * 2017-01-03 2017-06-13 苏睿 The compression method and device of image and its compression method and device of character block
CN108205676A (en) * 2017-11-22 2018-06-26 西安万像电子科技有限公司 The method and apparatus for extracting pictograph region

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080304762A1 (en) * 2007-06-06 2008-12-11 Canon Kabushiki Kaisha Image processing apparatus and method
CN101816177A (en) * 2007-09-13 2010-08-25 微软公司 Textual image coding
CN101217668A (en) * 2008-01-14 2008-07-09 浙江大学 A mixed image compression method based on block classification
CN101790023A (en) * 2009-01-22 2010-07-28 夏普株式会社 Method for compressing image, image compressing device and image processing system
CN103839252A (en) * 2012-11-27 2014-06-04 京瓷办公信息系统株式会社 Image processing device
US20150030066A1 (en) * 2013-07-23 2015-01-29 Futurewei Technologies, Inc. Screen content coding systems and methods
CN106686384A (en) * 2016-11-29 2017-05-17 苏睿 Character block compression method, device, image compression method and device
CN106851294A (en) * 2017-01-03 2017-06-13 苏睿 The compression method and device of image and its compression method and device of character block
CN108205676A (en) * 2017-11-22 2018-06-26 西安万像电子科技有限公司 The method and apparatus for extracting pictograph region

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
T. LIN: "Compound image compression for real-time computer screen image transmission", 《 IEEE TRANSACTIONS ON IMAGE PROCESSING》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113507604A (en) * 2021-06-15 2021-10-15 上海辰珅科技有限公司 Image encoding method and device, and image decoding method and device
CN114496410A (en) * 2021-12-29 2022-05-13 四川天邑康和通信股份有限公司 HDMI wire core extrusion process
CN114496410B (en) * 2021-12-29 2023-06-30 四川天邑康和通信股份有限公司 HDMI wire core extrusion process

Similar Documents

Publication Publication Date Title
KR102640992B1 (en) Point cloud processing
KR102071764B1 (en) Picture coding and decoding methods and devices
CN104754361B (en) Image Coding, coding/decoding method and device
US20060204086A1 (en) Compression of palettized images
US20220222861A1 (en) Method, device, and storage medium for data encoding/decoding
CN113542740B (en) Image transmission method and device
CN104853211A (en) Image compression method and apparatus employing various forms of reference pixel storage spaces
KR101946598B1 (en) Image coding and decoding method and device
WO2009036255A2 (en) Textual image coding
JP2000050268A (en) Image coding device
CN106686384B (en) The compression method and device and method for compressing image and device of character block
CN112383779A (en) Image encoding method and device, image decoding method and device, and processor
CN110996127B (en) Image encoding and decoding method, device and system
CN106604032B (en) Method and device for compressing Chinese character blocks in image and method and device for compressing image
EP1917659A1 (en) Image management
CN113068034A (en) Video encoding method and device, encoder, equipment and storage medium
US7065254B2 (en) Multilayered image file
JP2022527883A (en) Handling of missing points in a point cloud
WO2021196234A1 (en) Video encoding and decoding method and device, and storage medium
KR20220034141A (en) point cloud processing
KR20210134041A (en) Processing of intermediate points in the point cloud
JP2021530890A (en) Point cloud processing
EP3713241A1 (en) Processing a point cloud
CN106713921B (en) The compression method and device and method for compressing image and device of character block
CN112887729B (en) Image coding and decoding method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210219