Weighted chroma prediction method, image coding and decoding method, codec and medium

By dividing the template candidate range of the current block into multiple sub-regions, selecting a suitable sub-region as the template area, determining the weight coefficient based on the difference value of the brightness reference pixel for weighted chromaticity prediction, the problem of insufficient adaptability to diverse image content in the prior art is solved, and more flexible and accurate prediction is achieved.

CN116016918BActive Publication Date: 2025-08-29ZHEJIANG DAHUA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211471130.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-21
Publication Date
2025-08-29
Estimated Expiration
2042-11-21

AI Technical Summary

Technical Problem

In the prior art, the weighted chromaticity prediction method is insufficient to adapt to the content of a diverse image, and fixed reference pixel areas lead to inflexibility in prediction.

Method used

The template candidate range of the current block is divided into multiple sub-regions, and the appropriate sub-regions are selected as the template area, and the weight coefficient is determined based on the difference of the brightness reference pixel, and weighted chromaticity prediction is performed to adapt to different image contents.

Benefits of technology

Flexible prediction of diverse image content is achieved, and the accuracy and adaptability of predictions are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116016918B_ABST
    Figure CN116016918B_ABST
Patent Text Reader

Abstract

The present application discloses a weighted chroma prediction method, an image encoding and decoding method, a codec and a medium. The weighted chroma prediction method includes: dividing the template candidate range of the current block into multiple sub-regions, selecting at least one sub-region as the template region of the current block; sampling the luminance reference pixels in the template region to obtain the sampled luminance reference pixels; sampling the current luminance block corresponding to the current block to obtain the sampled current luminance block; determining the weight coefficient of each luminance pixel in the sampled current luminance block corresponding to each sampled luminance reference pixel based on the difference between each luminance pixel in the sampled current luminance block and each sampled luminance reference pixel; predicting the chroma prediction block corresponding to the current chroma block based on the weight coefficient and the chroma reference pixel corresponding to each sampled luminance reference pixel. The above scheme can adapt to diverse image content.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of video image coding and decoding, and in particular to a weighted chrominance prediction method, an image coding and decoding method, a codec, and a medium. Background Art

[0002] Video image data is relatively large, and pixel data (RGB, YUV, etc.) often needs to be compressed. This compressed data is called a video stream, which is transmitted to the user via a wired or wireless network for decoding and viewing. The entire video encoding process includes prediction, transformation, quantization, and encoding. The most commonly used color encoding methods in video encoding are YUV and RGB. In YUV, Y represents brightness, or the grayscale value of the image, while U and V (i.e., Cb and Cr) represent chrominance, describing the image's color and saturation. Each Y luminance block corresponds to a Cb and a Cr chrominance block, and each chrominance block corresponds to only one luminance block.

[0003] Weighted chroma prediction (WCP) is a method that uses the difference between the current luminance component pixel and the reference pixel to obtain the weight and uses it to predict the current chroma component. The reference pixel area used in the existing technology is fixed, and the upper and left adjacent reference pixels are used at the same time. This is not flexible enough for diverse image content. Summary of the Invention

[0004] The main technical problem solved by this application is to provide a weighted chrominance prediction method, image encoding and decoding method, codec and medium that can adapt to diverse image content.

[0005] To solve the above problems, the first aspect of the present application provides a weighted chrominance prediction method, the method comprising: dividing a template candidate range of a current block into multiple sub-regions, selecting at least one sub-region from the multiple sub-regions as a template region of the current block; sampling luma reference pixels in the template region based on the number and shape of chroma reference pixels in the template region to obtain sampled luma reference pixels; wherein the number and shape of the sampled luma reference pixels are the same as the number and shape of the sampled chroma reference pixels; sampling a current luma block corresponding to the current block based on the size of a current chroma block corresponding to the current block to obtain a sampled current luma block; wherein the size of the sampled current luma block is the same as the size of the current chroma block; determining a weight coefficient for each luma pixel in the sampled current luma block corresponding to each sampled luma reference pixel based on a difference between each luma pixel in the sampled current luma block and each sampled luma reference pixel; and predicting a chroma prediction block corresponding to the current chroma block based on the weight coefficient and the chroma reference pixel corresponding to each sampled luma reference pixel.

[0006] Among them, dividing the template candidate range of the current block into multiple sub-regions and selecting at least one sub-region from the multiple sub-regions as the template region of the current block includes: dividing the template candidate range of the current block into multiple sub-regions; arbitrarily combining at least some of the multiple sub-regions to obtain combined template regions corresponding to multiple prediction sub-modes; selecting a target prediction sub-mode from the multiple prediction sub-modes, and using the combined template region corresponding to the target prediction sub-mode as the template region of the current block.

[0007] Wherein, said dividing the template candidate range of the current block into a plurality of said sub-regions includes: dividing the reconstructed pixels above the current block into a first sub-region, and dividing the reconstructed pixels on the left side of the current block into a second sub-region; said arbitrarily combining at least part of the plurality of said sub-regions to obtain a plurality of combined template regions corresponding to prediction sub-modes includes: taking the first sub-region as a combined template region corresponding to a first prediction sub-mode; taking the second sub-region as a combined template region corresponding to a second prediction sub-mode; and taking the combination of the first sub-region and the second sub-region as a combined template region corresponding to a third prediction sub-mode.

[0008] Among them, the method of selecting a target prediction sub-mode from the multiple prediction sub-modes and using the combined template area corresponding to the target prediction sub-mode as the template area of ​​the current block includes: using the combined template areas corresponding to the first prediction sub-mode, the second prediction sub-mode and the third prediction sub-mode as the template area of ​​the current block, and calculating the chroma prediction blocks under the first prediction sub-mode, the second prediction sub-mode and the third prediction sub-mode; obtaining the cost values ​​of the first prediction sub-mode, the second prediction sub-mode and the third prediction sub-mode respectively according to the current chroma block and the chroma prediction blocks under the first prediction sub-mode, the second prediction sub-mode and the third prediction sub-mode; selecting the prediction sub-mode with the smallest cost value as the target prediction sub-mode, and using the combined template area corresponding to the target prediction sub-mode as the template area of ​​the current block.

[0009] Among them, the selecting of a target prediction sub-mode from the multiple prediction sub-modes and using the combined template area corresponding to the target prediction sub-mode as the template area of ​​the current block includes: obtaining the aspect ratio of the current block; in response to the aspect ratio of the current block being greater than a first preset threshold, selecting the first prediction sub-mode as the target prediction sub-mode and using the first sub-area as the template area of ​​the current block; in response to the aspect ratio of the current block being less than a second preset threshold, selecting the second prediction sub-mode as the target prediction sub-mode and using the second sub-area as the template area of ​​the current block; in response to the aspect ratio of the current block being not greater than the first preset threshold and not less than the second preset threshold, selecting the third prediction sub-mode as the target prediction sub-mode and using the combination of the first sub-area and the second sub-area as the template area of ​​the current block; wherein, the first preset threshold is greater than the second preset threshold.

