Image compression device and method, electronic equipment and computer readable storage medium

By dividing the image into multiple image blocks and using the unique quantization parameters of the image block to perform Hadamard transformation, the problem of poor edge reconstruction effect during image compression in the existing technology is solved, and the stability of the quantization process and the image block are improved. quantification accuracy.

CN118612439APending Publication Date: 2024-09-06BEIJING ESWIN COMPUTING TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410868081.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

The existing fixed-ratio compression method based on Hadamard transform uses the same quantization parameter table during image compression, so it has poor reconstruction effect on large mutation locations (such as edges) of the image, and it is difficult to design the quantization parameter table.

Method used

Divide the image to be compressed into multiple image blocks of the same size, perform Hadamard transform respectively, and use the second quantization parameter specific to the image block to quantize the AC component to improve the stability of the quantization process and avoid the difficulty in designing the quantization parameter table. .

Benefits of technology

By considering the differences between different image blocks and using the unique quantization parameters of the image blocks for full quantification, the stability of the quantization process and the image reconstruction effect are improved. In particular, the reconstruction effect is significantly improved at the position where the image has a large mutation. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118612439A
    Figure CN118612439A
Patent Text Reader

Abstract

The invention provides an image compression device and method, electronic equipment and a computer readable storage medium, and the device comprises a segmentation module which is used for segmenting a to-be-compressed image into a plurality of image blocks; the conversion module is used for obtaining a coefficient matrix of the image blocks; the first quantization module is used for quantizing the direct current component in the coefficient matrix according to the first quantization parameter to obtain a first quantization result of the image block; the second quantization module is used for calculating a second quantization parameter corresponding to the image block and quantizing the alternating current component of the image block through the second quantization parameter to obtain a second quantization result of the image block; and the storage module is used for obtaining and storing a compression result according to the first quantification result and the second quantification result. According to the method and the device, the design difficulty of the quantization parameter table is avoided, and the problem that the reconstruction effect at the position with relatively large mutation of the image is relatively poor due to the fact that all the image blocks use the same quantization parameter table is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an image compression device, method, electronic device and computer-readable storage medium. Background Art

[0002] The original data of an image usually takes up a large storage space, so the original data of the image needs to be compressed to save storage space and reading time.

[0003] When compressing an image, a fixed-ratio compression method based on Hadamard transform can be used to ensure that the data volume of the compressed file is relatively fixed, so that the compression result can be controlled so that the compressed file can be stored in a storage unit of a predetermined size. At present, the fixed-ratio compression method based on Hadamard transform uses a fixed quantization parameter table to quantize each component after Hadamard transform, and finally aggregates the quantization results of each component to obtain a compression result.

[0004] However, the current fixed-rate compression method based on Hadamard transform requires that the quantization parameter table used be determined based on multiple attempts based on experience, and the same quantization parameter table is used for quantization of each image block during compression. This can cause instability in the quantization process, resulting in poor reconstruction effects at locations with large image mutations (such as edges). Summary of the invention

[0005] The embodiments of the present application provide an image compression device, method, electronic device and computer-readable storage medium to solve the problems in the prior art.

[0006] In a first aspect, an embodiment of the present application provides an image compression device, the device comprising:

[0007] A segmentation module, used for segmenting the image to be compressed into a plurality of image blocks, wherein the sizes of the plurality of image blocks are consistent;

[0008] A Hadamard transform module, used for transforming each of the image blocks into a frequency domain to obtain a coefficient matrix of each of the image blocks; the coefficient matrix includes a DC component and an AC component;

[0009] A first quantization module, used for quantizing a DC component in the coefficient matrix according to a first quantization parameter to obtain a first quantization result of each image block;

[0010] A second quantization module is used to calculate a second quantization parameter corresponding to each of the image blocks, and quantize the AC component of the image block by the second quantization parameter to obtain a second quantization result of each of the image blocks; the second quantization parameter is used to represent the maximum shift amount of the AC component when compressing the AC component of the image block;

[0011] The saving module is used to obtain and save the compression result of the image to be compressed according to the first quantization results of all the image blocks and the second quantization results of all the image blocks.

[0012] In a second aspect, an embodiment of the present application provides an image compression method, the image compression method comprising:

[0013] Dividing the image to be compressed into a plurality of image blocks, wherein the sizes of the plurality of image blocks are consistent;

[0014] Transforming each of the image blocks into the frequency domain to obtain a coefficient matrix of each of the image blocks; the coefficient matrix includes a DC component and an AC component;

[0015] quantizing a direct current component in the coefficient matrix according to a first quantization parameter to obtain a first quantization result for each of the image blocks;

[0016] Calculating a second quantization parameter corresponding to each of the image blocks, and quantizing the AC component of the image block by using the second quantization parameter to obtain a second quantization result of each of the image blocks; the second quantization parameter is used to characterize the maximum shift amount of the AC component when compressing the AC component of the image block;

[0017] According to the first quantization results and the second quantization results of all the image blocks, a compression result of the image to be compressed is obtained and saved.

[0018] The image compression device of the embodiment of the present application includes: a segmentation module, which is used to segment the image to be compressed into multiple image blocks of the same size; a conversion module, which is used to transform the image block into the frequency domain to obtain the coefficient matrix of the image block, a first quantization module, which is used to quantize the DC component in the coefficient matrix according to the first quantization parameter to obtain the first quantization result of the image block, a second quantization module, which is used to calculate the corresponding second quantization parameter for each image block, and a storage module, which is used to obtain the compression result of the image to be compressed and save it according to the first quantization results of all image blocks and the second quantization results of all image blocks. When quantizing the AC component in the coefficient matrix, the differences between different image blocks are fully considered, so that the AC component of the image block can be fully quantized using the second quantization parameter exclusive to the image block, and the accuracy is maximized, which can improve the stability of the quantization process, avoid the difficulty in designing the quantization parameter table, and solve the problem of poor reconstruction effect at the position of large mutation of the image caused by using the same quantization parameter table for all image blocks.

