Image encoding method, device, product, equipment and medium
By calculating the horizontal and vertical gradients of the target encoding block, determining the texture direction information and skipping the unreasonable division mode, the problem of high time consumption by existing encoders when selecting the optimal division mode is solved, and coding efficiency is improved.
Patent Information
- Application Number
- CN202510053055.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-14
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-01-14
AI Technical Summary
Existing encoders spend a lot of time in selecting the optimal division mode, resulting in a decrease in encoding efficiency.
By calculating the lateral and vertical gradients of the target coded block, the texture direction information is determined, and the unreasonable division mode is skipped according to the texture direction information and preset thresholds, thereby reducing the time consumption of selecting the optimal division mode.
This improves the encoding efficiency and reduces the time consumption of choosing the optimal division mode, thereby improving the efficiency of the encoding process.
Smart Images

Figure CN119484824B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of coding technology, and in particular to an image coding method, device, product, equipment and medium. Background Art
[0002] Before video transmission, it is usually necessary to encode the video, that is, to encode the video images in the video. At present, many encoders need to divide the image into blocks step by step during the encoding process to obtain coding units for encoding. In order to obtain coding units with better encoding effects, it is usually necessary to determine the optimal division mode from various division modes before dividing the blocks, and then divide them. In this way, a lot of time is spent on finding the optimal division mode, resulting in reduced encoding efficiency. Summary of the invention
[0003] In view of this, the purpose of this application is to provide an image coding method, apparatus, product, device and medium, which can reduce the time consumption of selecting the optimal partitioning mode, thereby improving the coding efficiency. The specific scheme is as follows:
[0004] In a first aspect, the present application discloses an image encoding method, comprising:
[0005] Calculating a horizontal gradient and a vertical gradient of a target coding block, wherein the target coding block is an image block in an image to be coded;
[0006] Calculating texture direction information of the target coding block based on the horizontal gradient and the vertical gradient;
[0007] Comparing the texture direction information with a preset threshold, and based on the comparison result, removing a target partitioning mode from a partitioning mode set corresponding to the target coding block to obtain a remaining partitioning mode;
[0008] Determining an optimal partitioning mode of the target coding block from the remaining partitioning modes;
[0009] The target coding block is divided based on the optimal division mode. If the division end condition is not met, the coding sub-block obtained by the division is determined as a new target coding block, and the step of calculating the horizontal gradient and the vertical gradient of the target coding block is triggered.
[0010] Optionally, the calculating the texture direction information of the target coding block based on the horizontal gradient and the vertical gradient includes:
[0011] Determine the ratio of the longitudinal gradient to the transverse gradient as first texture direction information of the target coding block, and determine the ratio of the transverse gradient to the longitudinal gradient as second texture direction information of the target coding block;
[0012] Accordingly, comparing the texture direction information with a preset threshold includes:
[0013] comparing the first texture direction information with a preset longitudinal threshold;
[0014] The second texture direction information is compared with a preset horizontal threshold.
[0015] Optionally, the partition pattern set is a partition pattern set corresponding to a third-generation audio and video coding standard encoder, and based on the comparison result, removing a target partition pattern from the partition pattern set corresponding to the target coding block includes:
[0016] If the first texture direction information is greater than a first preset vertical threshold, removing the horizontal ternary tree division mode from the division mode set corresponding to the target coding block;
[0017] If the first texture direction information is greater than a second preset vertical threshold, eliminating the horizontal binary tree division mode from the division mode set corresponding to the target coding block, wherein the second preset vertical threshold is greater than the first preset vertical threshold;
[0018] If the second texture direction information is greater than a first preset horizontal threshold, removing the vertical ternary tree division mode from the division mode set corresponding to the target coding block;
[0019] If the second texture direction information is greater than a second preset horizontal threshold, the vertical binary tree division mode is eliminated from the division mode set corresponding to the target coding block, wherein the second preset horizontal threshold is greater than the first preset horizontal threshold.
[0020] Optionally, calculating the horizontal gradient and the vertical gradient of the target coding block includes:
[0021] Dividing the target coding block into a preset number of sub-blocks;
[0022] Calculate the transverse gradient and longitudinal gradient of each sub-block based on the Sobel operator;
[0023] The sum of the horizontal gradients and the sum of the vertical gradients of the preset number of sub-blocks are calculated to obtain the horizontal gradient and the vertical gradient of the target coding block.
[0024] Optionally, the calculating the transverse gradient and the longitudinal gradient of each sub-block based on the Sobel operator includes:
[0025] For each sub-block, the horizontal gradient and the vertical gradient of each pixel are calculated based on the neighboring pixels of each pixel, and the horizontal gradient of each pixel and the vertical gradient of each pixel are summed to obtain the horizontal gradient and the vertical gradient of the sub-block.
[0026] Optionally, determining the optimal partitioning mode of the target coding block from the remaining partitioning modes includes:
[0027] The coding losses obtained by dividing the target coding block according to the remaining division modes are compared, and the remaining division mode with the smallest coding loss is determined as the optimal division mode of the target coding block.
[0028] In a second aspect, the present application discloses an image encoding device, comprising:
[0029] An image gradient calculation module, used to calculate the horizontal gradient and the vertical gradient of a target coding block, wherein the target coding block is an image block in the image to be coded;
[0030] A direction information calculation module, used to calculate the texture direction information of the target coding block based on the horizontal gradient and the vertical gradient;
[0031] A division mode elimination module, used for comparing the texture direction information with a preset threshold, and eliminating a target division mode from a division mode set corresponding to the target coding block based on the comparison result, to obtain a remaining division mode;
[0032] A partitioning module determination module, configured to determine an optimal partitioning mode of the target coding block from the remaining partitioning modes;
[0033] A coding block division module, used for dividing the target coding block based on the optimal division mode;
[0034] The end condition judgment module is used to determine the divided coding sub-block as a new target coding block if the division end condition is not met, and trigger the image gradient calculation module to execute the step of calculating the horizontal gradient and the vertical gradient of the target coding block.
[0035] In a third aspect, the present application discloses a computer program product, including a computer program / instruction, which implements the aforementioned image encoding method when executed by a processor.
[0036] In a fourth aspect, the present application discloses an electronic device, including a memory and a processor, wherein:
[0037] The memory is used to store the computer program;
[0038] The processor is used to execute the computer program to implement the aforementioned image encoding method.
[0039] In a fifth aspect, the present application discloses a computer-readable storage medium for storing a computer program, wherein the computer program implements the aforementioned image encoding method when executed by a processor.
[0040] It can be seen from the above scheme that the present application provides an image coding method, including: calculating the horizontal gradient and the vertical gradient of the target coding block, wherein the target coding block is an image block in the image to be encoded; calculating the texture direction information of the target coding block based on the horizontal gradient and the vertical gradient; comparing the texture direction information with a preset threshold, and based on the comparison result, eliminating the target division mode from the division mode set corresponding to the target coding block to obtain the remaining division mode; determining the optimal division mode of the target coding block from the remaining division modes; dividing the target coding block based on the optimal division mode, and if the division end condition is not met, determining the coding sub-block obtained by the division as a new target coding block, and triggering the step of calculating the horizontal gradient and the vertical gradient of the target coding block.
[0041] It can be seen that the beneficial effects of the present application are: when selecting the optimal division mode of the target coding block, the horizontal gradient and the vertical gradient of the target coding block are first calculated, and then the texture direction information of the target coding block is determined, and unreasonable division modes are skipped based on the texture direction information and the preset threshold, which can reduce the time consumption of selecting the optimal division mode, thereby improving the coding efficiency.
[0042] Correspondingly, an image encoding device, product, equipment and readable storage medium provided by the present application also have the above-mentioned technical effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0044] Figure 1 A flow chart of an image encoding method provided in an embodiment of the present application;
[0045] Figure 2 A schematic diagram of a division mode skipping provided in an embodiment of the present application;
[0046] Figure 3 A schematic diagram of the structure of an image encoding device provided in an embodiment of the present application;
[0047] Figure 4 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0049] First, the terms involved in this application are explained:
[0050] AVS3 (Audio Video Standard 3) is a new generation of video coding standard after AVS1 (the first generation of audio and video coding standard) and AVS2 (the second generation of audio and video coding standard). It is mainly used for efficient audio and video compression. The AVS3 encoder is a software or hardware tool that implements the video compression algorithm of the standard. It is used to compress the original uncompressed video signal into an AVS3 format bitstream for storage or transmission. In actual applications, the AVS3 encoder can be used in the following areas. Ultra-high-definition content distribution: such as 4K / 8K video on demand, ultra-high-definition TV; live video: such as live events, real-time streaming; cloud games and VR (Virtual Reality) / AR (Augmented Reality): provide low-latency high-quality video transmission; video surveillance: efficient storage of large-scale high-definition video content. In these applications, the encoder is required to perform the encoding process more efficiently while ensuring video quality.
[0051] The Sobel operator is one of the operators in image processing, sometimes called the Sobel-Feldman operator or the Sobel filter. It is often used for edge detection in the field of image processing and computer vision. It is a discrete difference operator used to calculate the approximate value of the gradient of the image brightness function. Using this operator at any point in the image, the Sobel operator operation will produce the corresponding gradient vector or its norm.
[0052] YUV is a color encoding method. Y stands for luminance, which is the grayscale value. It represents the brightness and darkness of the image. The range of Y is from 0 to 255, where 0 represents pure black and 255 represents pure white. U stands for red chroma and V stands for blue chroma.
[0053] See also Figure 1 As shown, the embodiment of the present application discloses an image encoding method, including:
[0054] Step S11: Calculate the horizontal gradient and the vertical gradient of the target coding block, wherein the target coding block is an image block in the image to be encoded.
[0055] In an embodiment of the present application, a target encoder may be used to encode a video image of a video to be transmitted, and the target encoder is an encoder including multiple division modes.
[0056] In an embodiment of the present application, based on a target encoder, the image to be encoded may be first divided into maximum coding units, such as 128*128 coding blocks, and the maximum coding unit may be determined as an initial target coding block to perform gradient calculation.
[0057] In an optional implementation, the target coding block may be divided into a preset number of sub-blocks; the lateral gradient and the longitudinal gradient of each sub-block may be calculated based on the Sobel operator; the sum of the lateral gradients and the sum of the longitudinal gradients of the preset number of sub-blocks may be calculated to obtain the lateral gradient and the longitudinal gradient of the target coding block.
[0058] Furthermore, in an embodiment of the present application, for each sub-block, the horizontal gradient and the vertical gradient of each pixel are calculated based on the adjacent pixels of each pixel, the horizontal gradient of each pixel is summed and the vertical gradient of each pixel is summed to obtain the horizontal gradient and the vertical gradient of the sub-block.
[0059] Step S12: Calculate the texture direction information of the target coding block based on the horizontal gradient and the vertical gradient.
[0060] In the embodiment of the present application, the ratio of the longitudinal gradient to the transverse gradient can be determined as the first texture direction information of the target coding block, and the ratio of the transverse gradient to the longitudinal gradient can be determined as the second texture direction information of the target coding block. That is, the ratio of the transverse gradient to the longitudinal gradient can reflect the texture direction of the target coding block.
[0061] Step S13: comparing the texture direction information with a preset threshold, and based on the comparison result, eliminating the target partition mode from the partition mode set corresponding to the target coding block to obtain the remaining partition modes.
[0062] Among them, the partitioning mode set includes a partitioning mode corresponding to the target encoder that can perform block partitioning on the target coding block. For example, the partitioning mode corresponding to the third-generation audio and video coding standard encoder may include QT (quadruple division), BT_HOR (horizontal binary tree division), BT_VER (vertical binary tree division), EQT_HOR (horizontal ternary tree division), EQT_VER (vertical ternary tree division). The leaf nodes of the quadtree can be further divided into BT (binary tree) or EQT (ternary tree), but the leaf nodes of BT or EQT are not allowed to be divided into quadtrees, the leaf nodes of BT can be divided into EQT, and the leaf nodes of EQT can also be divided into BT.
[0063] In this embodiment of the present application, the first texture direction information may be compared with a preset longitudinal threshold; and the second texture direction information may be compared with a preset transverse threshold.
[0064] In an optional implementation, if the first texture direction information is greater than a preset longitudinal threshold, the texture direction of the target coding block is longitudinal, and the transverse division method can be eliminated. In another optional implementation, if the second texture direction information is greater than a preset transverse threshold, the texture direction of the target coding block is transverse, and the transverse division method can be eliminated.
[0065] Furthermore, in order to more accurately skip inappropriate division modes, when the division mode set is the division mode set corresponding to the third-generation audio and video coding standard encoder, the target division mode is eliminated from the division mode set corresponding to the target coding block based on the comparison result, including: if the first texture direction information is greater than the first preset vertical threshold, the horizontal ternary tree division mode is eliminated from the division mode set corresponding to the target coding block; if the first texture direction information is greater than the second preset vertical threshold, the horizontal binary tree division mode is eliminated from the division mode set corresponding to the target coding block, wherein the second preset vertical threshold is greater than the first preset vertical threshold; if the second texture direction information is greater than the first preset horizontal threshold, the vertical ternary tree division mode is eliminated from the division mode set corresponding to the target coding block; if the second texture direction information is greater than the second preset horizontal threshold, the vertical binary tree division mode is eliminated from the division mode set corresponding to the target coding block, wherein the second preset horizontal threshold is greater than the first preset horizontal threshold.
[0066] That is, the embodiment of the present application can design two thresholds of different sizes to skip the ternary tree division mode and the binary tree division mode respectively. The first texture direction information and the first preset longitudinal threshold can be compared first. If the first texture direction information is greater than the first preset longitudinal threshold, the horizontal ternary tree division mode is eliminated. The first texture direction information and the second preset longitudinal threshold are compared again. If the first texture direction information is greater than the second preset longitudinal threshold, the horizontal binary tree division mode is eliminated. The comparison of the horizontal thresholds is similar, that is, the second texture direction information and the first preset transverse threshold can be compared first. If the second texture direction information is greater than the first preset transverse threshold, the vertical ternary tree division mode is eliminated. The second texture direction information and the second preset transverse threshold are compared again. If the second texture direction information is greater than the second preset transverse threshold, the vertical binary tree division mode is eliminated.
[0067] Step S14: Determine the optimal partitioning mode of the target coding block from the remaining partitioning modes.
[0068] The embodiment of the present application can compare the coding losses obtained by dividing the target coding block according to the remaining division modes, and determine the remaining division mode with the smallest coding loss as the optimal division mode of the target coding block.
[0069] The coding loss is the difference between the image block obtained by dividing the target coding block according to the corresponding division mode and decoding after encoding and the original target coding block, that is, the target coding block before encoding.
[0070] Step S15: Divide the target coding block based on the optimal division mode. If the division end condition is not met, determine the divided coding sub-block as a new target coding block, and trigger the step of calculating the horizontal gradient and the vertical gradient of the target coding block.
[0071] The division end condition may be that the size of the coded sub-block obtained by division reaches a preset minimum size, such as 4*4, or reaches a predetermined division depth.
[0072] In the embodiment of the present application, the above steps S11 to S15 are performed for each maximum coding unit, and the code stream data corresponding to the image to be coded is determined based on the code stream data corresponding to the coding block finally obtained by division (i.e., the coding block of the optimal size obtained by division) and the coding data corresponding to the division information corresponding to the coding block of the optimal size, and transmitted to the decoding device. Among them, the coding block of the optimal size is the coding block with the smallest corresponding coding loss, and the division information may include whether to divide and the division mode.
[0073] It can be seen that when selecting the optimal division mode of the target coding block, the embodiment of the present application first calculates the horizontal gradient and the vertical gradient of the target coding block, and then determines the texture direction information of the target coding block, and skips the unreasonable division mode based on the texture direction information and the preset threshold, which can reduce the time consumption of selecting the optimal division mode, thereby improving the coding efficiency.
[0074] Below, taking the image encoding process of the AVS3 encoder as an example, the image encoding scheme provided by the present application is further described, which may specifically include the following steps:
[0075] 1. Pass the YUV image into the AVS3 encoder and divide the YUV image into 128x128 coding blocks.
[0076] 2. For each coding block, the most appropriate partitioning mode needs to be determined. There are five types of partitioning modes: QT (quadruple partitioning), BT_HOR (horizontal binary tree partitioning), BT_VER (vertical binary tree partitioning), EQT_HOR (horizontal ternary tree partitioning), and EQT_VER (vertical ternary tree partitioning). The leaf nodes of the quadtree can be further divided into BT or EQT, but the leaf nodes of BT or EQT are not allowed to be divided into quadtrees. The leaf nodes of BT can be divided into EQT, and the leaf nodes of EQT can also be divided into BT.
[0077] 3. Before partitioning, calculate the Sobel operator for the current block. The specific calculation method is as follows:
[0078] Divide the current block into 4 sub-blocks. Traverse all pixel values in each sub-block and perform the following operations for each pixel value:
[0079] The numerical value of the current pixel value is represented by pixel_cur, the numerical value of the pixel value above it is represented by pixel_up, and the numerical value of the pixel value below it is represented by pixel_down.
[0080] The formula for calculating the lateral gradient is as follows:
[0081] .
[0082] Among them, min represents the minimum value operation, abs represents the absolute value operation, and represents the left shift operation. Pixel_up[1] represents the pixel value of the pixel on the right side of pixel_up, and pixel_up[-1] represents the pixel value of the pixel on the left side of pixel_up. Similarly, the pixel values of the pixels on the right side of pixel_down and pixel_cur are pixel_down[1] and pixel_cur[1], and the pixel values of the pixels on the left side of pixel_down and pixel_cur are pixel_down[-1] and pixel_cur[-1].
[0083] The formula for calculating the longitudinal gradient is as follows:
[0084] .
[0085] The horizontal gradient pixel_hor of each pixel is added to get SUB_HOR, and the vertical gradient pixel_ver of each pixel is added to get SUB_VER. The SUB_VER values obtained from each block are added to get VER; the SUB_HOR values obtained from each block are added to get HOR.
[0086] 4. Using VER and HOR obtained in step 3, calculate VER_DEV_HOR and HOR_DEV_VER. The calculation method is as follows:
[0087] ;
[0088] .
[0089] 5. If VER_DEV_HOR is greater than the threshold THRE_EQT (this value is an empirical value), then skip the EQT_HOR of the current block; on this basis, if VER_DEV_HOR is greater than the threshold THRE_BT (this value is an empirical value), then skip the BT_HOR of the current block.
[0090] 6. If HOR_DEV_VER is greater than the threshold THRE_EQT (this value is an empirical value), then skip the EQT_VER of the current block; on this basis, if HOR_DEV_VER is greater than the threshold THRE_BT (this value is an empirical value), then skip the BT_VER of the current block.
[0091] 7. Execute the remaining partitioning methods, and repeat the partitioning repeatedly until the partitioning cannot be continued. The minimum size of the coding block is 4x4. Steps 3, 4, 5, and 6 need to be executed before each partitioning. The partitioning mode is skipped in advance before the partitioning, so as to skip unnecessary partitioning modes. For example, see Figure 2 As shown, Figure 2 A schematic diagram of a division mode skipping provided in an embodiment of the present application. After skipping, other modules in the encoding process can be executed.
[0092] 8. Compare all the partitioning options and finally select the best partitioning method for each 128x128 block.
[0093] 9. Encode the information of each divided block and finally output the encoded code stream of the YUV image.
[0094] The embodiment of the present application determines the texture direction of the coding block by calculating the Sobel operator, thereby skipping certain horizontal or vertical division modes in the division module in AVS3, and finally accelerating the selection of the division mode in AVS3 and accelerating the AVS3 encoder. In this way, the texture direction of the current block to be divided is determined by using the horizontal and vertical gradient approximations calculated by the Sobel operator, thereby skipping certain division modes in AVS3, and the Sobel operator can quickly skip the division module of the AVS3 encoder, thereby accelerating the AVS3 encoder while ensuring quality.
[0095] For further information, see Figure 3 As shown, the embodiment of the present application discloses an image encoding device, including:
[0096] An image gradient calculation module 11, used to calculate the horizontal gradient and the vertical gradient of a target coding block, wherein the target coding block is an image block in the image to be coded;
[0097] A direction information calculation module 12, used to calculate the texture direction information of the target coding block based on the horizontal gradient and the vertical gradient;
[0098] A division mode elimination module 13 is used to compare the texture direction information with a preset threshold, and based on the comparison result, eliminate the target division mode from the division mode set corresponding to the target coding block to obtain the remaining division modes;
[0099] A partitioning module determining module 14, configured to determine an optimal partitioning mode of the target coding block from the remaining partitioning modes;
[0100] A coding block division module 15, configured to divide the target coding block based on the optimal division mode;
[0101] The end condition judgment module 16 is used to determine the divided coding sub-block as a new target coding block if the division end condition is not met, and trigger the image gradient calculation module to execute the step of calculating the horizontal gradient and the vertical gradient of the target coding block.
[0102] The direction information calculation module 12 is specifically used to determine the ratio of the longitudinal gradient to the transverse gradient as the first texture direction information of the target coding block, and to determine the ratio of the transverse gradient to the longitudinal gradient as the second texture direction information of the target coding block;
[0103] Correspondingly, the division mode elimination module 13 is specifically used to compare the first texture direction information with a preset vertical threshold; compare the second texture direction information with a preset horizontal threshold. When the division mode set is the division mode set corresponding to the third-generation audio and video coding standard encoder, if the first texture direction information is greater than the first preset vertical threshold, the horizontal ternary tree division mode is eliminated from the division mode set corresponding to the target coding block; if the first texture direction information is greater than the second preset vertical threshold, the horizontal binary tree division mode is eliminated from the division mode set corresponding to the target coding block, wherein the second preset vertical threshold is greater than the first preset vertical threshold; if the second texture direction information is greater than the first preset horizontal threshold, the vertical ternary tree division mode is eliminated from the division mode set corresponding to the target coding block; if the second texture direction information is greater than the second preset horizontal threshold, the vertical binary tree division mode is eliminated from the division mode set corresponding to the target coding block, wherein the second preset horizontal threshold is greater than the first preset horizontal threshold.
[0104] The image gradient calculation module 11 may specifically include:
[0105] A sub-block division module, used for dividing the target coding block into a preset number of sub-blocks;
[0106] A sub-block calculation module, used for calculating the transverse gradient and the longitudinal gradient of each sub-block based on the Sobel operator;
[0107] The gradient calculation module is used to calculate the sum of the horizontal gradients and the sum of the vertical gradients of the preset number of sub-blocks to obtain the horizontal gradient and the vertical gradient of the target coding block.
[0108] Among them, the sub-block calculation module is specifically used to calculate the horizontal gradient and the vertical gradient of each pixel based on the adjacent pixels of each pixel for each sub-block, sum the horizontal gradient of each pixel and sum the vertical gradient of each pixel to obtain the horizontal gradient and the vertical gradient of the sub-block.
[0109] The partitioning module determination module 14 is specifically used to compare the coding losses obtained by partitioning the target coding block according to the remaining partitioning modes, and determine the remaining partitioning mode with the smallest coding loss as the optimal partitioning mode of the target coding block.
[0110] It can be seen that when selecting the optimal division mode of the target coding block, the embodiment of the present application first calculates the horizontal gradient and the vertical gradient of the target coding block, and then determines the texture direction information of the target coding block, and skips the unreasonable division mode based on the texture direction information and the preset threshold, which can reduce the time consumption of selecting the optimal division mode, thereby improving the coding efficiency.
[0111] Furthermore, an embodiment of the present application discloses a computer program product, including a computer program / instruction, which implements the image encoding method disclosed in the aforementioned embodiment when executed by a processor.
[0112] For the specific process of the above-mentioned image encoding method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0113] See also Figure 4 As shown, an embodiment of the present application discloses an electronic device 20, including a processor 21 and a memory 22; wherein the memory 22 is used to store a computer program; and the processor 21 is used to execute the computer program, the image encoding method disclosed in the above embodiment.
[0114] For the specific process of the above-mentioned image encoding method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0115] Furthermore, the memory 22 as a carrier for storing resources may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the storage method may be temporary storage or permanent storage.
[0116] In addition, the electronic device 20 also includes a power supply 23, a communication interface 24, an input / output interface 25 and a communication bus 26; wherein the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input / output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0117] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the image encoding method disclosed in the aforementioned embodiment.
[0118] For the specific process of the above-mentioned image encoding method, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.
[0119] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0120] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0121] The above is a detailed introduction to an image encoding method, device, product, equipment and medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. An image coding method, characterized in that: include: Calculating a horizontal gradient and a vertical gradient of a target coding block, wherein the target coding block is an image block in an image to be coded; Determine the ratio of the longitudinal gradient to the transverse gradient as first texture direction information of the target coding block, and determine the ratio of the transverse gradient to the longitudinal gradient as second texture direction information of the target coding block; The first texture direction information is compared with a preset longitudinal threshold, the second texture direction information is compared with a preset horizontal threshold, and based on the comparison results, a target partitioning mode is eliminated from the partitioning mode set corresponding to the target coding block to obtain a remaining partitioning mode; Determining an optimal partitioning mode of the target coding block from the remaining partitioning modes; The target coding block is divided based on the optimal division mode, and if the division end condition is not met, the coding sub-block obtained by the division is determined as a new target coding block, and the step of calculating the horizontal gradient and the vertical gradient of the target coding block is triggered; Among them, the division mode set is the division mode set corresponding to the third-generation audio and video coding standard encoder, and the target division mode is eliminated from the division mode set corresponding to the target coding block based on the comparison result, including: if the first texture direction information is greater than the first preset vertical threshold, the horizontal ternary tree division mode is eliminated from the division mode set corresponding to the target coding block; if the first texture direction information is greater than the second preset vertical threshold, the horizontal binary tree division mode is eliminated from the division mode set corresponding to the target coding block, wherein the second preset vertical threshold is greater than the first preset vertical threshold; if the second texture direction information is greater than the first preset horizontal threshold, the vertical ternary tree division mode is eliminated from the division mode set corresponding to the target coding block; if the second texture direction information is greater than the second preset horizontal threshold, the vertical binary tree division mode is eliminated from the division mode set corresponding to the target coding block, wherein the second preset horizontal threshold is greater than the first preset horizontal threshold.
2. The image encoding method according to claim 1, characterized in that The calculating of the horizontal gradient and the vertical gradient of the target coding block includes: Dividing the target coding block into a preset number of sub-blocks; Calculate the transverse gradient and longitudinal gradient of each sub-block based on the Sobel operator; The sum of the horizontal gradients and the sum of the vertical gradients of the preset number of sub-blocks are calculated to obtain the horizontal gradient and the vertical gradient of the target coding block.
3. The image encoding method according to claim 2, characterized in that The step of calculating the transverse gradient and the longitudinal gradient of each sub-block based on the Sobel operator includes: For each sub-block, the horizontal gradient and the vertical gradient of each pixel are calculated based on the neighboring pixels of each pixel, and the horizontal gradient of each pixel and the vertical gradient of each pixel are summed to obtain the horizontal gradient and the vertical gradient of the sub-block.
4. The image encoding method according to any one of claims 1 to 3, characterized in that: The determining the optimal partitioning mode of the target coding block from the remaining partitioning modes comprises: The coding losses obtained by dividing the target coding block according to the remaining division modes are compared, and the remaining division mode with the smallest coding loss is determined as the optimal division mode of the target coding block.
5. An image encoding device, characterized in that: include: An image gradient calculation module, used to calculate the horizontal gradient and the vertical gradient of a target coding block, wherein the target coding block is an image block in the image to be coded; a direction information calculation module, configured to determine a ratio of a longitudinal gradient to a transverse gradient as first texture direction information of the target coding block, and to determine a ratio of a transverse gradient to a longitudinal gradient as second texture direction information of the target coding block; a partitioning mode elimination module, configured to compare the first texture direction information with a preset longitudinal threshold, compare the second texture direction information with a preset horizontal threshold, and eliminate a target partitioning mode from a partitioning mode set corresponding to the target coding block based on the comparison result, to obtain a remaining partitioning mode; A partitioning module determination module, configured to determine an optimal partitioning mode of the target coding block from the remaining partitioning modes; A coding block division module, used for dividing the target coding block based on the optimal division mode; an end condition judgment module, configured to determine the coding sub-block obtained by the division as a new target coding block if the division end condition is not met, and trigger the image gradient calculation module to execute the step of calculating the horizontal gradient and the vertical gradient of the target coding block; Among them, the division mode set is the division mode set corresponding to the third-generation audio and video coding standard encoder, and the target division mode is eliminated from the division mode set corresponding to the target coding block based on the comparison result, including: if the first texture direction information is greater than the first preset vertical threshold, the horizontal ternary tree division mode is eliminated from the division mode set corresponding to the target coding block; if the first texture direction information is greater than the second preset vertical threshold, the horizontal binary tree division mode is eliminated from the division mode set corresponding to the target coding block, wherein the second preset vertical threshold is greater than the first preset vertical threshold; if the second texture direction information is greater than the first preset horizontal threshold, the vertical ternary tree division mode is eliminated from the division mode set corresponding to the target coding block; if the second texture direction information is greater than the second preset horizontal threshold, the vertical binary tree division mode is eliminated from the division mode set corresponding to the target coding block, wherein the second preset horizontal threshold is greater than the first preset horizontal threshold.
6. A computer program product, characterized in that The method comprises a computer program / instruction, which, when executed by a processor, implements the image encoding method according to any one of claims 1 to 4.
7. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store the computer program; The processor is used to execute the computer program to implement the image encoding method according to any one of claims 1 to 4.
8. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein when the computer program is executed by a processor, the image encoding method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Multifunctional video coding CU division rapid decision method and storage medium
CN111147867A
Rapid CU division method for VVC of ERP panoramic video and storage medium
CN117041736A