[0010] Among them, the selecting of a target prediction sub-mode from the multiple prediction sub-modes and using the combined template area corresponding to the target prediction sub-mode as the template area of ​​the current block includes: obtaining the texture tendency of the current block and judging whether the current block is a horizontal texture block or a vertical texture block; in response to the current block being a vertical texture block, selecting the first prediction sub-mode as the target prediction sub-mode and using the first sub-area as the template area of ​​the current block; in response to the current block being a horizontal texture block, selecting the second prediction sub-mode as the target prediction sub-mode and using the second sub-area as the template area of ​​the current block; in response to the current block being neither a vertical texture block nor a horizontal texture block, selecting the third prediction sub-mode as the target prediction sub-mode and using the combination of the first sub-area and the second sub-area as the template area of ​​the current block.

[0011] The obtaining of the texture tendency of the current block and determining whether the current block is a horizontal texture block or a vertical texture block includes: using a Sobel operator to calculate horizontal gradients and vertical gradients of a pixel window within the current block to obtain horizontal gradient values ​​and vertical gradient values ​​of a plurality of pixel windows; determining whether the pixel texture within each pixel window is a horizontal texture or a vertical texture based on the horizontal gradient values ​​and vertical gradient values ​​of the pixel window; obtaining a first ratio of the number of pixel windows having horizontal textures to the total number of all pixel windows, and a second ratio of the number of pixel windows having vertical textures to the total number of all pixel windows; determining that the current block is a horizontal texture block in response to the first ratio being not less than a first ratio threshold and the second ratio being not greater than a second ratio threshold; and determining that the current block is a vertical texture block in response to the first ratio being not greater than the second ratio threshold and the second ratio being not less than the first ratio threshold; wherein the first ratio threshold is greater than the second ratio threshold.

[0012] Among them, the determining whether the pixel texture in each pixel window is a horizontal texture or a vertical texture based on the horizontal gradient value and the vertical gradient value of the pixel window includes: if the absolute value of the horizontal gradient value of the pixel window is less than a third preset threshold, determining that the pixel texture in the pixel window is a horizontal texture; if the absolute value of the vertical gradient value of the pixel window is less than a fourth preset threshold, determining that the pixel texture in the pixel window is a vertical texture.

[0013] Wherein, a syntax element is added to the chroma prediction block corresponding to the current chroma block, and the syntax element represents the prediction sub-mode adopted to obtain the chroma prediction block.

[0014] Among them, the sampling of the luminance reference pixels in the template area based on the number and shape of the chrominance reference pixels in the template area to obtain the sampled luminance reference pixels includes: selecting the luminance reference pixel at the first preset position in the template area as the sampled luminance reference pixel according to the number and shape of the chrominance reference pixels in the template area; or, selecting one luminance reference pixel in the template area according to a preset number of intervals as the sampled luminance reference pixel according to the number and shape of the chrominance reference pixels in the template area; or, grouping the luminance reference pixels in the template area based on a filter according to the number and shape of the chrominance reference pixels in the template area, and performing interpolation weighting on each group of luminance reference pixels using the filter to obtain a sampled luminance reference pixel.

[0015] The sampling of the current luminance block corresponding to the current block based on the size of the current chrominance block corresponding to the current block to obtain the sampled current luminance block includes: selecting a luminance pixel at a second preset position in the current luminance block as a sampled luminance pixel, so that the size of the sampled current luminance block composed of all the sampled luminance pixels is the same as the size of the current chrominance block; or evenly dividing the current luminance block into a plurality of block areas of the same size, selecting a luminance pixel from each of the block areas as the sampled luminance pixel, so that all the sampled luminance pixels constitute the sampled current luminance block; wherein the width of the block area is the ratio of the width of the current luminance block to the width of the current chrominance block, and the height of the block area is the ratio of the height of the current luminance block to the height of the current chrominance block; or moving the filter in the horizontal and vertical directions within the current luminance block, obtaining a sampled luminance pixel each time the filter moves, and the size of the sampled current luminance block composed of all the sampled luminance pixels is the same as the size of the current chrominance block.

[0016] Among them, the method of determining the weight coefficient of each luminance pixel in the sampled current luminance block corresponding to each sampled luminance reference pixel based on the difference between each luminance pixel in the sampled current luminance block and each sampled luminance reference pixel includes: for any luminance pixel in the sampled current luminance block, obtaining the absolute value of the difference between the arbitrary luminance pixel and each sampled luminance reference pixel; obtaining a representative value corresponding to the absolute value of each difference according to a preset functional relationship; and using all representative values ​​to calculate the weight coefficient of the arbitrary luminance pixel corresponding to each sampled luminance reference pixel.

[0017] Among them, the chroma prediction block corresponding to the current chroma block is predicted based on the weight coefficient and the chroma reference pixel corresponding to each sampled luminance reference pixel, including: obtaining the two current chroma blocks corresponding to the current luminance block; determining the target luminance pixel corresponding to an arbitrary chroma pixel of each current chroma block in the sampled current luminance block, and obtaining the weight coefficient of the target luminance pixel corresponding to each sampled luminance reference pixel; multiplying the weight coefficient of the target luminance pixel corresponding to each sampled luminance reference pixel by the chroma reference pixel corresponding to each sampled luminance reference pixel one by one, and obtaining the final prediction value of the arbitrary chroma pixel after addition; and obtaining the chroma prediction block corresponding to each current chroma block according to the final prediction values ​​of all chroma pixels of each current chroma block.

[0018] To solve the above problems, the second aspect of the present application provides an image encoding and decoding method, which includes: using a traditional intra-frame prediction mode to predict and reconstruct a current luminance block corresponding to a current block in an image; determining a chroma prediction block of a current chroma block corresponding to the current luminance block based on the weighted chroma prediction method of the first aspect above; and encoding and decoding the current block based on the chroma prediction block.

[0019] To solve the above problems, the third aspect of the present application provides a codec, which includes a processor and a memory connected to each other; the memory is used to store program instructions, and the processor is used to execute the program instructions to implement the method of the first aspect or the second aspect above.

[0020] To solve the above problems, the fourth aspect of the present application provides a computer-readable storage medium having program instructions stored thereon, which implement the method of the above first aspect or second aspect when executed by a processor.

[0021] The beneficial effect of the present invention is as follows: Different from the prior art, in the weighted chroma prediction method of the present application, the template candidate range of the current block is divided into multiple sub-regions, at least one sub-region is selected from the multiple sub-regions as the template region of the current block, and then based on the number and shape of the chroma reference pixels in the template region, the luminance reference pixels in the template region are sampled to obtain sampled luminance reference pixels, so that the number and shape of the sampled luminance reference pixels are the same as the number and shape of the chroma reference pixels. At the same time, based on the size of the current chroma block corresponding to the current block, the current luminance block corresponding to the current block is sampled to obtain the sampled current luminance block, so that the size of the sampled current luminance block is the same as the size of the current chroma block. Therefore, the weight coefficient of each luminance pixel in the sampled current luminance block corresponding to each sampled luminance reference pixel can be determined according to the difference between each luminance pixel in the sampled current luminance block and each sampled luminance reference pixel, and then the chroma prediction block corresponding to the current chroma block is predicted according to the weight coefficient and the chroma reference pixel corresponding to each sampled luminance reference pixel. By selectively determining the template area of ​​the current block from the template candidate range, a suitable prediction mode can be selected for weighted chrominance prediction according to diverse image contents, and the prediction method is more flexible. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 This is a flow chart of an embodiment of a weighted chroma prediction method of the present application;

