An image encoding method, apparatus, computer device, and storage medium

By classifying images and converting formats, selecting the appropriate encoding format for encoding, the problem of reduced picture quality or excessive encoder capability requirements during YUV444 format image encoding is solved, and high-quality encoding and cost reduction is achieved.

CN117729336BActive Publication Date: 2025-06-24XIAOHONGSHU TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310836763.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-07
Publication Date
2025-06-24
Estimated Expiration
2043-07-07

AI Technical Summary

Technical Problem

During image processing, when encoding and compression of YUV444 format images, the prior art may easily lead to a decrease in picture quality or excessive requirements for encoder capabilities, making it difficult to meet the high picture quality requirements of different images.

Method used

By acquiring the image to be processed, decoding the target image, and classifying and processing it according to its content information, determining the image category will be performed for format conversion, and selecting an appropriate encoding format (such as YUV444 or YUV420) for encoding processing.

Benefits of technology

The encoded image quality is improved, and the user's high image quality requirements for different images are met, while reducing image encoding and storage costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117729336B_ABST
    Figure CN117729336B_ABST
Patent Text Reader

Abstract

An embodiment of the present application discloses an image encoding method, apparatus, computer device, and storage medium. The method includes: obtaining an image to be processed, decoding the image to be processed to obtain a target image; obtaining content information of the target image, and classifying the target image according to the content information of the target image to obtain a category of the target image; determining a format corresponding to the category of the target image according to the category of the target image, and performing format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded; and encoding the image to be encoded to obtain an encoded image. In this way, the quality of the encoded image can be improved to meet the high picture quality requirements of users for different images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technologies, and in particular, to an image encoding method, apparatus, computer device, and storage medium. Background Art

[0002] Currently, when publishing graphic and text note content in many applications, problems such as blurred images and color deviations are likely to occur. Among them, for a large part of YUV444 format images, when the image processing server encodes and compresses such images, there are usually two different processing strategies. One is to directly convert the YUV444 format to the YUV420 (Y'CbCr4:2:0) format for re-encoding, and the other is to continue to maintain the YUV444 format for re-encoding. Among them, the former can save the file size to a certain extent during the YUV format conversion, but at the same time, it will also cause a reduction in the image quality in some scenarios (such as pictures with rich colors and many edge lines in text); while the latter has higher requirements for the encoder's ability during re-encoding and must be able to support compressing the input YUV444 format. Therefore, how to better encode YUV444 format pictures is very important. Summary of the Invention

[0003] Embodiments of this application provide an image encoding method, apparatus, computer device, and storage medium, which can improve the quality of the encoded image and meet the high image quality requirements of users for different images.

[0004] In a first aspect, embodiments of this application provide an image encoding method, including:

[0005] Obtain an image to be processed, and decode the image to be processed to obtain a target image;

[0006] Obtain the content information of the target image, and classify the target image according to the content information of the target image to obtain the category of the target image;

[0007] Determine the format corresponding to the category of the target image according to the category of the target image, and perform format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded;

[0008] Perform encoding processing on the image to be encoded to obtain an encoded image.

[0009] In a second aspect, embodiments of this application provide an image encoding apparatus, including:

[0010] An obtaining unit, configured to obtain an image to be processed, and decode the image to be processed to obtain a target image;

[0011] A classification unit for obtaining content information of the target image and classifying the target image based on the content information of the target image to obtain the category of the target image;

[0012] A determination unit for determining a format corresponding to the category of the target image according to the category of the target image, and performing format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded;

[0013] An encoding unit for encoding the image to be encoded to obtain an encoded image.

[0014] In a third aspect, an embodiment of the present application provides a computer device, which includes a processor and a memory, and the processor is used to execute the method described in the first aspect above.

[0015] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, in which program instructions are stored, and when the program instructions are executed, the method described in the first aspect above is implemented.

[0016] In the embodiment of the present application, by obtaining an image to be processed, decoding the image to be processed to obtain a target image; obtaining content information of the target image, and classifying the target image based on the content information of the target image to obtain the category of the target image; determining a format corresponding to the category of the target image according to the category of the target image, and performing format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded; encoding the image to be encoded to obtain an encoded image, so as to improve the quality of the encoded image and meet the high picture quality requirements of users for different images. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0018] Figure 1 is a flowchart of an image encoding method provided by an embodiment of the present application;