[0019] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 is a block diagram of an image compression device provided by an embodiment of the present application;

[0021] Figure 2 This is a schematic diagram of image block segmentation of an image to be compressed provided by an embodiment of the present application;

[0022] Figure 3 It is a schematic diagram of segmentation and splicing of an image block provided in an embodiment of the present application;

[0023] Figure 4 is another schematic diagram of segmentation and splicing of image blocks provided in an embodiment of the present application;

[0024] Figure 5 is a schematic diagram of sorting AC components of an image block provided by an embodiment of the present application;

[0025] Figure 6 It is a schematic diagram of an implementation flow of an image compression method provided in an embodiment of the present application;

[0026] Figure 7 is a flowchart of the steps of an image compression method provided by an embodiment of the present application;

[0027] Figure 8 is a block diagram of an electronic device provided in an embodiment of the present application;

[0028] Fig. 9 It is a block diagram of another electronic device according to another embodiment of the present application. DETAILED DESCRIPTION

[0029] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.

[0030] In the field of image compression, compression methods can be divided into lossless compression and lossy compression from the perspective of information loss. Lossless compression algorithms include run-length coding, Huffman coding, etc. The main purpose of such algorithms is to remove redundant information of the image data itself, that is, structural redundancy. Lossy compression algorithms include Joint Photographic Experts Group (JPEG), JPEG2000, etc. The main purpose of such algorithms is to remove visual redundant information, that is, spatial redundancy. Compression methods can be divided into variable length compression and fixed ratio compression from the perspective of compression rate. Variable length compression can achieve lossless or lossy compression, but it is difficult to predict the size of the compressed file in advance, so it is difficult to determine the minimum capacity of the storage unit, and it is impossible to achieve flexible local data update and random access. Therefore, the embodiments of the present application generally adopt a fixed ratio compression method. The local update data of fixed ratio compression is convenient and flexible, and the size of the file obtained after compression is controllable, so that the compressed file can be stored in a storage unit of a predetermined size, and data overflow will not occur.

[0031] In the embodiments of this application, refer to Figure 1 , which shows a block diagram of an image compression device, including: a segmentation module 101, a Hadamard transformation module 102, a first quantization module 1031, a second quantization module 104 and a storage module 105.

[0032] The segmentation module 101 is used to segment the image to be compressed into a plurality of image blocks, where the sizes of the plurality of image blocks are the same.

[0033] In an embodiment of the present application, to compress an image to be compressed, the image to be compressed can first be divided into multiple image blocks of the same size, so that image compression can be subsequently achieved with the image blocks as the compression granularity. Compared with directly compressing the entire image, compressing the image blocks reduces the difficulty of data processing and improves the compression efficiency.

[0034] For example, refer to Figure 2 , a rectangular image to be compressed can be divided into 10×8 image blocks. The image blocks are independent and non-overlapping, and each image block is adjacent to the surrounding image blocks, that is, the edges of the image blocks overlap.

[0035] The conversion module 102 is used to transform each of the image blocks into the frequency domain to obtain a coefficient matrix of each of the image blocks; the coefficient matrix includes a direct current component and an alternating current component.

[0036] Specifically, the conversion module 102 may use Hadamard Transform to transform each image block into the frequency domain to obtain a coefficient matrix of each image block.

[0037] Hadamard transform is a commonly used transform technique in image processing, which is implemented using the Hadamard matrix as the transform matrix. Hadamard transform is a typical non-sinusoidal function transform. The more evenly distributed the image data is, the more concentrated the data after the Hadamard transform is on the corners of the matrix. Therefore, Hadamard transform has the property of energy concentration, which can compress the non-zero elements of the matrix to only the corners, so it can be used in the field of image compression. The advantage of Hadamard transform is that it only requires real number operations, does not require multiplication operations, and only involves addition and subtraction operations, which makes its calculation efficiency higher.

[0038] In an embodiment of the present application, the image block can be processed by Hadamard transform, which can convert the image block into a set of orthogonal Hadamard basis functions to obtain the frequency representation of the image block, that is, the coefficient matrix of the image block. The core idea is to achieve image compression by reducing the number of areas with non-zero changes in the image.

[0039] Specifically, taking an image block [B] containing 4×4 pixels as an example, the calculation method of the Hadamard transform is as follows:

[0040]

[0041] That is, after the image block [B] is multiplied by the symmetric Hadamard matrix, the corresponding coefficient matrix can be obtained.

[0042] In the coefficient matrix, M_dc is the DC component. After the Hadamard transform, most of the information of the image block is concentrated in the DC component in the upper left corner of the coefficient matrix. The DC component represents the average brightness of the image block. M_ac is the AC component. It can be seen that there are many AC components in the coefficient matrix. The AC component represents the edge, details and other features of the image block. The compression of the image block includes the compression of the DC component and the AC component in the coefficient matrix.

[0043] The first quantization module 103 is used to quantize the direct current component in the coefficient matrix according to a first quantization parameter to obtain a first quantization result of each image block.

[0044] In the embodiment of the present application, since the DC component is the component with the most concentrated image information, a fixed first quantization parameter is used to quantize the DC component to retain most of its data content.

[0045] Specifically, the quantization of the DC component can be designed as a simple shift operation, that is, a right shift, and the shift amount is the value of the first quantization parameter. The quantization process includes:

[0046] Mq_dc=M_dc>>qp

[0047] Among them, Mq_dc is the first quantization result of the DC component, M_dc is the DC component, qp is the first quantization parameter, and >> is a right shift operation.

[0048] In this way, during dequantization, only a simple left shift operation is required to obtain the restored DC component:

[0049] M_dc=Mq_dc< <qp

[0050] The second quantization module 104 is used to calculate a second quantization parameter corresponding to each of the image blocks, and quantize the AC component of the image block using the second quantization parameter to obtain a second quantization result of each of the image blocks.