[0023] Figure 2 yes Figure 1 A flow chart of an embodiment of step S11;

[0024] Figure 3This is a schematic diagram of the division of the template candidate range in an application scenario of this application;

[0025] Figure 4 yes Figure 2 A flow chart of an embodiment of step S113;

[0026] Figure 5 yes Figure 2 A flow chart of another embodiment of step S113;

[0027] Figure 6 yes Figure 2 A flow chart of another embodiment of step S113;

[0028] Figure 7 yes Figure 6 Flow chart of step S1131c in an embodiment;

[0029] Figure 8 is a schematic diagram of the Sobel operator in an application scenario of this application;

[0030] Figure 9 This is a schematic diagram of gradient calculation using the Sobel operator in an application scenario of the present application;

[0031] Figure 10 This is a schematic diagram of sampling the current luminance block in an application scenario of the present application;

[0032] Figure 11 is a schematic diagram of sampling the current luminance block in another application scenario of the present application;

[0033] Figure 12 yes Figure 1 A flow chart of an embodiment of step S14;

[0034] Figure 13 yes Figure 1 A flow chart of an embodiment of step S15;

[0035] Figure 14 This is a flowchart of an embodiment of the image encoding and decoding method of the present application;

[0036] Figure 15 This is a schematic structural diagram of an embodiment of the codec of the present application;

[0037] Figure 16 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION

[0038] The following describes the embodiments of the present application in detail with reference to the accompanying drawings.

[0039] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.

[0040] The terms "system" and "network" are often used interchangeably in this document. The term "and / or" is simply a description of an association between related objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. Furthermore, the character " / " generally indicates that the related objects are in an "or" relationship. Furthermore, "multiple" in this document means two or more than two.

[0041] See also Figure 1 , Figure 1 FIG. 1 is a flow chart of an embodiment of a weighted chroma prediction method of the present application. The weighted chroma prediction method in this embodiment includes the following steps:

[0042] Step S11: Divide the template candidate range of the current block into multiple sub-regions, and select at least one sub-region from the multiple sub-regions as the template region of the current block.

[0043] Weighted Chroma Prediction (WCP) is a method that uses the difference between the current luminance component pixel and the reference pixel to obtain the weight, and is used for the prediction of the current chrominance component. Since the pixels in the template area are needed to build the weight coefficient model, the template area needs to be selected first. Since the template candidate range of the current block is the range of reconstructed pixels around the current block that can be used as a prediction reference, in the existing scheme, if the reconstructed pixels above and to the left of the current block exist and are available, the template area of ​​the current block will definitely select the reconstructed pixels above and to the left of the current block at the same time. However, this application takes into account the richness of the image content. Selecting the reconstructed pixels above and to the left as the template area is not necessarily conducive to improving the accuracy of the prediction value of the current block. Therefore, the embodiment of the present application divides the template candidate range of the current block into multiple sub-areas, and then selects at least one sub-area from the multiple sub-areas as the template area of ​​the current block.

[0044] Please combine Figure 2 , Figure 2 yes Figure 1 Flowchart of step S11 in an embodiment. In one embodiment, the above step S11 specifically includes:

[0045] Step S111: dividing the template candidate range of the current block into a plurality of sub-regions.

[0046] It is understandable that the template candidate range of the current block can be determined according to actual conditions, such as Figure 3As shown, the template candidate range of the current block S1 may include one or more rows of reconstructed pixels S2 above the current block, and one or more columns of reconstructed pixels S3 on the left side of the current block.

[0047] In one embodiment, step S111 may specifically include dividing the reconstructed pixels above the current block into a first sub-region and dividing the reconstructed pixels to the left of the current block into a second sub-region. If the template candidate range of the current block includes the reconstructed pixels above the current block and the reconstructed pixels to the left of the current block, the reconstructed pixels above the current block may be divided into the first sub-region, and the reconstructed pixels to the left of the current block may be divided into the second sub-region.

[0048] Step S112: arbitrarily combining at least some of the multiple sub-regions to obtain a combined template region corresponding to multiple prediction sub-patterns.

[0049] It can be understood that after the template candidate area is divided into multiple sub-areas, at least some of the multiple sub-areas can be arbitrarily combined to obtain multiple combination schemes. Each combination can correspond to a prediction sub-mode, that is, a combined template area corresponding to multiple prediction sub-modes can be obtained.

[0050] In one embodiment, the above-mentioned step S112 may specifically include: using the first sub-region as a combined template region corresponding to the first prediction sub-mode; using the second sub-region as a combined template region corresponding to the second prediction sub-mode; and using the combination of the first sub-region and the second sub-region as a combined template region corresponding to the third prediction sub-mode.

[0051] After the reconstructed pixels above the current block are divided into the first sub-region and the reconstructed pixels on the left side of the current block are divided into the second sub-region, the first sub-region itself can be used as a combination method, that is, the first sub-region can be used as a combination template region corresponding to the first prediction sub-mode, the second sub-region itself can also be used as a combination method, that is, the second sub-region can be used as a combination template region corresponding to the second prediction sub-mode, and the first sub-region and the second sub-region together can be used as a combination method, that is, the combination of the first sub-region and the second sub-region can be used as a combination template region corresponding to the third prediction sub-mode.

[0052] Step S113: selecting a target prediction sub-mode from the plurality of prediction sub-modes, and using the combined template region corresponding to the target prediction sub-mode as the template region of the current block.

[0053] For example, when the first sub-region is used as the combined template region corresponding to the first prediction sub-mode, the second sub-region is used as the combined template region corresponding to the second prediction sub-mode, and the combination of the first sub-region and the second sub-region is used as the combined template region corresponding to the third prediction sub-mode, three prediction sub-modes are actually given. Therefore, one prediction sub-mode can be selected from the three prediction sub-modes as the target prediction sub-mode, and the combined template region corresponding to the target prediction sub-mode is used as the template region of the previous block.

[0054] Please combine Figure 4 , Figure 4 yes Figure 2 Flowchart of step S113 in an embodiment. In one embodiment, the above step S113 specifically includes:

[0055] Step S1131a: Use the combined template areas corresponding to the first prediction sub-mode, the second prediction sub-mode and the third prediction sub-mode as the template areas of the current block respectively, and calculate the chrominance prediction blocks under the first prediction sub-mode, the second prediction sub-mode and the third prediction sub-mode.

[0056] Step S1132a: According to the current chroma block and the chroma prediction blocks under the first prediction sub-mode, the second prediction sub-mode and the third prediction sub-mode, respectively obtain the cost values ​​of the first prediction sub-mode, the second prediction sub-mode and the third prediction sub-mode.