[0019] Figure 2 is a distribution diagram of pixel positions provided by an embodiment of the present application;

[0020] Figure 3 is a flowchart of another image encoding method provided by an embodiment of the present application;

[0021] Figure 4 It is a schematic structural diagram of an image encoding device provided by an embodiment of the present application;

[0022] Figure 5 It is a schematic structural diagram of a computer device provided by an embodiment of the present application. Specific embodiments

[0023] Next, the technical solutions in the embodiments of the present application will be clearly described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0024] The present application proposes an image encoding scheme. By obtaining an image to be processed, decoding the image to be processed to obtain a target image; obtaining content information of the target image, and classifying the target image according to the content information of the target image to obtain the category of the target image; determining a format corresponding to the category of the target image according to the category of the target image, and performing format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded; and performing encoding processing on the image to be encoded to obtain an encoded image.

[0025] Furthermore, the present application divides the target image into blocks, and converts the target image into a corresponding format for encoding according to the number of blocks in the target image whose color values meet the preset conditions and the degree of change of the pixels of the image, realizing maintaining the YUV444 format in scenarios with high picture quality requirements, and encoding in the YUV420 format in scenarios with low picture quality requirements. This can not only improve the quality of the encoded image and meet the high picture quality requirements of users for different images, but also reduce the image encoding and storage costs.

[0026] An image encoding method provided by the present application can be applied to any scenario where images need to be encoded.

[0027] The image encoding method provided in the embodiments of the present application can be applied to an image encoding device. The image encoding device can be set in a computer device. In some embodiments, the computer device can be a server, and the server includes but is not limited to a Linux server. The computer device can include but is not limited to intelligent terminal devices such as smart phones, tablet computers, laptop computers, desktop computers, in-vehicle intelligent terminals, and smart watches.

[0028] Next, the image encoding method provided by the embodiments of the present application will be schematically described in conjunction with the accompanying drawings.

[0029] Specifically, please refer to Figure 1 ,Figure 1 It is a schematic flowchart of an image encoding method provided by an embodiment of the present application. The image encoding method of the embodiment of the present application can be executed by an image encoding device, and the image encoding device can be set in a computer device.

[0030] S101: Obtain an image to be processed, and decode the image to be processed to obtain a target image.

[0031] In the embodiment of the present application, the computer device can obtain an image to be processed and decode the image to be processed to obtain a target image. Among them, the image to be processed can be a true-color picture in YUV444 format uploaded by the user, and the target image can be a picture in YUV444 / RGB format.

[0032] S102: Obtain the content information of the target image, and classify the target image according to the content information of the target image to obtain the category of the target image.

[0033] In the embodiment of the present application, the computer device can obtain the content information of the target image, and classify the target image according to the content information of the target image to obtain the category of the target image. Among them, the content information of the target image includes, but is not limited to, one or more of resolution, color information, brightness information, etc.

[0034] In one embodiment, when the computer device classifies the target image according to the content information of the target image to obtain the category of the target image, it can obtain the resolution, color information, and brightness information of the target image; classify the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image.

[0035] In an alternative implementation, when the computer device classifies the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image, it can, when the resolution of the target image is greater than the resolution threshold, perform scaling processing on the target image according to the scaling rule, and classify the scaled image according to the resolution, color information, and brightness information of the scaled image to obtain the category of the target image. In some embodiments, the scaling rule can be a custom rule, such as reducing the target image according to a preset ratio, and the preset ratio can be a custom ratio value.

[0036] For example, assuming that the resolution WxH of the target image is greater than the resolution threshold 1920x1080, the computer device can reduce the width and height of the target image by 1 / 2 to obtain a scaled image.

