JPEG (Joint Photographic Experts Group) image coding and decoding method and device and computer program product

By extracting features and clustering JPEG image blocks, an adaptive quantization matrix is ​​generated, which solves the problem that a fixed quantization matrix cannot adapt to differences in image features, thereby improving compression efficiency and image quality.

CN121985122APending Publication Date: 2026-05-05SPREADTRUM COMM (TIANJIN) INC
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SPREADTRUM COMM (TIANJIN) INC
Filing Date
2026-01-16
Publication Date
2026-05-05

AI Technical Summary

Technical Problem

In existing JPEG image encoding and decoding methods, the fixed quantization matrix cannot adapt to the differences in texture and brightness features in different image regions, resulting in the loss of details in complex textures and insufficient compression in smooth areas, affecting the balance between compression efficiency and reconstruction quality.

Method used

By extracting features from image patches, image patches with similar features are divided into categories based on a clustering algorithm, and a matching quantization matrix is ​​generated for each category. Different numbers of categories are set for luminance and chrominance components to optimize the quantization process.

Benefits of technology

It achieves adaptive quantization based on image content, improving compression efficiency while maintaining image quality, and ensuring the practicality and compatibility of the encoding and decoding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121985122A_ABST
    Figure CN121985122A_ABST
Patent Text Reader

Abstract

The invention discloses a JPEG (Joint Photographic Experts Group) image encoding and decoding method and device and a computer program product, and relates to the technical field of image processing. The coding method comprises the following steps: carrying out block processing on a to-be-coded image; extracting features of each image block; clustering the image blocks into a limited number of categories based on the features; for each category, generating a quantization matrix of the category according to the frequency domain coefficient characteristics of the image blocks of the category; and according to the category to which each image block belongs, calling a corresponding quantization matrix for quantization, and generating a coding code stream containing the index information and each category of quantization matrix data. The decoding method comprises the following steps: analyzing a 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. According to the method, the quantization matrixes corresponding to the categories are clustered, so that the JPEG compression efficiency is remarkably improved, the extra storage and code stream overhead is effectively controlled, and good compatibility is kept.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to a JPEG image encoding / decoding method, apparatus, and computer program product. Background Technology

[0002] JPEG is widely used in image compression, mainly involving steps such as block division, discrete cosine transform, quantization, and entropy coding. In the quantization stage, existing schemes typically employ a fixed, normalized quantization matrix. However, a fixed matrix cannot adapt to differences in texture, brightness, and other features across different image regions, leading to detail loss in complex textures and insufficient compression in smooth areas, thus affecting the balance between compression efficiency and reconstruction quality.

[0003] Therefore, there is an urgent need for a JPEG image encoding and decoding method that can adaptively adjust the quantization process according to the image content while optimizing storage and bitstream overhead. Summary of the Invention

[0004] This application provides a JPEG image encoding / decoding method, apparatus, and computer program product.

[0005] Firstly, this application provides a JPEG image encoding method, including: The image to be encoded is acquired and divided into blocks to obtain multiple image blocks; Extract features from each image patch; Based on the features of image patches, image patches are classified into categories; Frequency domain coefficient features are extracted based on image patches belonging to each category, and a quantization matrix for that category is generated; For each image block, the image block is quantized based on the quantization matrix corresponding to its category, and an encoded bitstream is generated based on the quantization result.

[0006] In some embodiments, the encoded bitstream includes at least the encoded data of each image block, index information indicating the category to which each image block belongs, and data of the quantization matrix for each category.

[0007] In some embodiments, features of the image patch are extracted, including at least one of frequency features based on discrete cosine transform coefficients, brightness features based on pixel values, and texture features based on gradients.

[0008] In some embodiments, classifying image blocks into categories based on their features includes: clustering image blocks based on features using a clustering algorithm, and determining the number of categories using preset rules.

[0009] 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.

[0010] In some embodiments, generating a quantization matrix for a category includes: adjusting the quantization step size of each frequency point in a reference quantization matrix based on the frequency domain coefficient features of the image blocks of that category, so as to generate a quantization matrix for that category.

