WO2021004126A1 - Image coding method and apparatus - Google Patents

Image coding method and apparatus Download PDF

Info

Publication number
WO2021004126A1
WO2021004126A1 PCT/CN2020/086334 CN2020086334W WO2021004126A1 WO 2021004126 A1 WO2021004126 A1 WO 2021004126A1 CN 2020086334 W CN2020086334 W CN 2020086334W WO 2021004126 A1 WO2021004126 A1 WO 2021004126A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
macroblock
text
macro block
information
Prior art date
Application number
PCT/CN2020/086334
Other languages
French (fr)
Chinese (zh)
Inventor
高鹏
范志刚
周毅
Original Assignee
西安万像电子科技有限公司
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 西安万像电子科技有限公司 filed Critical 西安万像电子科技有限公司
Publication of WO2021004126A1 publication Critical patent/WO2021004126A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
    • G06V10/267Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion by performing operations on regions, e.g. growing, shrinking or watersheds
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/40Extraction of image or video features
    • G06V10/56Extraction of image or video features relating to colour
    • 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/30Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using hierarchical techniques, e.g. scalability

Definitions

  • the present disclosure relates to the field of electronic information technology, and in particular to image coding methods and devices.
  • the technology of image encoding and decoding processing algorithms also develops rapidly.
  • the image is first recognized, text macroblocks or image macroblocks are determined according to the recognition results, and then corresponding encoding and decoding algorithms are determined according to different macroblocks.
  • the frame image is divided into fixed-size macroblocks, and the macroblocks are divided into two types: picture and text according to the proportion of basic colors in the macroblock and the number of high-gradient pixels.
  • the basic color refers to the basic color, base color
  • the basic color refers to the gray value that appears most frequently in the image as the basic color, that is, the main color in an image.
  • the disadvantage of this algorithm is that when processing images based on these two features, macroblocks that are not real text will be recognized as text macroblocks. For example, in the process of processing desktop icon images, because the macroblocks corresponding to the desktop icon images contain many types of colors, if the blocks that are not real text are recognized as text macroblocks, the text encoding algorithm is used to process the non-text Macro blocks, the coding effect cannot meet the preset requirements, and obvious color layering between adjacent macro blocks will occur.
  • the embodiments of the present disclosure provide an image encoding method and device, which can solve the problem of poor encoding effect due to the recognition of macroblocks containing images as text macroblocks during frame image processing.
  • the technical scheme is as follows:
  • an image encoding method including:
  • the first macro block includes: text information and image information
  • an image layer and a text layer are generated;
  • the text macroblock and the text layer are coded according to the first coding algorithm, and the image layer is coded according to the second coding algorithm to generate the coded macroblock.
  • the method before acquiring the first macroblock, the method further includes:
  • the ratio information including: ratio information of high gradient pixels and ratio information of basic color pixels;
  • the method determining the text macroblock and the image macroblock in the first macroblock includes:
  • generating an image layer and a text layer in the method includes:
  • the method generates a text layer based on high gradient pixels, including
  • Target position information Acquiring target position information and an average pixel value corresponding to the target position information, where the target position information refers to position information corresponding to pixels other than high gradient pixels in the text layer;
  • the text layer is generated according to the high gradient pixels and the preset pixels.
  • the image coding method provided by the embodiment of the present disclosure obtains the first macro block in the target frame image, and the first macro block, that is, the macro block containing text information and image information in the frame image is determined as a text macro in the prior art. After dividing the first macro block according to the color information of the first macro block, the text macro block and the image macro block are generated.
  • the image in the image macro block is an image containing text information; After the layering process, the text layer and the image layer are generated, the text encoding method is adopted for the text macroblock and the text layer map, and the image encoding method is adopted for the image layer layer.
  • an image encoding device which includes: a first acquisition module, a first determination module, a layer generation module, and an image generation module;
  • the first acquisition module is configured to acquire the first macro block and the color information corresponding to the first macro block, and the first macro block includes: text information and image information;
  • the first determining module is configured to determine the text macroblock and the image macroblock in the first macroblock according to the color information corresponding to the first macroblock, and the image in the image macroblock is an image containing text information;
  • the layer generation module is used to generate image layers and text layers after dividing image macroblocks according to preset algorithms
  • the image generation module is used to encode the text macroblock and the text layer according to the first encoding algorithm, and to generate the encoded macroblock after encoding the image layer according to the second encoding algorithm.
  • the device further includes: an image acquisition module and a second determination module,
  • the image acquisition module is configured to acquire a frame image and the proportion information of at least one macroblock in the frame image, the proportion information including: proportion information of high gradient pixels and proportion information of basic color pixels;
  • the second determining module is configured to determine that at least one macroblock in the frame image is the first macroblock when the ratio information of at least one macroblock in the frame image meets a preset requirement.
  • the first determining module of the device includes: an acquiring unit, a first determining unit, a second determining unit, and a third determining unit,
  • the acquiring unit is configured to acquire the number of color types in at least one sub-macroblock in the first macroblock according to the color information;
  • the first determining unit is configured to determine that the sub-macroblock is an image macroblock when the number of color types in the sub-macroblock is greater than the preset number;
  • the second determining unit is configured to determine that the sub-macroblock is a text macroblock when the number of color types in the sub-macroblock is less than or equal to the preset number;
  • the third determining unit is configured to determine the text macro block and the image macro block in the first macro block according to the image macro block or the text macro block corresponding to the sub macro block.
  • the layer generating module of the device includes a first acquiring unit and a generating unit
  • the first obtaining unit is configured to analyze the image macroblock, and obtain high gradient pixels in the image macroblock according to the analysis result;
  • the generating unit is configured to generate a text layer based on the high gradient pixels, and generate an image layer based on pixels other than the high gradient pixels in the image.
  • the layer generating module of the device includes a determining unit, a second acquiring unit, a first generating unit, and a second generating unit,
  • the second acquiring unit is used to acquire the target position information and the average pixel value corresponding to the target position information.
  • the target position information refers to the position information corresponding to pixels other than high gradient pixels in the text layer;
  • the first generating unit is configured to generate and determine a preset pixel according to the target position information and the average pixel value corresponding to the target position information;
  • the second generating unit is used to generate a text layer according to the high gradient pixels and the preset pixels.
  • Fig. 1 is a flowchart of an image coding method provided by an embodiment of the present disclosure
  • Figure 2 is a structural diagram of an image encoding device provided by an embodiment of the present disclosure
  • Fig. 3 is a structural diagram 1 of an image encoding device provided by an embodiment of the present disclosure.
  • Fig. 4 is a structural diagram 2 of an image encoding device provided by an embodiment of the present disclosure.
  • Fig. 5 is a structural diagram 3 of an image encoding device provided by an embodiment of the present disclosure.
  • Fig. 6 is a structural diagram 4 of an image encoding device provided by an embodiment of the present disclosure.
  • the embodiment of the present disclosure provides an image encoding method. As shown in FIG. 1, the image encoding method includes the following steps:
  • the first macro block includes: text information and image information.
  • the color information is used to indicate the color information corresponding to the pixels in the first macroblock, and may include information such as the number of color types included in the first macroblock and the color value corresponding to the pixel.
  • the method of the present disclosure includes determining the first macro block in the frame image, that is, determining the image macro block and the text macro block in the target frame image, including:
  • ratio information includes: ratio information of high gradient pixels and ratio information of basic color pixels, and the basic color is determined according to the gray value in the frame image;
  • the first macroblock of the at least one macroblock in the frame image is determined.
  • the basic color of the image frame may be determined according to the frequency histogram of the frame image, or may be determined according to the number of occurrences of each color value in the frame image.
  • the number of medium and high gradient pixels obtained in the image frame includes:
  • the first pixel is determined as a high gradient pixel
  • the above-mentioned first macroblock is the text macroblock determined by the prior art.
  • the prior art determines the text macroblock based on the characteristics of simple color of the text macroblock; according to the basic color pixel ratio and high gradient in the frame image The number of pixels, etc., divide the frame image into text macroblocks or picture macroblocks.
  • the strategy of identifying image macroblocks and text macroblocks in an image based on the basic color ratio and high gradient pixels based on the prior art For example, a certain macroblock of an image contains a large number of high gradient pixels, and the macroblock contains The proportion of basic color pixels is high, indicating that the macroblock contains fewer colors, the difference is large, and the color is relatively single, so it is divided into text macroblocks; but this strategy is to determine whether a pixel is a basic color pixel. Calculated according to the pixel values in a range. If the color in the target image is a gradual color, several pixels with similar pixel values will be divided into basic color pixels, which increases the proportion of basic color pixels in the macro block. As a result, the macro block containing the image is determined to be a text macro block.
  • the present disclosure takes the text macroblock after the target frame image is divided as the first macroblock in the prior art, and further processes the first macroblock to improve the data accuracy and the encoding effect.
  • the method of the present disclosure aims to solve the problem that when dividing frame images into text macroblocks and image macroblocks, the type of macroblock cannot be accurately determined due to the algorithm based on the prior art, and the macroblock containing image information and text information is divided into It is a text macro block, where the frame image can be an image formed by superimposing multiple layers of images, or an image with rich colors.
  • the image in the image macroblock is an image containing text information.
  • the image may be an icon with embedded text or a picture with embedded text.
  • the first macroblock is further divided into text macro blocks and image macro blocks, which specifically include:
  • Obtain the number of color types in an image macroblock For example, for an image macroblock of 16*16 size, determine whether the number of color types in the image macroblock exceeds a threshold. If not, It is determined that the image macro block is a text type macro block, and if it exceeds, it is determined that the text macro block is a picture or icon type embedded with text.
  • an image layer and a text layer are generated.
  • the method of the present disclosure when generating an image layer and a text layer according to the high gradient feature data in the image macroblock, includes:
  • the blank pixels in the text layer or the image layer are filled according to the preset pixel values to generate the image layer and the text layer.
  • the absolute value of each pixel is calculated by the difference between the pixel values of the four pixels of up, down, left, and right, and it is determined whether the sum of the absolute values exceeds the preset threshold; when the target gradient value exceeds the preset Threshold, the pixel is determined to be a high gradient pixel.
  • filling the blank pixels in the text layer or the image layer according to the preset pixel value includes
  • the blank pixels corresponding to the target position information are filled.
  • the first encoding algorithm may be an encoding algorithm for text types
  • the second encoding algorithm may be an encoding algorithm for image types
  • the second encoding algorithm may be encoded in a JPEG progressive encoding manner.
  • the typical JPEG progressive encoding scheme is to arrange the data after DCT transformation (DCT, Discrete Cosine Transform, commonly used image compression algorithm) in a zigzag scanning manner, and first encode the low-frequency components, and then display it on the decoding display side. See the rough outline of a frame, and then transmit the high-frequency components that carry detailed information.
  • the image coding method provided by the embodiment of the present disclosure obtains the first macro block in the target frame image, and the first macro block, that is, the macro block containing text information and image information in the frame image is determined as a text macro in the prior art. After dividing the first macro block according to the color information of the first macro block, the text macro block and the image macro block are generated.
  • the image in the image macro block is an image containing text information; After the layering process, the text layer and the image layer are generated, the text encoding method is adopted for the text macroblock and the text layer map, and the image encoding method is adopted for the image layer layer.
  • the image encoding device 20 includes: a first acquisition module 201, a first determination module 202, a layer generation module 203, and an image generation module 204;
  • the first acquisition module 201 is used to acquire the color information corresponding to the first macro block and the first macro block, the first macro block includes: text information and image information.
  • the first determining module 202 is configured to determine the text macroblock and the image macroblock in the first macroblock according to the color information corresponding to the first macroblock, and the image in the image macroblock is an image containing text information.
  • the first determining module 202 includes: an acquiring unit 2021, a first determining unit 2022, a second determining unit 2023, and a third determining unit 2024,
  • the acquiring unit 2021 is configured to acquire the number of color types in at least one sub-macroblock in the first macroblock according to the color information;
  • the first determining unit 2022 is configured to determine that the sub macro block is an image macro block when the number of color types in the sub macro block is greater than the preset number;
  • the second determining unit 2023 is configured to determine that the sub-macroblock is a text macroblock when the number of color types in the sub-macroblock is less than or equal to the preset number;
  • the third determining unit 2023 is configured to determine the text macro block and the image macro block in the first macro block according to the image macro block or the text macro block corresponding to the sub macro block.
  • the layer generating module 203 is configured to generate image layers and text layers after dividing the image macroblocks according to a preset algorithm.
  • the layer generating module 203 in the device of the present disclosure includes a first obtaining unit 2031 and a generating unit 2032,
  • the first obtaining unit 2031 is configured to analyze the image macroblock, and obtain the high gradient pixels in the image macroblock according to the analysis result;
  • the generating unit 2032 is configured to generate a text layer according to the high gradient pixels, and generate an image layer according to pixels other than the high gradient pixels in the image.
  • the second acquiring unit 2033 is configured to acquire target position information and an average pixel value corresponding to the target position information, where the target position information refers to the position corresponding to pixels other than high-gradient pixels in the text layer information;
  • the first generating unit 2034 is configured to generate and determine preset pixels according to the target position information and the average pixel value corresponding to the target position information;
  • the second generating unit 3035 is configured to generate the text layer according to the high gradient pixels and the preset pixels.
  • the device 20 of the present disclosure further includes: an image acquisition module 205 and a second determination module 206,
  • the second determining module 206 is configured to determine that at least one macroblock in the frame image is the first macroblock when the ratio information of at least one macroblock in the frame image meets a preset requirement.
  • the image encoding device obtains the first macro block in the target frame image, and the first macro block, that is, in the prior art, determines the macro block containing text information and image information in the frame image as a text macro After dividing the first macro block according to the color information of the first macro block, the text macro block and the image macro block are generated.
  • the image in the image macro block is an image containing text information; After the layering process, the text layer and the image layer are generated, the text encoding method is adopted for the text macroblock and the text layer map, and the image encoding method is adopted for the image layer layer.
  • the non-transitory computer-readable storage medium may be a read-only memory (English: Read Only Memory, ROM), random access memory (English: Random Access Memory, RAM), CD-ROM, magnetic tape, floppy disk and optical data storage device, etc.
  • the storage medium stores computer instructions for executing the image encoding method described in the embodiment corresponding to FIG. 1, which will not be repeated here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)