[0037] In an alternative embodiment, when the computer device classifies the target image based on the resolution, color information, and brightness information of the target image to obtain the category of the target image, it may obtain the resolution of the target image, and when the resolution of the target image is less than or equal to the resolution threshold, classify the target image based on the resolution, color information, and brightness information of the target image to obtain the category of the target image.

[0038] In one embodiment, when the computer device classifies the target image based on the resolution, color information, and brightness information of the target image to obtain the category of the target image, it may divide the target image into blocks according to a block division rule to obtain a plurality of sub-blocks; obtain the number of sub-blocks in the target image whose color information meets a preset condition; and classify the target image based on the number of sub-blocks whose color information meets the preset condition, the resolution of the target image, and the brightness information of the target image. In some embodiments, the block division rule may be a custom rule.

[0039] For example, when the computer device divides the target image into blocks according to the block division rule to obtain a plurality of sub-blocks, it may divide the target image into blocks of 16x16 pixels to obtain a plurality of sub-blocks.

[0040] In one embodiment, when the computer device obtains the number of sub-blocks in the target image whose color information meets a preset condition, it may obtain the color value of each sub-block in the plurality of sub-blocks and count the number of times each color value appears in the corresponding sub-block; when the number of times is less than the number threshold, determine that the number of sub-blocks in the target image whose color information meets the preset condition is incremented by 1; when the number of times is greater than or equal to the number threshold, determine that the number of sub-blocks in the target image whose color information does not meet the preset condition remains unchanged. Wherein, the initial value of the number of sub-blocks in the target image whose color information meets the preset condition is 0.

[0041] In one embodiment, the number of sub-blocks whose color information meets the preset condition may be represented by a quantity identifier, and the initial value of the quantity identifier is 0. The computer device may determine to increment the quantity identifier when it determines that the number of times each color value appears in the corresponding sub-block is less than the number threshold, and determine to keep the quantity identifier unchanged when it determines that the number of times each color value appears in the corresponding sub-block is greater than or equal to the number threshold. In some embodiments, the quantity identifier may include, but is not limited to, one or more characters among letters, words, and numbers.

[0042] In one embodiment, when the computer device classifies a target image based on the number of sub-blocks whose color information meets a preset condition, the resolution of the target image, and the brightness information of the target image, it can calculate the ratio of the sub-blocks whose color information meets the preset condition to all sub-blocks based on the number of sub-blocks whose color information meets the preset condition and the brightness information of the target image; when the ratio is greater than the ratio threshold, determine the category of the target image based on the resolution of the target image and the brightness information of the target image.

[0043] Further, when the computer device calculates the ratio of the sub-blocks whose color information meets the preset condition to all sub-blocks based on the number of sub-blocks whose color information meets the preset condition and the brightness information of the target image, it can be calculated according to the following formula (1).

[0044]

[0045] Among them, count is used to indicate the number of sub-blocks whose color information meets the preset condition, WxH is the resolution of the target image, and 16x16 is the pixel of 16x16 (blocking rule).

[0046] In one embodiment, when the computer device determines the category of the target image based on the resolution of the target image and the brightness information of the target image, it can calculate the average spatial activity of the target image based on the resolution of the target image and the brightness information of the target image, and the average spatial activity is used to indicate the degree of change of the target image pixel values; when the average spatial activity of the target image is greater than the preset threshold, determine that the target image belongs to the first category; when the average spatial activity of the target image is less than or equal to the preset threshold, determine that the target image belongs to the second category.

[0047] Further, before the computer device calculates the average spatial activity of the target image based on the resolution of the target image and the brightness information of the target image, it can detect whether the number of sub-blocks whose color information meets the preset condition meets the specified condition. If the detection result is that the number of sub-blocks whose color information meets the preset condition meets the specified condition, then execute the step of calculating the average spatial activity of the target image based on the resolution of the target image and the brightness information of the target image. Among them, when the number of sub-blocks whose color information meets the preset condition count meets the following formula (2), it is determined that the number of sub-blocks whose color information meets the preset condition meets the specified condition.

[0048]