[0011] Secondly, this application provides a JPEG image decoding method, including: Obtain the encoded bitstream, which includes at least the encoded data of multiple image blocks, index information indicating the category to which each image block belongs, and data of the quantization matrix for each category; Based on the index information, determine the quantization matrix corresponding to each image block; The quantization coefficients of each image block are dequantized based on the quantization matrix corresponding to each image block. The image is constructed based on the quantization coefficients after inverse quantization.

[0012] Thirdly, this application provides a JPEG image encoding apparatus, comprising: The block segmentation module is configured to acquire the image to be encoded and perform block segmentation processing to obtain multiple image blocks; The feature extraction module is configured to extract features from each image patch; The classification module is configured to divide image patches into multiple categories based on the features of the image patches; The matrix generation module is configured to extract frequency domain coefficient features based on image patches belonging to each category and generate a quantization matrix for that category. The quantization module is configured to quantize an image patch based on the quantization matrix corresponding to its category. The bitstream generation module is configured to generate an encoded bitstream based on the quantization results of image blocks.

[0013] Fourthly, this application provides a JPEG image decoding apparatus, comprising: The bitstream parsing module is configured to obtain the encoded bitstream, which includes at least the encoded data of multiple image blocks, index information indicating the category to which each image block belongs, and data of the quantization matrix for each category; The matrix determination module is configured to determine the quantization matrix corresponding to each image block based on the index information. The inverse quantization module is configured to inverse quantize the quantization coefficients of each image block based on the quantization matrix corresponding to each image block. The image reconstruction module is configured to construct an image based on the quantization coefficients after inverse quantization.

[0014] Fifthly, this application provides a computer program product, including a computer-readable storage medium on which a computer program is stored, and a method for implementing any one of the methods when the computer program is executed by a processor.

[0015] The at least one technical solution adopted in this application can achieve the following beneficial effects: by extracting image patch features and performing clustering, image patches with similar features are grouped into the same category, thereby enabling image patches to be classified with a finite number of categories far fewer than the total number of image patches. Based on this, a quantization matrix matching its frequency domain statistical features is generated for each category, allowing the quantization process to match the detailed features of the image content of that category, effectively overcoming the problem that a fixed quantization matrix cannot adapt to changes in image content. Furthermore, considering the difference in sensitivity of the human visual system to luminance and chrominance, more categories are set for the luminance component to achieve finer quantization, while fewer categories are set for the chrominance component to optimize bitrate allocation, thereby improving compression efficiency while better maintaining subjective image quality. In addition, the category index information and the quantization matrix data of each category are encapsulated in the header of the encoded bitstream, enabling efficient image recovery during decoding, achieving high compression performance while ensuring the practicality of encoding and decoding and compatibility with standard formats.

[0016] It should be understood that both the foregoing general description and the following detailed description are exemplary and intended to provide further illustration of the claimed technology. Attached Figure Description

[0017] The above and other objects, features, and advantages of this application will become more apparent from the more detailed description of the embodiments of this application in conjunction with the accompanying drawings. The accompanying drawings are used to provide a further understanding of the embodiments of this application and form part of the specification. They are used together with the embodiments of this application to explain this application and do not constitute a limitation thereof. In the accompanying drawings, the same reference numerals generally represent the same components or steps.

[0018] Figure 1 This illustration schematically shows an overall flowchart of a JPEG image encoding method according to an embodiment of this application; Figure 2 This illustration schematically shows a flowchart of image block feature extraction in a JPEG image encoding method according to an embodiment of this application; Figure 3 This illustration schematically shows a diagram of an image block clustering process according to an embodiment of the present application for a JPEG image encoding method; Figure 4 This illustration schematically shows a quantization matrix generation process of a JPEG image encoding method according to an embodiment of this application; Figure 5This illustration schematically shows a process diagram of generating the encoded bitstream of a JPEG image encoding method according to an embodiment of this application; Figure 6 This illustration schematically shows an overall flow diagram of a JPEG image decoding method according to an embodiment of this application; Figure 7 This schematic diagram illustrates the overall structure of a JPEG image encoding apparatus according to an embodiment of the present application. Figure 8 This illustration schematically shows a matrix generation module structure of a JPEG image encoding apparatus according to an embodiment of the present application; Figure 9 This schematic diagram illustrates the overall structure of a JPEG image decoding apparatus according to an embodiment of the present application. Figure 10 This illustration schematically shows a matrix determination module structure of a JPEG image decoding apparatus according to an embodiment of this application; Figure 11 An exemplary block diagram of a computer program product for a JPEG image encoding / decoding method according to an embodiment of this application is illustrated.

