CN-121985122-A - JPEG image coding and decoding method, device and computer program product
Abstract
The application discloses a JPEG image coding and decoding method, a device and a computer program product, and relates to the technical field of image processing. The coding method comprises the steps of carrying out blocking processing on an image to be coded, extracting characteristics of each image block, clustering the image blocks into a limited number of categories based on the characteristics, generating a quantization matrix of each category according to the frequency domain coefficient characteristics of the image block, carrying out quantization according to the corresponding quantization matrix of each category to which each image block belongs, and generating a coding code stream containing index information and each category of quantization matrix data. The decoding method comprises the steps of analyzing the code stream to obtain index information and quantization matrix data, and determining a corresponding quantization matrix for each image block according to the index information to perform inverse quantization and image reconstruction. The application effectively controls the additional storage and code stream expenditure and maintains good compatibility while obviously improving the JPEG compression efficiency through clustering the quantization matrixes corresponding to each class.
Inventors
- NIU JUNHUI
- GUO CHUNLEI
- LI RONG
- JI LIHUI
Assignees
- 展讯通信(天津)有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20260116
Claims (10)
- 1. A JPEG image encoding method, comprising: Acquiring an image to be encoded and performing blocking processing to obtain a plurality of image blocks; Extracting the characteristics of each image block; Classifying the image blocks based on the characteristics of the image blocks; Extracting frequency domain coefficient features based on the image blocks belonging to each category, and generating a quantization matrix of the category; And quantizing each image block based on the quantization matrix corresponding to the category to which the image block belongs, and generating a coding code stream based on a quantization result.
- 2. The JPEG image encoding method according to claim 1, wherein said encoded code stream comprises at least encoded data of each of said image blocks, index information indicating said category to which each of said image blocks belongs, and data of said quantization matrix of each of said categories.
- 3. The JPEG image encoding method according to claim 1, wherein said feature of said image block is extracted, comprising at least one of a frequency feature based on discrete cosine transform coefficients, a luminance feature based on pixel values, a texture feature based on gradients.
- 4. The JPEG image encoding method according to claim 1, wherein classifying each of said image blocks based on said characteristics of said image blocks comprises clustering said image blocks based on said characteristics by a clustering algorithm, and determining the number of said categories by a preset rule.
- 5. The JPEG image encoding method according to claim 4, wherein the image block includes a luminance component block and a chrominance component block, wherein the number of categories into which the luminance component block is divided is greater than the number of categories into which the chrominance component block is divided.
- 6. The JPEG image encoding method according to claim 1, wherein generating the quantization matrix of the class includes adjusting a quantization step size of each frequency point in a reference quantization matrix based on the frequency domain coefficient characteristic of the image block of the class to generate the quantization matrix of the class.
- 7. A JPEG image decoding method, comprising: Acquiring a coded code stream, wherein the coded code stream at least comprises coded data of a plurality of image blocks, index information for indicating the category to which each image block belongs and data of quantization matrixes of each category; determining the quantization matrix corresponding to each image block according to the index information; dequantizing quantization coefficients of the image blocks based on the quantization matrices corresponding to the image blocks; And constructing an image based on the quantized coefficients after the inverse quantization.
- 8. A JPEG image encoding device, comprising: The block dividing module is configured to acquire an image to be encoded and perform block dividing processing to acquire a plurality of image blocks; a feature extraction module configured to extract features of each of the image blocks; a classification module configured to divide the image blocks into a plurality of categories based on the features of the image blocks; a matrix generation module configured to extract frequency domain coefficient features based on the image blocks belonging to each of the categories, and generate a quantization matrix for the category; a quantization module configured to quantize, for the image block, the image block based on the quantization matrix corresponding to the category to which the image block belongs; And the code stream generating module is configured to generate a code stream based on the quantization result of the image block.
- 9. A JPEG image decoding apparatus, comprising: The code stream analysis module is configured to acquire a code stream, wherein the code stream at least comprises code data of a plurality of image blocks, index information for indicating the category to which each image block belongs and data of quantization matrixes of each category; The matrix determining module is configured to determine the quantization matrix corresponding to each image block according to the index information; The inverse quantization module is configured to inverse quantize quantization coefficients of the image blocks based on the quantization matrixes corresponding to the image blocks; and the image reconstruction module is configured to construct an image based on the quantized coefficients after the inverse quantization.
- 10. A computer program product comprising a computer readable storage medium having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements the method according to any of claims 1 to 7.
Description
JPEG image coding and decoding method, device and computer program product Technical Field The present application relates to the field of image processing technologies, and in particular, to a JPEG image encoding and decoding method, apparatus, and computer program product. Background JPEG is widely applied to image compression and mainly comprises the steps of blocking, discrete cosine transformation, quantization, entropy coding and the like. In the quantization step, the existing scheme generally adopts a fixed standardized quantization matrix. However, the fixed matrix cannot adapt to the characteristic differences of textures, brightness and the like of different image areas, so that details are lost at complex textures, compression is insufficient in a smooth area, and the balance of compression efficiency and reconstruction quality is affected. Therefore, there is a need for a JPEG image encoding and decoding method that can adaptively adjust the quantization process according to the image content while optimizing the storage and code stream overhead. Disclosure of Invention The application provides a JPEG image coding and decoding method, a device and a computer program product. In a first aspect, the present application provides a JPEG image encoding method, comprising: Acquiring an image to be encoded and performing blocking processing to obtain a plurality of image blocks; Extracting the characteristics of each image block; classifying the image blocks based on the characteristics of the image blocks; Extracting frequency domain coefficient characteristics based on image blocks belonging to each category, and generating a quantization matrix of the category; for each image block, quantizing the image block based on a quantization matrix corresponding to the category to which the image block belongs, and generating a coding code stream based on a quantization result. In some embodiments, the encoded code stream includes at least encoded data of each image block, index information indicating a category to which each image block belongs, and data of each quantization matrix. In some embodiments, the features of the image block are extracted, including at least one of a frequency feature based on discrete cosine transform coefficients, a luminance feature based on pixel values, and a texture feature based on gradients. In some embodiments, classifying the image blocks based on their features includes clustering the image blocks based on their features by a clustering algorithm and determining the number of classes by a preset rule. In some embodiments, an image block includes a luminance component block and a chrominance component block, wherein the number of categories into which the luminance component block is divided is greater than the number of categories into which the chrominance component block is divided. In some embodiments, generating a class quantization matrix includes adjusting a quantization step size of each frequency point in a reference quantization matrix based on frequency domain coefficient characteristics of an image block of the class to generate the class quantization matrix. In a second aspect, the present application provides a JPEG image decoding method, comprising: acquiring a coded code stream, wherein the coded code stream at least comprises coded data of a plurality of image blocks, index information for indicating the category to which each image block belongs and data of each quantization matrix; Determining a quantization matrix corresponding to each image block according to the index information; dequantizing quantization coefficients of the image blocks based on quantization matrices corresponding to the image blocks; an image is constructed based on the dequantized quantized coefficients. In a third aspect, the present application provides a JPEG image encoding device, comprising: The block dividing module is configured to acquire an image to be encoded and perform block dividing processing to acquire a plurality of image blocks; A feature extraction module configured to extract features of each image block; A classification module configured to divide the image blocks into a plurality of categories based on features of the image blocks; a matrix generation module configured to extract frequency domain coefficient features based on image blocks belonging to each category and generate a quantization matrix of the category; The quantization module is configured to quantize the image block based on a quantization matrix corresponding to the category to which the image block belongs; and a code stream generating module configured to generate a code stream based on the quantization result of the image block. In a fourth aspect, the present application provides a JPEG image decoding apparatus, comprising: the code stream analysis module is configured to acquire a code stream, wherein the code stream at least comprises coded data of a plurality of image blocks, index i