[0049] Among them, count is used to indicate the number of sub-blocks whose color information meets the preset condition, WxH is the resolution of the target image, 16x16 is the pixel of 16x16 (blocking rule), and TH2 is the specified threshold.

[0050] In one embodiment, when calculating the average spatial activity of the target image based on the resolution of the target image and the brightness information of the target image, the computer device can calculate it according to the following formula (3).

[0051]

[0052] Wherein,

[0053] A ij = α × A1 ij +(1 - α)A2 ij ,

[0054]

[0055]

[0056] Wherein, W and H are the width and height of the resolution of the target picture, α is a weight coefficient, and exemplarily α can be taken as 0.5. Wherein Aij represents the spatial activity of the pixel at the position (i, j) in the current target picture, A1ij and A2ij represent the pixel spatial activities calculated from different directions, and P(i, j) represents the luminance pixel value of the pixel position (i, j). Specifically, it can Figure 2 be illustrated by an example. Figure 2 is a schematic diagram of the distribution of a pixel position provided by an embodiment of the present application. As Figure 2 shown, it is the relationship between the pixel point (i, j) and its surrounding 8 adjacent pixel positions. If a certain adjacent pixel does not exist when calculating the activity, the pixel value is recorded as 0 at this time.

[0057] By calculating the average spatial activity of the target image, the embodiment of the present application can determine the relationship between the brightness of each position in the target image and the brightness of the surrounding positions of each position, so as to facilitate determining the degree of change in the brightness of the target image.

[0058] S103: Determine the format corresponding to the category of the target image according to the category of the target image, and perform format conversion on the target image according to the determined format corresponding to the category of the target image to obtain the image to be encoded.

[0059] In the embodiment of the present application, the computer device can determine the format corresponding to the category of the target image according to the category of the target image, and perform format conversion on the target image according to the determined format corresponding to the category of the target image to obtain the image to be encoded.

[0060] In one embodiment, when the computer device determines that the target image belongs to the first category, it can determine that the format corresponding to the first category is the YUV444 format, and perform format conversion on the target image according to the YUV444 format to obtain the image to be encoded.

[0061] In one embodiment, when the computer device determines that the target image belongs to the second category, it can determine that the format corresponding to the second category is the YUV420 format, and perform format conversion on the target image according to the YUV444 format to obtain the image to be encoded.

[0062] Embodiments of the present application can distinguish the first category that needs to maintain the original image format (i.e., the YUV444 format) and the second category of images that can perform color downsampling (using the YUV420 format) through the pixel information of the image and the average spatial activity of the pixels, which helps to further improve the image quality of images with different color pixels on the basis of ensuring the image quality.

[0063] S104: Perform encoding processing on the image to be encoded to obtain an encoded image.

[0064] In embodiments of the present application, the computer device can perform encoding processing on the image to be encoded to obtain an encoded image. Among them, if the target image is of the first category, the picture encoder for performing encoding processing on the image to be encoded can be JPEG, HEIF, AVIF, etc. If it is of the second category, the picture encoder can be JPEG, WebP, HEIF, AVIF, etc.

[0065] Embodiments of the present application obtain a to-be-processed image, decode the to-be-processed image to obtain a target image; obtain the content information of the target image, and perform classification processing on the target image according to the content information of the target image to obtain the category of the target image; determine the format corresponding to the category of the target image according to the category of the target image, and perform format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded; perform encoding processing on the image to be encoded to obtain an encoded image, so as to improve the quality of the encoded image and meet the high image quality requirements of users for different images.

[0066] For details, please refer to Figure 3 , Figure 3 which is a schematic flowchart of another image encoding method provided by embodiments of the present application. The image encoding method of embodiments of the present application can be executed by an image encoding device, where the image encoding device is disposed in a computer device, and the specific explanation of the computer device is as described above. Specifically, the method of embodiments of the present application includes the following steps.

[0067] S301: Obtain a to-be-processed image in YUV44 format, and decode the to-be-processed image in YUV44 format to obtain a target image in YUV44 / RGB format.

[0068] In an embodiment of the present application, a computer device may obtain a to-be-processed image in YUV44 format, and decode the to-be-processed image in YUV44 format to obtain a target image in YUV44 / RGB format.