[0019] In the diagram: 701, Block segmentation module; 702, Feature extraction module; 703, Classification module; 704, Matrix generation module; 705, Quantization module; 706, Bitstream generation module; 707, Feature extraction submodule; 708, Adjustment coefficient calculation submodule; 709, Initial matrix generation submodule; 710, Constraint processing submodule; 901, Bitstream parsing module; 902, Matrix determination module; 903, Inverse quantization module; 904, Image reconstruction module; 905, Index parsing submodule; 906, Matrix selection submodule; 1101, Computer program. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of this application more apparent, exemplary embodiments according to this application will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments of this application. It should be understood that this application is not limited to the exemplary embodiments described herein.

[0021] Figure 1 The illustration shows an overall flowchart of a JPEG image encoding method according to an embodiment of this application.

[0022] like Figure 1 As shown, the steps are as follows: S101, the image to be encoded is preprocessed and divided into blocks to obtain multiple image blocks. Specifically, the image is converted from the RGB color space to the YCrCb color space to process the luminance and chrominance information separately. After the conversion, the image of each color channel is uniformly divided into fixed sizes, such as 8 pixels × 8 pixels, to obtain non-overlapping image blocks.

[0023] S102, extract features from each image patch to obtain the corresponding feature vector. For each image patch, feature calculation is performed, including frequency features based on discrete cosine transform coefficients, brightness or chromaticity mean features based on pixel values, and texture features based on image gradients. The calculated features are then normalized and combined into a multi-dimensional feature vector.

[0024] S103, clustering image patches based on feature vectors to obtain the category corresponding to each image patch. Clustering algorithms such as K-means are used to analyze the feature vectors of all image patches, grouping patches with similar features into the same category. During the clustering process, optimization methods such as the elbow method are used to determine the optimal number of categories, and finally, the category corresponding to each image patch is obtained.

[0025] S104: Based on the frequency domain coefficient characteristics of image patches in each category, generate the quantization matrix corresponding to that category. Specifically, statistically analyze the frequency domain coefficient distribution characteristics of all image patches in that category after discrete cosine transform. Based on the frequency domain coefficient distribution characteristics obtained above, calculate the importance weight of each frequency point, i.e., each position in the discrete cosine transform coefficient matrix. This importance weight is usually inversely proportional to the average energy of the discrete cosine transform coefficients at that frequency point. Use these calculated importance weights to adjust the quantization step size of the corresponding frequency point in the standard JPEG reference quantization matrix, thereby generating a quantization matrix that matches the content characteristics of that category. Furthermore, to ensure practicality and stability, apply preset upper and lower bound constraints to the adjusted quantization step size.

[0026] S105: Image blocks are quantized using quantization matrices corresponding to each category, and an encoded bitstream is generated based on the quantization results. When encoding each image block, the corresponding quantization matrix is ​​selected according to its category to quantize its discrete cosine transform coefficients. The quantized discrete cosine transform coefficients are then entropy-encoded and compressed. The header of the encoded bitstream embeds complete data of all category-specific quantization matrices generated during the encoding process, as well as index information recording the correspondence between each image block and its category label. The main body of the encoded bitstream consists of the aforementioned entropy-encoded and compressed discrete cosine transform coefficient data. The header information and the main body data are combined according to a predetermined format to obtain a complete compressed bitstream.

[0027] Figure 2The illustration shows a schematic diagram of the image block feature extraction process of a JPEG image encoding method according to an embodiment of this application.

[0028] like Figure 2 As shown, the steps are as follows: S201, Perform a Discrete Cosine Transform (DCT) on each image block to obtain the corresponding frequency domain coefficient block. Apply the DCT to each divided image block to transform the image data from the spatial domain to the frequency domain. After the transformation, frequency domain coefficient blocks of the same size are obtained. The coefficients in the upper left corner of the frequency domain coefficient block represent low-frequency components, mainly carrying the basic outline and overall information of the image; the coefficients in the lower right corner of the frequency domain coefficient block represent high-frequency components, which usually correspond to the details, edges, and texture information in the image.

