A method for compressing image and video
By considering the perceptual characteristics of the human visual system in video encoding, calculating perceptual weighting factors and optimizing bit allocation and quantization parameters, the problem of low visual quality in the existing technology is solved, and bit rate reduction and video quality improvement are achieved.
Patent Information
- Application Number
- CN201910616192.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-07-09
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2039-07-09
AI Technical Summary
Existing video coding technology fails to fully consider the perceptual characteristics of the human visual system, resulting in low subjective quality of encoded images under the same mean square error condition, and fails to effectively utilize the visual masking effect and contrast sensitivity, affecting video compression efficiency.
By calculating the perceptual distortion of the coding unit, the perceptual weighting factor is established to guide the bit allocation of image groups, images and coding tree units. The perceptual weighted mean square error is used to replace the mean square error, and the bit allocation and quantization parameters are optimized, combined with the comparison of the human visual system. Sensitivity, attentional mechanisms, and masking effects.
Achieving a 7.71% reduction in bitrate and a 0.46dB video perceived quality gain, improving video compression performance while maintaining 99.996% bitrate control accuracy.
Smart Images

Figure CN112218088B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of video coding technology, and in particular, relates to an image and video compression method. Background Art
[0002] With the rapid development of multimedia technologies such as ultra-high definition, virtual reality, and 3D video, multimedia data is growing exponentially, bringing huge challenges to data storage and transmission. In order to further improve the compression efficiency of video to alleviate the pressure of data storage and transmission, a new generation of video coding standards has emerged, namely High Efficiency Video Coding (HEVC). In the video coding standard, one of the important modules is bit rate control, which is used to effectively meet the limited channel bandwidth. The process of bit rate control can be divided into two steps. The first step is bit allocation, which determines the optimal target number of bits in the group of picture (Group of Picture, GOP), picture and coding tree unit (Coding Tree Unit, CTU) level based on the given target total number of bits; the second step is to determine the value of the quantization parameter (Quantization Parameter, QP) according to the RQ model or R-λ model, and each coding unit independently determines the quantization parameter according to the target number of bits.
[0003] In 2012, a bitrate control algorithm based on the RQ model was proposed. Subsequently, Li et al. used lambda to establish the R-λ model to determine the quantization parameter, which significantly improved the bitrate control accuracy. Li's work considered the bit allocation algorithm for non-intra frames, but did not fully consider the bit allocation for intra frames. Therefore, proposals JCTVC-M02570 and JCTVC-M00360 improved Li's work. In the JCTVC-M0257 algorithm, for the intra-frame bit allocation algorithm, the number of bits allocated to each coding unit is determined by the linear correlation between the number of bits and the sum of absolute transform difference (SATD). In addition to the above bitrate control methods, there are also some perception-based methods. Gao et al. used structural similarity (SSIM) and game theory to guide the bit allocation at the intra-frame coding tree unit level. Yang et al. used gradient amplitude similarity deviation to perform the coding tree unit level bit allocation algorithm. In addition, Gao et al. proposed a bit allocation algorithm based on saliency detection, used phase consistency to detect edge saliency, and proposed a bit rate control algorithm based on phase consistency.
[0004] Accurate bit allocation is the basis of the entire bitrate control algorithm. The coding tree unit level bit allocation algorithm is used to improve the quality of each frame of the image. Because the intra frame is used as a reference frame for subsequent coded frames, the encoding quality of the intra frame directly affects the subsequent coded frames, so the encoding of the intra frame is very important. At present, the intra-frame based coding tree unit level bit allocation algorithm uses the mean absolute difference of the coding tree units in the same position as the weight of bit allocation, but this method of calculating the weight does not fully consider the perceptual characteristics of the human visual system. Therefore, the subjective quality of the obtained encoded image is not high. This is because our encoding goal is to minimize distortion under a certain bit rate constraint, but the current distortion metric is the mean square error (MSE), which does not fully consider the perceptual characteristics of the human visual system. Figure 1 As shown in the figure, it is a comparison chart of different visual qualities under the same MSE. Figure 1 (a) is the original image, Figure 1 (b) is the traditional distorted image, MSE = 48, Figure 1 (c) is the perceptually distorted image, MSE = 48. Figure 1 (b) and Figure 1 (c) It can be seen that under the same MSE, the visual quality of the two images is different. Figure 1 The visual quality of (c) is better than Figure 1 (b) This is because Figure 1 The distortion in (c) is concentrated in the background trees and weeds, where there is a large visual masking effect, so the distortion perceived by the human eye is very low. Figure 1 The distortion of (b) is concentrated in the foreground people and some areas with flat textures. These areas not only have weak masking effects, but the human eye is more sensitive to distortion in these areas, so the human eye can easily detect the distortion.
[0005] It can be seen that due to the masking effect, under the same MSE, the difference in the distortion position makes the subjective quality of the video perceived by the human eye different. Therefore, bit allocation based on the perceptual characteristics of the human visual system can bring better visual quality. Summary of the invention
[0006] The present application provides an image and video compression method, which aims to solve one of the above-mentioned technical problems in the prior art at least to a certain extent.
[0007] In order to solve the above problems, this application provides the following technical solutions:
[0008] A method for compressing images and videos, comprising the following steps:
[0009] Step a: Calculate the perceptual distortion of a coding unit using the perceptual characteristics of the human visual system, wherein the coding unit includes a group of pictures, an image, and a coding tree unit; establish relationship models between the perceptual distortion and the bit rate of the group of pictures, the image, and the coding tree unit, respectively, and calculate the perceptual weighting factors of the group of pictures, the image, and the coding tree unit through the relationship models;
[0010] Step b: calculating the optimal number of bits allocated to the group of pictures, the picture and the coding tree unit according to the perceptual weighting factor, and performing bit allocation for the group of pictures to be encoded, the picture and the coding tree unit according to the calculation result of the optimal number of bits;
[0011] Step c: After performing bit allocation for the group of pictures, pictures and coding tree units, the optimal quantization parameters of the group of pictures, pictures and coding tree units to be encoded are calculated, and the group of pictures, pictures and coding tree units to be encoded are encoded according to the optimal quantization parameters.
[0012] The technical solution adopted by the embodiment of the present application also includes: in the step a, the perceptual weighting factor calculation formulas of the image group, image and coding tree unit are respectively: and
[0013] in, is the perceptual weight associated with the content of the i-th image group, N means a video contains N image groups; is the perceptual weight associated with the content of the i-th image, M means that an image group contains M images; is the perceptual weight associated with the content of the i-th coding tree unit, and L indicates that an image contains L coding tree units.
[0014] The technical solution adopted by the embodiment of the present application also includes: in the step a, the relationship model between the perceptual distortion and the bit rate of the image group, the image and the coding tree unit is: PWD = m*e n*R 、PWD=α·R β ,
[0015] The technical solution adopted by the embodiment of the present application also includes: in the step a, the perceptual weighting factors of the image group, the image and the coding tree unit calculated by the relational model further include:
[0016] Step a1: using the perceptual characteristics of the human visual system, the perceptual distortion of each image group, image and coding tree unit is calculated respectively;
[0017] Step a2: Establish the relationship model R-PWD between the perceptual distortion and the bit rate of each picture group, picture and coding tree unit respectively;
[0018] Step a3: Calculate the perceptual weighting factors of the image group, image and coding tree unit to be encoded respectively through the relationship model between the perceptual distortion and bit rate of each image group, image and coding tree unit, and perform bit allocation of the image group, image and coding tree unit respectively according to the perceptual weighting factors.
[0019] The technical solution adopted in the embodiment of the present application also includes: the calculation method of the perceptual distortion of the image group, image and coding tree unit includes a perceptual distortion calculation method integrating the contrast sensitivity of the human eye, a perceptual distortion calculation method integrating the attention mechanism of the human eye, and a perceptual distortion calculation method integrating the masking effect of the human eye, or a combination of one or more perceptual distortion calculation methods.
[0020] The technical solution adopted in the embodiment of the present application also includes: the method for calculating the perceptual weight is: using m coding units, the coding units include the PWD and R values of the image group, the image and the coding tree unit, and performing the least squares method to adaptively calculate the value of the perceptual weight of the coding unit, and the perceptual weight of each coding unit is constrained between [1.0,40.0].
[0021] The technical solution adopted by the embodiment of the present application also includes: in the step b, the calculation formula for calculating the optimal number of bits allocated to the image group to be encoded, the image and the coding tree unit according to the perceptual weighting factor is:
[0022]
[0023] In the above formula, R opt (i) is the optimal number of bits to be allocated to each coding unit, including group of pictures, pictures and coding tree units, is the perceptual weighting factor of the i-th coding unit, is the optimal number of remaining bits when encoding the i-th coding unit.
[0024] Compared with the prior art, the beneficial effects produced by the embodiments of the present application are: the image and video compression method of the embodiments of the present application takes into account the perceptual characteristics of the human visual system such as contrast sensitivity, visual attention mechanism, masking effect, etc., calculates the perceptual distortion of the video, and derives the perceptual weighting factor through the relationship between bit rate and perceptual distortion to perform optimal bit allocation. Compared with the existing coding tree unit-level bit allocation algorithm, under the same perceptual quality conditions, the present application achieves a 7.71% bit rate reduction; under the same bit rate conditions, the present application achieves a 0.46dB video perceptual quality gain, further improving the video compression performance. In addition, the efficient image and video compression method based on visual perception of the present application also maintains an excellent bit rate control accuracy of 99.996%. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is a comparison chart of different visual qualities under the same MSE; among them, Figure 1 (a) is the original image, Figure 1 (b) is the traditional distorted image. Figure 1 (c) is the perceptually distorted image;
[0026] Figure 2 is a flow chart of the image and video compression method of an embodiment of the present application;
[0027] Figure 3 The R-PWPSNR curves of KristenAndSara sequence under different algorithms;
[0028] Figure 4 The perceptual quality (PWPSNR) of each frame of the KristenAndSara sequence under different algorithms;
[0029] Figure 5 It is the actual number of bits of each frame image of KristenAndSara sequence under different algorithms. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. The specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0031] Based on the shortcomings of the prior art, the present application proposes an image and video compression method based on visual perception, which minimizes the perceptual distortion of each coding unit under a given bit rate constraint. First, in order to better represent the perceptual distortion, the perceptual characteristics of the human visual system are used to calculate the perceptual distortion of each coding unit, and the relationship between the bit rate and the perceptual distortion is established. The perceptual weighted mean square error is used instead of the mean square error to measure the distortion. Then, the relationship between the bit rate (R) and the perceptual weighted mean square error (PWD) is calculated by statistical experiments and recorded as the R-PWD model. Finally, the perceptual weighting factor is derived from the R-PWD model to guide the bit allocation of the three levels of the coding unit: the image group, the image, and the coding tree unit.
[0032] For details, please refer to Figure 2 , is a flow chart of the image and video compression method of the embodiment of the present application. The image and video compression method of the embodiment of the present application comprises the following steps:
[0033] Step 100: Obtain the target number of bits R of the previous level coding unit of the current coding unit pic ;
[0034] Step 101: Calculate the SATD (the Sum of Absolute TransformDifference, Hadamard transform absolute error sum) values of all coding units;
[0035] Step 102: Calculate the initial bit number of all coding units according to the SATD value;
[0036] In step 102, the coding unit described in the embodiment of the present application includes a picture group, a picture, and a coding tree unit. Taking the coding tree unit (CodingTreeUnit, CTU) as an example, the initial bit number calculation formula is:
[0037]
[0038] In formula (1), C CTU (i) is the calculated SATD value of the i-th CTU, which is used as the initial bit weight; R CTU (i) is the initial number of bits allocated to the i-th CTU, N is the number of CTUs in the frame to be encoded, and R pic It is the target number of bits for one frame of image.
[0039] Step 103: using the perceptual characteristics of the human visual system, respectively calculating the perceptual distortion of the coding units, establishing a relationship model R-PWD between the bit rate (R) and the perceptual weighted mean square error (PWD), and calculating the perceptual weighting factor of each coding unit through the relationship model R-PWD;
[0040] In step 103, the embodiment of the present application respectively calculates the perceptual weighting factors of the three levels of the group of pictures, the picture and the coding tree unit by using the perceptual distortion method, and performs bit allocation of the three levels of the group of pictures, the picture and the coding tree unit in a recursive order according to the perceptual weighting factors. The specific bit allocation method is as follows:
[0041] Step 1031: Calculate the perceptual distortion of each image group using the perceptual characteristics of the human visual system;
[0042] Step 1032: Establish a relationship model between the perceptual distortion and the bit rate of each image group; wherein the relationship model between the perceptual distortion and the bit rate of the image group is R-PWD, and the relationship between PWD and R is PWD=m*e n*R .
[0043] Step 1033: Calculate the perceptual weight of the image group to be encoded by using the relationship model between the perceptual distortion and the bit rate of each image group, and allocate bits of the image group according to the perceptual weight; wherein the perceptual weighting factor calculation formula of the image group is:
[0044]
[0045] In formula (2), is the perceptual weight associated with the content of the i-th image group, and N indicates that a video contains N image groups.
[0046] Step 1034: Calculate the perceptual distortion of each image using the perceptual characteristics of the human visual system;
[0047] Step 1035: Establish a relationship model between the perceptual distortion and the bit rate of each image; wherein the relationship model between the perceptual distortion and the bit rate of each image is R-PWD, and the relationship between PWD and R is PWD=α·R β .
[0048] Step 1036: Calculate the perceptual weight of the image to be encoded by using the relationship model between the perceptual distortion and the bit rate of each image, and allocate bits of the image according to the perceptual weight; wherein the perceptual weighting factor calculation formula of the image is:
[0049]
[0050] In formula (3), is the perceptual weight associated with the content of the i-th image, and M indicates that an image group contains M images.
[0051] Step 1037: Calculate the perceptual distortion of each coding tree unit using the perceptual characteristics of the human visual system;
[0052] Step 1038: Establish a relationship model between the perceptual distortion and the bit rate of each coding tree unit; wherein the relationship model between the perceptual distortion and the bit rate of each coding tree unit is R-PWD, and the relationship between PWD and R is
[0053] Step 1039: Calculate the perceptual weight of the coding tree unit to be encoded by using the relationship model between the perceptual distortion and the bit rate of each coding tree unit, and perform bit allocation of the coding tree unit to be encoded according to the perceptual weight; wherein the perceptual weighting factor calculation formula of the coding tree unit is:
[0054]
[0055] In formula (4), is the perceptual weight associated with the content of the i-th coding tree unit, and L indicates that an image contains L coding tree units.
[0056] In the above, the value of the perceptual weight is obtained by fitting the PWD and R values of m coding units and performing least squares adaptive calculation. The value range of m can be 1 to N (N is the number of coding units in the frame to be encoded). In the embodiment of the present application, m=16 is preferred; the value of the perceptual weight of each coding unit is constrained to be between [1.0,40.0], and the specific value range can be set according to actual operations.
[0057] In other embodiments of the present application, the calculation method of the perceptual distortion of the image group, image and coding tree unit includes but is not limited to the perceptual distortion calculation method integrating the contrast sensitivity of the human eye, the perceptual distortion calculation method integrating the attention mechanism of the human eye, the perceptual distortion calculation method integrating the masking effect of the human eye, and the perceptual quality indicators such as SSIM (structural similarity index, structural similarity) One or more perceptual distortion calculation methods are combined. It can be understood that in each level of the R-PWD model, the relationship between PWD and R can also be replaced or adjusted according to actual operations.
[0058] Step 104: Estimating the number of bits remaining when encoding the current coding unit
[0059] In step 104, taking the coding tree unit as an example, the number of remaining bits estimated by the coding tree unit is The calculation formula is:
[0060]
[0061] In formula (5), C CTU (i) is the calculated SATD value of the i-th CTU.
[0062] Step 105: obtaining the actual number of bits remaining when encoding the current coding unit, and adjusting the estimated number of remaining bits with the actual number of remaining bits;
[0063] In step 105, taking the coding tree unit as an example, the calculation formula for the adjusted remaining bits of the coding tree unit is:
[0064]
[0065] In formula (6), is the number of remaining bits after adjustment, is the actual number of remaining bits, i is the number of coded CTUs, is the estimated number of remaining bits, W is the size of the smoothing window, the value of W can be set between 1 and N (N is the number of CTUs contained in the frame to be encoded), and the value of W is set to 4 in the embodiment of the present application.
[0066] Step 106: Calculate the optimal number of bits R allocated to each coding unit according to the perceptual weighting factor opt , and performing bit allocation for each coding unit according to the calculation result;
[0067] In step 106, taking the coding tree unit as an example, the optimal number of bits R of the coding tree unit is opt The calculation formula is:
[0068]
[0069] In formula (7), R opt (i) is the optimal number of bits to allocate to each coding tree unit, is the perceptual weighting factor of the i-th coding tree unit in the current frame to be coded, is the optimal number of remaining bits when encoding the i-th coding tree unit.
[0070] Step 107: After performing bit allocation, use the R-λ model λ = α·bpp β Calculate the λ value of the coding unit to be encoded;
[0071] Step 108: Calculate an optimal quantization parameter (QP) of the coding unit to be encoded according to a relationship QP-λ: QP=c1×ln(λ)+c2, and encode the coding unit to be encoded according to the optimal quantization parameter (QP);
[0072] In step 108, the value of the optimal quantization parameter (QP) c1 is set to 4.2005, and the value of c2 is set to 13.7122, which can be set according to actual applications. The video encoder can be an image quality encoder such as H.264, H.265 or JPEG, and the embodiment of the present application is preferably an H.265 encoder.
[0073] Step 109: Determine whether all coding units have been fully coded. If not, re-execute step 104; if all coding units have been fully coded, execute step 110;
[0074] Step 110: End encoding of the frame to be encoded.
[0075] In order to verify the feasibility and effectiveness of this application, experiments have been carried out on the HM-16.7 reference software. The experimental coding structure is all intra-frame (All Intra) coding, the rate control mode is turned on, and CTU-level rate control is performed. The experiment uses 11 test sequences, namely Traffic, BasketballDrive, BQTerrace, Cactus, ParkScene, RaceHorse, BQMall, Vidyo, KristenAndSara, Johnny, Tennis, and each sequence encodes 150 frames. JCTVC-K0103, JCTVC-M0257, and HM-16.7 default algorithms are used as comparative experiments. Compared with JCTVC-K0103, this application saves 7.71% of bits on BD-BR and obtains a gain of 0.46dB on BD-PSNR. In the best case, BD-BR saves 11.13% of bits and BD-PWPSNR increases by 0.64dB. For specific experimental results, please refer to Figures 3 to 5 , Figure 3 R-PWPSNR curves of KristenAndSara sequence under different algorithms. Figure 4 is the perceptual quality (PWPSNR) of each frame of the KristenAndSara sequence under different algorithms, Figure 5 is the actual number of bits per frame of the KristenAndSara sequence under different algorithms. Figure 3 It can be clearly seen from the R-PWD curve in that the RD performance of the algorithm proposed in this application is better than the default algorithms of JCTVC-K0103, JCTVC-M0257 and HM-16.7 under the full intra-frame coding structure. At the same bit rate, the perceptual weighted peak signal-to-noise ratio (PWPSNR) of the algorithm proposed in this application is higher than the default algorithms of JCTVC-K0103, JCTVC-M0257 and HM-16.7. At the same PWPSNR, the algorithm proposed in this application uses less bit rate than the default algorithms of JCTVC-K0103, JCTVC-M0257 and HM-16.7. From Figure 4 It can be seen that the image quality of each frame of the algorithm proposed in this application is significantly better than that of other algorithms. Figure 5It can be seen that according to the example of "KristenAndSara", at the same bit rate, the bit fluctuation of the algorithm proposed in this application is smaller and more stable than that of other algorithms.
[0076] The image and video compression method of the embodiment of the present application takes into account the perceptual characteristics of the human visual system, such as masking effect, contrast sensitivity, and visual attention, calculates the perceptual distortion of the video, and derives the perceptual weighting factor through the relationship between bit rate and perceptual distortion to perform optimal bit allocation, which can be applied to image and video compression of intra-frames and inter-frames at the same time. Compared with the existing coding tree unit-level bit allocation algorithm, under the same perceptual quality conditions, the present application achieves a 7.71% bit rate reduction; under the same bit rate conditions, the present application achieves a 0.46dB video perceptual quality gain, further improving the video compression performance. In addition, the efficient image and video compression method based on visual perception of the present application also maintains an excellent bit rate control accuracy of 99.996%.
[0077] The above description of the disclosed embodiments enables professionals and technicians in the field to implement or use the present application. Various modifications to these embodiments will be apparent to professionals and technicians in the field, and the general principles defined in this application can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown in the present application, but will conform to the widest range consistent with the principles and novel features disclosed in the present application.
Claims
1. An image and video compression method, characterized in that: The following steps are involved: Step a: Calculate the perceptual distortion of a coding unit using the perceptual characteristics of the human visual system, wherein the coding unit includes a group of pictures, an image, and a coding tree unit; establish relationship models between the perceptual distortion and the bit rate of the group of pictures, the image, and the coding tree unit, respectively, and calculate the perceptual weighting factors of the group of pictures, the image, and the coding tree unit through the relationship models; Step b: calculating the optimal number of bits allocated to the group of pictures, the picture and the coding tree unit according to the perceptual weighting factor, and performing bit allocation for the group of pictures to be encoded, the picture and the coding tree unit according to the calculation result of the optimal number of bits; Step c: after performing bit allocation of the group of pictures, the picture and the coding tree unit, calculating the optimal quantization parameters of the group of pictures, the picture and the coding tree unit to be encoded, and encoding the group of pictures, the picture and the coding tree unit to be encoded according to the optimal quantization parameters; In step a, the calculation formulas for the perceptual weighting factors of the image group, image and coding tree unit are respectively: and in, is the perceptual weight associated with the content of the i-th image group, N means a video contains N image groups; is the perceptual weight associated with the content of the i-th image, M means that an image group contains M images; is the perceptual weight associated with the content of the i-th coding tree unit, L means that an image contains L coding tree units; The relationship models between the perceptual distortion and bit rate of the group of pictures, pictures and coding tree units are: PWD = m*e n*R 、PWD=α·R β , In the step b, the calculation formula for calculating the optimal number of bits allocated to the group of pictures to be encoded, the picture and the coding tree unit according to the perceptual weighting factor is: In the above formula, R opt (i) is the optimal number of bits to allocate to each coding unit, where the coding unit includes group of pictures, pictures and coding tree units, ω P (i) is the perceptual weighting factor of the i-th coding unit, R O (i) is the optimal number of remaining bits when encoding the i-th coding unit.
2. The image and video compression method according to claim 1, characterized in that: In the step a, the step of calculating the perceptual weighting factors of the group of pictures, the pictures and the coding tree units through the relational model further comprises: Step a1: using the perceptual characteristics of the human visual system, the perceptual distortion of each image group, image and coding tree unit is calculated respectively; Step a2: Establish the relationship model R-PWD between the perceptual distortion and the bit rate of each picture group, picture and coding tree unit respectively; Step a3: Calculate the perceptual weighting factors of the image group, image and coding tree unit to be encoded respectively through the relationship model between the perceptual distortion and bit rate of each image group, image and coding tree unit, and perform bit allocation of the image group, image and coding tree unit respectively according to the perceptual weighting factors.
3. The image and video compression method according to claim 2, characterized in that: The calculation method of the perceptual distortion of the image group, image and coding tree unit includes a perceptual distortion calculation method integrating human eye contrast sensitivity, a perceptual distortion calculation method integrating human eye attention mechanism, a perceptual distortion calculation method integrating human eye masking effect, or a combination of two or more perceptual distortion calculation methods.
4. The image and video compression method according to claim 3, characterized in that: The method for calculating the perceptual weight is: using m coding units, the coding units include the PWD and R values of the picture group, the picture and the coding tree unit, and performing the least squares method to adaptively calculate the value of the perceptual weight of the coding unit, and the perceptual weight of each coding unit is constrained between [1.0, 40.0].