[0069] S302: Classify the target image in YUV44 / RGB format to obtain the category of the target image, where the category includes a first category or a second category.

[0070] In an embodiment of the present application, a computer device may classify the target image in YUV44 / RGB format to obtain the category of the target image, where the category includes a first category or a second category. Optionally, the computer device may obtain the content information of the target image, and classify the target image according to the content information of the target image to obtain the category of the target image.

[0071] S303: When it is determined that the target image belongs to the first category, determine to convert the target image into an image in YUV444 format, and perform encoding processing on the converted image in YUV444 format to obtain an encoded image in YUV444 format.

[0072] In an embodiment of the present application, a computer device may, when it is determined that the target image belongs to the first category, determine to convert the target image into an image in YUV444 format, and perform encoding processing on the converted image in YUV444 format to obtain an encoded image in YUV444 format.

[0073] In an embodiment of the present application, by maintaining the YUV444 format of the image in a scenario with high image quality requirements, it helps to improve the quality of the encoded image.

[0074] S304: When it is determined that the target image belongs to the second category, determine to convert the target image into an image in YUV420 format, and perform encoding processing on the converted image in YUV420 format to obtain an encoded image in YUV420 format.

[0075] In an embodiment of the present application, a computer device may, when it is determined that the target image belongs to the second category, determine to convert the target image into an image in YUV420 format, and perform encoding processing on the converted image in YUV420 format to obtain an encoded image in YUV420 format.

[0076] In an embodiment of the present application, by maintaining the YUV420 format of the image in a scenario with low image quality requirements, it helps to improve the quality of the encoded image.

[0077] In the embodiments of the present application, for a to-be-processed image in YUV444 format uploaded by a user, different encoding strategies are adopted for adaptive encoding processing of the to-be-processed image according to the content information of the to-be-processed image, that is, the YUV444 format is maintained in scenarios with high image quality requirements, and encoding is performed in YUV420 format in scenarios with low image quality requirements. This can not only ensure the image quality after encoding and meet the high image quality requirements of users for graphic notes, but also further compress the size of the image during the image encoding process, reducing the image transcoding and storage costs.

[0078] Please refer to Figure 4 , Figure 4 FIG. is a schematic structural diagram of an image encoding device provided by an embodiment of the present application. Specifically, the device is disposed in a computer device, and the device includes: an acquisition unit 401, a classification unit 402, a determination unit 403, and an encoding unit 404;

[0079] The acquisition unit 401 is configured to acquire a to-be-processed image and decode the to-be-processed image to obtain a target image;

[0080] The classification unit 402 is configured to acquire the content information of the target image and perform classification processing on the target image according to the content information of the target image to obtain the category of the target image;

[0081] The determination unit 403 is configured to determine the format corresponding to the category of the target image according to the category of the target image, and perform format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded;

[0082] The encoding unit 404 is configured to perform encoding processing on the image to be encoded to obtain an encoded image.

[0083] Further, when the classification unit 402 performs classification processing on the target image according to the content information of the target image to obtain the category of the target image, it is specifically configured to:

[0084] Acquire the resolution, color information, and brightness information of the target image;

[0085] Classify the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image.

[0086] Further, when the classification unit 402 classifies the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image, it is specifically configured to:

[0087] In the case where the resolution of the target image is greater than the resolution threshold, scale the target image according to the scaling rule, and classify the scaled image based on the resolution, color information, and brightness information of the scaled target image to obtain the category of the target image;

[0088] In the case where the resolution of the target image is less than or equal to the resolution threshold, classify the target image based on the resolution, color information, and brightness information of the target image to obtain the category of the target image.

[0089] Further, when the classification unit 402 classifies the target image based on the resolution, color information, and brightness information of the target image to obtain the category of the target image, it specifically is used for:

[0090] Divide the target image into blocks according to the block division rule to obtain a plurality of sub-blocks;

[0091] Obtain the number of sub-blocks in the target image whose color information meets the preset condition;