[0057] Step S1133a: selecting the prediction sub-mode with the smallest cost value as the target prediction sub-mode, and using the combined template area corresponding to the target prediction sub-mode as the template area of ​​the current block.

[0058] In one embodiment, by traversing three prediction sub-modes and predicting the current chroma block according to the template area of ​​the current block under each prediction sub-mode, the chroma prediction block under each prediction sub-mode can be obtained. By comparing the current chroma block with the chroma prediction block under each prediction sub-mode, the cost value corresponding to each prediction sub-mode can be obtained. Therefore, the prediction sub-mode with the smallest cost value can be selected as the target prediction sub-mode, and the template area of ​​the current block can be obtained.

[0059] Please combine Figure 5 , Figure 5 yes Figure 2 FIG. 1 is a flow chart of another embodiment of step S113. In one embodiment, the above step S113 specifically includes:

[0060] Step S1131b: Obtain the aspect ratio of the current block. When the aspect ratio of the current block is greater than the first preset threshold, step S1132b is executed; when the aspect ratio of the current block is less than the second preset threshold, step S1133b is executed; when the aspect ratio of the current block is not greater than the first preset threshold and not less than the second preset threshold, step S1134b is executed. Herein, the first preset threshold is greater than the second preset threshold.

[0061] Step S1132b: Select the first prediction sub-pattern as the target prediction sub-pattern, and use the first sub-region as the template region of the current block.

[0062] Step S1133b: Select the second prediction sub-pattern as the target prediction sub-pattern, and use the second sub-region as the template region of the current block.

[0063] Step S1134b: Select the third prediction sub-pattern as the target prediction sub-pattern, and use the combination of the first sub-region and the second sub-region as the template region of the current block.

[0064] In another embodiment, the prediction sub-pattern can be selected according to the relationship between the width and height of the current block; when width / height > T1 (T1 is the first preset threshold), only the reconstructed pixels above the current block are selected as the template region, that is, the first prediction sub-pattern is selected; when height / width > 1 / T2 (i.e., width / height < T2, T2 is the second preset threshold), only the reconstructed pixels on the left side of the current block are selected as the template region, that is, the second prediction sub-pattern is selected; when T2 ≤ width / height ≤ T1, the reconstructed pixels above and on the left side of the current block are selected as the template region, that is, the third prediction sub-pattern is selected. For example, set T1 = 2, T2 = 1 / 4; then for a current block of 16*4, its aspect ratio is 4, greater than T1, so only the reconstructed pixels above are selected as the template region; for a current block of 4*32, its aspect ratio is 1 / 8, less than T2, so only the reconstructed pixels on the left side are selected as the template region; for a current block of 8*4 or 4*16, the aspect ratio is 2 or 1 / 4, which is between T2 and T1, and at this time the reconstructed pixels above and on the left side are selected as the template region.

[0065] Please combine Figure 6 , Figure 6 is Figure 2 a schematic flowchart of another embodiment of step S113. In one embodiment, the above step S113 specifically includes:

[0066] Step S1131c: Obtain the texture tendency of the current block and determine whether the current block is a horizontal texture block or a vertical texture block. If the current block is a vertical texture block, execute step S1132c; if the current block is a horizontal texture block, execute step S1133c; if the current block is neither a vertical texture block nor a horizontal texture block, execute step S1134c.

[0067] Step S1132c: Select the first prediction sub-mode as the target prediction sub-mode, and use the first sub-region as the template region of the current block.

[0068] Step S1133c: Select the second prediction sub-mode as the target prediction sub-mode, and use the second sub-region as the template region of the current block.

[0069] Step S1134c: Select the third prediction sub-mode as the target prediction sub-mode, and use the combination of the first sub-region and the second sub-region as the template region of the current block.

[0070] In another embodiment, a prediction sub-mode may be selected based on the texture tendency of the current block; if the current block is a vertical texture block, only the reconstructed pixels above the current block are selected as the template area, i.e., the first prediction sub-mode is selected; if the current block is a horizontal texture block, only the reconstructed pixels to the left of the current block are selected as the template area, i.e., the second prediction sub-mode is selected; if the current block is neither a vertical texture block nor a horizontal texture block, the reconstructed pixels above and to the left of the current block are selected as the template area, i.e., the third prediction sub-mode is selected.

[0071] It is understandable that the texture tendency of the current block can be obtained by gradient calculation, hash value calculation, transformation, etc. Figure 7 , Figure 7 yes Figure 6 Flowchart of step S1131c in an embodiment. In one embodiment, the above step S1131c specifically includes:

[0072] Step S11311: using the Sobel operator to calculate the horizontal gradient and the vertical gradient of the pixel window in the current block, and obtaining the horizontal gradient values ​​and the vertical gradient values ​​of several pixel windows.

[0073] Specifically, the Sobel operator can be used to calculate the horizontal and vertical gradients of the pixels in the current block. Figure 8 As shown, Figure 8 The left side shows the horizontal Sobel operator, Figure 8 The right side shows the vertical Sobel operator, using Figure 8The Sobel operator shown is a 3*3 window that moves in a raster scan manner with a step size of 1 pixel and traverses the pixels in the current block. Each time the window moves, there is a corresponding set of horizontal gradient values ​​and vertical gradient values. Figure 9 , Figure 9 This is a schematic diagram of gradient calculation using the Sobel operator in an application scenario of this application. For example, for a 4*4 current block, the 3*3 window movement process is as follows: Figure 9 As shown in the dotted box, there are 4 windows in total, corresponding to 4 groups of horizontal gradient values ​​and vertical gradient values.

[0074] Step S11312: Determine whether the pixel texture in each pixel window is a horizontal texture or a vertical texture according to the horizontal gradient value and the vertical gradient value of the pixel window.

[0075] In one embodiment, if the absolute value of the horizontal gradient value of the pixel window is less than a third preset threshold, the pixel texture within the pixel window is judged to be a horizontal texture; if the absolute value of the vertical gradient value of the pixel window is less than a fourth preset threshold, the pixel texture within the pixel window is judged to be a vertical texture.

[0076] Specifically, the third preset threshold T3=50 and the fourth preset threshold T4=100 can be set. Therefore, when the absolute value of the horizontal gradient value corresponding to a window is less than 50, the pixel texture in the window is regarded as a horizontal texture. When the absolute value of the vertical gradient value corresponding to a window is less than 100, the pixel texture in the window is regarded as a vertical texture.

[0077] Step S11313: Obtain a first ratio of the number of pixel windows whose pixel texture is horizontal texture to the total number of pixel windows, and a second ratio of the number of pixel windows whose pixel texture is vertical texture to the total number of pixel windows. When the first ratio is not less than a first ratio threshold and the second ratio is not greater than a second ratio threshold, execute step S11314; when the first ratio is not greater than the second ratio threshold and the second ratio is not less than the first ratio threshold, execute step S11315. The first ratio threshold is greater than the second ratio threshold.

[0078] Step S11314: Determine whether the current block is a horizontal texture block.

[0079] Step S11315: Determine whether the current block is a vertical texture block.