[0051] The second quantization parameter is used to represent the maximum shift amount of the AC component when compressing the AC component of the image block.

[0052] After the image to be compressed is segmented, different image blocks reflect the characteristics of different positions of the image to be compressed, so the image contents of different image blocks are different or even quite different. In the related art, a fixed quantization parameter table is sampled to uniformly quantize the AC components of each image block, which will result in the quantization process not taking into account the differences between the image blocks, resulting in poor quantization effect, and the design of the quantization parameter table is difficult and relies on experience, which also makes quantization difficult to proceed smoothly. Specifically, using a fixed quantization parameter table to quantize the AC component can only satisfy a portion of the image blocks, while the AC components of the other image blocks may not be accurate enough, or the values ​​are limited to the maximum value of the quantization table, which will result in poor compression effect of these image blocks, such as causing noise to appear at locations with large mutations such as edges.

[0053] In the embodiment of the present application, considering that the image contents of different image blocks in the image to be compressed are different or even quite different, the use of a fixed quantization parameter table can be abandoned, and instead a corresponding second quantization parameter is calculated for each image block. The second quantization parameter of each image block is used to characterize the maximum number of shifts of the AC component when compressing the AC component of the image block, that is, each AC component has a dedicated second quantization parameter, which is the minimum value of the quantization value that can quantize the AC component, and ensures that the reconstructed value after inverse quantization can reach the maximum value of the AC component, and at the same time, the accuracy is maximized. In this way, on the basis of ensuring that the second quantization parameter can fully compress the image block, the differences between different image blocks are taken into consideration, thereby improving the compression quality of the AC component.

[0054] For example, refer to Figure 2After dividing a to-be-compressed image into 10×8 image blocks, a corresponding second quantization parameter is calculated for each image block. After quantizing the AC component of the corresponding image block by the second quantization parameter, 10×8 second quantization results are obtained.

[0055] The embodiment of the present application calculates the corresponding second quantization parameter for each image block, thereby taking into account the differences between different image blocks, so that the image block can be fully quantized using the second quantization parameter specific to the image block, while the accuracy is maximized, thus avoiding the difficulty in designing the quantization parameter table, and solving the problem of poor reconstruction effect at positions with large image mutations (such as edges) caused by the use of the same quantization parameter table for all image blocks. In addition, the embodiment of the present application only includes addition, subtraction and shift operations for quantization of compressed images, and does not involve multiplication and division, so the computational complexity is low and easy to implement in hardware.

[0056] In the embodiment of the present application, the quantization of the AC component can be designed as a simple shift operation, that is, a right shift, and the shift amount is the value of the second quantization parameter. The quantization process includes:

[0057] Mq_ac[1:x]=M_ac[1:x]>>max_qp

[0058] Among them, Mq_ac is the second quantization result of the AC component, M_ac is the AC component, max_qp is the second quantization parameter, and >> is a right shift operation.

[0059] The saving module 105 is used to obtain and save the compression result of the image to be compressed according to the first quantization results of all the image blocks and the second quantization results of all the image blocks.

[0060] In an embodiment of the present application, after obtaining the first quantization result and the second quantization result of each image block, the first quantization result and the second quantization result of each image block can be combined into the quantization result of the image block, and finally the quantization results of all image blocks are combined to form a compression result of the image to be compressed for storage, thereby realizing quantization compression of the image to be compressed.

[0061] It should be noted that the second quantization parameter of each image block may also be stored together with the compressed data, and the image block may be dequantized by the second quantization parameter of each image block during subsequent decompression.

[0062] In summary, the image compression device of the embodiment of the present application includes: a segmentation module, which is used to segment the image to be compressed into multiple image blocks of the same size; a conversion module, which is used to transform the image block into the frequency domain to obtain the coefficient matrix of the image block, a first quantization module, which is used to quantize the DC component in the coefficient matrix according to the first quantization parameter to obtain the first quantization result of the image block, a second quantization module, which is used to calculate the corresponding second quantization parameter for each image block, and a storage module, which is used to obtain and store the compression result of the image to be compressed according to the first quantization results of all image blocks and the second quantization results of all image blocks. When quantizing the AC component in the coefficient matrix, the differences between different image blocks are fully considered, so that the AC component of the image block can be fully quantized using the second quantization parameter exclusive to the image block, and the accuracy is maximized, which can improve the stability of the quantization process, avoid the difficulty in designing the quantization parameter table, and solve the problem of poor reconstruction effect at the position of large mutation of the image caused by using the same quantization parameter table for all image blocks.

[0063] Optionally, the segmentation module 101 is specifically used for:

[0064] The image to be compressed is divided into a plurality of non-overlapping and mutually adjacent image blocks.

[0065] In the case that the image block obtained by segmentation is a rectangle, the rectangular image block is cropped and re-joined to obtain an image block in a square or vector form after the re-joining.

[0066] In the embodiments of this application, refer to Figure 2 , the image to be compressed can be divided into multiple non-overlapping and adjacent image blocks. However, the embodiment of the present application does not limit the shape of the image block on the basis of ensuring that the sizes of the multiple image blocks are consistent, and the image block can be a rectangle or a long rectangle.

[0067] Specifically, when the image blocks obtained by segmentation are all rectangular, the embodiment of the present application can crop the rectangular image blocks and splice them again to obtain image blocks in square or vector form after splicing again. This is because the storage capacity of square and vector image blocks is smaller, which saves more storage resources and is easier to implement in hardware. Preferably, the rectangular image blocks are cropped and spliced ​​again to obtain square image blocks. If square image blocks cannot be obtained after splicing again, they are spliced ​​again to obtain vector image blocks.

[0068] For example, refer to Figure 3For an image block that is divided into a rectangle and includes 2×8 pixels, the rectangular image block can be divided into two image sub-blocks I and II. The image sub-blocks I and II both include 2×4 pixels. After splicing the two image sub-blocks I and II again, a square image block can be obtained. The square image block includes 4×4 pixels.