Abstract

The present disclosure relates to the technical field of electronic information, and provided are an image coding method and apparatus, which may resolve the problem in a frame image processing process in which the coding effect is poor due to a macro block that comprises image information and text information being identified as a text macro block. A specific technical solution is as follows: the image coding method provided in embodiments of the present disclosure: obtaining a first macro block in a target frame image, and then according to color information of the first macro block, dividing the first macro block to then generate a text macro block and an image macro block, wherein an image in the image macro block is an image that comprises text information; once hierarchical processing is performed on the image macro block, generating a text layer and an image layer, using a text coding means for the text layer and the text macro block, and using an image coding means for the image layer. The present disclosure is used for image coding.

Description

图像编码方法及装置Image coding method and device 技术领域Technical field
本公开涉及电子信息技术领域,尤其涉及图像编码方法及装置。The present disclosure relates to the field of electronic information technology, and in particular to image coding methods and devices.
背景技术Background technique
随着对图像处理算法的快速发展,对图像编解码处理算法技术也随之快速发展。在现有技术中,在对图像进行编解码处理时,会先将图像进行识别,根据识别结果确定文字宏块或者图像宏块,再根据不同的宏块确定对应的编解码算法。其中,针对文字宏块颜色简单的特点,将帧图像划分为固定大小的宏块,再根据宏块中基本色占比和高梯度像素个数将宏块划分为图片和文本两种类型,其中,基本色是指基本颜色,base color,基本色是指图像中出现次数最多的灰度值作为基本颜色,即一个图像中的主要色,。此算法的缺点是基于这两个特征处理图像时,会将不是真正文本的宏块识别为文本宏块。例如,在对桌面图标图像的处理过程中,因为桌面图标图像对应的宏块中包含的颜色种类较多,如果将不是真正文本的块识别为文本宏块,并利用文本编码算法处理该非文本宏块,则编码效果无法满足预设要求,会出现明显的相邻宏块之间颜色分层。With the rapid development of image processing algorithms, the technology of image encoding and decoding processing algorithms also develops rapidly. In the prior art, when encoding and decoding an image, the image is first recognized, text macroblocks or image macroblocks are determined according to the recognition results, and then corresponding encoding and decoding algorithms are determined according to different macroblocks. Among them, in view of the simple color of text macroblocks, the frame image is divided into fixed-size macroblocks, and the macroblocks are divided into two types: picture and text according to the proportion of basic colors in the macroblock and the number of high-gradient pixels. The basic color refers to the basic color, base color, the basic color refers to the gray value that appears most frequently in the image as the basic color, that is, the main color in an image. The disadvantage of this algorithm is that when processing images based on these two features, macroblocks that are not real text will be recognized as text macroblocks. For example, in the process of processing desktop icon images, because the macroblocks corresponding to the desktop icon images contain many types of colors, if the blocks that are not real text are recognized as text macroblocks, the text encoding algorithm is used to process the non-text Macro blocks, the coding effect cannot meet the preset requirements, and obvious color layering between adjacent macro blocks will occur.
发明内容Summary of the invention
本公开实施例提供一种图像编码方法及装置,能够解决在帧图像处理过程中因为将含有图像的宏块识别为文本宏块,导致编码效果不佳的问题。该技术方案如下:The embodiments of the present disclosure provide an image encoding method and device, which can solve the problem of poor encoding effect due to the recognition of macroblocks containing images as text macroblocks during frame image processing. The technical scheme is as follows:
根据本公开实施例的第一方面,提供一种图像编码方法,该方法包括:According to a first aspect of the embodiments of the present disclosure, there is provided an image encoding method, the method including:
获取第一宏块及该第一宏块对应的颜色信息,该第一宏块包括:文本信息和图像信息;Acquiring a first macro block and color information corresponding to the first macro block, where the first macro block includes: text information and image information;
根据该第一宏块对应的颜色信息,确定该第一宏块中的文字宏块和图像宏块,该图像宏块中的图像为包含文本信息的图像;Determining the text macro block and the image macro block in the first macro block according to the color information corresponding to the first macro block, and the image in the image macro block is an image containing text information;
根据预设算法对该图像宏块进行划分处理后,生成图像图层和文本图层;After dividing and processing the image macroblock according to a preset algorithm, an image layer and a text layer are generated;
根据第一编码算法对该文字宏块和该文本图层进行编码,并根据第二编 码算法对该图像图层进行编码后,生成已编码宏块。The text macroblock and the text layer are coded according to the first coding algorithm, and the image layer is coded according to the second coding algorithm to generate the coded macroblock.
在一个实施例中,该方法在获取第一宏块之前,该方法还包括:In an embodiment, before acquiring the first macroblock, the method further includes:
获取帧图像及该帧图像中至少一个宏块的比例信息,该比例信息包括:高梯度像素的比例信息和基本色像素的比例信息;Acquiring a frame image and ratio information of at least one macroblock in the frame image, the ratio information including: ratio information of high gradient pixels and ratio information of basic color pixels;
在该帧图像中至少一个宏块的比例信息符合预设要求时,确定该帧图像中至少一个宏块为该第一宏块。When the ratio information of at least one macro block in the frame image meets a preset requirement, it is determined that at least one macro block in the frame image is the first macro block.
在一个实施例中,该方法在确定该第一宏块中的文字宏块和图像宏块,包括:In an embodiment, the method determining the text macroblock and the image macroblock in the first macroblock includes:
根据该颜色信息,获取该第一宏块中至少一个子宏块中颜色种类的数量;Obtaining the number of color types in at least one sub-macroblock in the first macroblock according to the color information;
当该子宏块中颜色种类的数量大于预设数量时,确定该子宏块为该图像宏块;When the number of color types in the sub-macroblock is greater than the preset number, determining that the sub-macroblock is the image macroblock;
当该子宏块中颜色种类的数量小于或等于预设数量时,确定该子宏块为该文字宏块;When the number of color types in the sub-macroblock is less than or equal to the preset number, determining that the sub-macroblock is the text macroblock;
根据该子宏块对应的该图像宏块或该文字宏块,确定该第一宏块中的该文字宏块和该图像宏块。Determine the text macro block and the image macro block in the first macro block according to the image macro block or the text macro block corresponding to the sub macro block.
在一个实施例中,该方法中生成图像图层和文本图层,包括:In an embodiment, generating an image layer and a text layer in the method includes:
解析该图像宏块,根据解析结果获取该图像宏块中的高梯度像素;Analyze the image macroblock, and obtain high-gradient pixels in the image macroblock according to the analysis result;
将该高梯度像素划分至文本图层,并将图像宏块中除高梯度像素外的像素划分至图像图层;Divide the high-gradient pixels into a text layer, and divide the pixels in the image macroblock except the high-gradient pixels into an image layer;
在处理完该图像宏块中所有像素后,根据预设像素值填补该文本图层或该图像图层中的空白像素后,生成该图像图层和该文本图层。After processing all the pixels in the image macroblock, fill the text layer or the blank pixels in the image layer according to the preset pixel value, and then generate the image layer and the text layer.
在一个实施例中,该方法中根据高梯度像素生成文本图层,包括In one embodiment, the method generates a text layer based on high gradient pixels, including
获取目标位置信息和所述目标位置信息对应的平均像素值,所述目标位置信息是指,所述文本图层中除高梯度像素外的像素对应的位置信息;Acquiring target position information and an average pixel value corresponding to the target position information, where the target position information refers to position information corresponding to pixels other than high gradient pixels in the text layer;
根据所述目标位置信息和所述目标位置信息对应的平均像素值,生成确定预设像素;Generating and determining preset pixels according to the target position information and the average pixel value corresponding to the target position information;
根据所述高梯度像素和所述预设像素,生成所述文本图层。The text layer is generated according to the high gradient pixels and the preset pixels.
本公开实施例提供的图像编码方法,通过获取目标帧图像中的第一宏块,该第一宏块,即现有技术中将帧图像中含有文本信息和图像信息的宏块判断为文本宏块的宏块,再根据第一宏块的颜色信息对第一宏块划分后,生成文字宏块和图像宏块,其中图像宏块中的图像为包含文本信息的图像;对图像宏块进行分层处理后,生成文本图层和图像图层,针对文字宏块和文本层图采用文本编码方式,以及对图像层图层采用图像编码方式。通过提高识别帧图像中文本宏块的准确度,避免了将含有图像信息和文本信息的宏块识别为文本宏块,并根据文本宏块和图像宏块不同的特性选择匹配的编码算法,从而提高了帧图像的编码效果,继而提高了帧图像编码后的视觉效果和压缩比效果。The image coding method provided by the embodiment of the present disclosure obtains the first macro block in the target frame image, and the first macro block, that is, the macro block containing text information and image information in the frame image is determined as a text macro in the prior art. After dividing the first macro block according to the color information of the first macro block, the text macro block and the image macro block are generated. The image in the image macro block is an image containing text information; After the layering process, the text layer and the image layer are generated, the text encoding method is adopted for the text macroblock and the text layer map, and the image encoding method is adopted for the image layer layer. By improving the accuracy of recognizing text macroblocks in frame images, it is avoided that macroblocks containing image information and text information are recognized as text macroblocks, and matching coding algorithms are selected according to the different characteristics of text macroblocks and image macroblocks, thereby The coding effect of the frame image is improved, and then the visual effect and compression ratio effect of the frame image after the coding is improved.
根据本公开实施例的第二方面,提供一种图像编码装置,该装置包括:第一获取模块、第一确定模块、图层生成模块和图像生成模块;According to a second aspect of the embodiments of the present disclosure, there is provided an image encoding device, which includes: a first acquisition module, a first determination module, a layer generation module, and an image generation module;
第一获取模块,用于获取第一宏块及第一宏块对应的颜色信息,第一宏块包括:文本信息和图像信息;The first acquisition module is configured to acquire the first macro block and the color information corresponding to the first macro block, and the first macro block includes: text information and image information;
第一确定模块,用于根据第一宏块对应的颜色信息,确定第一宏块中的文字宏块和图像宏块,图像宏块中的图像为包含文本信息的图像;The first determining module is configured to determine the text macroblock and the image macroblock in the first macroblock according to the color information corresponding to the first macroblock, and the image in the image macroblock is an image containing text information;
图层生成模块,用于根据预设算法对图像宏块进行划分处理后,生成图像图层和文本图层;The layer generation module is used to generate image layers and text layers after dividing image macroblocks according to preset algorithms;
图像生成模块,用于根据第一编码算法对文字宏块和文本图层进行编码,并根据第二编码算法对图像图层进行编码后,生成已编码宏块。The image generation module is used to encode the text macroblock and the text layer according to the first encoding algorithm, and to generate the encoded macroblock after encoding the image layer according to the second encoding algorithm.
在一个实施例中,该装置还包括:图像获取模块和第二确定模块,In an embodiment, the device further includes: an image acquisition module and a second determination module,
所述图像获取模块,用于获取帧图像及该帧图像中至少一个宏块的比例信息,该比例信息包括:高梯度像素的比例信息和基本色像素的比例信息;The image acquisition module is configured to acquire a frame image and the proportion information of at least one macroblock in the frame image, the proportion information including: proportion information of high gradient pixels and proportion information of basic color pixels;
第二确定模块,用于在帧图像中至少一个宏块的比例信息符合预设要求时,确定所述帧图像中至少一个宏块为第一宏块。The second determining module is configured to determine that at least one macroblock in the frame image is the first macroblock when the ratio information of at least one macroblock in the frame image meets a preset requirement.
在一个实施例中,该装置的第一确定模块,包括:获取单元、第一确定单元,第二确定单元和第三确定单元,In an embodiment, the first determining module of the device includes: an acquiring unit, a first determining unit, a second determining unit, and a third determining unit,
获取单元,用于根据颜色信息,获取第一宏块中至少一个子宏块中颜色种类的数量;The acquiring unit is configured to acquire the number of color types in at least one sub-macroblock in the first macroblock according to the color information;
第一确定单元,用于当子宏块中颜色种类的数量大于预设数量时,确定子宏块为图像宏块;The first determining unit is configured to determine that the sub-macroblock is an image macroblock when the number of color types in the sub-macroblock is greater than the preset number;
第二确定单元,用于当子宏块中颜色种类的数量小于或等于预设数量时,确定子宏块为文字宏块;The second determining unit is configured to determine that the sub-macroblock is a text macroblock when the number of color types in the sub-macroblock is less than or equal to the preset number;
第三确定单元,用于根据子宏块对应的图像宏块或文字宏块,确定第一宏块中的文字宏块和图像宏块。The third determining unit is configured to determine the text macro block and the image macro block in the first macro block according to the image macro block or the text macro block corresponding to the sub macro block.
在一个实施例中,该装置的图层生成模块,包括第一获取单元和生成单元In one embodiment, the layer generating module of the device includes a first acquiring unit and a generating unit
第一获取单元,用于解析图像宏块,根据解析结果获取图像宏块中的高梯度像素;The first obtaining unit is configured to analyze the image macroblock, and obtain high gradient pixels in the image macroblock according to the analysis result;
生成单元,用于在根据所述高梯度像素生成文本图层,并根据所述图像中除高梯度像素外的其他像素生成图像图层。The generating unit is configured to generate a text layer based on the high gradient pixels, and generate an image layer based on pixels other than the high gradient pixels in the image.
在一个实施例中,该装置的图层生成模块,包括,确定单元、第二获取单元、第一生成单元和第二生成单元,In one embodiment, the layer generating module of the device includes a determining unit, a second acquiring unit, a first generating unit, and a second generating unit,
第二获取单元,用于获取目标位置信息和目标位置信息对应的平均像素值,目标位置信息是指,文本图层中除高梯度像素外的像素对应的位置信息;The second acquiring unit is used to acquire the target position information and the average pixel value corresponding to the target position information. The target position information refers to the position information corresponding to pixels other than high gradient pixels in the text layer;
第一生成单元,用于根据目标位置信息和目标位置信息对应的平均像素值,生成确定预设像素;The first generating unit is configured to generate and determine a preset pixel according to the target position information and the average pixel value corresponding to the target position information;
第二生成单元,用于根据高梯度像素和预设像素,生成文本图层。The second generating unit is used to generate a text layer according to the high gradient pixels and the preset pixels.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure.
附图说明Description of the drawings
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。The drawings herein are incorporated into the specification and constitute a part of the specification, show embodiments in accordance with the disclosure, and together with the specification are used to explain the principle of the disclosure.
图1是本公开实施例提供的一种图像编码方法的流程图;Fig. 1 is a flowchart of an image coding method provided by an embodiment of the present disclosure;
图2是本公开实施例提供的一种图像编码装置的结构图;Figure 2 is a structural diagram of an image encoding device provided by an embodiment of the present disclosure;
图3是本公开实施例提供的一种图像编码装置的结构图1;Fig. 3 is a structural diagram 1 of an image encoding device provided by an embodiment of the present disclosure;
图4是本公开实施例提供的一种图像编码装置的结构图2;Fig. 4 is a structural diagram 2 of an image encoding device provided by an embodiment of the present disclosure;
图5是本公开实施例提供的一种图像编码装置的结构图3;Fig. 5 is a structural diagram 3 of an image encoding device provided by an embodiment of the present disclosure;
图6是本公开实施例提供的一种图像编码装置的结构图4。Fig. 6 is a structural diagram 4 of an image encoding device provided by an embodiment of the present disclosure.
具体实施方式Detailed ways
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本公开相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本公开的一些方面相一致的装置和方法的例子。Here, exemplary embodiments will be described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present disclosure. Rather, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
实施例一Example one
本公开实施例提供一种图像编码方法,如图1所示,该图像编码方法包括以下步骤:The embodiment of the present disclosure provides an image encoding method. As shown in FIG. 1, the image encoding method includes the following steps:
101、获取第一宏块及该第一宏块对应的颜色信息。101. Acquire a first macro block and color information corresponding to the first macro block.
其中,第一宏块包括:文本信息和图像信息。Among them, the first macro block includes: text information and image information.
其中,颜色信息,用于指示该第一宏块中的像素对应的颜色信息,可以包括第一宏块中包括的颜色种类的数量、像素对应的颜色值等信息。The color information is used to indicate the color information corresponding to the pixels in the first macroblock, and may include information such as the number of color types included in the first macroblock and the color value corresponding to the pixel.
本公开该方法在获取第一宏块之前,包括在帧图像中确定第一宏块,即在目标帧图像中确定图像宏块和文本宏块,包括:Before acquiring the first macro block, the method of the present disclosure includes determining the first macro block in the frame image, that is, determining the image macro block and the text macro block in the target frame image, including:
获取帧图像及该帧图像中至少一个宏块的比例信息,该比例信息包括:高梯度像素的比例信息和基本色像素的比例信息,该基本色根据该帧图像中的灰度值确定;Acquiring a frame image and ratio information of at least one macroblock in the frame image, where the ratio information includes: ratio information of high gradient pixels and ratio information of basic color pixels, and the basic color is determined according to the gray value in the frame image;
在该帧图像中至少一个宏块的比例信息符合预设要求时,确定该帧图像中中至少一个宏块的第一宏块。When the ratio information of at least one macroblock in the frame image meets the preset requirement, the first macroblock of the at least one macroblock in the frame image is determined.
其中,获取帧图像中至少一个宏块的比例信息,包括:Wherein, obtaining the ratio information of at least one macroblock in the frame image includes:
先确定帧图像中至少一个宏块对应的基本色和高梯度像素,进而根据该帧图像中至少一个宏块基本色像素的个数占该帧图像中所有像素的比例,即 为基本色像素的比例;根据该帧图像中至少一个宏块高梯度像素的个数占该帧图像中至少一个宏块所有像素的比例,即为高像素像像素的比例。First determine the basic color and high gradient pixels corresponding to at least one macro block in the frame image, and then according to the ratio of the number of basic color pixels of at least one macro block in the frame image to all pixels in the frame image, that is, the basic color pixel Proportion; according to the ratio of the number of high gradient pixels in at least one macroblock in the frame image to all pixels in at least one macroblock in the frame image, that is, the ratio of high-pixel image pixels.
进一步的,图像帧的基本色,即图像帧中的主颜色,可以根据帧图像的频率直方图确定,也可以根据帧图像的中每个颜色值出现的次数确定。Further, the basic color of the image frame, that is, the main color in the image frame, may be determined according to the frequency histogram of the frame image, or may be determined according to the number of occurrences of each color value in the frame image.
进一步的,获取图像帧的中高梯度像素的个数包括:Further, the number of medium and high gradient pixels obtained in the image frame includes:
判断帧图像中每个像素的像素值与相邻任意一个像素的像素值的差值是否大于或等于第三阈值;Determine whether the difference between the pixel value of each pixel in the frame image and the pixel value of any adjacent pixel is greater than or equal to the third threshold;
若根据该帧图像中第一像素的像素值与相邻任意一个像素的像素值的差值大于或等于第三阈值时,将第一像素确定为高梯度像素;If the difference between the pixel value of the first pixel in the frame image and the pixel value of any adjacent pixel is greater than or equal to the third threshold, the first pixel is determined as a high gradient pixel;
统计第一像素的个数。即,通过相邻像素间的差值比较,实现对高梯度像素的统计。Count the number of first pixels. That is, by comparing the difference between adjacent pixels, the statistics of high gradient pixels are realized.
上述的第一宏块即通过现有技术确定的文本宏块,现有技术在确定文本宏块时,基于文本宏块颜色简单的特点特性;根据帧图像中的基本色像素占比和高梯度像素个数等,将帧图像分成文字宏块或图片宏块。The above-mentioned first macroblock is the text macroblock determined by the prior art. The prior art determines the text macroblock based on the characteristics of simple color of the text macroblock; according to the basic color pixel ratio and high gradient in the frame image The number of pixels, etc., divide the frame image into text macroblocks or picture macroblocks.
但是基于现有技术的根据基本色比例和高梯度像素识别图像中的图像宏块和文字宏块策略:如,图像某一个宏块中包含的高梯度像素个数多、且该宏块包含的基本色像素的比例高,说明该宏块包含的颜色较少,差异较大,颜色较为单一,则将其划分为文字宏块;但是这种策略在判断某一像素是否是基本色像素,是根据一个区间范围内的像素值去计算的,若目标图像中颜色为渐变色,则会将若干个像素值接近的像素均划分为基本色像素,增加了该宏块中基本色像素的比例,从而导致将该包含图像的宏块确定为文本宏块。However, the strategy of identifying image macroblocks and text macroblocks in an image based on the basic color ratio and high gradient pixels based on the prior art: For example, a certain macroblock of an image contains a large number of high gradient pixels, and the macroblock contains The proportion of basic color pixels is high, indicating that the macroblock contains fewer colors, the difference is large, and the color is relatively single, so it is divided into text macroblocks; but this strategy is to determine whether a pixel is a basic color pixel. Calculated according to the pixel values in a range. If the color in the target image is a gradual color, several pixels with similar pixel values will be divided into basic color pixels, which increases the proportion of basic color pixels in the macro block. As a result, the macro block containing the image is determined to be a text macro block.
因此本公开对现有技术中将目标帧图像划分后文本宏块作为第一宏块,并针对该第一宏块进一步的处理,提高了数据精准度,也提高了编码效果。Therefore, the present disclosure takes the text macroblock after the target frame image is divided as the first macroblock in the prior art, and further processes the first macroblock to improve the data accuracy and the encoding effect.
针对上述,本公开该方法针对于解决在划分帧图像为文本宏块和图像宏块时因为基于现有技术的算法,无法准确判断宏块类型,将包含图像信息和文本信息的宏块,划分为文本宏块,其中,该帧图像可以是多层图像叠加而成的图像,也可以是图像色彩丰富的图像。In view of the above, the method of the present disclosure aims to solve the problem that when dividing frame images into text macroblocks and image macroblocks, the type of macroblock cannot be accurately determined due to the algorithm based on the prior art, and the macroblock containing image information and text information is divided into It is a text macro block, where the frame image can be an image formed by superimposing multiple layers of images, or an image with rich colors.
102、根据颜色信息,确定该第一宏块中的文字宏块和图像宏块。102. Determine the text macroblock and the image macroblock in the first macroblock according to the color information.
其中,图像宏块中的图像为包含文本信息的图像,例如,该图像可以是嵌有文字的图标或嵌有文字的图片。Wherein, the image in the image macroblock is an image containing text information. For example, the image may be an icon with embedded text or a picture with embedded text.
基于上述分析,针对现有技术中划分文本宏块的缺陷,无法准确将渐变色或者颜色复杂的帧图像划分文本宏块或者图像宏块,因此根据第一宏块的颜色信息,将第一宏块进一步划分为文本宏块和图像宏块,具体包括:Based on the above analysis, in view of the defects of dividing text macroblocks in the prior art, frame images with gradient colors or complex colors cannot be accurately divided into text macroblocks or image macroblocks. Therefore, according to the color information of the first macroblock, the first macroblock The blocks are further divided into text macro blocks and image macro blocks, which specifically include:
根据该颜色信息,获取该第一宏块中至少一个子宏块中颜色种类的数量;Obtaining the number of color types in at least one sub-macroblock in the first macroblock according to the color information;
当该子宏块中颜色种类的数量大于预设数量时,确定该子宏块为该图像宏块;When the number of color types in the sub-macroblock is greater than the preset number, determining that the sub-macroblock is the image macroblock;
当该子宏块中颜色种类的数量小于或等于预设数量时,确定该子宏块为该文字宏块;When the number of color types in the sub-macroblock is less than or equal to the preset number, determining that the sub-macroblock is the text macroblock;
根据该子宏块对应的图像宏块或文字宏块,确定该第一宏块中的文字宏块和图像宏块。Determine the text macro block and the image macro block in the first macro block according to the image macro block or the text macro block corresponding to the sub macro block.
此处列举具体示例进行阐述:获取图像宏块中的颜色种类的数量,比如,对于16*16大小的图像宏块,判断该图像宏块中的颜色种类的数量是否超过阈值,若未超过,则确定该图像宏块为文本类型宏块,若超过,则确定该文字宏块为嵌有文本的图片或图标类型。Here are specific examples to illustrate: Obtain the number of color types in an image macroblock. For example, for an image macroblock of 16*16 size, determine whether the number of color types in the image macroblock exceeds a threshold. If not, It is determined that the image macro block is a text type macro block, and if it exceeds, it is determined that the text macro block is a picture or icon type embedded with text.
103、根据预设算法对该图像宏块进行划分处理后,生成图像图层和文本图层。103. After performing division processing on the image macroblock according to a preset algorithm, an image layer and a text layer are generated.
在可选实施例中,本公开该方法,根据图像宏块中的高梯度特征数据,生成图像图层和文本图层时,包括:In an optional embodiment, the method of the present disclosure, when generating an image layer and a text layer according to the high gradient feature data in the image macroblock, includes:
解析该图像宏块,根据解析结果获取该图像宏块中的高梯度像素;Analyze the image macroblock, and obtain high-gradient pixels in the image macroblock according to the analysis result;
将图像宏块中高梯度像素划分至文本图层,并将图像宏块中除高梯度像素外的像素划分至图像图层;Divide the high-gradient pixels in the image macroblock into the text layer, and divide the pixels except the high-gradient pixels in the image macroblock into the image layer;
在处理完该图像宏块中所有像素后,根据预设像素值填补该文本图层或该图像图层中的空白像素,生成该图像图层和该文本图层。After all the pixels in the image macroblock are processed, the blank pixels in the text layer or the image layer are filled according to the preset pixel values to generate the image layer and the text layer.
针对上述方法,其中根据解析结果获取该图像宏块中的高梯度像素之前,包括确定图像宏块中的高梯度像素:For the above method, before obtaining the high gradient pixels in the image macroblock according to the analysis result, it includes determining the high gradient pixels in the image macroblock:
遍历图像宏块包含的每一个像素,并获取每个像素对应的梯度值。根据 每个像素对应的像素值,将每个像素分别与上下左右四个像素的像素值作差求得绝对值,并判断该绝对值的和是否超过预设阈值;当目标梯度值超过预设阈值,则确定该像素为高梯度像素。Traverse each pixel contained in the image macroblock, and obtain the gradient value corresponding to each pixel. According to the pixel value corresponding to each pixel, the absolute value of each pixel is calculated by the difference between the pixel values of the four pixels of up, down, left, and right, and it is determined whether the sum of the absolute values exceeds the preset threshold; when the target gradient value exceeds the preset Threshold, the pixel is determined to be a high gradient pixel.
针对上述方法,其中根据预设像素值填补该文本图层或该图像图层中的空白像素,包括Aiming at the above method, filling the blank pixels in the text layer or the image layer according to the preset pixel value includes
根据该至少一个像素划分至该文本图层或图像图层中对应的位置信息,确定该文本图层或该图像图层中空白像素的目标位置信息;Determine the target position information of the blank pixels in the text layer or the image layer according to the corresponding position information in the at least one pixel divided into the text layer or the image layer;
获取该目标位置信息预设范围内像素的平均像素值;Obtaining an average pixel value of pixels within a preset range of the target position information;
根据该平均像素值,填补该目标位置信息对应的空白像素。According to the average pixel value, the blank pixels corresponding to the target position information are filled.
104、根据第一编码算法对文字宏块和文本图层进行编码,并根据第二编码算法对图像图层进行编码后,生成已编码宏块。104. Encode the text macroblock and the text layer according to the first encoding algorithm, and after encoding the image layer according to the second encoding algorithm, generate an encoded macroblock.
在可选实施例中,第一编码算法可以是针对于文字类型的编码算法,第二编码算法可以是针对图像类型的编码算法,其中第二编码算法,可以采用JPEG渐进式编码方式进行编码。其中,JPEG渐进式编码的典型方案是对DCT变换(DCT,即离散余弦变换,常用图像压缩算法)后的数据按照Z字型扫描的方式排列,先将低频分量进行编码,在解码显示端会看到一帧画面的大致轮廓,然后再传输承载细节信息的高频分量。In an alternative embodiment, the first encoding algorithm may be an encoding algorithm for text types, and the second encoding algorithm may be an encoding algorithm for image types, and the second encoding algorithm may be encoded in a JPEG progressive encoding manner. Among them, the typical JPEG progressive encoding scheme is to arrange the data after DCT transformation (DCT, Discrete Cosine Transform, commonly used image compression algorithm) in a zigzag scanning manner, and first encode the low-frequency components, and then display it on the decoding display side. See the rough outline of a frame, and then transmit the high-frequency components that carry detailed information.
本公开实施例提供的图像编码方法,通过获取目标帧图像中的第一宏块,该第一宏块,即现有技术中将帧图像中含有文本信息和图像信息的宏块判断为文本宏块的宏块,再根据第一宏块的颜色信息对第一宏块划分后,生成文字宏块和图像宏块,其中图像宏块中的图像为包含文本信息的图像;对图像宏块进行分层处理后,生成文本图层和图像图层,针对文字宏块和文本层图采用文本编码方式,以及对图像层图层采用图像编码方式。通过提高识别帧图像中文本宏块的准确度,避免了将含有图像信息和文本信息的宏块识别为文本宏块,并根据文本宏块和图像宏块不同的特性选择匹配的编码算法,从而提高了帧图像的编码效果,继而提高了帧图像编码后的视觉效果和压缩比效果。The image coding method provided by the embodiment of the present disclosure obtains the first macro block in the target frame image, and the first macro block, that is, the macro block containing text information and image information in the frame image is determined as a text macro in the prior art. After dividing the first macro block according to the color information of the first macro block, the text macro block and the image macro block are generated. The image in the image macro block is an image containing text information; After the layering process, the text layer and the image layer are generated, the text encoding method is adopted for the text macroblock and the text layer map, and the image encoding method is adopted for the image layer layer. By improving the accuracy of recognizing text macroblocks in frame images, it is avoided that macroblocks containing image information and text information are recognized as text macroblocks, and matching coding algorithms are selected according to the different characteristics of text macroblocks and image macroblocks, thereby The coding effect of the frame image is improved, and then the visual effect and compression ratio effect of the frame image after the coding is improved.
实施例二Example two
基于上述图1对应的实施例中所描述的图像编码方法,下述为本公开装 置实施例,可以用于执行本公开方法实施例。Based on the image coding method described in the embodiment corresponding to FIG. 1, the following are embodiments of the disclosed device, which can be used to implement the method embodiments of the disclosure.
本公开实施例提供一种图像编码装置,如图2所示,该图像编码装置20包括:第一获取模块201、第一确定模块202、图层生成模块203和图像生成模块204;An embodiment of the present disclosure provides an image encoding device. As shown in FIG. 2, the image encoding device 20 includes: a first acquisition module 201, a first determination module 202, a layer generation module 203, and an image generation module 204;
第一获取模块201,用于获取第一宏块及第一宏块对应的颜色信息,第一宏块包括:文本信息和图像信息.The first acquisition module 201 is used to acquire the color information corresponding to the first macro block and the first macro block, the first macro block includes: text information and image information.
第一确定模块202,用于根据第一宏块对应的颜色信息,确定第一宏块中的文字宏块和图像宏块,图像宏块中的图像为包含文本信息的图像。The first determining module 202 is configured to determine the text macroblock and the image macroblock in the first macroblock according to the color information corresponding to the first macroblock, and the image in the image macroblock is an image containing text information.
如图3所示,在可选实施例中,第一确定模块202,包括:获取单元2021、第一确定单元2022,第二确定单元2023和第三确定单元2024,As shown in FIG. 3, in an optional embodiment, the first determining module 202 includes: an acquiring unit 2021, a first determining unit 2022, a second determining unit 2023, and a third determining unit 2024,
获取单元2021,用于根据颜色信息,获取第一宏块中至少一个子宏块中颜色种类的数量;The acquiring unit 2021 is configured to acquire the number of color types in at least one sub-macroblock in the first macroblock according to the color information;
第一确定单元2022,用于当子宏块中颜色种类的数量大于预设数量时,确定子宏块为图像宏块;The first determining unit 2022 is configured to determine that the sub macro block is an image macro block when the number of color types in the sub macro block is greater than the preset number;
第二确定单元2023,用于当子宏块中颜色种类的数量小于或等于预设数量时,确定子宏块为文字宏块;The second determining unit 2023 is configured to determine that the sub-macroblock is a text macroblock when the number of color types in the sub-macroblock is less than or equal to the preset number;
第三确定单元2023,用于根据子宏块对应的图像宏块或文字宏块,确定第一宏块中的文字宏块和图像宏块。The third determining unit 2023 is configured to determine the text macro block and the image macro block in the first macro block according to the image macro block or the text macro block corresponding to the sub macro block.
图层生成模块203,用于根据预设算法对图像宏块进行划分处理后,生成图像图层和文本图层。The layer generating module 203 is configured to generate image layers and text layers after dividing the image macroblocks according to a preset algorithm.
如图4所示,在可选实施例中,本公开装置中图层生成模块203,包括第一获取单元2031和生成单元2032,As shown in FIG. 4, in an alternative embodiment, the layer generating module 203 in the device of the present disclosure includes a first obtaining unit 2031 and a generating unit 2032,
第一获取单元2031,用于解析图像宏块,根据解析结果获取图像宏块中的高梯度像素;The first obtaining unit 2031 is configured to analyze the image macroblock, and obtain the high gradient pixels in the image macroblock according to the analysis result;
生成单元2032,用于根据所述高梯度像素生成文本图层,并根据所述图像中除高梯度像素外的其他像素生成图像图层。The generating unit 2032 is configured to generate a text layer according to the high gradient pixels, and generate an image layer according to pixels other than the high gradient pixels in the image.
如图5所示,在可选实施例中,本公开装置的图层生成模块203,包括,第二获取单元2033、第一生成单元2034和第二生成单元2035,As shown in FIG. 5, in an alternative embodiment, the layer generation module 203 of the device of the present disclosure includes a second acquisition unit 2033, a first generation unit 2034, and a second generation unit 2035,
所述第二获取单元2033,用于获取目标位置信息和所述目标位置信息对应的平均像素值,所述目标位置信息是指,所述文本图层中除高梯度像素外的像素对应的位置信息;The second acquiring unit 2033 is configured to acquire target position information and an average pixel value corresponding to the target position information, where the target position information refers to the position corresponding to pixels other than high-gradient pixels in the text layer information;
所述第一生成单元2034,用于根据所述目标位置信息和所述目标位置信息对应的平均像素值,生成确定预设像素;The first generating unit 2034 is configured to generate and determine preset pixels according to the target position information and the average pixel value corresponding to the target position information;
所述第二生成单元3035,用于根据所述高梯度像素和所述预设像素,生成所述文本图层。The second generating unit 3035 is configured to generate the text layer according to the high gradient pixels and the preset pixels.
如图6所示,在可选实施例中,本公开装置20还包括:图像获取模块205和第二确定模块206,As shown in FIG. 6, in an optional embodiment, the device 20 of the present disclosure further includes: an image acquisition module 205 and a second determination module 206,
图像获取模块205,用于获取帧图像及帧图像中至少一个宏块的比例信息,比例信息包括:高梯度像素的比例信息和基本色像素的比例信息;The image acquisition module 205 is configured to acquire the frame image and the proportion information of at least one macroblock in the frame image. The proportion information includes: proportion information of high gradient pixels and proportion information of basic color pixels;
第二确定模块206,用于在所述帧图像中至少一个宏块的比例信息符合预设要求时,确定所述帧图像中至少一个宏块为所述第一宏块。The second determining module 206 is configured to determine that at least one macroblock in the frame image is the first macroblock when the ratio information of at least one macroblock in the frame image meets a preset requirement.
本公开实施例提供的图像编码装置,通过获取目标帧图像中的第一宏块,该第一宏块,即现有技术中将帧图像中含有文本信息和图像信息的宏块判断为文本宏块的宏块,再根据第一宏块的颜色信息对第一宏块划分后,生成文字宏块和图像宏块,其中图像宏块中的图像为包含文本信息的图像;对图像宏块进行分层处理后,生成文本图层和图像图层,针对文字宏块和文本层图采用文本编码方式,以及对图像层图层采用图像编码方式。通过提高识别帧图像中文本宏块的准确度,避免了将含有图像信息和文本信息的宏块识别为文本宏块,并根据文本宏块和图像宏块不同的特性选择匹配的编码算法,从而提高了帧图像的编码效果,继而提高了帧图像编码后的视觉效果和压缩比效果。The image encoding device provided by the embodiment of the present disclosure obtains the first macro block in the target frame image, and the first macro block, that is, in the prior art, determines the macro block containing text information and image information in the frame image as a text macro After dividing the first macro block according to the color information of the first macro block, the text macro block and the image macro block are generated. The image in the image macro block is an image containing text information; After the layering process, the text layer and the image layer are generated, the text encoding method is adopted for the text macroblock and the text layer map, and the image encoding method is adopted for the image layer layer. By improving the accuracy of recognizing text macroblocks in frame images, it is avoided that macroblocks containing image information and text information are recognized as text macroblocks, and matching coding algorithms are selected according to the different characteristics of text macroblocks and image macroblocks, thereby The coding effect of the frame image is improved, and then the visual effect and compression ratio effect of the frame image after the coding is improved.
基于上述图1对应的实施例中所描述的图像编码方法,本公开实施例还提供一种计算机可读存储介质,例如,非临时性计算机可读存储介质可以是只读存储器(英文:Read Only Memory,ROM)、随机存取存储器(英文:Random Access Memory,RAM)、CD-ROM、磁带、软盘和光数据存储装置等。该存储介质上存储有计算机指令,用于执行上述图1对应的实施例中所描述的图像编码方法,此处不再赘述。Based on the image encoding method described in the embodiment corresponding to FIG. 1, embodiments of the present disclosure also provide a computer-readable storage medium. For example, the non-transitory computer-readable storage medium may be a read-only memory (English: Read Only Memory, ROM), random access memory (English: Random Access Memory, RAM), CD-ROM, magnetic tape, floppy disk and optical data storage device, etc. The storage medium stores computer instructions for executing the image encoding method described in the embodiment corresponding to FIG. 1, which will not be repeated here.
本领域技术人员在考虑说明书及实践这里公开的公开后,将容易想到本公开的其它实施方案。本申请旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由下面的权利要求指出。After considering the specification and practicing the disclosure disclosed herein, those skilled in the art will easily think of other embodiments of the present disclosure. This application is intended to cover any variations, uses, or adaptive changes of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or conventional technical means in the technical field not disclosed in the present disclosure . The description and the embodiments are to be regarded as exemplary only, and the true scope and spirit of the present disclosure are pointed out by the following claims.