[0092] Classify the target image based on the number of sub-blocks whose color information meets the preset condition, the resolution of the target image, and the brightness information of the target image.

[0093] Further, when the classification unit 402 obtains the number of sub-blocks in the target image whose color information meets the preset condition, it specifically is used for:

[0094] Obtain the color value of each sub-block in the plurality of sub-blocks, and count the number of times each color value appears in the corresponding sub-block;

[0095] When the number of times is less than the number-of-times threshold, determine that the number of sub-blocks in the target image whose color information meets the preset condition is incremented by 1;

[0096] When the number of times is greater than or equal to the number-of-times threshold, determine that the number of sub-blocks in the target image whose color information does not meet the preset condition remains unchanged.

[0097] Further, when the classification unit 402 classifies the target image based on the number of sub-blocks whose color information meets the preset condition, the resolution of the target image, and the brightness information of the target image, it specifically is used for:

[0098] Calculate the ratio of the sub-blocks whose color information meets the preset condition to all sub-blocks based on the number of sub-blocks whose color information meets the preset condition and the brightness information of the target image;

[0099] When the ratio is greater than the ratio threshold, determine the category of the target image based on the resolution of the target image and the brightness information of the target image.

[0100] Further, when the classification unit 402 determines the category of the target image according to the resolution of the target image and the brightness information of the target image, it specifically is used for:

[0101] Calculating the average spatial activity of the target image according to the resolution of the target image and the brightness information of the target image, where the average spatial activity is used to indicate the degree of change of the pixel values of the target image;

[0102] When the average spatial activity of the target image is greater than a preset threshold, determining that the target image belongs to the first category;

[0103] When the average spatial activity of the target image is less than or equal to the preset threshold, determining that the target image belongs to the second category;

[0104] When the determination unit 403 determines the format corresponding to the category of the target image according to the category of the target image, it specifically is used for:

[0105] In the case of determining that the target image belongs to the first category, determining that the format corresponding to the first category is the YUV444 format;

[0106] In the case of determining that the target image belongs to the second category, determining that the format corresponding to the second category is the YUV420 format.

[0107] In the embodiments of the present application, by obtaining an image to be processed, decoding the image to be processed to obtain a target image; obtaining the content information of the target image, and classifying the target image according to the content information of the target image to obtain the category of the target image; determining the format corresponding to the category of the target image according to the category of the target image, and performing format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded; and encoding the image to be encoded to obtain an encoded image, so as to improve the quality of the encoded image and meet the high image quality requirements of users for different images.

[0108] Please refer to Figure 5 , Figure 5 which is a schematic structural diagram of a computer device provided by an embodiment of the present application. Specifically, the computer device includes: a memory 501 and a processor 502.

[0109] In one embodiment, the computer device further includes a data interface 503, and the data interface 503 is used to transfer data information between the computer device and other devices.

[0110] The memory 501 may include a volatile memory; the memory 501 may also include a non-volatile memory; the memory 501 may further include a combination of the above types of memories. The processor 502 may be a central processing unit (CPU). The processor 502 may further include a hardware chip. The above hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The above PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), or any combination thereof.

[0111] The memory 501 is used to store a program, and the processor 502 may call the program stored in the memory 501 to perform the following steps:

[0112] Obtain an image to be processed, and decode the image to be processed to obtain a target image;

[0113] Obtain the content information of the target image, and classify the target image according to the content information of the target image to obtain the category of the target image;

[0114] Determine a format corresponding to the category of the target image according to the category of the target image, and perform format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded;

[0115] Perform encoding processing on the image to be encoded to obtain an encoded image.

[0116] Further, when the processor 502 classifies the target image according to the content information of the target image to obtain the category of the target image, it is specifically used for:

[0117] Obtain the resolution, color information, and brightness information of the target image;

[0118] Classify the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image.

[0119] Further, when the processor 502 classifies the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image, it is specifically configured to:

[0120] In the case where the resolution of the target image is greater than the resolution threshold, perform a scaling process on the target image according to the scaling rule, and classify the scaled image according to the resolution, color information, and brightness information of the scaled target image to obtain the category of the target image;