[0069] For example, refer to Figure 4 For an image block that is segmented into a rectangle and includes 2×4 pixels, the rectangular image block can be segmented to obtain two image sub-blocks I and II. Both image sub-blocks I and II include 1×4 pixels. After splicing the two image sub-blocks I and II again, a vector image block can be obtained. The vector image block includes 1×8 pixels.

[0070] Optionally, the first quantization module 103 is specifically configured to:

[0071] According to the first quantization parameter, the direct current component in the coefficient matrix is ​​processed through a shift operation to obtain a first quantization result of the image block.

[0072] Quantization is a compression technology widely used in the field of image processing. The purpose of image quantization is to achieve image compression. Its goal is to use quantization technology on the original image to reduce its data volume without losing useful information or introducing negligible loss, so that the device can transmit or store images at a lower bit rate, thereby saving the maintenance cost of image data. Quantization operation is specifically the process of converting the continuous brightness change interval corresponding to the sampling point (image block) into a single specific digital number.

[0073] In the embodiment of the present application, the quantization of the DC component can be designed as a simple shift operation, that is, a right shift, and the shift amount is the value of the first quantization parameter. The quantization process includes:

[0074] Mq_dc=M_dc>>qp

[0075] Among them, Mq_dc is the first quantization result of the DC component, M_dc is the DC component, qp is the first quantization parameter, and >> is a right shift operation.

[0076] During the compression process of the embodiment of the present application, shift operations can be used to replace multiplication and division, that is, only addition and subtraction operations and shift operations are performed during the compression process, and multiplication and division are not involved. The calculation complexity is low and it is easy to implement in hardware.

[0077] Optionally, the second quantization module 104 is specifically configured to: for each of the image blocks,

[0078] The AC components in the coefficient matrix are sorted, and a corresponding bit value is set for each AC component according to the sorting result.

[0079] According to the bit value of the AC component, a quantization value corresponding to the AC component is calculated.

[0080] The quantization value is used to represent the amount of shifting required for the AC component when the bit value is used as the compression value of the AC component.

[0081] The maximum value among all the quantization values ​​is selected as the second quantization parameter.

[0082] The second quantization parameter is used to represent the maximum shift amount of the AC component when compressing the AC component of the image block.

[0083] In the embodiment of the present application, the coefficient matrix of the image block includes a large number of AC components, and the AC components are used to characterize the edges, details, and other features of the image block. Due to the distribution characteristics of the image content in the image block, the importance of different AC components in the multiple AC components corresponding to the image block is different. When quantizing, it is hoped that the more important AC components will lose less information, so that the data quality after image compression can be guaranteed.

[0084] In an embodiment of the present application, since an image block has corresponding multiple AC components, and different AC components represent different features, the AC components in the coefficient matrix can be sorted according to the degree of importance, and the corresponding bit value can be set for each AC component according to the sorting result. The strategy for allocating bit values ​​includes: allocating larger bit values ​​to AC components with higher importance. After the AC components with higher importance are assigned larger bit values, the more information the AC components retain after being compressed, and the less information loss. The bit value is the bit size occupied by the AC component after compression. For example, an AC component is 2 bits before compression. If the bit value set for the AC component is 1 bit, the AC component is set to 1 bit after compression for the quantization process. This has the effect of controlling the data volume of the compressed file.

[0085] In the embodiment of the present application, the bit value set for the AC component reflects the size of the result obtained after the AC component is compressed. Therefore, based on the bit value, the embodiment of the present application can calculate the quantization value corresponding to the AC component, that is, the quantization result of the bit value can be obtained after quantizing the AC component by the quantization value. In this way, for the AC components included in an image block, the quantization value corresponding to each AC component can be calculated. Since the bit values ​​of different AC components may be different, the quantization values ​​corresponding to different AC components may also be different.

[0086] Specifically, the quantization operation in the embodiment of the present application can adopt a right shift operation, so the quantization value specifically reflects the shift amount of the right shift operation, that is, the number of bits corresponding to the AC component is calculated to save the AC component. The calculation result is the quantization value corresponding to the AC component.

[0087] In the embodiment of the present application, after calculating the quantization value of each AC component in the image block, the maximum value of the quantization values ​​of all AC components can be selected as the second quantization parameter, that is, all the AC components in the image block are uniformly quantized using the second quantization parameter, and the second quantization parameter of each image block is used to characterize the maximum number of shifts of the AC component when compressing the AC component of the image block, that is, each AC component has a dedicated second quantization parameter, and the second quantization parameter is the minimum value of the quantization value that can quantize the AC component, and it is ensured that the reconstructed value after inverse quantization can reach the maximum value of the AC component, and the accuracy is maximized. The embodiment of the present application takes into account the differences between different image blocks, so that the image block can be fully quantized using the second quantization parameter dedicated to the image block, and the accuracy is maximized, which avoids the difficulty in designing the quantization parameter table, and solves the problem of poor reconstruction effect at positions with large image mutations (such as edges) caused by all image blocks using the same quantization parameter table.

[0088] Optionally, the second quantization module 104 is specifically configured to: initialize a quantization value corresponding to the AC component, and quantize the AC component according to the quantization value to obtain a third quantization result.

[0089] If the third quantization result is less than or equal to the numerical value represented by the bit value of the AC component, the current value of the quantization value is determined as the quantization value corresponding to the AC component; otherwise, the quantization value is adjusted, and the AC component is re-quantized according to the adjusted quantization value until the third quantization result obtained is less than or equal to the numerical value represented by the bit value of the AC component, and the current value of the quantization value is determined as the quantization value corresponding to the AC component.