Claims (10)

  1. 一种图像编码方法,其特征在于,所述方法包括:An image coding method, characterized in that the method includes:
    获取第一宏块及所述第一宏块对应的颜色信息,所述第一宏块包括:文本信息和图像信息;Acquiring a first macro block and color information corresponding to the first macro block, where the first macro block includes: text information and image information;
    根据所述第一宏块对应的颜色信息,确定所述第一宏块中对应的文字宏块和图像宏块,所述图像宏块中的图像为包含文本信息的图像;Determine, according to the color information corresponding to the first macro block, corresponding text macro blocks and image macro blocks in the first macro block, and the image in the image macro block is an image containing text information;
    根据预设算法对所述图像宏块进行划分处理后,生成图像图层和文本图层;After dividing and processing the image macroblocks according to a preset algorithm, an image layer and a text layer are generated;
    根据第一编码算法对所述文字宏块和所述文本图层进行编码,并根据第二编码算法对所述图像图层进行编码后,生成已编码宏块。The text macroblock and the text layer are coded according to the first coding algorithm, and the image layer is coded according to the second coding algorithm to generate coded macroblocks.
  2. 根据权利要求1所述的方法,其特征在于,所述获取第一宏块之前,所述方法还包括:The method according to claim 1, characterized in that, before said obtaining the first macroblock, the method further comprises:
    获取帧图像及所述帧图像中至少一个宏块的比例信息,所述比例信息包括:高梯度像素的比例信息和基本色像素的比例信息;Acquiring a frame image and ratio information of at least one macroblock in the frame image, where the ratio information includes: ratio information of high gradient pixels and ratio information of basic color pixels;
    在所述帧图像中至少一个宏块的比例信息符合预设要求时,确定所述帧图像中至少一个宏块为所述第一宏块。When the ratio information of at least one macro block in the frame image meets a preset requirement, it is determined that at least one macro block in the frame image is the first macro block.
  3. 根据权利要求1所述的方法,其特征在于,所述确定所述第一宏块中的文字宏块和图像宏块,包括:The method according to claim 1, wherein the determining the text macroblock and the image macroblock in the first macroblock comprises:
    根据所述颜色信息,获取所述第一宏块中至少一个子宏块中颜色种类的数量;Acquiring, according to the color information, the number of color types in at least one sub-macroblock in the first macroblock;
    当所述子宏块中颜色种类的数量大于预设数量时,确定所述子宏块为所述图像宏块;When the number of color types in the sub-macroblock is greater than a preset number, determining that the sub-macroblock is the image macroblock;
    当所述子宏块中颜色种类的数量小于或等于预设数量时,确定所述子宏块为所述文字宏块;When the number of color types in the sub-macroblock is less than or equal to a preset number, determining that the sub-macroblock is the text macroblock;
    根据所述子宏块对应的所述图像宏块或所述文字宏块,确定所述第一宏块中的所述文字宏块和所述图像宏块。Determine the text macro block and the image macro block in the first macro block according to the image macro block or the text macro block corresponding to the sub macro block.
  4. 根据权利要求1所述的方法,其特征在于,所述生成图像图层和文本图层,包括:The method according to claim 1, wherein said generating an image layer and a text layer comprises:
    解析所述图像宏块,根据解析结果获取所述图像宏块中的高梯度像素;Parse the image macroblock, and obtain high gradient pixels in the image macroblock according to the analysis result;
    根据所述高梯度像素生成文本图层,并根据所述图像中除高梯度像素外的其他像素生成图像图层。A text layer is generated according to the high gradient pixels, and an image layer is generated according to pixels other than the high gradient pixels in the image.
  5. 根据权利要求4所述的方法,其特征在于,所述根据所述高梯度像素生成文本图层,包括,The method according to claim 4, wherein said generating a text layer according to said high gradient pixels comprises:
    获取目标位置信息和所述目标位置信息对应的平均像素值,所述目标位置信息是指,所述文本图层中除高梯度像素外的像素对应的位置信息;Acquiring target position information and an average pixel value corresponding to the target position information, where the target position information refers to position information corresponding to pixels other than high gradient pixels in the text layer;
    根据所述目标位置信息和所述目标位置信息对应的平均像素值,确定预设像素;Determine a preset pixel according to the target position information and the average pixel value corresponding to the target position information;
    根据所述高梯度像素和所述预设像素,生成所述文本图层。The text layer is generated according to the high gradient pixels and the preset pixels.
  6. 一种图像编码装置,其特征在于,包括:第一获取模块、第一确定模块、图层生成模块和图像生成模块;An image coding device, characterized by comprising: a first acquisition module, a first determination module, a layer generation module, and an image generation module;
    所述第一获取模块,用于获取第一宏块及所述第一宏块对应的颜色信息,所述第一宏块包括:文本信息和图像信息;The first obtaining module is configured to obtain a first macro block and color information corresponding to the first macro block, and the first macro block includes: text information and image information;
    所述第一确定模块,用于根据所述第一宏块对应的颜色信息,确定所述第一宏块中的文字宏块和图像宏块,所述图像宏块中的图像为包含文本信息的图像;The first determining module is configured to determine the text macroblock and the image macroblock in the first macroblock according to the color information corresponding to the first macroblock, and the image in the image macroblock contains text information Image;
    所述图层生成模块,用于根据预设算法对所述图像宏块进行划分处理后,生成图像图层和文本图层;The layer generating module is configured to generate an image layer and a text layer after the image macroblock is divided and processed according to a preset algorithm;
    所述图像生成模块,用于根据第一编码算法对所述文字宏块和所述文本图层进行编码,并根据第二编码算法对所述图像图层进行编码后,生成已编码宏块。The image generation module is configured to encode the text macroblock and the text layer according to a first encoding algorithm, and generate an encoded macroblock after encoding the image layer according to a second encoding algorithm.
  7. 根据权利要求6所述的装置,其特征在于,还包括:图像获取模块和第二确定模块,The device according to claim 6, further comprising: an image acquisition module and a second determination module,
    所述图像获取模块,用于获取帧图像及所述帧图像中至少一个宏块的比例信息,所述比例信息包括:高梯度像素的比例信息和基本色像素的比例信息;The image acquisition module is configured to acquire a frame image and scale information of at least one macroblock in the frame image, and the scale information includes: scale information of high gradient pixels and scale information of basic color pixels;
    所述第二确定模块,用于在所述帧图像中至少一个宏块的比例信息符合 预设要求时,确定所述帧图像中至少一个宏块为所述第一宏块。The second determining module is configured to determine that at least one macroblock in the frame image is the first macroblock when the ratio information of at least one macroblock in the frame image meets a preset requirement.
  8. 根据权利要求6所述的装置,其特征在于,所述第一确定模块,包括:获取单元、第一确定单元,第二确定单元和第三确定单元,The device according to claim 6, wherein the first determining module comprises: an acquiring unit, a first determining unit, a second determining unit, and a third determining unit,
    所述获取单元,用于根据所述颜色信息,获取所述第一宏块中至少一个子宏块中颜色种类的数量;The acquiring unit is configured to acquire the number of color types in at least one sub-macroblock in the first macroblock according to the color information;
    所述第一确定单元,用于当所述子宏块中颜色种类的数量大于预设数量时,确定所述子宏块为所述图像宏块;The first determining unit is configured to determine that the sub-macroblock is the image macroblock when the number of color types in the sub-macroblock is greater than a preset number;
    所述第二确定单元,用于当所述子宏块中颜色种类的数量小于或等于预设数量时,确定所述子宏块为所述文字宏块;The second determining unit is configured to determine that the sub-macroblock is the text macroblock when the number of color types in the sub-macroblock is less than or equal to a preset number;
    所述第三确定单元,用于根据所述子宏块对应的所述图像宏块或所述文字宏块,确定所述第一宏块中的所述文字宏块和所述图像宏块。The third determining unit is configured to determine the text macro block and the image macro block in the first macro block according to the image macro block or the text macro block corresponding to the sub macro block.
  9. 根据权利要求6所述的装置,其特征在于,所述图层生成模块,包括第一获取单元和生成单元,The device according to claim 6, wherein the layer generating module includes a first acquiring unit and a generating unit,
    所述第一获取单元,用于解析所述图像宏块,根据解析结果获取所述图像宏块中的高梯度像素;The first obtaining unit is configured to analyze the image macroblock, and obtain high gradient pixels in the image macroblock according to the analysis result;
    所述生成单元,用于根据所述高梯度像素生成文本图层,并根据所述图像中除高梯度像素外的其他像素生成图像图层。The generating unit is configured to generate a text layer according to the high gradient pixels, and generate an image layer according to pixels other than the high gradient pixels in the image.
  10. 根据权利要求6所述的装置,其特征在于,所述图层生成模块,包括,第二获取单元、第一生成单元和第二生成单元,The device according to claim 6, wherein the layer generating module comprises a second acquiring unit, a first generating unit and a second generating unit,
    所述第二获取单元,用于获取目标位置信息和所述目标位置信息对应的平均像素值,所述目标位置信息是指,所述文本图层中除高梯度像素外的像素对应的位置信息;The second acquiring unit is configured to acquire target position information and an average pixel value corresponding to the target position information, where the target position information refers to position information corresponding to pixels other than high gradient pixels in the text layer ;
    所述第一生成单元,用于根据所述目标位置信息和所述目标位置信息对应的平均像素值,生成确定预设像素;The first generating unit is configured to generate and determine preset pixels according to the target position information and the average pixel value corresponding to the target position information;
    所述第二生成单元,用于根据所述高梯度像素和所述预设像素,生成所述文本图层。The second generating unit is configured to generate the text layer according to the high gradient pixels and the preset pixels.