[0029] S202 calculates the frequency, brightness, and texture features of an image patch based on the frequency domain coefficient block. The frequency feature calculation is based on the analysis of the distribution characteristics of the discrete cosine transform coefficients in the frequency domain. The smoothness or texture complexity of the image patch is quantified by calculating the ratio of the energy of the coefficients in the low-frequency region to the total energy of the entire coefficient block.

[0030] The calculation of brightness features is directly based on the pixel values ​​of the original image block. The average value of all pixel values ​​is calculated for the brightness component block to characterize the brightness of the image block.

[0031] Texture feature calculation is based on the structural changes of image patches in the spatial domain. By calculating the statistical magnitude of the gradient of pixels in the horizontal and vertical directions within the patch, the richness and directionality of the edges within the image patch are reflected.

[0032] (Formula 1) Formula 1 is used to quantify the smoothness or texture complexity of image patches and is one of the core dimensions of the feature vector. This represents the set of the first 10 low-frequency coefficients after the discrete cosine transform, corresponding to the key region in the frequency domain that carries the basic outline of the image. This indicates the frequency points of an image patch after discrete cosine transform. The coefficient value at a given point is calculated by dividing the numerator by the sum of the energies of the first 10 low-frequency coefficients and the denominator by the total energy of the entire discrete cosine coefficient block. The ratio of these two values ​​is given by the denominator. The larger the value, the smoother the image patch and the simpler the texture; conversely, the smaller the value, the more complex the texture. The size of the discrete cosine coefficient block is typically 8×8.

[0033] (Formula 2) Formula 2 is used to calculate the brightness of image patches based on the luminance component, adapting to the human eye's sensitivity to brightness. In the luminance component image block The pixel grayscale value at a given location is obtained by summing all pixel values ​​and then dividing by 64, since the image block size is 8×8, totaling 64 pixels. This value directly reflects the overall brightness level of the image patch, providing a quantitative basis for the brightness dimension in subsequent clustering.

[0034] (Formula 3) Formula 3 is used to quantify the edge richness of image patches in the horizontal direction, indirectly reflecting the density of texture details. Among these... Obtained through Sobel operator or finite difference method Position horizontal gradient value, The standard deviation of the horizontal gradient is obtained by taking the square root of the sum of the squares of the deviations of the gradient values ​​from the mean, with a denominator of 63. The larger the value, the denser the horizontal edges and the richer the image block texture.

[0035] (Formula 4) Formula 4 is used to quantify the edge richness of image patches in the vertical direction. Wherein... Indicating an 8×8 image block Vertical gradient magnitude at position This is the mean of all vertical gradient values ​​within the image patch, used to eliminate the influence of overall gradient offset on the calculation results. The denominator is set to 63 based on the degree-of-freedom correction design, ensuring the statistical validity of the standard deviation calculation. The result is obtained by calculating the sum of squares of the deviations of all vertical gradient values ​​from the mean, averaging them, and then taking the square root. It can objectively reflect the density and uniformity of the vertical edges. The larger the value, the richer the vertical edges of the image patch and the more complex the texture; the smaller the value, the smoother the vertical edges.

[0036] S203: Based on the calculated frequency features, brightness features, and texture features, a feature vector for the image patch is obtained. Specifically, the calculated feature values ​​are normalized and combined to form a multidimensional feature vector for the corresponding image patch.

[0037] Figure 3 The illustration shows a schematic diagram of the image block clustering process of a JPEG image encoding method according to an embodiment of this application.