[0090] In an embodiment of the present application, when calculating the quantization value of each AC component, an initialized quantization value (such as a quantization value of 0) can be first assigned to each AC component, and then the AC component is quantized according to the quantization value to obtain a third quantization result, and it is determined whether the third quantization result is greater than the value represented by the bit value assigned to the AC component. If it is greater, it is considered that the compression degree of the current quantization value is not enough, and the quantization value is incremented (such as adding 1 to the current quantization value), and the AC component is continued to be quantized with the incremented quantization value to obtain a new third quantization result, and then it is still determined whether the third quantization result is greater than the value represented by the bit value assigned to the AC component, until the latest third quantization result is less than or equal to the value represented by the bit value assigned to the AC component, it is considered that the quantization meets the compression requirements, and the current quantization value is used as the quantization value corresponding to the AC component. For example, after the quantization value of an AC component is incremented from 0 4 times (each time incremented by 1), the obtained third quantization result is less than or equal to the bit value assigned to the AC component, then the quantization value of the AC component is 4. Through such calculation method, the quantized value of each AC component can be determined quickly and accurately.

[0091] Optionally, the second quantization module 104 is specifically configured to:

[0092] The AC components in the coefficient matrix are sorted according to a preset sorting method to obtain at least one sorting result.

[0093] A corresponding bit value is set for each AC component in the sorting result, so that the bit value of the AC component with a higher sorting level is greater than the bit value of the AC component with a lower sorting level.

[0094] In an embodiment of the present application, the AC components in the coefficient matrix can be sorted according to a preset sorting method, so that the AC components with higher importance are ranked higher, and then a corresponding bit value is set for each AC component according to the sorting result. The strategy for allocating bit values ​​includes: allocating larger bit values ​​to AC components with higher importance.

[0095] Specifically, the purpose of fixed-rate compression is to make the data volume of the compressed file controllable so that the compressed file can be stored in a storage area of ​​a specified size. Therefore, after the number of bits of the compressed image block is determined according to the compression ratio, the corresponding bit value can be set for each AC component according to the importance sorting result of the AC component. The sum of these bit values ​​is equal to the above-mentioned number of bits.

[0096] For example, suppose an image block with 100 bits before compression includes 3 AC components and 1 DC component. If it is compressed at a rate of 2, the number of bits of the compressed image block is 50 bits, that is, the compression result of the image block includes: the sum of the bit values ​​of the 3 AC components, the bit value of the DC component, and the second quantization parameter of 1 bit, and the sum of the three is 50 bits. Among them, the order of the 3 AC components is: AC component 1, AC component 2, AC component 3, then the number of bits of AC component 1 is greater than or equal to the number of bits of AC component 2, and the number of bits of AC component 2 is greater than or equal to the number of bits of AC component 3.

[0097] Optionally, the second quantization module 104 is specifically configured to:

[0098] When the original shape of the image block is a square, the AC components in the coefficient matrix are sorted according to a ZigZag sorting method to obtain a sorting result.

[0099] In an embodiment of the present application, when the original shape of the image block is a square (not a rectangular image block divided and then reassembled into a square image block), the ZigZag sorting method can be used to sort the AC components in the coefficient matrix to obtain a sorting result.

[0100] Specifically, in a square image block, the most important AC component is generally concentrated in the upper left corner of the image block, while the least important AC component is generally concentrated in the lower right corner of the image block. Therefore, by finding a path from the upper left corner of the image block to the lower right corner of the image block, a ranking result in which the importance of the AC components is ranked from high to low can be obtained. The embodiment of the present application can specifically use the ZigZag sorting method to find the sorting path. The ZigZag sorting method is a method of searching for a path in an image block in a Z-shape, thereby searching for a ranking result in which the importance of the AC components is ranked from high to low.

[0101] For example, refer to Figure 5 A square image block includes 16 AC components from 0 to 15. The most important AC component 0 is located in the upper left corner of the image block, and the least important AC component 15 is located in the lower right corner of the image block. Then, by searching for the sequence of AC components from high to low importance according to the ZigZag sorting method, the sorting result can be obtained: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]. In this sorting result, the importance level decreases in turn.

[0102] Sub-step 20312: When the original shape of the image block is a rectangle, the AC components in the coefficient matrix are sorted respectively according to a plurality of different sorting methods to obtain a plurality of sorting results.

[0103] In an embodiment of the present application, when the original shape of the image block is a rectangle, the sorting method may not be unique. The embodiment of the present application may sort the AC components in the coefficient matrix according to multiple different sorting methods to obtain multiple sorting results. The embodiment of the present application does not specifically limit the sorting method in this case.

[0104] Optionally, when the AC components in the coefficient matrix are sorted respectively to obtain a plurality of different sorting results, the second quantization module 104 is specifically configured to:

[0105] For each of the sorting results, an AC component in the sorting result is quantized according to a second quantization parameter corresponding to the sorting result to obtain an initial quantization result corresponding to the sorting result.

[0106] According to the initial quantized component, the AC component is sequentially quantized, inversely quantized and inversely Hadamard transformed to obtain a reconstructed value.

[0107] A mean square error between the AC component and the reconstructed value is calculated.

[0108] An initial quantization result of the sorting result with the smallest mean square error is selected as the second quantization result of the image block.

[0109] In the embodiments of the present application, the above embodiments mentioned that when the original shape of the image block is a rectangle, the sorting result of the AC component of the image block may not be unique, that is, there may be multiple sorting results of the AC component of the image block.

[0110] When there are multiple sorting results of the AC component of the image block, the corresponding second quantization parameter can be calculated for each sorting result. The embodiment of the present application can calculate the error of each sorting result by quantizing and dequantizing each sorting result respectively, wherein the sorting result with the smallest error is the optimal sorting result, and the second quantization parameter and quantization result of the optimal sorting result can be retained for use later.