[0080] It can be understood that if a certain proportion of the texture of the current block tends to be horizontal or vertical, the corresponding prediction sub-mode only selects the reconstructed pixels on the left or above the current block as the template area. For example, the first ratio threshold w1=0.8 and the second ratio threshold w2=0.1 can be set; therefore, for all windows in the current block, if the number of windows with an absolute value of the horizontal gradient value less than the threshold T3=50 accounts for a ratio of w1=0.8 or more to the number of windows, and the number of windows with an absolute value of the vertical gradient value less than the threshold T4=100 accounts for a ratio of w2=0.1 or less to the number of windows, then the current block is considered to be a horizontal texture block. At this time, only the reconstructed pixels on the left side of the current block are taken as the template area, that is, the second prediction sub-mode is selected; if the number of windows with an absolute value of the horizontal gradient value less than the threshold T3=50 accounts for a ratio of w2=0.1 or less to the number of windows, then the second prediction sub-mode is selected; When the ratio of the number of pixels whose absolute value of vertical gradient value is less than threshold value T4=100 is less than w2=0.1 and the ratio of the number of pixels whose absolute value of vertical gradient value is less than threshold value T4=100 to the number of windows is greater than w1=0.8, the current block is considered to be a vertical texture block. At this time, only the reconstructed pixels above the current block are taken as the template area, that is, the first prediction sub-mode is selected; except for the above two cases, it is considered that the features of the current block with respect to the horizontal texture block or the vertical texture block are not significant, that is, the current block belongs to neither a horizontal texture block nor a vertical texture block. At this time, the reconstructed pixels above and to the left of the current block should be selected as the template area, that is, the third prediction sub-mode is selected.

[0081] In one embodiment, a syntax element is added to the chroma prediction block corresponding to the current chroma block, where the syntax element indicates a prediction sub-mode used to obtain the chroma prediction block.

[0082] By setting syntactic elements, the adopted predictor mode can be indicated during bitstream transmission. When adopting the above scheme of traversing three predictor modes to select the target predictor mode, the used predictor mode can be indicated by transmitting syntactic elements. For example, a block-level syntactic identifier wcp_sub_mode is set. Where wcp_sub_mode being equal to 0 represents the third predictor mode WCP_LT that selects both the upper and left reconstructed pixels, wcp_sub_mode being equal to 1 represents the first predictor mode WCP_T that only takes the upper reconstructed pixels, and wcp_sub_mode being equal to 2 represents the second predictor mode WCP_L that only takes the left reconstructed pixels. For the current block, after traversing the three predictor modes, assume the rate-distortion cost of the third predictor mode WCP_LT is RDcost1, the rate-distortion cost of the second predictor mode WCP_L is RDcost2, and the rate-distortion cost of the first predictor mode WCP_T is RDcost3, and RDcost2 < RDcost1 < RDcost3, then the syntactic element wcp_sub_mode = 3 is transmitted, representing the use of the second predictor mode WCP_L. When adopting the scheme of selecting the target predictor mode according to the relationship between the width and height of the current block or the texture tendency, no additional syntactic elements need to be transmitted. Of course, the identifier corresponding to the predictor mode can also be transmitted to reduce the computational complexity at the decoding end.

[0083] Step S12: Sample the luminance reference pixels in the template region based on the number and shape of the chrominance reference pixels in the template region, to obtain the sampled luminance reference pixels. Wherein, the number and shape of the sampled luminance reference pixels are the same as those of the chrominance reference pixels;

[0084] It can be understood that for an image in YUV444 sampling format, since the luminance component and chrominance component of a block are originally of the same size, sampling is not required. Considering the commonly used YUV420 sampling format in existing schemes, where the size of the luminance block is larger than that of the chrominance block, the number of luminance reference pixels in the template region is more than that of the chrominance reference pixels. Therefore, the luminance reference pixels in the template region need to be downsampled to match the number and shape of the chrominance reference pixels in the template region, ensuring that the number and shape of the sampled luminance reference pixels above are the same as those of the chrominance reference pixels in the upper template region, and the number and shape of the sampled luminance reference pixels on the left are the same as those of the chrominance reference pixels in the left template region. At the same time, downsampling can also reduce the computational complexity.

[0085] In one embodiment, step S12 may include selecting, based on the number and shape of the chrominance reference pixels in the template area, a luma reference pixel at a first preset position in the template area as the sampled luma reference pixel. By setting the first preset position and selecting only the luma reference pixel at the first preset position in the template area, the number and shape of the sampled luma reference pixels can be controlled to be consistent with the number and shape of the chrominance reference pixels in the template area.

[0086] In another embodiment, step S12 may include selecting, based on the number and shape of the chroma reference pixels in the template area, a luma reference pixel at a preset interval in the template area as the sampled luma reference pixel. Specifically, the luma reference pixels in the template area above the current block may be sampled at every several luma reference pixels along the horizontal axis, and the luma reference pixels in the template area to the left of the current block may be sampled at every several luma reference pixels along the vertical axis. This allows the number and shape of the sampled luma reference pixels to be consistent with the number and shape of the chroma reference pixels in the template area.

[0087] In another embodiment, the above-mentioned step S12 may specifically include: grouping the luma reference pixels in the template area based on a filter according to the number and shape of the chroma reference pixels in the template area, and performing interpolation and weighting on each group of luma reference pixels using the filter to obtain a sampled luma reference pixel. By designing a filter, the luma reference pixels in the template area are grouped based on the filter, the number of groups being equal to the number of chroma reference pixels in the template area, and performing interpolation and weighting on each group using the filter to obtain a sampled luma reference pixel, so that the number and shape of the final sampled luma reference pixels are consistent with the number and shape of the chroma reference pixels in the template area.

[0088] Step S13: based on the size of the current chrominance block corresponding to the current block, sampling the current luminance block corresponding to the current block to obtain a sampled current luminance block, wherein the size of the sampled current luminance block is the same as the size of the current chrominance block.

[0089] Similarly, considering that in the YUV420 sampling format commonly used in existing solutions, the size of the luminance block is larger than the size of the chrominance block, the luminance block needs to be downsampled to match the size of the chrominance block. For example, if the size of the current chrominance block is wc*hc, and the size of the corresponding current luminance block is wl*hl, the size of the sampled current luminance block obtained after downsampling must also become wc*hc. At the same time, downsampling can also reduce computational complexity.

[0090] In one embodiment, step S13 may specifically include selecting luma pixels at a second preset position in the current luma block as the sampled luma pixels, so that the size of the sampled current luma block composed of all the sampled luma pixels is the same as the size of the current chroma block. By setting the second preset position and selecting only the luma pixels at the second preset position in the current luma block, the number of luma pixels in the sampled current luma block and the number of chroma pixels in the current chroma block can be controlled to be consistent, so that the size of the sampled current luma block is the same as the size of the current chroma block.