PCT/CN2020/086334 2019-07-09 2020-04-23 Image coding method and apparatus WO2021004126A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910616543.9 2019-07-09
CN201910616543.9A CN110505483A (en) 2019-07-09 2019-07-09 Image encoding method and device

Publications (1)

Publication Number Publication Date
WO2021004126A1 true WO2021004126A1 (en) 2021-01-14

Family

ID=68585560

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/086334 WO2021004126A1 (en) 2019-07-09 2020-04-23 Image coding method and apparatus

Country Status (2)

Country Link
CN (1) CN110505483A (en)
WO (1) WO2021004126A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110505483A (en) * 2019-07-09 2019-11-26 西安万像电子科技有限公司 Image encoding method and device
CN111447452A (en) * 2020-03-30 2020-07-24 西安万像电子科技有限公司 Data coding method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100316119A1 (en) * 2009-06-11 2010-12-16 Texas Instruments Incorporated Preserving text quality in video encoding
CN103700121A (en) * 2013-12-30 2014-04-02 Tcl集团股份有限公司 Method and device for compressing composite image
US20160328389A1 (en) * 2015-05-07 2016-11-10 Topcomics Co., Ltd System for supporting multiple languages in webtoons
CN107566842A (en) * 2017-08-31 2018-01-09 西安万像电子科技有限公司 The methods, devices and systems of image coding and decoding compression
CN108205676A (en) * 2017-11-22 2018-06-26 西安万像电子科技有限公司 The method and apparatus for extracting pictograph region
CN110505483A (en) * 2019-07-09 2019-11-26 西安万像电子科技有限公司 Image encoding method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100316119A1 (en) * 2009-06-11 2010-12-16 Texas Instruments Incorporated Preserving text quality in video encoding
CN103700121A (en) * 2013-12-30 2014-04-02 Tcl集团股份有限公司 Method and device for compressing composite image
US20160328389A1 (en) * 2015-05-07 2016-11-10 Topcomics Co., Ltd System for supporting multiple languages in webtoons
CN107566842A (en) * 2017-08-31 2018-01-09 西安万像电子科技有限公司 The methods, devices and systems of image coding and decoding compression
CN108205676A (en) * 2017-11-22 2018-06-26 西安万像电子科技有限公司 The method and apparatus for extracting pictograph region
CN110505483A (en) * 2019-07-09 2019-11-26 西安万像电子科技有限公司 Image encoding method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LI, XIN ET AL.: "Block-based Segmentation and Adaptive Coding for Visually Lossless Compression of Scanned Documents", IEEE, vol. 3, no. 4,, 10 October 2001 (2001-10-10), XP010563380, DOI: 20200710083353A *
WU, JING ET AL.: "Block classification-based compression method for computer screen image", JOURNAL OF ZHEJIANG UNIVERSITY, ENGINEERING SCIENCE, vol. 43,, no. 4,, 30 April 2009 (2009-04-30), DOI: 20200710083245X *