[0111] Specifically, for each sorting result, the AC component in the sorting result can be quantized according to the second quantization parameter corresponding to the sorting result to obtain an initial quantization result corresponding to the sorting result, and the AC component of the sorting result is quantized, dequantized and inverse Hadamard transformed in turn according to the initial quantization component to obtain a reconstruction value, and then the mean square error between the AC component and the reconstruction value is calculated. The mean square error value reflects the error size generated in the quantization process according to the second quantization parameter of the sorting result. The smaller the value, the better the sorting result. Therefore, the embodiment of the present application can select the initial quantization result of the sorting result with the smallest mean square error as the second quantization result of the image block.

[0112] Optionally, the storage module 105 is specifically used for:

[0113] When the number of the sorting results is 1, the first quantization results of all the image blocks, the second quantization results of all the image blocks, and the second quantization parameter are saved as the compression result.

[0114] In the case where there are multiple sorting results, the first quantization results of all the image blocks, the second quantization results of all the image blocks, the serial number of the sorting result with the smallest mean square error, and the second quantization parameter of the sorting result with the smallest mean square error are saved as the compression results, and the serial number of the sorting result is used to find the sorting result.

[0115] In the embodiment of the present application, when the number of sorting results is 1, after obtaining the first quantization result and the second quantization result of each image block, the first quantization result and the second quantization result of each image block and the second quantization parameter can be combined into the quantization result of the image block, and finally the quantization results of all image blocks are combined to form the compression result of the image to be compressed for storage, thereby realizing the quantization compression of the image to be compressed. In subsequent decompression, the image block can be inversely quantized by the second quantization parameter of each image block and the first and second quantization results (the first quantization parameter used in quantization and inverse quantization is the same parameter, so it does not need to be stored in the compression result).

[0116] In an embodiment of the present application, when there are multiple sorting results, in addition to storing the first quantization result, the second quantization result and the second quantization parameter, the compression result may also store the serial number of the sorting result with the smallest mean square error. The serial number is used to find the sorting result with the smallest mean square error during decompression, so that the inverse quantization process is implemented based on the sorting result with the smallest mean square error.

[0117] Reference Figure 6 , which shows a flowchart of an implementation of an image compression method, including two schemes:

[0118] For plan 1:

[0119] Step 1: Get the image block.

[0120] Solution 1 takes an 8-bit-3-channel image to be compressed as an example. The image can be converted into a YUV image first, and then the Y channel and UV channel are compressed at different ratios (the importance of the Y channel is greater than that of the UV channel, so the compression rate of the Y channel must be less than that of the UV channel). Here, only the compression process of one channel is described, such as the U channel. The image block after segmentation includes 4×4 pixels. Each image block is 128 bits before compression.

[0121] Step 2: Hadamard transform.

[0122] Perform Hadamard transform on the image block to obtain the coefficient matrix of the image block:

[0123]

[0124] In the coefficient matrix, M_dc is the DC component; M_ac is the AC component, and the number of AC components is 15.

[0125] Step 3: quantize the DC component.

[0126] That is, the DC component M_dc is right-shifted by the first quantization parameter (eg, right-shifted by 5 bits) to obtain a quantization value Mq_dc, where Mq_dc is 7 bits.

[0127] Step 4.1. Sort the AC components.

[0128] If the original shape of the image block of Scheme 1 is a square, ZigZag scanning sorting can be used to assign more bits to the AC components at the front of the sorting, and fewer bits to the AC components at the back of the sorting. For example, for the 15 AC components in the sorting result, the bits are allocated from the beginning to the end in the following order: 4 bits, 4 bits, 3 bits, 3 bits, 3 bits, 3 bits, 3 bits, 3 bits, 2 bits, 2 bits, 2 bits, 2 bits, 2 bits, 2 bits, 2 bits, 2 bits, a total of 40 bits.

[0129] Step 4.2: Calculate the maximum quantization parameter (second quantization parameter).

[0130] According to the sorted AC components and the number of allocated bits, calculate how many bits are needed to right shift to save the component with the specified number of bits, that is, the quantization value of each AC component. Then select the maximum quantization value as the maximum quantization parameter (the second quantization parameter), such as using 3 bits to save the second quantization parameter (that is, the value range of the second quantization parameter is 0-7).

[0131] Step 5: Quantify the AC component.

[0132] Shift M_ac[1:15] right by the maximum quantization parameter, recorded as the quantization value of the AC component Mq_ac[1:15]

[0133] Step 6: Save the quantitative information.

[0134] The maximum quantization parameter max_qp (occupying 3 bits), the DC component quantization result Mq_dc, and the AC component quantization result Mq_ac[1:15] are stored as quantization information in a storage unit of a predetermined size, a total of 50 bits. Thus, the 128-bit image block is compressed to 50 bits.

[0135] For option 2:

[0136] Step 1: Get the image block.

[0137] Solution 2 takes an 8-bit 3-channel image to be compressed as an example, and the image blocks after segmentation include 4×4 pixels. Each image block is 128 bits before compression.

[0138] Step 2: Hadamard transform.

[0139] Perform Hadamard transform on the image block to obtain the coefficient matrix of the image block:

[0140]

[0141] In the coefficient matrix, M_dc is the DC component; M_ac is the AC component, and the number of AC components is 15.

[0142] Step 3: quantize the DC component.

[0143] That is, the DC component M_dc is right-shifted by the first quantization parameter (eg, right-shifted by 5 bits) to obtain a quantization value Mq_dc, where Mq_dc is 7 bits.

[0144] Step 4.1. Sort the AC components.

[0145] The original shape of the image block of scheme 2 is a rectangle, and a variety of different sorting methods can be used to scan and sort to obtain two groups of sorting results. In the sorting results, more bits are given to the AC components that are ranked first, and fewer bits are given to the AC components that are ranked later.