[0091] In another embodiment, the above step S13 may specifically include: dividing the current luminance block into several block areas of the same size on average, selecting a luminance pixel from each block area as the sampled luminance pixel, so that all sampled luminance pixels constitute the sampled current luminance block; wherein the width of the block area is the ratio of the width of the current luminance block to the width of the current chrominance block, and the height of the block area is the ratio of the height of the current luminance block to the height of the current chrominance block. Specifically, if the size of the current chrominance block is wc*hc, and the size of the corresponding current luminance block is wl*hl, the current luminance block may be divided into several block areas of the same size, each block area having a size of (wl / wc)*(hl / hc), and extracting a luminance pixel from each block area, so that the size of the sampled current luminance block composed of all sampled luminance pixels is wc*hc, which is the same as the size of the current chrominance block. Please combine Figure 10 , Figure 10 This is a schematic diagram of sampling the current luminance block in an application scenario of the present application. In this embodiment, the size of the current chrominance block is 4*4, and the size of the current luminance block is 8*8. The current luminance block needs to be evenly divided into 16 2*2 block areas. If the pixel in the upper left corner of each block area is extracted to complete the downsampling, the size of the sampled current luminance block is 4*4.

[0092] In another embodiment, the above step S13 may specifically include: moving the filter in the horizontal and vertical directions within the current luminance block, obtaining a sampled luminance pixel each time it moves, and the size of the sampled current luminance block composed of all sampled luminance pixels is the same as the size of the current chrominance block. By designing a filter, the current luminance block is coefficient-weighted sampled based on the filter coefficient, and the filter moves in the horizontal and vertical directions within the current luminance block, obtaining a sampling point each time it moves, and it must be ensured that the final sampling size is consistent with the size of the current chrominance block. Please combine Figure 11 , Figure 11This is a schematic diagram of sampling the current luminance block in another application scenario of the present application. In this embodiment, the size of the current chrominance block is 4*4, the size of the current luminance block is 8*8, and the filter is a 5-tap cross filter. Taking the sampling of the first row and the first column of the current luminance block as an example, one of the filter shifting methods is: the filter shifts 1 pixel horizontally or vertically each time, and 4 sampled pixels are obtained in the first row and 4 sampled pixels are obtained in the first column; finally, the filter needs to be shifted horizontally and vertically to sample a 4*4 luminance block.

[0093] It can be understood that, in the embodiment of the present application, the specific sampling method of the brightness reference pixel in step S12 and the specific sampling method of the current block brightness block in step S13 can be freely combined.

[0094] Step S14: Determine a weight coefficient of each luminance pixel in the sampled current luminance block corresponding to each sampled luminance reference pixel according to the difference between each luminance pixel in the sampled current luminance block and each sampled luminance reference pixel.

[0095] It can be understood that after completing the above-mentioned downsampling process of the current luminance block and the luminance reference pixels of the template area, the weight coefficient of each luminance pixel in the sampled current luminance block corresponding to each sampled luminance reference pixel can be determined based on the difference between each luminance pixel in the sampled current luminance block and each sampled luminance reference pixel, thereby realizing the construction of a weight model using the downsampled current luminance block and the luminance reference pixels.

[0096] Please combine Figure 12 , Figure 12 yes Figure 1 Flowchart of step S14 in an embodiment. In one embodiment, the above step S14 specifically includes:

[0097] Step S141: for any luminance pixel in the sampled current luminance block, obtain the absolute value of the difference between the arbitrary luminance pixel and each of the sampled luminance reference pixels.

[0098] Step S142: Obtain a representative value corresponding to the absolute value of each difference according to a preset functional relationship.

[0099] Step S143: Calculate the weight coefficient of the arbitrary brightness pixel corresponding to each of the sampled brightness reference pixels using all representative values.

[0100] Specifically, in the embodiment of the present application, the current luminance block has been predicted and reconstructed according to the traditional intra-frame prediction mode, and then downsampled using any of the above methods. The reconstructed value of the sampled current luminance block can be represented by cur(x, y). In addition, the luminance reference pixels of the template area are downsampled using any of the above methods, and the sampled luminance reference pixels are set to ref(x, y). For the luminance pixel cur(a, b) corresponding to a certain position (a, b) in the sampled current luminance block, it is necessary to perform a difference with all the sampled luminance reference pixels in the template area and take the absolute value. Assuming that there are k sampled luminance reference pixels in the template area (0, 1, ..., k-1), there will be k difference values ​​D0, D1, ..., Dk-1 corresponding to the luminance pixel cur(a, b). Therefore, for each difference value of the luminance pixel cur(a, b), a function relationship is established to obtain the representative value corresponding to the difference value, so that there will be k representative values ​​V0, V1, ..., Vk-1: Vn = f(Dn), n = 0, 1, ..., k-1. This function relationship can be linear or nonlinear. Then, these k representative values ​​can be used to calculate k weight coefficients S0, S1,…, Sk-1: Sn=Vn / (V0+V1+,…,+Vk-1), n=0, 1,…, k-1, each weight coefficient represents the weight coefficient of the luminance pixel cur(a, b) in the sampled current luminance block corresponding to each sampled luminance reference pixel.

[0101] Step S15: predicting a chroma prediction block corresponding to the current chroma block according to the weight coefficient and the chroma reference pixel corresponding to each sampled luminance reference pixel.

[0102] A weight coefficient model between each luminance pixel and all luminance template pixels is constructed using the downsampled current luminance block and the luminance reference pixels. This weight coefficient model can then be used for the current chrominance block, and the chrominance reference pixels are substituted into the weight coefficient model to obtain the predicted value of the current chrominance block.

[0103] Please combine Figure 13 , Figure 13 yes Figure 1 Flowchart of step S15 in an embodiment. In one embodiment, the above step S15 specifically includes:

[0104] Step S151: Obtain the two current chrominance blocks corresponding to the current luminance block.

[0105] Step S152: Determine the target luminance pixel corresponding to any chrominance pixel of each current chrominance block in the sampled current luminance block, and obtain the weight coefficient of the target luminance pixel corresponding to each sampled luminance reference pixel.

[0106] Step S153: multiply the weight coefficient of each sampled luminance reference pixel corresponding to the target luminance pixel by the chrominance reference pixel corresponding to each sampled luminance reference pixel one by one, and obtain the final prediction value of the arbitrary chrominance pixel after adding them.

[0107] Step S154: Obtain a chroma prediction block corresponding to each current chroma block according to the final prediction values ​​of all chroma pixels of each current chroma block.

[0108] Specifically, for the current luminance block, two current chrominance blocks having a co-location relationship with the current luminance block can be obtained. For the luminance pixel cur(a, b) corresponding to a certain position (a, b) in the sampled current luminance block, two chrominance pixels corresponding to the luminance pixel cur(a, b) in the two current chrominance blocks can be obtained. For the current chrominance pixel of each current chrominance block, the k weight coefficients corresponding to the current luminance pixel cur(a, b) and the k chrominance reference pixels in the template area can be multiplied and added one by one to obtain the final prediction value of the current chrominance pixel position. By obtaining the final prediction values ​​of all chrominance pixels of the two current chrominance blocks, the chrominance prediction blocks corresponding to the two current chrominance blocks can be obtained, thereby realizing the prediction of the chrominance blocks.