[0038] like Figure 3 As shown, the steps are as follows: S301, determine the optimal number of clusters for the luminance and chrominance component blocks using the elbow method. Specifically, the elbow method can be used as the preset rule. It sets a range of candidate cluster numbers for each component set, performs clustering for each candidate number within the range, and calculates the total error expressed as the sum of squared intra-cluster distances. The cluster number corresponding to the point where the error descent rate shows a significant inflection point is taken as the optimal cluster number. Perform the following operations for the luminance and chrominance component block sets respectively: Set a range of candidate cluster numbers for each component set; perform clustering for each candidate number within the range and calculate the corresponding total error, expressed as the sum of squared intra-cluster distances. As the number of clusters increases, the total error decreases, and the rate of error descent gradually slows down. The point where the error descent rate shows a significant inflection point is called the elbow point, and the cluster number corresponding to this point is taken as the optimal cluster number for that component. Because the human eye is more sensitive to luminance details, the optimal cluster number for the luminance component is usually higher than that for the chrominance component, thus distinguishing between different components.

[0039] S302, based on the determined optimal number of clusters, performs clustering algorithms on the luminance component blocks and chrominance component blocks respectively. Specifically, the K-means algorithm can be used. Alternatively, lightweight classification networks such as MobileNet or EfficientNet can be selected to perform category pre-detection of the image before clustering. Using the optimal number of clusters determined for each component as input parameters, the selected clustering algorithm is applied to divide the feature vectors of all image patches for the corresponding component. Clustering for the luminance component and chrominance component is performed independently.

[0040] S303, Based on the clustering results, the category corresponding to each image patch is obtained. After clustering is completed, each image patch is divided into a specific cluster, and each cluster is defined as an independent category. Based on the cluster division results, the corresponding category of each image patch is determined.

[0041] Figure 4 The illustration shows a schematic diagram of the quantization matrix generation process of a JPEG image encoding method according to an embodiment of this application.

[0042] like Figure 4 As shown, the steps are as follows: S401, Select a category for which the quantization matrix to be generated, and extract the frequency domain coefficient features of the image patches in that category. Specifically, for all image patches included in the selected category, obtain the discrete cosine transform coefficient blocks of all image patches in that category. By analyzing the values ​​of the discrete cosine transform coefficient blocks at the same frequency point, extract statistical features that characterize the overall frequency domain properties of the category as frequency domain coefficient features.

[0043] S402, based on the frequency domain coefficient characteristics, calculates the deviation of each frequency point relative to the reference distribution, obtaining the quantization step size adjustment coefficient for each frequency point. Based on the extracted frequency domain statistical features, an adjustment coefficient is calculated for each frequency point in the discrete cosine transform coefficient matrix. The calculation follows this principle: smaller adjustment coefficients are assigned to frequencies with higher average energy, and larger adjustment coefficients are assigned to frequencies with lower average energy. This generates differentiated adjustment coefficients for frequencies with different average energy levels, which are then used to adjust the quantization step size accordingly in subsequent steps.

[0044] (Formula 5) Formula 5 achieves the inverse correlation matching between the frequency point quantization step size and the coefficient energy. It is the frequency of all image patches in the current category. The mean absolute value of the discrete cosine coefficients at a given frequency reflects the energy density at that frequency. k This is a normalization constant to ensure that the weight scaling ratio is consistent across all frequency points, thus avoiding adjustment deviations caused by category differences. ε It can usually be set to 0.001 to prevent the denominator from being 0. According to this formula, low-frequency points with high energy, which carry the core information of the image, will receive a smaller weight. The lower energy, higher frequency points carry less important details and are given greater weight, corresponding to a larger quantization step size to preserve details.

[0045] S403: Multiply the quantization step size adjustment coefficient by the step size of the corresponding frequency point in the preset reference quantization matrix to obtain the initial quantization matrix for this category. Obtain the JPEG reference quantization matrix as the reference matrix. Multiply the calculated adjustment coefficient of each frequency point by the quantization step size of the corresponding frequency point in the reference quantization matrix to obtain the scaled quantization step size. Based on the scaled step sizes of all frequency points, form the initial quantization matrix for this category.

[0046] (Formula 6) Formula 6 generates a quantization matrix adapted to the category features based on the JPEG baseline quantization matrix and frequency point weights. It is a JPEG reference quantization matrix, which provides a basic quantization benchmark and ensures compatibility. The frequency adjustment coefficient is calculated using the formula above. This is a rounding function to ensure the quantization step size is an integer, conforming to the hardware implementation logic of JPEG encoding. The generated... Constraints must be met Setting the lower limit to 1 can avoid excessive retention of redundant information due to an excessively small quantization step size, while setting the upper limit to 30 to 50 can ensure compression efficiency and achieve a quantization effect that balances category feature matching and compression efficiency.

