Compression methods and related electronic devices
By employing an adaptive data compression method and utilizing quantization functions and scaling factor determination circuits, the problems of overload, noise, and fuzziness in image data compression are solved, achieving efficient data compression and noise reduction.
Patent Information
- Application Number
- CN202210006702.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-05
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2042-01-05
AI Technical Summary
Existing technologies are prone to problems such as overload, increased data volume, granular noise, and edge jaggedness during image data compression. It is difficult to reduce the amount of extra data and the degree of noise and jaggedness while avoiding overload.
An adaptive data compression method is adopted. By setting a quantization function and multiple scaling factors, the transformed data is calculated using a transformation matrix, a specific scaling factor is determined, and a quantization operation is performed using a quantization function. Combined with a scaling factor determination circuit and a quantization circuit, overload is avoided and noise and fuzz are reduced.
It effectively compresses image data, avoids overload, reduces the amount of extra data, reduces granular noise and edge jaggedness, and improves compression efficiency.
Smart Images

Figure CN116456089B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a data compression method using quantization. Background Technology
[0002] To reduce the amount of image data, data compression using quantization is generally employed. The compressed data size primarily depends on the number of codewords in the codebook; that is, how many bits are needed to represent the index value of each codeword. The data size of each data unit (e.g., the brightness value of each pixel) can then be replaced with a smaller index value for subsequent storage or transmission. Furthermore, to minimize compression distortion, it's desirable to minimize the difference between each data unit and its nearest codeword. Therefore, common practices include using predictors or transforms to concentrate the data distribution as close to 0 as possible, and employing non-uniform quantization to achieve smaller quantization errors.
[0003] However, when the predictor is inaccurate, or the transformation cannot achieve a sparse representation of the data, the data may deviate significantly from zero, or even exceed the codebook boundaries, resulting in overload. The most direct way to solve the overload problem is to increase the number of codewords, but this also increases the data volume. Alternatively, the codebook boundaries can be expanded to prevent data from exceeding the numerical boundaries, but this may result in a lower sampling rate, leading to more severe granular noise and edge busyness. Summary of the Invention
[0004] Therefore, one of the objectives of this invention is to propose an adaptive data compression method that can minimize the amount of extra data and reduce the degree of granular noise and edge jaggedness while avoiding overload, thereby solving the problems described in the prior art.
[0005] In one embodiment of the present invention, a compression method is provided, comprising the following steps: setting a quantization function; setting multiple scaling factors; receiving image data; transforming the data of a block of a frame in the image data using a transformation matrix to calculate multiple transformed data; determining a specific scaling factor from the multiple scaling factors based on the multiple transformed data; and quantizing the multiple adjusted data using the quantization function to generate compressed data, wherein the multiple adjusted data are obtained by combining the multiple transformed data with the specific scaling factor.
[0006] In one embodiment of the present invention, an electronic device is provided, comprising a compression circuit, wherein the compression circuit is configured with a quantization function and a plurality of scaling factors, and the compression circuit includes a scaling factor determination circuit and a quantization circuit. The scaling factor determination circuit receives image data and, for a block of a frame in the image data, uses a transformation matrix to transform the data of that block to calculate a plurality of transformed data, and determines a specific scaling factor from the plurality of scaling factors based on the plurality of transformed data. The quantization circuit is coupled to the scaling factor determination circuit and is used to use the quantization function to quantize the plurality of adjusted data to generate compressed data, wherein the plurality of adjusted data is obtained by combining the plurality of transformed data with the specific scaling factor. Attached Figure Description
[0007] Figure 1 This is a schematic diagram of an electronic device according to an embodiment of the present invention.
[0008] Figure 2 This is a flowchart of a compression method according to an embodiment of the present invention.
[0009] Explanation of reference numerals in the attached figures:
[0010] 100 - Electronic device; 110 - Image capture device; 120 - Compression circuit
[0011] 122 - Scaling factor determination circuit; 124 - Quantization circuit; 130 - Storage element
[0012] road
[0013] 140-Image Processing Circuit 200~214-Steps Detailed Implementation
[0014] Figure 1 This is a schematic diagram of an electronic device 100 according to an embodiment of the present invention. Figure 1As shown, the electronic device 100 includes an image capture device 110, a compression circuit 120, a storage element 130, and an image processing circuit 140, wherein the compression circuit 120 includes a scaling factor determination circuit 122 and a quantization circuit 124. In this embodiment, the electronic device 100 can be any electronic device capable of capturing images, such as a digital camera, a laptop computer, a mobile phone, or a desktop computer with a camera installed.
[0015] In the operation of electronic device 100, image capture device 110 captures images of the external environment to generate multiple sets of image data, such as multiple consecutive image frames. Then, to reduce the amount of data in the multiple sets of image data, compression circuit 120 compresses the multiple sets of image data to generate multiple sets of compressed image data, and stores the compressed image data in storage element 130. Afterwards, image processing circuit 140 reads the multiple sets of compressed image data stored in storage element 130 and performs image processing operations on the compressed image data, such as noise reduction, to generate processed image data for the back-end circuit. Furthermore, as described in the background art, conventional compression circuits may experience overload, increased data volume, granular noise, or edge jaggedness. Therefore, the compression circuit 120 proposed in this embodiment employs an adaptive data compression method, which can use different scaling factors according to the content of the currently processed image data to minimize the amount of additional data and reduce the degree of granular noise and edge jaggedness while avoiding overload. Furthermore, the operation of the image capture device 110 and image processing circuit 140 described above is well known to those skilled in the art and is not the focus of this invention. Therefore, the following description focuses only on the compression circuit 120.
[0016] First, the compression circuit 120 is set with a quantization function Q(x) with a value range of [-R, R], where R can be any suitable value, such as "2048". That is, when the value range is between "-2048" and "2048", the operation of the quantization function Q(x) will not have an overload problem.
[0017] Next, the compression circuit 120 is first configured to have a set of scaling factors, wherein the set of scaling factors includes 1, S0, S1, ..., S n-1 S k =2 k For example, assuming n equals 4, this set of scaling factors includes four scaling factors: 1, 2, 4, and 8. Furthermore, for all possible data d processed by the compression circuit 120, there exists a scaling factor S. k And thus Specifically, assuming that each block processed by the compression circuit 120 contains 1*8 pixels, and the luminance value of each pixel is represented by 12 bits, the compression circuit 120 will use a transformation matrix, such as an 8*8 Hadamard matrix, to transform the luminance values of the 1*8 pixels to the frequency domain to obtain the transformed data during the compression process. For details, refer to the following formula:
[0018] Where d1 to d8 represent the brightness values of 1*8 pixels, and d1' to d8' represent the transformed data. In the 8*8 Hadamard matrix, the first column (row) is the DC coefficient, and the 2nd to 8th columns are the high-frequency coefficients. In this embodiment, the scaling factor is set to the transformed data d2' to d8' calculated from the high-frequency coefficients. That is, the "all possible data d during processing by the compression circuit 120" mentioned above refers to the transformed data d2' to d8' corresponding to the high frequencies. For example, suppose d1 to d8 are (2 12 -1), (2) 12 -1), (2) 12 -1), (2) 12 -1), 0, 0, 0, then the transformed data d5' calculated using the high-frequency coefficients of the 5th column of the Adama matrix is 4*(2 12 -1)-4*0<2 14 Since the transformed data d5' is the maximum value processed by the compression circuit 120, the maximum scaling factor can be set to 8 to make 4*(2 12 -1)-4*0<2 14 = 8*R, where R is 2048.
[0019] Next, during the process of compression circuit 120 receiving and compressing image data from image capture device 110, firstly, for each block, scaling factor determination circuit 122 uses the Hadamard matrix to calculate multiple transformed data corresponding to high frequencies, and determines the scaling factor of the multiple transformed data based on the maximum value among the multiple transformed data corresponding to high frequencies. Referring to the above formula (1), scaling factor determination circuit 122 can find the maximum value M obtained by taking the absolute value of the transformed data d2' to d8', and find the value that satisfies... The smallest scaling factor S k The smallest scaling factor S determined therein kThis is for use with all the transformed data d2' to d8'. For example, assuming R = 2048, if the maximum absolute value M of the transformed data d2' to d8' is less than 2048, then the scaling factor determination circuit 122 can determine the scaling factor as "2"; if the maximum absolute value M of the transformed data d2' to d8' is between 2048 and 4096, then the scaling factor determination circuit 122 can determine the scaling factor as "2"; if the maximum absolute value M of the transformed data d2' to d8' is between 4096 and 8192, then the scaling factor determination circuit 122 can determine the scaling factor as "4"; and if the maximum absolute value M of the transformed data d2' to d8' is between 8192 and 16384, then the scaling factor determination circuit 122 can determine the scaling factor as "8".
[0020] In the operation of the scaling factor determination circuit 122, using the condition that... The scaling factor is chosen to avoid the overload phenomenon mentioned in the background (that is, the value of the transformed data exceeds the range of the quantization function Q(x) in the range of [-R, R]), and to satisfy... The smallest scaling factor S k This is to avoid granular noise and jagged image edges during subsequent decoding.
[0021] After determining the scaling factor, the quantization circuit 124 adjusts the transformed data d2' to d8' using the scaling factor to generate the adjusted data (that is, (d2' / S)). k )~(d8' / S k The quantization operation is performed to produce compressed data; that is, the quantization circuit 124 uses the quantization function Q(d2' / S) to perform quantization. k To calculate the compressed data corresponding to the transformed data d2', use the quantization function Q(d3' / S). k To calculate the compressed data corresponding to the transformed data d3', ..., using the quantization function Q(d8' / S) k The quantization circuit 124 calculates the compressed data corresponding to the transformed data d8'. Furthermore, since the transformed data d1' calculated using the DC coefficient in the first column of the Adama matrix may have a high value, the quantization circuit 124 can independently quantize the transformed data d1' to generate compressed data corresponding to the transformed data d1'.
[0022] Next, the compression circuit 120 temporarily stores the compressed data in the storage element 130. The image processing circuit 140 uses an internal decompression circuit to decompress the compressed data using an inverse quantization function corresponding to the quantization function Q(x) and a scaling factor corresponding to each block to obtain the decompressed data. That is, for each block, the content received by the decompression circuit includes Q(d' / S). k The decompression circuit calculates the decompressed data based on the numerical value "k" and the value "k". Q -1 The function is the inverse quantization function, and d' contains the transformed data d2' to d8'.
[0023] In the above embodiments, since the transformed data d2' to d8' corresponding to high frequencies share the same scaling factor S k Therefore, the scaling factor S can be avoided. k The excessive amount of data affects the overall compressed data. Furthermore, by determining whether it meets the requirements... The smallest scaling factor S k This can minimize the amount of extra data and reduce granular noise and edge jaggedness while avoiding overload.
[0024] To illustrate, suppose the compression circuit 120 processes a block containing 8 pixels each time, and each pixel has a luminance value of 12 bits. In this embodiment, the transformed data d1' can be quantized to produce 13 bits of compressed data, and each transformed data d2' to d8' can be quantized to produce 7 bits of compressed data (that is, the codebook has 128 codewords). Adding the four scaling factors, which can be represented using 2 bits, the amount of data generated by the compression circuit 120 can be 64 bits (13 + 7 * 7 + 2 = 64). For a block of 8 pixels, the average compressed data per pixel is 8 bits. Therefore, this embodiment can effectively compress image data while simultaneously avoiding overload and improving grainy noise and edge jaggedness.
[0025] It should be noted that the block size and the size and content of the Hadamard matrix described above are merely illustrative examples and not limitations of the present invention. In other embodiments, the block size and corresponding Hadamard matrix processed by the compression circuit 120 at one time can be changed according to the designer's considerations and the image content.
[0026] Figure 2 This is a flowchart of a compression method according to an embodiment of the present invention. See also... Figure 1 , 2 Based on the above embodiments, the compression method of this embodiment is described below.
[0027] Step 200: Process begins.
[0028] Step 202: Set a quantization function Q(x) with a range of [-R, R].
[0029] Step 204: Set multiple scaling factors 1, S0, S1, ..., S n-1 S k =2 k Furthermore, for all possible data d during processing, there exists a factor S. k And thus
[0030] Step 206: Receive image data from the image capture device.
[0031] Step 208: For each block in a frame of image data, use a transformation matrix to transform the data of the block to calculate multiple transformed data corresponding to high frequencies, and determine a specific scaling factor based on the maximum value among the multiple transformed data.
[0032] Step 210: Use the quantization function Q(x) to quantize multiple adjusted data to produce compressed data, wherein the multiple adjusted data are obtained by combining the multiple transformed data with the specific scaling factor.
[0033] Step 212: Temporarily store the compressed data in the storage device.
[0034] Step 214: Decompress the compressed data using an inverse quantization function corresponding to the quantization function Q(x) and the scaling factor.
[0035] In the above embodiments, the high-frequency coefficients of the Adama matrix used only have a horizontal direction. However, in other embodiments, the Adama matrix used by the compression circuit 120 can contain multiple sub-matrices of high-frequency coefficients in different directions. Each sub-matrix can determine its own scaling factor based on the maximum value of the absolute value of its transformed data, so as to more effectively reduce the amplification of granular noise and edge jaggedness during the decompression process.
[0036] For example, the Adamant matrix used by the compression circuit 120 can be represented as follows:
[0037]
[0038] Where V represents submatrices with high-frequency coefficients in the vertical direction, H represents submatrices with high-frequency coefficients in the horizontal direction, and D represents submatrices with high-frequency coefficients in the diagonal direction. In this embodiment, all submatrices V have a single scaling factor, all submatrices H have a single scaling factor, and all submatrices D also have a single scaling factor.
[0039] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made in accordance with the scope of the claims of the present invention shall be covered by the present invention.
Claims
1. A compression method, comprising: Set a quantization function, which has a range of values; Set multiple scaling factors; Receive image data; For a block of a frame in the image data, a transformation matrix is used to transform the data of the block in order to calculate multiple transformed data; Based on the maximum absolute value of the multiple transformed data and the range of the quantization function, a specific scaling factor is determined from the multiple scaling factors; as well as The quantization function is used to quantize multiple adjusted data to produce compressed data, wherein the multiple adjusted data are obtained by combining the multiple transformed data with the specific scaling factor.
2. The compression method of claim 1, wherein, The step of transforming the data of the block in the frame of the image data using the transformation matrix to calculate the plurality of transformed data includes: For the block of the frame in the image data, the transformation matrix is used to transform the data of the block to calculate the multiple transformed data corresponding to the extremely high frequency.
3. The compression method of claim 2, wherein, The transformation matrix includes a set of DC coefficients and multiple sets of high-frequency coefficients. The step of using the transformation matrix to transform the data of the block to calculate the multiple transformed data corresponding to the ultra-high frequency includes: The multiple sets of high-frequency coefficients are used to transform the data of the block to calculate the multiple transformed data corresponding to the ultra-high frequency.
4. The compression method of claim 1, wherein, The range of the quantization function is [-R, R]. The step of determining the specific scaling factor from the plurality of scaling factors based on the maximum absolute value of the plurality of transformed data and the range of the quantization function includes: According to a maximum value of the plurality of transformed data after taking absolute values and a value range of the quantization function, a minimum scaling factor satisfying is selected from the plurality of scaling factors as the specific scaling factor, wherein M is the maximum value of the plurality of transformed data after taking absolute values, S k is the specific scaling factor.
5. An electronic device comprising: A compression circuit includes a quantization function and multiple scaling factors. The quantization function has a range of values. The compression circuit comprises: A scaling factor determination circuit is used to receive image data, and for a block of a frame in the image data, use a transformation matrix to transform the data of the block to calculate multiple transformed data, and determine a specific scaling factor from the multiple scaling factors based on the maximum absolute value of the multiple transformed data and the range of the quantization function; and A quantization circuit, coupled to the scaling factor determination circuit, uses the quantization function to quantize multiple adjusted data to generate compressed data, wherein the multiple adjusted data are obtained by combining the multiple transformed data with the specific scaling factor. 6.The electronic device of claim 5, wherein, For a block of a frame in the image data, the scaling factor determination circuit uses the transformation matrix to transform the data of the block in order to calculate the multiple transformed data corresponding to extremely high frequencies.
7. The electronic device according to claim 6, characterized in that, The transformation matrix includes a set of DC coefficients and multiple sets of high-frequency coefficients, and the scaling factor determination circuit uses the multiple sets of high-frequency coefficients to transform the data of the block to calculate the multiple transformed data corresponding to the ultra-high frequency.
8. The electronic device according to claim 5, characterized in that, The quantization function has a range of [-R, R], and the scaling factor determination circuit selects a scaling factor from the plurality of scaling factors that satisfy the condition based on the maximum absolute value of the plurality of transformed data and the range of the quantization function. The smallest scaling factor is used as the specific scaling factor, where M is the maximum absolute value among the multiple transformed data, and S... k This refers to the specific scaling factor.
Citation Information
Patent Citations
Image compression method and device
CN104683801A