Also Published As

Publication number Publication date
CN110505483A (en) 2019-11-26

Similar Documents

Publication Publication Date Title
JP4732660B2 (en) Visual attention system
Liu et al. Just noticeable difference for images with decomposition model for separating edge and textured regions
WO2016082277A1 (en) Video authentication method and apparatus
WO2021004126A1 (en) Image coding method and apparatus
CN103905812A (en) Texture/depth combination up-sampling method
WO2019037471A1 (en) Video processing method, video processing device and terminal
Wang et al. Perceptually quasi-lossless compression of screen content data via visibility modeling and deep forecasting
CN106686383A (en) Depth map intra-frame coding method capable of preserving edge of depth map
CN106331730A (en) Double-compression detection method by using quantification factor same as H.264 video
CN110460855B (en) Image processing method and system
US20200351518A1 (en) Prediction direction selection method and apparatus in image encoding, and storage medium
CN110930287B (en) Image steganography detection method and device, computer equipment and storage medium
CN110782501B (en) Image processing method and device
US20140184739A1 (en) Foreground extraction method for stereo video
EP2309452A1 (en) Method and arrangement for distance parameter calculation between images
CN112954355A (en) Image frame processing method and device
CN105847849A (en) Video frame detection method and device, video frame processing system and computer device
Farah et al. Full-reference and reduced-reference quality metrics based on SIFT
US7940996B2 (en) Image noise detection
KR101484531B1 (en) Method and system of panel area detection using sparse representation based on image segmentation
CN114926556B (en) Processing method of three-dimensional video point cloud picture
CN117115433B (en) Display abnormality detection method, device, equipment and storage medium
CN111654701B (en) Video coding preprocessing method, device, equipment and computer readable storage medium
CN111260533B (en) Image watermarking method and system for fusing texture rule features in image blocks and between blocks
JP4944966B2 (en) How to mark a digital image with a digital watermark

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20837245

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 20837245

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 20837245

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 08/09/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20837245

Country of ref document: EP

Kind code of ref document: A1