[0047] S404, apply upper and lower bound constraints to the quantization step size of the initial quantization matrix to obtain the quantization matrix corresponding to that category. For each quantization step size in the initial quantization matrix, determine whether it exceeds the preset lower and upper bounds. Set step sizes smaller than the lower bound to the lower bound value, and set step sizes larger than the upper bound value to the upper bound value. This prevents excessively small quantization step sizes from causing low compression efficiency and increased computational burden, or excessively large quantization step sizes from causing unacceptable information loss and severe image quality degradation. The matrix after the above constraint processing is the quantization matrix corresponding to that category.

[0048] Figure 5 The illustration shows a schematic diagram of the encoding stream generation process of a JPEG image encoding method according to an embodiment of this application.

[0049] like Figure 5 As shown, the steps are as follows: S501, based on the quantization results, construct an encoded bitstream header that includes at least the encoded data of each image block, index information indicating the category to which each image block belongs, and quantization matrix data for each category. Specifically, the index information records the category to which each image block belongs according to a predetermined arrangement of the image blocks, thereby establishing a mapping relationship between the image block position and the category. At the same time, the quantization matrix data generated for each category during the encoding process is also written into the header.

[0050] S502, the entropy-encoded data of the quantization coefficients of the image blocks is used as the main body of the encoded bitstream and combined with the encoded bitstream header to generate a complete encoded bitstream. Specifically, the discrete cosine transform coefficients of each quantized image block are entropy-encoded to obtain compressed discrete cosine transform coefficient data as the main body of the bitstream. Based on the encoded bitstream header and the encoded bitstream main body, a complete compressed bitstream is generated.

[0051] Figure 6 The illustration shows an overall flowchart of a JPEG image decoding method according to an embodiment of this application.

[0052] like Figure 6 As shown, the steps are as follows: S601, parse the encoded bitstream to obtain the index information indicating the category of each image patch, the quantization matrix data of each category, and the entropy-coded data of the image patches. Specifically, separate the header and body from the received encoded bitstream. Parse the header information to obtain the index information recorded therein, arranged in the order of image patches, and extract the quantization matrix data of each category. At the same time, obtain the entropy-coded compressed image patch coefficient data from the body of the encoded bitstream.

[0053] S602, Based on the index information, determine the corresponding quantization matrix for each image block. According to the category indicated by the index information, and in the order corresponding to the image blocks, sequentially select the quantization matrix that matches the category to which each image block belongs from the parsed quantization matrix data of each category.

[0054] S603, dequantize the quantization coefficients of the corresponding image block using the determined quantization matrix. Specifically, decode the entropy-coded data of each image block to recover its quantized discrete cosine transform coefficient matrix. For each image block, use the quantization matrix of the corresponding category to perform dequantization on the discrete cosine transform coefficient matrix to obtain its approximate original transform coefficients.

[0055] (Formula 7) Equation 7 represents the inverse process of the encoding quantization operation, used to recover the frequency domain coefficients of image blocks, providing a foundation for image reconstruction. Wherein... This is the quantization coefficient matrix obtained after Huffman decoding. The quantization matrix corresponding to the category of the current image patch determined by the bitstream index table is multiplied by the quantization matrix. These are the original discrete cosine coefficients that are approximately restored.

[0056] S604 constructs and outputs an image based on the dequantized coefficients. The inverse discrete cosine transform (ICT) is applied to the discrete cosine transform coefficient matrix obtained after dequantization of each image block to reconstruct each image block. The reconstructed image blocks are then stitched together sequentially to obtain complete Y-component, Cb-component, and Cr-component images. The Y-component, Cb-component, and Cr-component images are then converted from the YCrCb color space to the RGB color space to generate and output the decoded image.

[0057] Figure 7 The schematic diagram illustrates the overall structure of a JPEG image encoding apparatus according to an embodiment of this application.

[0058] like Figure 7 As shown, the device includes a block segmentation module 701, a feature extraction module 702, a classification module 703, a matrix generation module 704, a quantization module 705, and a code stream generation module 706.

