WO-2026091948-A1 - IMAGE ENCODING METHOD AND APPARATUS, IMAGE DECODING METHOD AND APPARATUS, DEVICE, STORAGE MEDIUM, AND PROGRAM PRODUCT
Abstract
The present application provides an image encoding method and apparatus, an image decoding method and apparatus, a device, a storage medium, and a program product; The image encoding method comprises: acquiring an image to be encoded; executing at least one image detection mode on the image on the basis of the priorities of multiple image detection modes to obtain an image detection result; respectively setting a quantization parameter for at least one macroblock in the image on the basis of the detection result; encoding each macroblock on the basis of the quantization parameter for each macroblock; and generating image encoding data of the image on the basis of macroblock encoding data obtained after encoding.
Inventors
- CHANG, QING
- CAO, Ruichen
- RAN, Lei
- HAN, Cunai
- WANG, YU
- HAO, Zhengliang
Assignees
- 腾讯科技(深圳)有限公司
Dates
- Publication Date
- 20260507
- Application Date
- 20250917
- Priority Date
- 20241030
Claims (20)
- An image encoding method, applied to an electronic device, the method comprising: Obtain the image to be encoded; Based on the priority of multiple image detection methods, at least one of the image detection methods is performed on the image to obtain the detection result of the image; Based on the detection results, quantization parameters are set for at least one macroblock in the image; Each macroblock is encoded based on the quantization parameters of each macroblock; Image encoded data of the image is generated based on the macroblock encoded data obtained after encoding.
- According to the method of claim 1, the plurality of image detection methods includes a first detection method and a second detection method, wherein the first detection method has a higher priority than the second detection method; The step of performing at least one of the image detection methods on the image according to the priority of multiple image detection methods to obtain the detection result of the image includes: The first detection method is performed on the image, and if a first region including a target object is detected from the image, a first detection result characterizing that the image includes the first region is generated; If the first region is not detected in the image or there are insufficient computing resources to perform the first detection method, the second detection method is performed on each macroblock in the image to obtain a second detection result.
- The method according to any one of claims 1 to 2, wherein performing the second detection method on each macroblock in the image to obtain a second detection result includes: Based on the proportion of pixels in multiple color intervals in the image, the target color interval corresponding to the second region of the target object is determined; The proportion of pixels belonging to the target color range in each macroblock is used as the probability that the macroblock includes the second region; A second detection result is generated based on the probability that each macroblock includes the second region.
- The method according to any one of claims 1 to 3, wherein determining the target color interval corresponding to the second region of the target object based on the proportion of pixels in multiple color intervals in the image, includes: In response to the fact that the proportion of pixels in the image belonging to a preset color range is within a preset pixel proportion range, the preset color range is used as the target color range to which the pixels of the second region of the target object belong; In response to the fact that the proportion of pixels in the image belonging to a preset color range is not within the preset pixel proportion range, a target color range is determined from multiple color ranges of the image, wherein the proportion of pixels in the target color range in the image is within the preset pixel proportion range, and the color difference between the preset color range and the target color range is less than a color difference threshold.
- The method according to any one of claims 1 to 4, wherein, after determining the target color region from the plurality of color regions of the image, the method further comprises: The preset color range is updated to the target color range, wherein the updated preset color range is used to perform the second detection method on the new image to be encoded.
- The method according to any one of claims 1 to 5, wherein, before performing the second detection method on each of the macroblocks in the image to obtain the second detection result, the method further comprises: For the multiple color intervals, determine the number of pixels in the image belonging to each color interval, wherein the multiple color intervals are obtained by dividing the color space; For each color range, the ratio of the number of pixels belonging to that color range to the total number of pixels in the image is taken as the proportion of pixels belonging to that color range in the image.
- The method according to any one of claims 1 to 6, wherein, When the target object is a living organism imaged in the image, the first region is the facial region of the living organism, and the second region is the skin region of the living organism; When the target object is an object imaged in the image, the first region is the main body region of the object, and the second region is a local region of the object.
- The method according to any one of claims 1 to 7, wherein performing the second detection method on each of the macroblocks in the image to obtain a second detection result includes: The flatness of each macroblock in the image is calculated. The proportion of pixels belonging to the target color range in each macroblock of the image is statistically analyzed, and the proportion is used as the probability that the macroblock includes the second region of the target object, wherein the target color range is the color value range of the second region of the target object; A second detection result is generated based on the flatness and probability of each macroblock.
- According to any one of claims 1 to 8, the multiple image detection methods include a first detection method and a second detection method, wherein the first detection method has a higher priority than the second detection method, and wherein performing the second detection method on each macroblock in the image to obtain a second detection result includes: The flatness of each macroblock in the image is calculated, and a second detection result is generated based on the flatness of each macroblock.
- The method according to any one of claims 1 to 9, wherein the step of statistically analyzing the flatness of each macroblock in the image comprises: For each of the macroblocks, the following processing is performed: The macroblock is converted to grayscale to obtain the grayscale value of each pixel in the macroblock; The average gray value of the macroblock is determined based on the gray value of each pixel. The gray-level variance of the macroblock is determined based on the gray-level mean, and is used as the flatness of the macroblock.
- The method according to any one of claims 1 to 10, wherein performing the first detection method on the image includes: A pre-trained detection model is invoked to perform keypoint detection on the image, and keypoint detection results are obtained, wherein the keypoint detection results include bounding boxes and keypoints; In response to the number of key points being a preset number of key points, the region corresponding to the bounding box is taken as the first region of the target object, and a first detection result is generated in which the image includes the first region, wherein the preset number of key points is used to determine the minimum number of the image including the first region.
- The method according to any one of claims 1 to 11, wherein, when the detection result is a first detection result, and the first detection result characterizes the image as including a first region of the target object, setting quantization parameters for at least one macroblock in the image according to the detection result includes: Identify macroblocks that at least partially overlap with the first region; A first quantization parameter is set for macroblocks that intersect with the first region, and a second quantization parameter is set for macroblocks that do not intersect with the first region, wherein the first quantization parameter is smaller than the second quantization parameter.
- The method according to any one of claims 1 to 12, wherein, when the detection result is a second detection result, and the second detection result characterizes the flatness of each macroblock and the probability that the macroblock includes a second region of a target object, the step of setting quantization parameters for at least one macroblock in the image based on the detection result includes: For each of the macroblocks, the following processing is performed: Determine the target flatness level of the macroblock among a set of preset flatness levels; Determine the target probability level among a preset plurality of probability levels in which the probability that the macroblock includes the second region; Based on the target flatness level and the target probability level, a quantization parameter table is queried to obtain a preset quantization parameter associated with the target flatness level and the target probability level, which is used as the quantization parameter of the macroblock. The quantization parameter table includes the mapping relationship between the plurality of flatness levels, the plurality of probability levels and the plurality of preset quantization parameters, and the preset quantization parameter is negatively correlated with the target flatness level and the probability level.
- The method according to any one of claims 1 to 13, wherein, when the detection result is a second detection result, and the second detection result characterizes the probability that each macroblock includes a second region of the target object, the step of setting quantization parameters for at least one macroblock in the image according to the detection result includes: For each of the macroblocks, the following processing is performed: The quantization parameters of the macroblock are generated based on the probability that the macroblock includes the second region of the target object, wherein the probability that the macroblock includes the second region is negatively correlated with the quantization parameters of the macroblock.
- The method according to any one of claims 1 to 14, wherein, when the detection result is a second detection result, and the second detection result characterizes the flatness of each macroblock, setting quantization parameters for at least one macroblock in the image based on the detection result includes: For each of the macroblocks, the following processing is performed: The quantization parameters of the macroblock are generated based on the flatness of the macroblock, wherein the flatness of the macroblock is negatively correlated with the quantization parameters of the macroblock.
- The method according to any one of claims 1 to 15, wherein, after setting quantization parameters for at least one macroblock in the image based on the detection result, the method further comprises: For each of the macroblocks, the following processing is performed: Determine the amount of change in the quantization parameter of the macroblock relative to a reference quantization coefficient, wherein the reference quantization coefficient is the quantization coefficient of a macroblock in the encoded image that is at the same position as the macroblock; The product of the change value and the adjustment coefficient is determined, and the quantization parameters of the macroblock are updated based on the sum of the product and the reference quantization coefficient, wherein the adjustment coefficient is positively correlated with the number of times the second region appears consecutively at the position of the macroblock.
- The method according to any one of claims 1 to 16, wherein acquiring the image to be encoded comprises: Obtain the uncompressed raw image; The original image can be used as the image to be encoded, or the original image can be downsampled and the resulting downsampled image can be used as the image to be encoded.
- An image encoding method, applied to an electronic device, the method comprising: Obtain the image to be encoded; Based on the proportion of pixels in multiple color intervals in the image, the target color interval corresponding to the target area of the target object is determined. The proportion of pixels belonging to the target color range in each macroblock of the image is used as the probability that each macroblock includes the target region of the target object; Based on the probability that each macroblock includes the target region, quantization parameters are set for at least one macroblock; Each macroblock is encoded based on the quantization parameters of each macroblock; Image encoded data of the image is generated based on the macroblock encoded data obtained after encoding.
- According to the method of claim 18, the step of determining the target color interval corresponding to the target region of the target object based on the proportion of pixels in multiple color intervals in the image includes: In response to the fact that the proportion of pixels in the image belonging to a preset color range is within a preset pixel proportion range, the preset color range is taken as the target color range to which the target region of the target object in the image belongs. In response to the fact that the proportion of pixels in the image belonging to a preset color range is not within the preset pixel proportion range, a target color range is determined from multiple color ranges of the image, wherein the proportion of pixels in the target color range in the image is within the preset pixel proportion range, and the color difference between the preset color range and the target color range is less than a color difference threshold.
- The method according to any one of claims 18 to 19, wherein setting quantization parameters for at least one macroblock based on the probability that each macroblock includes the target region, comprises: For each of the macroblocks, the following processing is performed: The quantization parameters of the macroblock are generated based on the probability that the macroblock includes the target region, wherein the probability that the macroblock includes the target region is negatively correlated with the quantization parameters of the macroblock.
Description
Image encoding methods, image decoding methods, devices, equipment, storage media, and software products Cross-reference of related applications This application is based on and claims priority to Chinese Patent Application No. 2024115374006, filed on October 30, 2024, the entire contents of which are incorporated herein by reference. Technical Field This application relates to the field of computer graphics, and more particularly to an image encoding method, an image decoding method, an apparatus, a device, a storage medium, and a program product. Background Technology As streaming services continue to proliferate, users are demanding higher and higher video clarity. However, maintaining the clarity of live images at high resolution requires a high encoding bitrate. Insufficient bandwidth can easily lead to buffering during viewing and also puts enormous bandwidth cost pressure on streaming service platforms. Related technologies address these issues by replacing the encoding standard with a more advanced one, such as upgrading from H.264 to H.265 or H.266. However, more advanced encoding standards have lower hardware compatibility, increasing the difficulty of promotion and leading to greater computational power consumption, making it difficult to achieve the same image encoding effect at lower encoding bitrates. Summary of the Invention This application provides an image encoding method, an image decoding method, an apparatus, a device, a storage medium, and a program product, which can achieve more precise encoding control. The technical solution of this application embodiment is implemented as follows: This application provides an image encoding method applied to an electronic device, the method comprising: Obtain the image to be encoded; Based on the priority of multiple image detection methods, at least one of the image detection methods is performed on the image to obtain the detection result of the image; Based on the detection results, quantization parameters are set for at least one macroblock in the image; Each macroblock is encoded based on the quantization parameters of each macroblock; Image encoded data of the image is generated based on the macroblock encoded data obtained after encoding. This application provides an image decoding method applied to an electronic device, the method comprising: Receive image encoded data, wherein the image encoded data is obtained through the image encoding method provided in the embodiments of this application; Based on the quantization parameters of each macroblock, the encoded data of each macroblock is decoded to obtain the macroblock decoded data of each macroblock; The macroblock decoding data of each macroblock is combined into a decoded image. This application provides an image encoding method applied to an electronic device, the method comprising: Obtain the image to be encoded; Based on the proportion of pixels in multiple color intervals in the image, the target color interval corresponding to the target area of the target object is determined. The proportion of pixels belonging to the target color range in each macroblock of the image is used as the probability that each macroblock includes the target region of the target object; Based on the probability that each macroblock includes the target region, quantization parameters are set for at least one macroblock; Each macroblock is encoded based on the quantization parameters of each macroblock; Image encoded data of the image is generated based on the macroblock encoded data obtained after encoding. This application provides an image decoding method applied to an electronic device, the method comprising: Receive image encoded data, wherein the image encoded data is obtained through the image encoding method provided in the embodiments of this application; Based on the quantization parameters of each macroblock, the encoded data of each macroblock is decoded to obtain the macroblock decoded data of each macroblock; The macroblock decoding data of each macroblock is combined into a decoded image. This application provides an image encoding device, including: The data acquisition module is configured to acquire the image to be encoded. The encoding module is configured to perform at least one of the image detection methods on the image according to the priority of multiple image detection methods, so as to obtain the detection result of the image; The encoding module is further configured to set quantization parameters for at least one macroblock in the image based on the detection results; The encoding module is further configured to encode each macroblock based on the quantization parameters of each macroblock; The encoding module is further configured to generate image encoding data of the image based on the macroblock encoding data obtained after encoding. This application provides an image decoding device, including: The data acquisition module is configured to receive image encoded data, where