Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in detail below.
Example one
Referring to fig. 1, fig. 1 is a schematic flow chart of an image encoding method according to an embodiment of the present invention; this embodiment describes an image encoding method provided by the present invention in detail, and the method includes the following steps:
step 1, selecting an estimation prediction mode of a current image block by selecting a prediction mode library;
video is a continuous sequence of image frames. For example, to improve the prediction accuracy of image data, an image is generally divided into a plurality of image blocks, and image coding is performed on the image block basis.
Before an image block is encoded, a selective prediction mode library is created, wherein the selective prediction mode library is a database formed by a plurality of predetermined prediction mode candidates, and each prediction mode candidate is a prediction method for a current image block. The number of the prediction mode candidates is multiple, three prediction mode candidates are selected in one embodiment, and the first prediction mode candidate is suitable for prediction of an image with general texture complexity; a second prediction mode candidate, adapted to predict an image of complex texture complexity; and a third prediction mode candidate, adapted to predict an image of simple texture complexity; the first prediction mode candidate is a prediction mode candidate for selecting an optimal reference based on multiple pixel components in the current image block; the second prediction mode candidate is a prediction mode candidate which selects the optimal reference based on different reference windows in the current image block; the third prediction mode candidate is a prediction mode candidate which selects the optimal division based on different division forms of the current image block.
The texture complexity of the current image block is judged by detecting the image characteristic information of the current image block, which specifically comprises the following steps: and calculating the difference value of every two adjacent pixel components in the current image block, and acquiring the gradient value of each current image block according to the difference value of every two adjacent pixel components. The specific calculation formula is as follows:
wherein, Grad represents the gradient value of each current image block, i represents the position index of the pixel component in the current image block, P represents the value of the pixel component in the current image block, and ABS represents absolute value operation. When the value of i is 0, the value represents the pixel component with the position index of 0, i.e. the first pixel component of the first row, and at this time, P is seti-1Is taken as P0I.e. byPi-Pi-1=P0-P0Further, the processing method of the first pixel component of the first row is the same.
Determining the maximum pixel difference value of two pixel components in the current image block according to the bit width of each pixel component in the current image block; for example, if the bit width of each pixel component is 9, the pixel value range of each pixel component is 0 to 511, the maximum pixel difference value of two pixel components in the current image block is 511, and the pixel difference value range of two pixel components in the current image block is 0 to 511. Setting gradient grading according to the maximum pixel difference value of two pixel components in the current image block, wherein the gradient grading can be divided into a plurality of grade intervals; preferably, the first threshold and the second threshold are set, and the first threshold and the second threshold can be manually set according to requirements. Classifying the pixel difference value range interval smaller than a first threshold value into a first-level interval; classifying the pixel difference value range interval which is larger than the first threshold and smaller than the second threshold into a second level interval; and classifying the pixel difference value range interval which is larger than the second threshold value and smaller than the maximum pixel difference value into a third level interval. Judging the level interval of the gradient value of the current image block; and determining the image characteristic information of the current image block according to the level interval of the gradient value of the current image block. Specifically, if the gradient value of the current image block is in the first-level interval, the image feature information of the current image block is simple complexity texture information; if the gradient value of the current image block is in the second-level interval, the image feature information of the current image block is general complexity texture information; and if the gradient value of the current image block is in the third level interval, the image characteristic information of the current image block is complex complexity texture information.
And predicting a prediction mode candidate as an estimated prediction mode for the current image block in the selected prediction mode library by utilizing the image characteristic information. Specifically, if the image feature information of the current image block is the simple complexity texture information, selecting a third prediction mode candidate as an estimated prediction mode; if the image characteristic information of the current image block is general complexity texture information, selecting a first prediction mode candidate as an estimation prediction mode; and if the image characteristic information of the current image block is the complexity texture information, selecting a second prediction mode candidate as an estimation prediction mode.
Step 2, predicting the image data in the current image block according to an estimation prediction mode to obtain residual data of the image data in the current image block;
if the estimated prediction mode is a first prediction mode candidate, predicting the current image block through the first prediction mode candidate, and acquiring image data in the current image block, namely residual data of each pixel component;
if the estimated prediction mode is a second prediction mode candidate, predicting the current image block through the second prediction mode candidate, and acquiring image data in the current image block, namely residual data of each pixel component;
and if the estimated prediction mode is a third prediction mode candidate, predicting the current image block through the third prediction mode candidate, and acquiring image data in the current image block, namely residual data of each pixel component.
And 3, coding the residual data of each pixel component in the current image block acquired in the step 2 and the estimated prediction mode index identifier corresponding to the current image block to form a code stream. And outputting the code stream to an image decoding end.
In the present embodiment, a plurality of prediction mode candidates are defined in advance in a selected prediction mode library, and an estimated prediction mode is selected to encode a current image block. The encoding method does not need to poll each prediction mode, reduces a large amount of calculation, and further improves the encoding compression rate of the video image.
Example two
The present embodiment describes in detail a process of predicting a current image block by the first prediction mode candidate, which is proposed by the present invention, on the basis of the above-described embodiments. The method comprises the following steps:
step 21, for the current image block, defining that the current pixel has K (K >1) pixel components, which are respectively pixel component 1 and pixel component 2 … … pixel component K;
step 22, for each pixel component of the current pixel, determining N texture direction gradient values G1-GN of each pixel component through the surrounding pixel components of the pixel component;
preferably, the surrounding pixel components of the current pixel component may be adjacent to the current pixel component, or may not be adjacent; as shown in fig. 2, fig. 2 is a schematic diagram illustrating positions of a current pixel component and surrounding pixel components according to an embodiment of the present invention; the CUR represents the current pixel component, i.e. the surrounding pixel component may be GHIK or ABCDEFJ.
Step 23, weighting the N texture direction gradient values G1-GN (G1-GN represents both the magnitude and the direction of the texture direction gradient value) of each pixel component to obtain a first weighted gradient value BG weighted by the N texture direction gradient values, wherein the weighting formula is as follows:
BGi=w1*G1+w2*G2+…+wN*GN(i=1…K)
wherein w1 and w2 … wN are weighting coefficients; BG1 is the first weighted gradient value for pixel component 1, BG2 is the first weighted gradient value for pixel component 2, and so on, BGK is the first weighted gradient value for pixel component K.
Preferably, the weighting coefficients w1, w2 … wN are set to obtain the optimal value BGbst of the first weighted gradient value of each pixel component according to the positional relationship of each pixel component and the corresponding pixel for calculating the texture direction gradient value.
Preferably, the closer the pixel for which the current texture direction gradient value is calculated is to the current pixel component, the larger the weighting coefficient value, the total of the weighting coefficient values is 1, specifically w1+ w2+ … + wN is 1.
Step 24, weighting the optimal value BGbst of the first weighted gradient values of the K pixel components to obtain a second weighted gradient value BG ″ weighted by the optimal value of the first weighted gradient value, where the weighting formula is as follows:
BG"i=t1*BGbst1+t2*BGbst2+…+tK*BGbstK(i=1…K)
wherein t1 and t2 … tK are weighting coefficients; BGbst1 is the optimal value of the first weighted gradient value of the pixel component 1, BGbst2 is the optimal value of the first weighted gradient value of the pixel component 2, and so on, BGbstK is the optimal value of the first weighted gradient value of the pixel component K, BG "1 is the second weighted gradient value of the pixel component 1, BG"2 is the second weighted gradient value of the pixel component 2, and so on, BG "K is the second weighted gradient value of the pixel component K, and the optimal value BG" bst of the second weighted gradient value BG "is determined.
Preferably, the weighting coefficients t1, t2 … tK are set to obtain the optimal value BGbst of the second weighted gradient value for each pixel component according to the relationship of each pixel component and the optimal value BGbst corresponding to the first weighted gradient value.
Preferably, the weighting coefficient value BGbst, which is the optimal value of the first weighting gradient value at the current pixel component, is the largest, the weighting coefficient value BGbst, which is the optimal value of the first weighting gradient value at other pixel components having increasing distances from the current pixel component, is gradually decreased, and the sum of the weighting coefficient values is 1, specifically, t1+ t2+ … + tk is 1.
The direction of the optimal value BG "bst of the second weighted gradient value is the reference direction Dir of the current pixel component.
Step 25, weighting the pixel values of all available pixel components in the reference direction of each pixel component to obtain a reference value Ref of each pixel component, where the weighting formula is as follows:
Refi=r1*cpt1+r2*cpt2+…+rN*cptN(i=1…K)
wherein r1 and r2 … rN are weighting coefficients, which may be the same or different; cpt 1-cptN are the pixel values of the N available pixel components in the reference direction of each pixel component; ref1 is the reference value for pixel component 1, Ref2 is the reference value for pixel component 2, and so on, and RefK is the reference value for pixel component K.
26, subtracting the reference value from the current pixel component pixel value to obtain a prediction residual Dif of the current pixel component pixel; the formula is as follows:
Difi=Curcpti-Refi(i=1…K)
wherein, cutcpt 1 is the pixel value of pixel component 1, cutcpt 2 is the pixel value of pixel component 2, and so on, and cutcptk is the pixel value of pixel component K; dif1 is the prediction residual for pixel component 1, Dif2 is the prediction residual for pixel component 2, and so on, DifK is the prediction residual for pixel component K.
And 27, repeating S22-S26 for the rest pixel components of the current pixel to obtain the prediction residuals of all the pixel components of the pixel, so as to obtain the prediction residuals of each pixel component in the current image block.
Preferably, the multi-pixel components can be processed in parallel or in series, as required by a specific application specification scenario.
In one embodiment, the present pixel is divided into Y, U, V pixel components as an example, and the specific steps are as follows:
step 31, defining that the current pixel has three pixel components, namely a pixel component Y, a pixel component U and a pixel component V;
step 32, for three pixel components of the current pixel, determining 3 texture direction gradient values G1, G2, G3 of each pixel component through the surrounding pixel components of each pixel component;
preferably, as for the pixel component Y, the pixel component U, and the pixel component V, respectively according to fig. 3, fig. 3 is a schematic diagram of gradient value calculation according to an embodiment of the present invention; ABS (K-H) is a 45-degree gradient value, ABS (K-G) is a 90-degree gradient value, ABS (K-F) is a 135-degree gradient value, and ABS (K-J) is a 180-degree gradient value. Wherein ABS is an absolute value operation.
And step 33, weighting the 3 texture direction gradient values G1, G2 and G3 in the step 32, such as 45-degree gradient values, 90-degree gradient values and 135-degree gradient values, for each pixel component Y, U and V to obtain a first weighted gradient value BG of each pixel component, and solving an optimal value of the first weighted gradient value BG of each pixel component.
Preferably, for example, for the Y pixel component, the distances between the pixel H at 45 degree gradient value, the pixel G at 90 degree gradient value and the pixel F at 135 degree gradient value and the Y pixel component gradually increase, so w1 is 0.5, w2 is 0.3, w3 is 0.2, BGbstY is 0.5 × G1+0.3 × G2+0.2 × G3. BGbstU and BGbstV can be obtained by the same method.
And step 34, weighting the optimal gradient value of the first weighted gradient values of the 3 pixel components to obtain a second weighted gradient value BG 'weighted by the optimal value of the first weighted gradient value, and selecting the optimal value BG' bst of the second weighted gradient value. The weighting is calculated as follows:
BG"bstY=0.5*BGbstY+0.3*BGbstU+0.2*BGbstV
BG"bstU=0.3*BGbstY+0.4*BGbstU+0.3*BGbstV
BG"bstV=0.2*BGbstY+0.3*BGbstU+0.5*BGbstV
wherein BG ' bstY is the optimum value of the second weighting gradient value of the pixel component Y, BG ' bstU is the optimum value of the second weighting gradient value of the pixel component U, BG ' bstV is the optimum value of the second weighting gradient value of the pixel component V, BGbstY is the optimum value of the first weighting gradient value of the pixel component Y, BGbstU is the optimum value of the first weighting gradient value of the pixel component U, BGbstV is the optimum value of the first weighting gradient value of the pixel component V.
The coefficient selection rule in the above formula is that the optimal value BGbst of the first weighting gradient value under the current pixel component has the largest weighting coefficient value, the optimal value BGbst of the first weighting gradient value under other pixel components whose distances from the current pixel component gradually increase gradually decreases gradually, and the sum of the weighting coefficient values is 1.
The BG "bst direction is the reference direction Dir of the current pixel component, i.e. DirY is the reference direction of the pixel component Y, DirU is the reference direction of the pixel component U, and DirV is the reference direction of the pixel component V.
Step 35, weighting the pixel values of 2 pixel components in the reference direction of the 3 pixel components to obtain the reference value Ref of the 3 pixel components, where the weighting formula is as follows:
RefY=r1*cpt1+r2*cpt2
RefU=r1*cpt1+r2*cpt2
RefV=r1*cpt1+r2*cpt2
wherein, RefY is a reference value of the Y pixel component, RefU is a reference value of the U pixel component, RefV is a reference value of the V pixel component, and cpt1, cpt2 are pixel component pixel values of each reference direction.
Preferably, for any pixel component, if it is 45 degrees reference, the reference value REF is 0.8 × I + 0.2E; if 90 degrees reference, the reference value is 0.8 × H + 0.2C; if 135 degrees reference, the reference value is 0.8G + 0.2A; if the reference value is 180 degrees, the reference value is 0.8 × K +0.2J, and the closer the pixel value of the pixel component is to the current pixel, the larger the configuration coefficient is.
Step 36, subtracting the reference value from the pixel value of the current pixel component to obtain the prediction residual difference Dif of the pixel component of the current pixel, which is calculated as follows:
DifY=CurcptY-RefY
DifU=CurcptU-RefU
DifV=CurcptV-RefV
wherein, cutpty is a pixel value of the pixel component Y, cutptu is a pixel value of the pixel component U, and cutptv is a pixel value of the pixel component V; DifY is the prediction residual of the pixel component Y, DifU is the prediction residual of the pixel component U, and DifV is the prediction residual of the pixel component V.
1. According to the embodiment, the prediction direction of the current pixel component can be more reasonably determined through the multi-directional gradient weighting of each pixel component and the direction weighting of the multi-pixel component at the same position, and a better prediction direction deviation rectifying effect can be achieved for the image with simple texture complexity. In addition, the method can balance the texture prediction directions between the pixel components at the same position and between the adjacent multi-pixel components of the same pixel component, reduce the possibility of misjudgment of single pixel component prediction, and finally further reduce the theoretical limit entropy of prediction.
2. The embodiment performs parallel processing on multiple pixel components, and is more beneficial to realizing the parallel processing of the prediction method. Compared with the long time and low efficiency of serial pixel component processing, the parallel processing can improve the processing speed by times, and is beneficial to the hardware realization of the prediction algorithm.
EXAMPLE III
The present embodiment describes in detail a process of predicting a current image block by the second prediction mode candidate according to the present invention on the basis of the above-described embodiments. The method comprises the following steps:
101. a plurality of predicted search windows is determined.
Referring to fig. 4 to 6, fig. 4 to 6 are schematic diagrams of pixel indexes and numbers of reconstructed pixels of three prediction search windows provided by an embodiment of the present invention. Fig. 4(a) and fig. 4(b) are a schematic diagram of a pixel index and a schematic diagram of a reconstructed pixel search number of a horizontal stripe prediction search window according to an embodiment of the present invention; fig. 5(a) and fig. 5(b) are a schematic diagram of a pixel index and a schematic diagram of a reconstructed pixel search number of a vertical stripe prediction search window according to an embodiment of the present invention; fig. 6(a) and fig. 6(b) are a schematic diagram of pixel index and a schematic diagram of reconstructed pixel search number of a rectangular prediction search window according to an embodiment of the present invention.
With CijRepresenting the current pixel, PijRepresenting the encoded reconstructed pixels. Where ij is the position index of the current pixel or the reconstructed pixel. A plurality of sliding windows are set as the prediction search windows, and the shapes of the prediction search windows can be horizontal strips, vertical strips, L-shaped, cross-shaped, T-shaped, rectangular and the like.
With reference to fig. 4 to 6, in the embodiment of the present invention, a plurality of prediction search windows with the same size and different shapes are set, for example, a first prediction search window, a second prediction search window, and a third prediction search window, respectively. The first prediction search window is a horizontal bar prediction search window, the window is in the shape of a horizontal bar, the second prediction search window is a vertical bar prediction search window, the window is in the shape of a vertical bar, the third prediction search window is a rectangular prediction search window, and the window is in the shape of a rectangle. The three prediction search windows are the same in size and each contain K pixels. Preferably, the plurality of prediction search windows each contain 8 pixels. E.g. the current pixel C within a first prediction search window, i.e. a horizontal stripe prediction search windowijAt the rightmost position, the other positions in the first prediction search window are encoded K-1 reconstructed pixels Pi-1,j、Pi-2,j、Pi-3,j、Pi-4,j、Pi-5,j、Pi-6,j、Pi-7,j(ii) a Within the second prediction search window, the vertical slice prediction search window, the current pixel CijAt the lowest position, and the other positions in the second prediction search window are the encoded K-1 reconstructed pixels Pi,j-1、Pi,j-2、Pi,j-3、Pi,j-4、Pi,j-5、Pi,j-6、Pi,j-7(ii) a Within a third, rectangular prediction search window, the current pixel CijAt the lower right corner, and the other positions in the third prediction search window are encoded K-1 reconstructed pixels Pi-1,j、Pi-2,j、Pi-3,j、Pi,j-1、Pi-1,j-1、Pi-2,j-1、Pi-3,j-1. For the current pixel CijWhen prediction is carried out, the current pixel C is predicted according to reconstruction values NewData (P) of K-1 reconstruction pixels in the first prediction search window, the second prediction search window and the third prediction search window respectivelyijReconstructed value of (C) NewDataij) Three reconstructed values NewData1 (C) are obtainedij)、NewData2(Cij)、NewData3(Cij) Wherein NewData1 (C)ij) For the current pixel C calculated in the first prediction search windowijFirst reconstructed value of (a), NewData2 (C)ij) For the current pixel C calculated in the second prediction search windowijSecond reconstructed value of (1), NewData3 (C)ij) For the current pixel C calculated in the third prediction search windowijAnd (3) a third reconstructed value.
In the embodiment of the invention, in each prediction search window, the current pixel C is predicted according to the reconstruction values of K-1 reconstruction pixelsijWhen the reconstruction value is obtained, sequentially numbering K-1 reconstruction pixels in the prediction search window into 0, 1, 2, K0、P1、P2、...Pk...、PK-2A sequential search is performed. For example, the first prediction search window of the embodiment of the present invention includes 7 reconstructed pixels arranged along the horizontal direction, the 7 reconstructed pixels are numbered from left to right, the number is from 0 to 6, and the 6 reconstructed pixels P are numbered0、P1、P2、P3、P4、P5、P6From the reconstructed pixel P numbered 00The search is started until the reconstructed pixel P with number 6 is searched6Looking for the current pixel CijThe first prediction residual is calculated. The second prediction search window comprises 7 reconstructed pixels along the vertical directionThe direction is arranged, 7 reconstruction pixels are numbered from top to bottom, the number is from 0 to 6, and the 6 reconstruction pixels P are numbered0、P1、P2、P3、P4、P5、P6From the reconstructed pixel P numbered 00The search is started until the reconstructed pixel P with number 6 is searched6Looking for the current pixel CijAnd calculating a second prediction residual. The third prediction search window comprises 7 reconstructed pixels which are arranged in a 4 multiplied by 2 matrix, the 7 reconstructed pixels are numbered from 0 to 6, and the 6 reconstructed pixels P are numbered0、P1、P2、P3、P4、P5、P6From the reconstructed pixel P numbered 00The search is started until the reconstructed pixel P with number 6 is searched6Looking for the current pixel CijAnd calculating a third prediction residual. Calculating the current pixel C in a plurality of prediction search windows respectivelyijThe method of predicting a plurality of residuals is described as follows.
102. Determining a current pixel CijN pixel components.
Setting a current pixel C
ijComprising N pixel components of
Wherein N is a natural number greater than 1,
represents the current pixel C
ijThe nth pixel component of (1). For example, the current pixel C
ijMay comprise 3 pixel components RGB, or 4 pixel components RGBW, or 3 pixel components Lab, or 3 pixel components YUV, or 4 pixel components CMYK.
103. Computing a current pixel C within a plurality of predictive search windowsijA plurality of weights Wij. The plurality of weights includes a first weight, a second weight, and a third weight. Current pixel C calculated in a first predictive search window, such as a horizontal stripe predictive search windowijWeight W ofijIs firstWeight, current pixel C calculated in a second predictive search window, e.g. a vertical slice predictive search windowijWeight W ofijFor the second weight, the current pixel C is calculated in a third prediction search window, such as a rectangular prediction search windowijWeight W ofijIs the third weight. In particular, the current pixel C is calculated within each prediction windowijWeight W ofijThe method of (1) is as follows:
within the prediction search window, corresponding to K-1 encoded reconstructed pixels P0、P1、P2、...Pk...、PK-2Weight WijComprising K-1 sub-weights, i.e.
Wij={Wij、0,Wij、1,Wij、2,...Wij、k...,Wij、K-2}
Wherein, W
ij、kIs the current pixel C
ijCorresponding to the encoded reconstructed pixel P
kSub-weights of (c). Sub-weight W
ij、kIs the current pixel C
ijOf N pixel components
Relative reconstructed pixel P
kOf N pixel components
N component sub-weights
The result of the weighted summation is
Wherein the content of the first and second substances,
is the current pixel C
ijOf the nth pixel component
Relative reconstructed pixel P
kOf the nth pixel component
The weight of the component(s) of (c),
are component weighted values and satisfy
In one embodiment of the present invention,
is taken as
In another embodiment of the invention, the pixel components are based on
Respectively with N pixel components
Is determined according to the distance, the closer the distance is, the corresponding distance is
The larger; in yet another embodiment of the invention, the determination is empirically determined
The value of (a).
In the embodiment of the invention, the current pixel CijWeight W ofijFrom the current pixel CijDiff weight DIF ofijAnd (4) determining. Corresponding to K-1 encoded reconstructed pixels P0、P1、P2、...Pk...、PK-2Difference degree weight DIFijWith K-1 diff sub-weights DIFij、kI.e. by
DIFij={DIFij、0,DIFij、1,DIFij、2,...DIFij、k...,DIFij、K-2}
The method for determining the weight provided by one embodiment of the invention comprises the following steps:
1031. calculating the current pixel C
ijPixel component of
Component disparity weighting with respect to pixel components of reconstructed pixels
Each pixel component
Component difference degree weight of
With K-1 component difference degree sub-weights
Namely, it is
Wherein the component difference degree sub-weight
According to the current pixel C
ijPixel component of
And a reconstructed pixel P
kPixel component of
Is determined.
Preferably, in the embodiment of the present invention, the component difference degree sub-weight
As pixel components
Original value of
And reconstructing the pixel components
Is a reconstructed value of
Of the absolute value of the difference, i.e.
1032. Calculating the current pixel C
ijWith respect to each reconstructed pixel P
kSub-weight W of
ij、k. Current pixel C
ijRelative reconstructed pixel P
kSub-weight W of
ij、kIs the current pixel C
ijOf N pixel components
Relative reconstructed pixel P
kOf N pixel components
N component difference degree sub-weights
Weighted summation, i.e.
Wherein the content of the first and second substances,
is the current pixel C
ijOf the nth pixel component
Relative reconstructed pixel P
kOf the nth pixel component
The component difference degree sub-weights of (a),
are component weighted values and satisfy
In one embodiment of the present invention,
is taken as
In another embodiment of the invention, the pixel components are based on
Respectively with N pixel components
Is determined according to the distance, the closer the distance is, the corresponding distance is
The larger; in yet another embodiment of the invention, the determination is empirically determined
The value of (a).
1033. Calculating the current pixel CijWeight W ofij. Then the weight is
104. According to a plurality of weights WijDetermining a current pixel CijAnd calculating a plurality of prediction residuals. The plurality of reference pixels include, for example, a first reference pixel, a second reference pixel, and a third reference pixel; the plurality of prediction residuals includes, for example, a first prediction residual, a second prediction residual, and a third prediction residual. In particular, the current pixel C is determined according to the first weightijCalculating to obtain a first prediction residual error; determining the current pixel C according to the second weightijCalculating to obtain a second prediction residual error; determining the current pixel C according to the third weightijAnd calculating to obtain a third prediction residual. Specifically, the method for calculating each prediction residual includes the following steps:
1041. according to weight WijDetermining a current pixel CijReference pixel P ofs. In particular, the slave weight W is calculated according to an optimal algorithmijK-1 sub-weights W ofij、kSelecting an optimal value, and reconstructing a pixel P corresponding to the optimal valuesAs the current pixel CijThe reference pixel of (2). The optimum value determining algorithm is, for example, a minimum weight determining algorithm, i.e. from the weight Wij={Wij、0,Wij、1,Wij、2,...Wij、k...,Wij、K-2Selecting the minimum value of the sub-weights, such as W, from K-1 sub-weights ofij、sCorresponding reconstructed pixel PsTo reconstruct the pixel PsAs the current pixel CijThe reference pixel of (2).
1042. Calculating the current pixel CijPrediction residual RES ofij. In particular, according to the reference pixel, i.e. PsReconstructed value of (N)s) Encoding a pixel C with the current pixelijOriginal value of (C) OldDataij) Calculating the current pixel CijRelative reference pixel PsPrediction residual RES ofijIs a
Wherein the content of the first and second substances,
is the current pixel C
ijOf the nth pixel component
Relative reference pixel P
sOf the nth pixel component
The prediction residual of (2).
Through the steps 101-104, the current pixel C is found in a plurality of prediction search windowsijAnd calculating to obtain a plurality of prediction residuals. E.g. finding the current pixel C within a first predictive search windowijFirst reference pixel Ps1And calculating to obtain a first prediction residual RESij1(ii) a Finding the current pixel C within the second predictive search windowijSecond reference pixel Ps2And calculating to obtain a second prediction residual RESij2(ii) a Finding the current pixel C within the third predictive search windowijThird reference pixel Ps3And calculating to obtain a third prediction residual RESij3。
105. Comparing the plurality of prediction residuals to determine an optimal prediction residual RESij_PerfAnd corresponding optimal reference pixel Ps_Perf. In a plurality of prediction residuals, e.g. a first prediction residual RESij1Second prediction residual RESij2Third prediction residual RESij3Determining the minimum prediction residual according to the minimum algorithm, and taking the minimum prediction residual as the current pixel CijIs best predicted residual RESij_PerfTaking the reference pixel corresponding to the minimum prediction residual as the current pixel CijIs optimized to the reference pixel Ps_Perf. The prediction residual of the current pixel is the prediction residual of each pixel component of the current pixel, and the prediction residual may also be referred to as residual data.
The difference in one embodiment is that step 103 computes the current pixel C within multiple prediction search windowsijA plurality of weights WijTime, weight WijDIF is weighted by the disparity of the current pixelijAnd location weight POSijAnd (4) jointly determining. Corresponding to K-1 encoded reconstructed pixels P0、P1、P2、...Pk...、PK-2Difference degree weight DIFijWith K-1 diff sub-weights DIFij、kLocation weighted POSijWith K-1 position sub-weights POSij、kI.e. by
DIFij={DIFij、0,DIFij、1,DIFij、2,...DIFij、k...,DIFij、K-2}
POSij={POSij、0,POSij、1,POSij、2,...POSij、k...,POSij、K-2}
Another method for determining a weight provided in the embodiment of the present invention includes the following steps:
1034. calculating pixel components of a current pixel
Component disparity weighting with respect to pixel components of reconstructed pixels
Each pixel component
Component difference degree weight of
With K-1 component difference degree sub-weights
Namely, it is
Wherein the component difference degree sub-weight
According to the current pixel C
ijPixel component of
And a reconstructed pixel P
kPixel component of
Is determined.
Preferably, in the embodiment of the present invention, the component difference degree sub-weight
As pixel components
Original value of
And reconstructing the pixel components
Is a reconstructed value of
Of the absolute value of the difference, i.e.
1035. Calculating pixel components of a current pixel
Component position weighting of pixel components relative to reconstructed pixels
Each pixel component
Component position weight of
With K-1 component positions sub-weights
Namely, it is
Wherein the component position sub-weights
According to the current pixel C
ijAnd a reconstructed pixel P
kIs determined.
Referring to fig. 7, fig. 7 is a schematic diagram of predicting position sub-weights in a search window according to an embodiment of the present invention. In the embodiment of the invention, the current pixel C is used
ijAnd a reconstructed pixel P
kThe number of pixels spaced apart as the component position sub-weight
Corresponding to K-1 reconstructed pixels P in the prediction search window
0、P
1、P
2、...P
k...、P
K-2E.g. with the current pixel C
ijAdjacent reconstructed pixel P
6And C
ijIf the number of interval pixels is 0, determining the sub-weight of the corresponding component position as
Reconstruction pixel P
5And C
ijIf the number of interval pixels is 1, determining the sub-weight of the corresponding component position as
Similarly, corresponding to 7 reconstructed pixels P
0、P
1、P
2、P
3、P
4、P
5、P
6The 7 component position sub-weights of (1):
1036. calculating pixel components of a current pixel
Component weight of (2)
Each pixel component
Component weight of (2)
With K-1 component sub-weights
Namely, it is
Wherein the component sub-weights are
Wherein the content of the first and second substances,
and
are respectively a difference weighted value and a position weighted value, anSatisfy the requirement of
In one embodiment of the invention, take
In another embodiment of the invention, according to
Is determined to correspond to
The value of (a) is,
the larger, the
The smaller; according to
Is determined by the size of
The value of (a) is,
the larger, the
The smaller. In a further embodiment of the present invention,
and
is determined from empirical values.
1037. Calculating the current pixel C
ijWith respect to each reconstructed pixel P
kSub-weight W of
ij、k. Current pixel C
ijRelative reconstructed pixel P
kSub-weight W of
ij、kIs the current pixel C
ijOf N pixel components
Relative reconstructed pixel P
kOf N pixel components
N component sub-weights
Weighted summation, i.e.
Wherein the content of the first and second substances,
are component weighted values and satisfy
In one embodiment of the present invention,
is taken as
In another embodiment of the invention, the pixel components are based on
Respectively with N pixel components
Is determined according to the distance, the closer the distance is, the corresponding distance is
The larger; in yet another embodiment of the invention, the determination is empirically determined
The value of (a).
1038. Calculating the current pixel CijThe weight of (1) is then
In one embodiment, the difference is that after step 105, the method further comprises:
106. outputting the optimal reference pixel P of the current pixels_PerfPosition information of (2) and optimal prediction residual RESij_Perf. Optimal reference pixel Ps_PerfMay be the optimal reference pixel Ps_PerfThe position index ij or the number s.
In summary, in the prediction mode of the embodiment of the present invention, a plurality of reference pixels are found by using prediction search windows of various shapes, and a plurality of prediction residuals are obtained by calculation, and an optimal prediction residual is selected from the plurality of prediction residuals. For complex texture images, the prediction effect is better, and the theoretical limit entropy is reduced.
Example four
The present embodiment describes in detail a process of predicting a current image block by a third prediction mode candidate, which is proposed by the present invention, on the basis of the above-described embodiments. The method comprises the following steps:
as shown in fig. 8a to 8c, fig. 8a to 8c are schematic diagrams illustrating different division manners provided by an embodiment of the invention; the method comprises the steps of dividing a current image block according to different division modes, specifically, dividing the current image block into an upper image block and a lower image block according to a horizontal division mode; dividing a current image block into a left image block and a right image block according to a vertical division mode; and partitioning the current image block according to a non-partitioning mode.
And respectively calculating different prediction residuals corresponding to the current image block in different segmentation modes. Specifically, for the horizontal division mode, subtracting the minimum value of the pixel components of the upper image block from all the pixel components of the upper image block to obtain the prediction residuals of all the pixel components of the upper image block; calculating the lower image block in the same way, subtracting the minimum value of the pixel components of the lower image block from all the pixel components of the lower image block to obtain the prediction residual errors of all the pixel components of the lower image block, and finally obtaining the first prediction residual errors of all the pixel components of the current image block; for the vertical division mode, subtracting the minimum value of the pixel components of the left image block from all the pixel components of the left image block to obtain the prediction residual errors of all the pixel components of the left image block; the right image block is calculated in the same way, the minimum value of the pixel components of the right image block is subtracted from all the pixel components of the right image block to obtain the prediction residual errors of all the pixel components of the right image block, and finally the second prediction residual errors of all the pixel components of the current image block are obtained; and for the non-segmentation mode, subtracting the minimum value of the pixel components in the current image block from the pixel components in the current image block to finally obtain a third prediction residual of all the pixel components of the current image block.
And respectively calculating different bit numbers corresponding to the current image block under different segmentation modes. Specifically, for the horizontal division mode, a first difference between a maximum value of a pixel component in an upper image block and a minimum value of the pixel component in the upper image block is calculated to obtain a first minimum bit number representing the first difference, a second difference between a maximum value of the pixel component in a lower image block and a minimum value of the pixel component in the lower image block is calculated to obtain a second minimum bit number representing the second difference, a first bit number is obtained according to the first minimum bit number, the second minimum bit number and a bit depth of original data of a current image block, and the first bit number satisfies the following formula:
MBIT1=N1*BIT_MIN1+N2*BIT_MIN2+2*BITDEPTH
where MBIT1 is the first BIT number, BIT _ MIN1 is the first minimum BIT number, N × BIT _ MIN2 is the second minimum BIT number, BITDEPTH is the BIT depth of the original data of the current image block, N1 is the number of pixel components in the upper image block, and N2 is the number of pixel components in the lower image block.
For the vertical division mode, calculating a third difference value between the maximum value of the pixel component in the left image block and the minimum value of the pixel component in the left image block to obtain a third minimum bit number representing the third difference value, calculating a fourth difference value between the maximum value of the pixel component in the right image block and the minimum value of the pixel component in the right image block to obtain a fourth minimum bit number representing the fourth difference value, and obtaining a second bit number according to the third minimum bit number, the fourth minimum bit number and the bit depth of original data of the current image block, wherein the second bit number satisfies the following requirements:
MBIT2=N3*BIT_MIN3+N4*BIT_MIN4+2*BITDETH
where MBIT2 is the second BIT number, BIT _ MIN3 is the third minimum BIT number, BIT _ MIN4 is the fourth minimum BIT number, BITDEPTH is the BIT depth of the original data of the current image block, N3 is the number of pixel components in the left image block, and N4 is the number of pixel components in the right image block.
For the non-segmentation mode, calculating a fifth difference value between the maximum value of the pixel component in the current image block and the minimum value of the pixel component in the current image block to obtain a fifth minimum bit number representing the fifth difference value, and obtaining a third bit number according to the fifth minimum bit number and the bit depth of the original data of the current image block, wherein the third bit number satisfies:
MBIT3=M*BIT_MIN5+2*BITDETH
where MBIT3 is the third BIT number, BIT _ MIN5 is the fifth minimum BIT number, BITDEPTH is the BIT depth of the original data of the current image block, and M is the number of pixel components in the current image block.
Selecting a segmentation mode according to different prediction residuals and different bit numbers, specifically, for a horizontal segmentation mode, obtaining a first reconstruction value of a current image block according to a first prediction residual, obtaining a first reconstruction difference value by calculating an absolute value of a difference between the first reconstruction value and an original value of the current image block, and calculating the first reconstruction difference value by using the first reconstruction difference value
And weighting the first bit number to obtain a first weighted value of the current image block in a horizontal segmentation mode, wherein the first weighted value satisfies the following formula:
RDO1=a*MBIT1+b*RES1
here, RDO1 is a first weight value, MBIT1 is a first number of bits, RES1 is a first reconstruction difference value, and a and b are weighting coefficients.
The values of a and b may be preset fixed values, further, a + b is 1, preferably, a may be selected to be 0.5, b may be selected to be 0.5, and a and b may also be flexibly adjusted in size.
For the vertical segmentation mode, a second reconstruction value of the current image block is obtained according to a second prediction residual error, an absolute value of a difference between the second reconstruction value and an original value of the current image block is obtained to obtain a second reconstruction difference value, the second reconstruction difference value and a second bit number are weighted to obtain a second weighted value of the current image block in the vertical segmentation mode, wherein the second weighted value meets the following formula:
RDO2=a*MBIT2+b*RES2
here, RDO2 is the second weighted value, MBIT2 is the second bit number, RES2 is the second reconstructed difference value, and a and b are weighting coefficients.
The values of a and b may be preset fixed values, further, a + b is 1, preferably, a may be selected to be 0.5, b may be selected to be 0.5, and a and b may also be flexibly adjusted in size.
For the non-segmentation mode, obtaining a third reconstruction value of the current image block according to a third prediction residual error, obtaining a third reconstruction difference value by calculating an absolute value of a difference between the third reconstruction value and an original value of the current image block, and weighting the third reconstruction difference value and a third bit number to obtain a third weighted value of the current image block in the non-segmentation mode, wherein the third weighted value satisfies the following formula;
RDO3=a*MBIT3+b*RES3
the RDO3 is a third weighted value, the MBIT3 is a third bit number, the RES3 is a third reconstruction difference value, and a and b are weighting coefficients.
The values of a and b may be preset fixed values, further, a + b is 1, preferably, a may be selected to be 0.5, b may be selected to be 0.5, and a and b may also be flexibly adjusted in size.
And selecting a partition mode corresponding to the minimum value of the first weighted value, the second weighted value and the third weighted value as a final partition mode, wherein the predicted residual error under the partition mode is a final predicted residual error. The prediction residual may also be referred to as residual data.
The prediction mode provided by the embodiment predicts through the correlation among the pixel component values of the current region, compares the compressed data amount of the three conditions of horizontal segmentation, vertical segmentation and non-segmentation by using the algorithm of the invention, selects the corresponding optimal segmentation mode to perform residual prediction so as to minimize the difference between the initial image block and the predicted image block, thereby improving the compression efficiency and the subjective picture quality.
EXAMPLE five
This embodiment describes in detail an image encoding device proposed by the present invention on the basis of the above-described embodiment, the device including:
the selector is used for selecting the estimation prediction mode of the current image block by selecting the prediction mode library; wherein, the selected prediction mode database is a database formed by a plurality of predetermined prediction mode candidates;
the predictor is used for predicting the image data in the current image block according to the estimation prediction mode to obtain residual data of the image data in the current image block;
and the encoder is used for encoding the residual data and the corresponding estimated prediction mode index identification to form a code stream.
Wherein the selected prediction mode library in the selector comprises a first prediction mode candidate, a second prediction mode candidate and a third prediction mode candidate; the first prediction mode candidate is a prediction mode candidate for selecting an optimal reference based on multiple pixel components in the current image block; the second prediction mode candidate is a prediction mode candidate which selects the optimal reference based on different reference windows in the current image block; and the third prediction mode candidate is a prediction mode candidate which selects the optimal division based on different division forms of the current image block.
Wherein the selecting of the estimated prediction mode in the selector comprises:
detecting image characteristic information of the current image block;
and predicting a prediction mode candidate for the current image block in a selected prediction mode library by using the image characteristic information as an estimated prediction mode of the current image block.
Wherein the predictor is specifically configured to:
if the estimated prediction mode is the first prediction mode candidate, predicting the current image block through the first prediction mode candidate to obtain residual data of image data in the current image block;
if the estimated prediction mode is the second prediction mode candidate, predicting the current image block through the second prediction mode candidate to obtain residual data of image data in the current image block;
if the estimated prediction mode is the third prediction mode candidate, predicting the current image block through the third prediction mode candidate, and acquiring residual data of image data in the current image block.
In summary, the present invention has been explained by using specific examples, and the above description of the embodiments is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention, and the scope of the present invention should be subject to the appended claims.