[0109] In the weighted chrominance prediction method of the present application, by selectively determining the template area of ​​the current block from the template candidate range, a suitable prediction mode can be selected for weighted chrominance prediction for diverse image contents, making the prediction method more flexible.

[0110] See also Figure 14 , Figure 14 1 is a flow chart of an embodiment of the image encoding and decoding method of the present application. The image encoding and decoding method in this embodiment includes the following steps:

[0111] Step S1401: predict and reconstruct the current luminance block corresponding to the current block in the image using a traditional intra-frame prediction mode.

[0112] Step S1402: Determine a chroma prediction block of a current chroma block corresponding to the current luminance block based on a weighted chroma prediction method, wherein the weighted chroma prediction method is any one of the weighted chroma prediction methods mentioned above.

[0113] Step S1403: Encode and decode the current block based on the chroma prediction block.

[0114] In this embodiment, the current block is an image block to be encoded and decoded. The traditional intra-frame prediction mode is first used to predict and reconstruct the current luminance block corresponding to the current block. Then, any of the above-mentioned weighted chrominance prediction methods can be used to predict the chrominance prediction block of the current chrominance block that has a co-location relationship with the current luminance block, and then the current block can be encoded and decoded.

[0115] In the image coding and decoding method of the present application, by selectively determining the template area of ​​the current block from the template candidate range, a suitable prediction mode can be selected for weighted chrominance prediction for diverse image contents, making the prediction method and coding and decoding method more flexible.

[0116] See also Figure 15 , Figure 15 This is a schematic diagram of the structure of an embodiment of the codec of the present application. The codec 150 in this embodiment includes a processor 152 and a memory 151 connected to each other. The memory 151 is used to store program instructions, and the processor 152 is used to execute the program instructions stored in the memory 151 to implement the steps of any of the above-mentioned weighted chrominance prediction methods or codec method embodiments. In a specific implementation scenario, the codec 150 may include, but is not limited to, a microcomputer or a server.

[0117] Specifically, the processor 152 is used to control itself and the memory 151 to implement the steps of any of the above-mentioned weighted chrominance prediction methods or coding and decoding method embodiments. The processor 152 can also be called a CPU (Central Processing Unit). The processor 152 may be an integrated circuit chip with signal processing capabilities. The processor 152 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 152 can be implemented by an integrated circuit chip.

[0118] See also Figure 16 , Figure 16 The computer-readable storage medium 160 of the present application stores program instructions 1600 thereon, which, when executed by a processor, implement the steps of any of the above-mentioned weighted chrominance prediction methods or encoding and decoding method embodiments.

[0119] The computer-readable storage medium 160 can specifically be a medium that can store program instructions 1600, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or it can also be a server that stores the program instructions 1600. The server can send the stored program instructions 1600 to other devices for execution, or it can also execute the stored program instructions 1600 itself.

[0120] In the several embodiments provided in this application, it should be understood that the disclosed methods, devices and apparatuses can be implemented in other ways. For example, the above-described device and apparatus implementation methods are merely schematic. For example, the division of modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0121] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0122] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0123] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

Claims

1. A weighted chrominance prediction method, characterized in that: The method comprises: Dividing a template candidate range of a current block into a plurality of sub-regions, arbitrarily combining at least some of the plurality of sub-regions to obtain a combined template region corresponding to a plurality of prediction sub-modes, selecting a prediction sub-mode from the plurality of prediction sub-modes as a target prediction sub-mode based on a relationship between a width and a height of the current block or a texture tendency of the current block, or comparing a current chroma block corresponding to the current block with a chroma prediction block calculated under each prediction sub-mode to obtain a cost value corresponding to each prediction sub-mode, selecting a prediction sub-mode with a minimum cost value as the target prediction sub-mode, and obtaining a template region for the current block based on the target prediction sub-mode; Sampling the luma reference pixels in the template area based on the number and shape of the chroma reference pixels in the template area to obtain sampled luma reference pixels; wherein the number and shape of the sampled luma reference pixels are the same as the number and shape of the chroma reference pixels; Sampling a current luminance block corresponding to the current block based on the size of the current chrominance block corresponding to the current block to obtain a sampled current luminance block; wherein the size of the sampled current luminance block is the same as the size of the current chrominance block; Determining a weight coefficient for each luma pixel in the sampled current luma block corresponding to each sampled luma reference pixel according to a difference between each luma pixel in the sampled current luma block and each sampled luma reference pixel; A chroma prediction block corresponding to the current chroma block is predicted based on the weight coefficient and the chroma reference pixel corresponding to each sampled luminance reference pixel.

2. The weighted chrominance prediction method according to claim 1, wherein Dividing a template candidate range of a current block into a plurality of sub-regions, and selecting at least one sub-region from the plurality of sub-regions as a template region of the current block, comprising: Dividing the template candidate range of the current block into a plurality of sub-regions; Arbitrarily combining at least some of the sub-regions to obtain a combination template region corresponding to a plurality of prediction sub-patterns; A target prediction sub-mode is selected from the plurality of prediction sub-modes, and a combined template region corresponding to the target prediction sub-mode is used as the template region of the current block.

3. The weighted chrominance prediction method according to claim 2, wherein: The dividing the template candidate range of the current block into the plurality of sub-regions includes: Dividing the reconstructed pixels above the current block into a first sub-region, and dividing the reconstructed pixels on the left side of the current block into a second sub-region; The step of arbitrarily combining at least some of the multiple sub-regions to obtain a combined template region corresponding to multiple prediction sub-patterns includes: Using the first sub-region as a combined template region corresponding to the first prediction sub-mode; using the second sub-region as a combined template region corresponding to the second prediction sub-mode; A combination of the first sub-region and the second sub-region is used as a combined template region corresponding to a third prediction sub-mode.

4. The weighted chrominance prediction method according to claim 3, wherein: The step of selecting a target prediction submode from the plurality of prediction submodes and using a combined template region corresponding to the target prediction submode as the template region of the current block includes: respectively using the combined template areas corresponding to the first prediction sub-mode, the second prediction sub-mode, and the third prediction sub-mode as the template areas of the current block, and calculating to obtain chroma prediction blocks under the first prediction sub-mode, the second prediction sub-mode, and the third prediction sub-mode; Obtaining cost values ​​of the first prediction submode, the second prediction submode, and the third prediction submode, respectively, according to the current chroma block and the chroma prediction blocks under the first prediction submode, the second prediction submode, and the third prediction submode; The prediction sub-mode with the smallest cost value is selected as the target prediction sub-mode, and the combined template area corresponding to the target prediction sub-mode is used as the template area of ​​the current block.

5. The weighted chrominance prediction method according to claim 3, wherein: The step of selecting a target prediction submode from the plurality of prediction submodes and using a combined template region corresponding to the target prediction submode as the template region of the current block includes: Obtaining the aspect ratio of the current block; In response to a situation where the aspect ratio of the current block is greater than a first preset threshold, selecting the first prediction sub-mode as the target prediction sub-mode and using the first sub-region as the template region of the current block; In response to a situation where the aspect ratio of the current block is less than a second preset threshold, selecting the second prediction sub-mode as the target prediction sub-mode and using the second sub-region as the template region of the current block; In response to the aspect ratio of the current block being not greater than the first preset threshold and not less than the second preset threshold, selecting the third prediction sub-mode as the target prediction sub-mode, and using a combination of the first sub-region and the second sub-region as the template region of the current block; The first preset threshold is greater than the second preset threshold.