[0146] The serial number of the sorting result of each group is group_id, which requires 1 bit. For example, when group_id = 0: M_ac4, M_ac12, M_ac1, M_ac2, M_ac5, M_ac6, M_ac3, M_ac7, M_ac8, M_ac9, M_ac13, M_ac10, M_ac14, M_ac11, M_ac15; when group_id = 1: M_ac4, M_ac12, M_ac5, M_ac1, M_ac2, M_ac3, M_ac6, M_ac7, M_ac8, M_ac9, M_ac10, M_ac11, M_ac13, M_ac14, M_ac15. For the 15 AC components in each sorting result, the number of bits is allocated sequentially from beginning to end, with a total of 40 bits.

[0147] Step 4.2: Calculate the maximum quantization parameter (the second quantization parameter).

[0148] For each group of sorting results, according to the sorted AC components and the allocated number of bits, calculate how many bits need to be shifted to the right to save this component with the specified number of bits, that is, the quantization value of each AC component. Then select the maximum quantization value as the maximum quantization parameter (the second quantization parameter) of this group of sorting results. For example, 3 bits are used to save the second quantization parameter (that is, the value range of the second quantization parameter is 0 - 7).

[0149] Step 4.3: Calculate the reconstructed value.

[0150] Use the maximum quantization parameter max_qp of each group of sorting results to reconstruct the AC components of this group of sorting results. For example, taking M_ac4 as an example, the reconstructed value after quantization and inverse quantization is Mr_ac4 = (M_ac4 >> max_qp) << max_qp; perform inverse Hadamard transform on Mr_dc and Mr_ac[1:15] to obtain the reconstructed values of each group.

[0151] Step 4.4: Calculate the final maximum quantization parameter.

[0152] That is, select the group of sorting results group_d1 with the smallest mean square error between the original value and the reconstructed value as the final sorting method, and the maximum quantization parameter of this group of sorting results is the final maximum quantization parameter, which requires 3 bits.

[0153] Step 5: Quantize the AC components.

[0154] Shift M_ac[1:15] to the right by the maximum quantization parameter, and denote it as the quantization value Mq_ac[1:15] of the AC components.

[0155] Step 6: Save the quantization information.

[0156] The group_d1 (occupies 1 bit), the maximum quantization parameter max_qp (occupies 3 bits), the DC component quantization result Mq_dc, and the AC component quantization result Mq_ac[1:15] are stored as quantization information in a storage unit of a predetermined size, a total of 51 bits. Thus, the 128-bit image block is compressed to 51 bits.

[0157] In summary, the image compression device of the embodiment of the present application includes: a segmentation module, which is used to segment the image to be compressed into multiple image blocks of the same size; a Hadamard transformation module, which is used to transform the image block to the frequency domain through the Hadamard transformation to obtain the coefficient matrix of the image block; a first quantization module, which is used to quantize the DC component in the coefficient matrix according to the first quantization parameter to obtain the first quantization result of the image block; a second quantization module, which is used to calculate the corresponding second quantization parameter for each image block; a storage module, which is used to obtain the compression result of the image to be compressed and save it according to the first quantization results of all image blocks and the second quantization results of all image blocks. When quantizing the AC component in the coefficient matrix, the differences between different image blocks are fully considered, so that the AC component of the image block can be fully quantized using the second quantization parameter exclusive to the image block, and the accuracy is maximized, which can improve the stability of the quantization process, avoid the difficulty in designing the quantization parameter table, and solve the problem of poor reconstruction effect at the position of large mutation of the image caused by using the same quantization parameter table for all image blocks.

[0158] Figure 7 1 is a flowchart of a method for image compression provided by an embodiment of the present application, the method comprising:

[0159] Step 201 : dividing the image to be compressed into a plurality of image blocks, wherein the sizes of the plurality of image blocks are consistent.

[0160] Step 202: transform each of the image blocks into the frequency domain to obtain a coefficient matrix of each of the image blocks; the coefficient matrix includes a DC component and an AC component.

[0161] Step 203: quantize the DC component in the coefficient matrix according to the first quantization parameter to obtain a first quantization result of each of the image blocks.

[0162] Step 204: calculate a second quantization parameter corresponding to each of the image blocks, and quantize the AC component of the image block using the second quantization parameter to obtain a second quantization result for each of the image blocks.

[0163] The second quantization parameter is used to represent the maximum shift amount of the AC component when compressing the AC component of the image block.

[0164] Step 205: Obtain and save the compression result of the image to be compressed according to the first quantization results and the second quantization results of all the image blocks.

[0165] The relevant description of steps 201 - 205 can refer to the above embodiment and will not be repeated here.

[0166] In summary, the image compression method of the embodiment of the present application divides the image to be compressed into multiple image blocks of the same size; then transforms the image block to the frequency domain to obtain a coefficient matrix of the image block, and quantizes the DC component in the coefficient matrix according to a first quantization parameter to obtain a first quantization result of the image block, and calculates a corresponding second quantization parameter for each image block. When quantizing the AC component in the coefficient matrix, the differences between different image blocks are fully considered, so that the use of the second quantization parameter specific to the image block can fully quantize the AC component of the image block with maximum accuracy. This can improve the stability of the quantization process, avoid the difficulty in designing the quantization parameter table, and solve the problem of poor reconstruction effect at positions with larger image mutations caused by using the same quantization parameter table for all image blocks.

[0167] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0168] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. Regarding the device in the above embodiment, the specific way in which each module performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.

[0169] An embodiment of the present application provides an electronic device, including the image compression device of the above embodiment.

[0170] Figure 8 is a block diagram of an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0171] Reference Figure 8 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 608 , an audio component 610 , an input / output (I / O) interface 612 , a sensor component 614 , and a communication component 616 .

[0172] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 608 and the processing component 602.

[0173] The memory 604 is used to store various types of data to support the operation of the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, multimedia, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0174] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.

[0175] The multimedia component 608 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 608 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a multimedia mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0176] The audio component 610 is used to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is used to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.

[0177] I / O interface 612 provides an interface between processing component 602 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0178] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of contact between the user and the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0179] The communication component 616 is used to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0180] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to implement the methods provided in the embodiments of the present application.