[0059] The block segmentation module 701 is configured to convert the input RGB image to the YCrCb color space and perform block processing on the image of each color channel to obtain image blocks.

[0060] The feature extraction module 702 is configured to perform discrete cosine transform on each image block and extract features, and then normalize and combine the extracted features to obtain the feature vector corresponding to each image block.

[0061] The classification module 703 is configured to cluster image patches based on feature vectors and obtain the category corresponding to each image patch based on the clustering results.

[0062] The matrix generation module 704 is configured to generate a quantization matrix corresponding to each category based on the frequency domain coefficient features of the image patch in each category.

[0063] The quantization module 705 is configured to select the corresponding quantization matrix based on the category of each image patch and quantize the discrete cosine transform coefficients of the image patch.

[0064] The bitstream generation module 706 is configured to generate an encoded bitstream based on the quantization result. The header of the encoded bitstream contains index information corresponding to the category and quantization matrix data for each category, while the main body of the bitstream contains discrete cosine transform coefficient data after entropy encoding compression.

[0065] Figure 8 The diagram illustrates a matrix generation module structure of a JPEG image encoding apparatus according to an embodiment of this application.

[0066] like Figure 8 As shown, the matrix generation module 704 includes a feature extraction submodule 707, an adjustment coefficient calculation submodule 708, an initial matrix generation submodule 709, and a constraint processing submodule 710.

[0067] The feature extraction submodule 707 is configured to obtain the discrete cosine transform coefficient blocks of all image blocks of the selected category, and extract the frequency domain coefficient features that characterize the overall frequency domain characteristics of the category.

[0068] The adjustment coefficient calculation submodule 708 is configured to calculate a quantization step size adjustment coefficient for each frequency point in the discrete cosine transform coefficient matrix based on the frequency domain coefficient characteristics.

[0069] The initial matrix generation submodule 709 is configured to multiply the adjustment coefficients of each frequency point by the step size of the corresponding frequency point in the reference quantization matrix to generate the initial quantization matrix of that category.

[0070] The constraint processing submodule 710 is configured to perform upper and lower limit constraint processing on each quantization step size in the initial quantization matrix to obtain the final quantization matrix of that category.

[0071] Figure 9 The schematic diagram illustrates the overall structure of a JPEG image decoding apparatus according to an embodiment of this application.

[0072] like Figure 9 As shown, the device includes a code stream parsing module 901, a matrix determination module 902, an inverse quantization module 903, and an image reconstruction module 904.

[0073] The bitstream parsing module 901 is configured to parse the encoded bitstream and obtain its index information, quantization matrix data of various categories, and image block data compressed by entropy coding.

[0074] The matrix determination module 902 is configured to determine the quantization matrix corresponding to each image block based on the index information.

[0075] The dequantization module 903 is configured to decode the entropy-encoded data of the image block to obtain the quantization coefficient matrix, and then use the determined quantization matrix to perform dequantization calculation.

[0076] The image reconstruction module 904 is configured to perform inverse discrete cosine transform on the discrete cosine transform coefficient matrix of each image block after inverse quantization to reconstruct the image block, and output the decoded image after stitching and color space conversion.

[0077] Figure 10 The diagram illustrates a matrix determination module structure of a JPEG image decoding apparatus according to an embodiment of this application.

[0078] like Figure 10 As shown, the matrix determination module 902 includes an index parsing submodule 905 and a matrix selection submodule 906.

[0079] Among them, the index parsing submodule 905 is configured to parse the index information to obtain the category corresponding to each image block.

[0080] The matrix selection submodule 906 is configured to select the corresponding quantization matrix from the parsed quantization matrix data of each category based on the category of the image patch.

[0081] Figure 11 An exemplary block diagram of a computer program product for a JPEG image encoding / decoding method according to an embodiment of this application is illustrated.

[0082] like Figure 11 As shown, the computer program product stores a computer program 1101, which, when executed by a processor, implements the method provided in any embodiment of this application.

[0083] The basic principles of this application have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this application are merely examples and not limitations, and should not be considered as essential features of each embodiment of this application. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the application to the necessity of employing the aforementioned specific details for implementation.

[0084] The block diagrams of devices, apparatuses, devices, and systems involved in this application are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.