[0121] In the case where the resolution of the target image is less than or equal to the resolution threshold, classify the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image.

[0122] Further, when the processor 502 classifies the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image, it is specifically configured to:

[0123] Divide the target image into blocks according to the block division rule to obtain a plurality of sub-blocks;

[0124] Obtain the number of sub-blocks in the target image whose color information meets the preset conditions;

[0125] Classify the target image according to the number of sub-blocks whose color information meets the preset conditions, the resolution of the target image, and the brightness information of the target image.

[0126] Further, when the processor 502 obtains the number of sub-blocks in the target image whose color information meets the preset conditions, it is specifically configured to:

[0127] Obtain the color value of each sub-block in the plurality of sub-blocks, and count the number of times each color value appears in the corresponding sub-block;

[0128] When the number of times is less than the number threshold, determine that the number of sub-blocks in the target image whose color information meets the preset conditions is incremented by 1;

[0129] When the number of times is greater than or equal to the number threshold, determine that the number of sub-blocks in the target image whose color information does not meet the preset conditions remains unchanged.

[0130] Further, when the processor 502 classifies the target image according to the number of sub-blocks whose color information meets the preset conditions, the resolution of the target image, and the brightness information of the target image, it is specifically configured to:

[0131] Calculate the ratio of the number of sub - blocks whose color information meets the preset conditions to all sub - blocks according to the number of sub - blocks whose color information meets the preset conditions and the brightness information of the target image;

[0132] When the ratio is greater than the ratio threshold, determine the category of the target image according to the resolution of the target image and the brightness information of the target image.

[0133] Further, when the processor 502 determines the category of the target image according to the resolution of the target image and the brightness information of the target image, it specifically is used for:

[0134] Calculate the average spatial activity of the target image according to the resolution of the target image and the brightness information of the target image, and the average spatial activity is used to indicate the degree of change of the pixel values of the target image;

[0135] When the average spatial activity of the target image is greater than the preset threshold, determine that the target image belongs to the first category;

[0136] When the average spatial activity of the target image is less than or equal to the preset threshold, determine that the target image belongs to the second category;

[0137] When the processor 502 determines the format corresponding to the category of the target image according to the category of the target image, it specifically is used for:

[0138] In the case of determining that the target image belongs to the first category, determine that the format corresponding to the first category is the YUV444 format;

[0139] In the case of determining that the target image belongs to the second category, determine that the format corresponding to the second category is the YUV420 format.

[0140] In the embodiment of the present application, by obtaining the image to be processed, decoding the image to be processed to obtain the target image; obtaining the content information of the target image, and classifying the target image according to the content information of the target image to obtain the category of the target image; determining the format corresponding to the category of the target image according to the category of the target image, and performing format conversion on the target image according to the determined format corresponding to the category of the target image to obtain the image to be encoded; encoding the image to be encoded to obtain the encoded image, so as to improve the quality of the encoded image and meet the high - picture - quality requirements of users for different images.

[0141] The embodiment of the present application also provides a computer - readable storage medium, the computer - readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the present application Figure 1 or Figure 3 the method described in the corresponding embodiment, and can also implementFigure 4 The device corresponding to the embodiment of the present application will not be elaborated here.

[0142] The computer-readable storage medium may be an internal storage unit of the device described in any of the foregoing embodiments, such as the hard disk or memory of the device. The computer-readable storage medium may also be an external storage device of the device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a Flash Card, etc. equipped on the device. Further, the computer-readable storage medium may also include both the internal storage unit and the external storage device of the device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.

[0143] An embodiment of the present application also provides a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the above various embodiments.

[0144] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it may include the processes of the embodiments of the above various methods. Among them, the storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM), etc.

[0145] Only some of the embodiments of the present application are disclosed above. Of course, the scope of rights of the present application cannot be limited by this. Those of ordinary skill in the art can understand all or part of the processes of the above embodiments, and the equivalent changes made according to the claims of the present application still fall within the scope covered by the present invention.

Claims