[0181] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of an electronic device 600 to perform the above method. For example, the non-transitory storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0182] Fig. 9 is a block diagram of an electronic device 700 according to an exemplary embodiment. Fig. 9 The electronic device 700 includes a processing component 722, which further includes one or more processors, and a memory resource represented by a memory 732 for storing instructions that can be executed by the processing component 722, such as an application. The application stored in the memory 732 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 722 is configured to execute instructions to perform the method provided in the embodiment of the present application.

[0183] The electronic device 700 may also include a power supply component 726 configured to perform power management of the electronic device 700, a wired or wireless network interface 750 configured to connect the electronic device 700 to a network, and an input / output (I / O) interface 758. The electronic device 700 may operate based on an operating system stored in the memory 732, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.

[0184] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the application disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.

[0185] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. An image compression device, characterized in that: The image compression device comprises: A segmentation module, used for segmenting the image to be compressed into a plurality of image blocks, wherein the sizes of the plurality of image blocks are consistent; A conversion module, used for transforming each of the image blocks into a frequency domain to obtain a coefficient matrix of each of the image blocks; the coefficient matrix includes a DC component and an AC component; A first quantization module, used for quantizing a DC component in the coefficient matrix according to a first quantization parameter to obtain a first quantization result of each image block; A second quantization module is used to calculate a second quantization parameter corresponding to each of the image blocks, and quantize the AC component of the image block by the second quantization parameter to obtain a second quantization result of each of the image blocks; the second quantization parameter is used to represent the maximum shift amount of the AC component when compressing the AC component of the image block; The saving module is used to obtain and save the compression result of the image to be compressed according to the first quantization results of all the image blocks and the second quantization results of all the image blocks.

2. The image compression device according to claim 1, characterized in that: The segmentation module is specifically used for: The image to be compressed is divided into a plurality of non-overlapping and mutually adjacent image blocks.

3. The image compression device according to claim 1, characterized in that: The first quantization module is specifically used to process the DC component in the coefficient matrix through a shift operation according to the first quantization parameter to obtain a first quantization result of the image block.

4. The image compression device according to claim 1, characterized in that: The second quantization module is specifically configured to: for each of the image blocks, Sorting the AC components in the coefficient matrix, and setting a corresponding bit value for each AC component according to the sorting result; Calculating a quantization value corresponding to the AC component according to the bit value of the AC component, wherein the quantization value is used to represent the amount of shift required for the AC component when the bit value is used as the compression value of the AC component; The maximum value among all the quantization values ​​is selected as the second quantization parameter.

5. The image compression device according to claim 4, characterized in that: The second quantization module is specifically used for: Sorting the AC components in the coefficient matrix according to a preset sorting method to obtain at least one sorting result; A corresponding bit value is set for each AC component in the sorting result, so that the bit value of the AC component with a higher sorting level is greater than the bit value of the AC component with a lower sorting level.

6. The image compression device according to claim 5, characterized in that: The second quantization module is specifically used for: In the case where the original shape of the image block is a square, the AC components in the coefficient matrix are sorted according to a ZigZag sorting method to obtain a sorting result; When the original shape of the image block is a rectangle, the AC components in the coefficient matrix are sorted respectively according to a plurality of different sorting methods to obtain a plurality of sorting results.

7. The image compression device according to claim 4, characterized in that: The second quantization module is specifically used for: Initializing the quantized value corresponding to the AC component; quantizing the AC component according to the quantization value to obtain a third quantization result; If the third quantization result is less than or equal to the value represented by the bit value of the AC component, determining the current value of the quantization value as the quantization value corresponding to the AC component; Otherwise, adjust the quantization value and re-quantize the AC component according to the adjusted quantization value until the third quantization result obtained is less than or equal to the numerical value represented by the bit value of the AC component, and determine the current value of the quantization value as the quantization value corresponding to the AC component.

8. The image compression device according to claim 4, characterized in that: When the AC components in the coefficient matrix are sorted respectively to obtain a plurality of different sorting results, the second quantization module is specifically used for: For each of the sorting results, quantizing an AC component in the sorting result according to a second quantization parameter corresponding to the sorting result, to obtain an initial quantization result corresponding to the sorting result; According to the initial quantized component, the AC component is sequentially quantized, dequantized and deconverted to obtain a reconstructed value; Calculating a mean square error between the AC component and the reconstructed value; The initial quantization result of the sorting result with the smallest mean square error is selected as the second quantization result of the image block.

9. The image compression device according to any one of claims 4 to 8, characterized in that: The storage module is specifically used for: When the number of the sorting results is 1, saving the first quantization results of all the image blocks, the second quantization results of all the image blocks, and the second quantization parameter as the compression result; In the case where there are multiple sorting results, the first quantization results of all the image blocks, the second quantization results of all the image blocks, the serial number of the sorting result with the smallest mean square error, and the second quantization parameter of the sorting result with the smallest mean square error are saved as the compression results, and the serial number of the sorting result is used to find the sorting result.

10. An image compression method, characterized in that: The image compression method comprises: Dividing the image to be compressed into a plurality of image blocks, wherein the sizes of the plurality of image blocks are consistent; Transforming each of the image blocks into the frequency domain to obtain a coefficient matrix of each of the image blocks; the coefficient matrix includes a DC component and an AC component; quantizing a direct current component in the coefficient matrix according to a first quantization parameter to obtain a first quantization result for each of the image blocks; Calculating a second quantization parameter corresponding to each of the image blocks, and quantizing the AC component of the image block by using the second quantization parameter to obtain a second quantization result of each of the image blocks; the second quantization parameter is used to characterize the maximum shift amount of the AC component when compressing the AC component of the image block; According to the first quantization results and the second quantization results of all the image blocks, a compression result of the image to be compressed is obtained and saved.

11. An electronic device, characterized in that: include: An image compression device as claimed in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method as claimed in claim 10 .