[0085] Additionally, as used herein, the "or" used in a list of items beginning with "at least one" indicates a separate list, such that a list of, for example, "at least one of A, B, or C" means A or B or C, or AB or AC or BC, or ABC (i.e., A and B and C). Furthermore, the word "exemplary" does not imply that the described example is preferred or better than other examples.

[0086] It should also be noted that in the system and method of this application, the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered as equivalent solutions of this application.

[0087] Various changes, substitutions, and modifications can be made to the technology described herein without departing from the teachings defined by the appended claims. Furthermore, the scope of the claims of this application is not limited to the specific aspects of the processes, machines, manufacturing, events, means, methods, and actions described above. Currently existing or later-developed processes, machines, manufacturing, events, means, methods, or actions that perform substantially the same function or achieve substantially the same result as the corresponding aspects described above can be utilized. Therefore, the appended claims include such processes, machines, manufacturing, events, means, methods, or actions within their scope.

[0088] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this application. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of this application. Therefore, this application is not intended to be limited to the aspects shown herein, but rather to be accorded the widest scope consistent with the principles and novel features disclosed herein.

[0089] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this application to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.

Claims

1. A JPEG image encoding method, characterized in that, include: The image to be encoded is acquired and divided into blocks to obtain multiple image blocks; Extract features from each of the image patches; Based on the characteristics of the image blocks, the image blocks are classified into categories; Frequency domain coefficient features are extracted based on the image patches belonging to each of the aforementioned categories, and a quantization matrix for that category is generated. For each image block, the image block is quantized based on the quantization matrix corresponding to its category, and an encoded bitstream is generated based on the quantization result.

2. The JPEG image encoding method according to claim 1, characterized in that, The encoded bitstream includes at least the encoded data of each image block, index information indicating the category to which each image block belongs, and the data of the quantization matrix of each category.

3. The JPEG image encoding method according to claim 1, characterized in that, The features extracted from the image patch include at least one of frequency features based on discrete cosine transform coefficients, brightness features based on pixel values, and texture features based on gradients.

4. The JPEG image encoding method according to claim 1, characterized in that, The process of classifying the image blocks into categories based on their features includes: clustering the image blocks based on their features using a clustering algorithm, and determining the number of categories using preset rules.

5. The JPEG image encoding method according to claim 4, characterized in that, 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, characterized in that, Generating the quantization matrix of the category includes: adjusting the quantization step size of each frequency point in the reference quantization matrix based on the frequency domain coefficient features of the image patch of the category, so as to generate the quantization matrix of the category.

7. A JPEG image decoding method, characterized in that, include: Obtain the encoded bitstream, which includes at least encoded data of multiple image blocks, index information indicating the category to which each image block belongs, and data of the quantization matrix for each category; Based on the index information, determine the quantization matrix corresponding to each image block; The quantization coefficients of the image blocks are dequantized based on the quantization matrix corresponding to each image block; An image is constructed based on the quantization coefficients after dequantization.

8. A JPEG image encoding device, characterized in that, include: The block segmentation module is configured to acquire the image to be encoded and perform block segmentation processing to obtain multiple image blocks; The feature extraction module is configured to extract features from each of the image blocks; The classification module is configured to divide the image patch into multiple categories based on the features of the image patch; The matrix generation module is configured to extract frequency domain coefficient features based on the image blocks belonging to each of the categories, and generate a quantization matrix for that category; The quantization module is configured to quantize the image patch based on the quantization matrix corresponding to its category. The bitstream generation module is configured to generate an encoded bitstream based on the quantization results of the image blocks.

9. A JPEG image decoding device, characterized in that, include: The bitstream parsing module is configured to acquire the encoded bitstream, which includes at least the encoded data of multiple image blocks, index information indicating the category to which each image block belongs, and data of the quantization matrix for each category; The matrix determination module is configured to determine the quantization matrix corresponding to each of the image blocks based on the index information; The inverse quantization module is configured to inverse quantize the quantization coefficients of the image blocks based on the quantization matrix corresponding to each image block; The image reconstruction module is configured to construct an image based on the quantization coefficients after inverse quantization.

10. A computer program product comprising a computer-readable storage medium on which a computer program is stored, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 7.