6. The weighted chrominance prediction method according to claim 3, wherein: The step of selecting a target prediction submode from the plurality of prediction submodes and using a combined template region corresponding to the target prediction submode as the template region of the current block includes: Obtaining a texture tendency of the current block, and determining whether the current block is a horizontal texture block or a vertical texture block; In response to the current block being a vertical texture block, selecting the first prediction sub-mode as the target prediction sub-mode, and using the first sub-region as a template region of the current block; In response to the current block being a horizontal texture block, selecting the second prediction sub-mode as the target prediction sub-mode, and using the second sub-region as a template region of the current block; In response to the current block being neither a vertical texture block nor a horizontal texture block, the third prediction submode is selected as the target prediction submode, and a combination of the first subregion and the second subregion is used as the template region of the current block.

7. The weighted chrominance prediction method according to claim 6, wherein: The acquiring the texture tendency of the current block and determining whether the current block is a horizontal texture block or a vertical texture block includes: Calculating the horizontal gradient and the vertical gradient of the pixel window in the current block using the Sobel operator to obtain the horizontal gradient values ​​and the vertical gradient values ​​of the plurality of pixel windows; Determining whether a pixel texture in each pixel window is a horizontal texture or a vertical texture according to a horizontal gradient value and a vertical gradient value of the pixel window; Obtaining a first ratio of the number of pixel windows whose pixel texture is a horizontal texture to the number of all pixel windows, and a second ratio of the number of pixel windows whose pixel texture is a vertical texture to the number of all pixel windows; In response to the first number ratio being not less than a first ratio threshold and the second number ratio being not greater than a second ratio threshold, determining that the current block is a horizontal texture block; In response to the first quantity ratio being not greater than a second ratio threshold and the second quantity ratio being not less than the first ratio threshold, determining that the current block is a vertical texture block; The first ratio threshold is greater than the second ratio threshold.

8. The weighted chrominance prediction method according to claim 7, wherein: The determining, according to the horizontal gradient value and the vertical gradient value of the pixel window, whether the pixel texture in each pixel window is a horizontal texture or a vertical texture comprises: If the absolute value of the horizontal gradient value of the pixel window is less than a third preset threshold, determining that the pixel texture in the pixel window is a horizontal texture; If the absolute value of the vertical gradient value of the pixel window is less than a fourth preset threshold, it is determined that the pixel texture in the pixel window is a vertical texture.

9. The weighted chrominance prediction method according to any one of claims 3 to 8, characterized in that: A syntax element is added to the chroma prediction block corresponding to the current chroma block, where the syntax element represents a prediction sub-mode adopted to obtain the chroma prediction block.

10. The weighted chrominance prediction method according to claim 1, wherein: The step of sampling the luminance reference pixels in the template area based on the number and shape of the chrominance reference pixels in the template area to obtain the sampled luminance reference pixels includes: Selecting, according to the number and shape of the chrominance reference pixels in the template area, a luminance reference pixel at a first preset position in the template area as the sampled luminance reference pixel; Or, according to the number and shape of the chrominance reference pixels in the template area, one luminance reference pixel is selected in each preset number of intervals in the template area as the sampled luminance reference pixel; Alternatively, according to the number and shape of the chrominance reference pixels in the template area, the luminance reference pixels in the template area are grouped based on a filter, and each group of luminance reference pixels is interpolated and weighted using the filter to obtain a sampled luminance reference pixel.

11. The weighted chrominance prediction method according to claim 1, wherein: The sampling of the current luminance block corresponding to the current block based on the size of the current chrominance block corresponding to the current block to obtain the sampled current luminance block includes: Selecting luma pixels at a second preset position in the current luma block as sampled luma pixels, so that a size of the sampled current luma block composed of all the sampled luma pixels is the same as a size of the current chroma block; Alternatively, the current luminance block is evenly divided into a plurality of block regions of the same size, and one luminance pixel is selected from each of the block regions as a sampled luminance pixel, so that all the sampled luminance pixels constitute the sampled current luminance block; wherein the width of the block region is the ratio of the width of the current luminance block to the width of the current chrominance block, and the height of the block region is the ratio of the height of the current luminance block to the height of the current chrominance block; Alternatively, the filter is moved in the horizontal and vertical directions within the current luminance block, and a sampled luminance pixel is obtained each time it is moved, and the size of the sampled current luminance block composed of all the sampled luminance pixels is the same as the size of the current chrominance block.

12. The weighted chrominance prediction method according to claim 1, wherein: The step of determining, based on a difference between each luminance pixel in the sampled current luminance block and each sampled luminance reference pixel, a weight coefficient for each luminance pixel in the sampled current luminance block corresponding to each sampled luminance reference pixel, includes: For any luminance pixel in the sampled current luminance block, obtaining an absolute value of a difference between the arbitrary luminance pixel and each of the sampled luminance reference pixels; Obtaining a representative value corresponding to the absolute value of each difference according to a preset functional relationship; All representative values ​​are used to calculate the weight coefficient of the arbitrary brightness pixel corresponding to each of the sampled brightness reference pixels.

13. The weighted chrominance prediction method according to claim 1, wherein: The predicting, based on the weight coefficient and the chroma reference pixel corresponding to each sampled luminance reference pixel, to obtain a chroma prediction block corresponding to the current chroma block includes: Obtain the two current chrominance blocks corresponding to the current luminance block; Determine a target luminance pixel corresponding to any chroma pixel of each of the current chroma blocks in the sampled current luminance block, and obtain a weight coefficient of the target luminance pixel corresponding to each of the sampled luminance reference pixels; Multiplying the weight coefficient of each sampled luminance reference pixel corresponding to the target luminance pixel by the chrominance reference pixel corresponding to each sampled luminance reference pixel in a one-to-one correspondence, and obtaining a final prediction value of the arbitrary chrominance pixel after adding the weight coefficient; A chroma prediction block corresponding to each current chroma block is obtained according to final prediction values ​​of all chroma pixels of each current chroma block.

14. An image encoding and decoding method, characterized in that: The method comprises: The traditional intra-frame prediction mode is used to predict and reconstruct the current luminance block corresponding to the current block in the image; Determining a chroma prediction block of a current chroma block corresponding to the current luminance block based on the weighted chroma prediction method according to any one of claims 1 to 13; The current block is encoded and decoded based on the chroma prediction block.

15. A codec, characterized in that: The codec includes a processor and a memory connected to each other; The memory is used to store program instructions, and the processor is used to execute the program instructions to implement the method according to any one of claims 1 to 14.

16. A computer-readable storage medium having program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the method according to any one of claims 1 to 14 is implemented.

Citation Information

Patent Citations

  • Cross-component chrominance prediction method and device based on neural network

    CN115190312A