1. An image encoding method, characterized in that, Including: Obtain an image to be processed, and decode the image to be processed to obtain a target image; Obtain the resolution, color information, and brightness information of the target image, and classify the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image, including: dividing the target image into blocks according to a block division rule to obtain a plurality of sub-blocks, obtaining the number of sub-blocks in the target image whose color information meets a preset condition, calculating the ratio of the sub-blocks whose color information meets the preset condition to all sub-blocks according to the number of sub-blocks whose color information meets the preset condition and the brightness information of the target image, when the ratio is greater than a ratio threshold, calculate the average spatial activity of the target image according to the resolution of the target image and the brightness information of the target image, the average spatial activity is used to indicate the degree of change of the pixel values of the target image, when the average spatial activity of the target image is greater than a preset threshold, determine that the target image belongs to the first category, and when the average spatial activity of the target image is less than or equal to the preset threshold, determine that the target image belongs to the second category; Determine a format corresponding to the category of the target image according to the category of the target image, and perform format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded; Perform encoding processing on the image to be encoded to obtain an encoded image.

2. The method according to claim 1, wherein The classifying the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image includes: In the case where the resolution of the target image is greater than a resolution threshold, perform scaling processing on the target image according to a scaling rule, and classify the scaled image according to the resolution, color information, and brightness information of the scaled target image to obtain the category of the target image; In the case where the resolution of the target image is less than or equal to the resolution threshold, classify the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image.

3. The method according to claim 1, wherein The obtaining the number of sub-blocks in the target image whose color information meets a preset condition includes: Obtain the color value of each sub-block in the plurality of sub-blocks, and count the number of times each color value appears in the corresponding sub-block; When the number of times is less than a number threshold, determine that the number of sub-blocks in the target image whose color information meets the preset condition is incremented by 1; When the number of times is greater than or equal to the number threshold, determine that the number of sub-blocks in the target image whose color information does not meet the preset condition remains unchanged.

4. The method according to claim 1, wherein The determining a format corresponding to the category of the target image according to the category of the target image includes: In the case where it is determined that the target image belongs to the first category, determine that the format corresponding to the first category is the YUV444 format; In the case where it is determined that the target image belongs to the second category, determine that the format corresponding to the second category is the YUV420 format.

5. An image encoding device, characterized in that, Including: An obtaining unit, configured to obtain an image to be processed, and decode the image to be processed to obtain a target image; A classification unit is used to obtain the resolution, color information, and brightness information of the target image, and classify the target image according to the resolution, color information, and brightness information of the target image to obtain the category of the target image, including: dividing the target image into blocks according to a block division rule to obtain a plurality of sub-blocks; obtaining the number of sub-blocks in the target image whose color information meets a preset condition, calculating the ratio of the sub-blocks whose color information meets the preset condition to all sub-blocks according to the number of sub-blocks whose color information meets the preset condition and the brightness information of the target image, when the ratio is greater than a ratio threshold, calculating the average spatial activity of the target image according to the resolution of the target image and the brightness information of the target image, the average spatial activity is used to indicate the degree of change of the pixel values of the target image, when the average spatial activity of the target image is greater than a preset threshold, determining that the target image belongs to the first category, when the average spatial activity of the target image is less than or equal to the preset threshold, determining that the target image belongs to the second category; A determination unit is used to determine a format corresponding to the category of the target image according to the category of the target image, and perform format conversion on the target image according to the determined format corresponding to the category of the target image to obtain an image to be encoded; An encoding unit is used to perform encoding processing on the image to be encoded to obtain an encoded image.

6. A computer device, characterized in that, It includes a processor and a memory, the processor and the memory are connected to each other, wherein, the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1-4.

7. A computer-readable storage medium, characterized in that, Program instructions are stored in the computer-readable storage medium, and when the program instructions are executed, the method according to any one of claims 1-4 is implemented.

Citation Information

Patent Citations

  • Non-reference screen video quality evaluation method and system based on mixed features

    CN114979709A

  • Image coding method and apparatus and image decoding method and apparatus, based on characteristics of regions of image

    US20130202201A1