Image decompression method and device
阅读说明:本技术 图像解压缩方法及装置 (Image decompression method and device ) 是由 朱江 于 2019-10-22 设计创作,主要内容包括:本申请公开了一种图像解压缩方法及装置。所述方法包括:获取图像压缩数据;基于预设的反量化因素,对所述图像压缩数据进行反量化,获得反量化数据;所述反量化因素为整数;对所述反量化数据进行DCT反变换,获得图像数据;所述DCT反变换包括移位运算和加法运算。本申请能够提高图像解压缩的处理效率。(The application discloses an image decompression method and device. The method comprises the following steps: acquiring image compression data; carrying out inverse quantization on the image compressed data based on a preset inverse quantization factor to obtain inverse quantization data; the inverse quantization factor is an integer; performing DCT inverse transformation on the inverse quantization data to obtain image data; the inverse DCT transform includes a shift operation and an addition operation. The image decompression processing method and device can improve the processing efficiency of image decompression.)
1. An image decompression method, comprising:
acquiring image compression data;
carrying out inverse quantization on the image compressed data based on a preset inverse quantization factor to obtain inverse quantization data; the inverse quantization factor is an integer;
performing DCT inverse transformation on the inverse quantization data to obtain image data; the inverse DCT transform includes a shift operation and an addition operation.
2. The image decompression method according to claim 1, wherein before the inverse quantization of the image compressed data based on the preset inverse quantization factor to obtain inverse quantized data, further comprising:
obtaining DCT transformation base and quantization factor in the image compression process;
acquiring a decimal part in the DCT transformation base;
shifting the decimal part left by a preset number to obtain an integer;
and multiplying the obtained integer by the quantization factor and then rounding to obtain the inverse quantization factor.
3. The image decompression method according to claim 2, wherein the dequantized data is a matrix of n rows and n columns, n > 1;
the performing DCT inverse transform on the inverse quantization data to obtain image data specifically includes:
performing transformation operation on each row of data of the inverse quantization data to obtain a row transformation matrix; the transform operation comprises a shift operation and an add operation;
performing transformation operation on each column of data of the row transformation matrix to obtain a column transformation matrix;
and shifting the column transformation matrix to the right by the preset digit to obtain the image data.
4. The image decompression method according to claim 3, wherein said performing a transform operation on each row of data of the dequantized data to obtain a row transform matrix comprises:
respectively taking each row of data in the inverse quantization data as a target matrix, forming odd-numbered bit data in the target matrix into an odd-numbered bit matrix, and forming even-numbered bit data in the target matrix into an even-numbered bit matrix;
performing first operation on the odd digit matrix to obtain a first operation matrix; the first operation comprises a shift operation and an add operation;
performing second operation on the even-numbered bit matrix to obtain a second operation matrix; the second operation comprises a shift operation and an add operation;
calculating the sum of the first operation matrix and the second operation matrix to obtain a first transformation matrix;
calculating a difference value between the first operation matrix and the second operation matrix to obtain a second transformation matrix;
merging the data in the first transformation matrix and the data in the second transformation matrix into a target transformation matrix corresponding to the target matrix; and the target transformation matrix corresponding to the n rows of data in the dequantized data forms the row transformation matrix.
5. The image decompression method according to claim 4, wherein the dequantized data is a matrix of 8 rows and 8 columns, and the target matrix is a matrix of 1 row and 8 columns;
the first operation is:
wherein Y _1C is a first operation matrix,
the second operation is:
wherein Y _2C is a second operation matrix,
6. An image decompression apparatus, comprising:
the data acquisition module is used for acquiring image compression data;
the inverse quantization module is used for carrying out inverse quantization on the image compressed data based on a preset inverse quantization factor to obtain inverse quantization data; the inverse quantization factor is an integer; and the number of the first and second groups,
the inverse transformation module is used for carrying out DCT inverse transformation on the inverse quantization data to obtain image data; the inverse DCT transform includes a shift operation and an addition operation.
7. The image decompression apparatus according to claim 6, further comprising:
the factor acquisition module is used for acquiring a DCT transformation base and a quantization factor in the image compression process;
a decimal obtaining module for obtaining a decimal part in the DCT transformation base;
the left shift module is used for shifting the decimal part to the left by a preset number to obtain an integer; and the number of the first and second groups,
and the rounding module is used for rounding up the obtained integer multiplied by the quantization factor to obtain the inverse quantization factor.
8. The image decompression apparatus according to claim 7, wherein the dequantized data is a matrix of n rows and n columns, n > 1;
the inverse transform module specifically includes:
the row transformation unit is used for carrying out transformation operation on each row of data of the inverse quantization data to obtain a row transformation matrix; the transform operation comprises a shift operation and an add operation;
the column transformation unit is used for carrying out transformation operation on each column of data of the row transformation matrix to obtain a column transformation matrix;
and the right shifting unit is used for shifting the column transformation matrix by the preset digit to the right to obtain the image data.
9. The image decompression apparatus according to claim 8, wherein the line transformation unit specifically comprises:
the matrix acquisition subunit is used for respectively taking each row of data in the inverse quantization data as a target matrix, forming odd-numbered data in the target matrix into an odd-numbered bit matrix, and forming even-numbered data in the target matrix into an even-numbered bit matrix;
the first operation subunit is used for performing first operation on the odd-numbered bit matrix to obtain a first operation matrix; the first operation comprises a shift operation and an add operation;
the second operation subunit is used for performing second operation on the even number bit matrix to obtain a second operation matrix; the second operation comprises a shift operation and an add operation;
the first calculation subunit is used for calculating the sum of the first operation matrix and the second operation matrix to obtain a first transformation matrix;
the second calculation subunit is used for calculating a difference value between the first operation matrix and the second operation matrix to obtain a second transformation matrix; and the number of the first and second groups,
a merging subunit, configured to merge data in the first transformation matrix and data in the second transformation matrix into a target transformation matrix corresponding to the target matrix; and the target transformation matrix corresponding to the n rows of data in the dequantized data forms the row transformation matrix.
10. The image decompression apparatus according to claim 9, wherein the dequantized data is a matrix of 8 rows and 8 columns, and the target matrix is a matrix of 1 row and 8 columns;
the first operation is:
wherein Y _1C is a first operation matrix,is an odd-numbered bit matrix, and da1, da3, da5 and da7 are odd-numbered bit data in the target matrix;
the second operation is:
wherein Y _2C is a second operation matrix,
Technical Field
The present application relates to the field of display panel technologies, and in particular, to an image decompression method and apparatus.
Background
With the improvement of the economic level, the flat panel television is more and more popular, the resolution of the television is higher and higher, and the data transmission amount is larger and larger in unit time from the initial high definition to the full high definition and then to 4K and 8K. In addition, the quality requirements of lcd tvs are getting higher and higher, and the lcd panel inevitably has the problem of non-uniform display quality due to the manufacturing process of the lcd tvs, and is compensated by the compensation algorithm of the uniformity of image quality. As the resolution of the lcd panel increases, the storage unit required for compensating data increases and the cost increases.
For larger and larger data transmission and storage, a commonly adopted method is data compression. Before data is stored or transmitted, the CPU is usually used for compression, the process usually has a relatively long time, and before the data is used, decompression is needed, for example, the data transmitted from the video APP/DVD on the playing network or the optical disc needs to be decompressed, and the process usually needs to be processed in real time. The FPGA has great advantages in real-time data processing, but the data type and the operation complexity greatly affect the use condition of FPGA resources.
However, DCT transform is a transform technique commonly used in compression techniques, and DCT transform not only has a large number of floating point operations, but also requires a large number of multipliers, and thus uses large resources. However, in the DCT inverse transform in the prior art, a large number of floating point operations and multiplication operations are required, which results in low processing efficiency of FPGA decompression.
Disclosure of Invention
The embodiment of the application provides an image decompression method and device, and aims to solve the problem of low processing efficiency during image decompression.
The embodiment of the application provides an image decompression method, which comprises the following steps:
acquiring image compression data;
carrying out inverse quantization on the image compressed data based on a preset inverse quantization factor to obtain inverse quantization data; the inverse quantization factor is an integer;
performing DCT inverse transformation on the inverse quantization data to obtain image data; the inverse DCT transform includes a shift operation and an addition operation.
Further, before the inverse quantization is performed on the image compressed data based on the preset inverse quantization factor to obtain inverse quantization data, the method further includes:
obtaining DCT transformation base and quantization factor in the image compression process;
acquiring a decimal part in the DCT transformation base;
shifting the decimal part left by a preset number to obtain an integer;
and multiplying the obtained integer by the quantization factor and then rounding to obtain the inverse quantization factor.
Further, the inverse quantization data is a matrix with n rows and n columns, wherein n is greater than 1;
the performing DCT inverse transform on the inverse quantization data to obtain image data specifically includes:
performing transformation operation on each row of data of the inverse quantization data to obtain a row transformation matrix; the transform operation comprises a shift operation and an add operation;
performing transformation operation on each column of data of the row transformation matrix to obtain a column transformation matrix;
and shifting the column transformation matrix to the right by the preset digit to obtain the image data.
Further, the performing a transformation operation on each row of data of the dequantized data to obtain a row transformation matrix specifically includes:
respectively taking each row of data in the inverse quantization data as a target matrix, forming odd-numbered bit data in the target matrix into an odd-numbered bit matrix, and forming even-numbered bit data in the target matrix into an even-numbered bit matrix;
performing first operation on the odd digit matrix to obtain a first operation matrix; the first operation comprises a shift operation and an add operation;
performing second operation on the even-numbered bit matrix to obtain a second operation matrix; the second operation comprises a shift operation and an add operation;
calculating the sum of the first operation matrix and the second operation matrix to obtain a first transformation matrix;
calculating a difference value between the first operation matrix and the second operation matrix to obtain a second transformation matrix;
merging the data in the first transformation matrix and the data in the second transformation matrix into a target transformation matrix corresponding to the target matrix; and the target transformation matrix corresponding to the n rows of data in the dequantized data forms the row transformation matrix.
Further, the inverse quantization data is a matrix with 8 rows and 8 columns, and the target matrix is a matrix with 1 row and 8 columns;
the first operation is:
wherein Y _1C is a first operation matrix,
is an odd-numbered bit matrix, and da1, da3, da5 and da7 are odd-numbered bit data in the target matrix;the second operation is:
wherein Y _2C is a second operation matrix,
and da2, da4, da6 and da8 are even bit data in the target matrix.An embodiment of the present application further provides an image decompression apparatus, including:
the data acquisition module is used for acquiring image compression data;
the inverse quantization module is used for carrying out inverse quantization on the image compressed data based on a preset inverse quantization factor to obtain inverse quantization data; the inverse quantization factor is an integer; and the number of the first and second groups,
the inverse transformation module is used for carrying out DCT inverse transformation on the inverse quantization data to obtain image data; the inverse DCT transform includes a shift operation and an addition operation.
Further, the apparatus further comprises:
the factor acquisition module is used for acquiring a DCT transformation base and a quantization factor in the image compression process;
a decimal obtaining module for obtaining a decimal part in the DCT transformation base;
the left shift module is used for shifting the decimal part to the left by a preset number to obtain an integer; and the number of the first and second groups,
and the rounding module is used for rounding up the obtained integer multiplied by the quantization factor to obtain the inverse quantization factor.
Further, the inverse quantization data is a matrix with n rows and n columns, wherein n is greater than 1;
the inverse transform module specifically includes:
the row transformation unit is used for carrying out transformation operation on each row of data of the inverse quantization data to obtain a row transformation matrix; the transform operation comprises a shift operation and an add operation;
the column transformation unit is used for carrying out transformation operation on each column of data of the row transformation matrix to obtain a column transformation matrix;
and the right shifting unit is used for shifting the column transformation matrix by the preset digit to the right to obtain the image data.
Further, the line transformation unit specifically includes:
the matrix acquisition subunit is used for respectively taking each row of data in the inverse quantization data as a target matrix, forming odd-numbered data in the target matrix into an odd-numbered bit matrix, and forming even-numbered data in the target matrix into an even-numbered bit matrix;
the first operation subunit is used for performing first operation on the odd-numbered bit matrix to obtain a first operation matrix; the first operation comprises a shift operation and an add operation;
the second operation subunit is used for performing second operation on the even number bit matrix to obtain a second operation matrix; the second operation comprises a shift operation and an add operation;
the first calculation subunit is used for calculating the sum of the first operation matrix and the second operation matrix to obtain a first transformation matrix;
the second calculation subunit is used for calculating a difference value between the first operation matrix and the second operation matrix to obtain a second transformation matrix; and the number of the first and second groups,
a merging subunit, configured to merge data in the first transformation matrix and data in the second transformation matrix into a target transformation matrix corresponding to the target matrix; and the target transformation matrix corresponding to the n rows of data in the dequantized data forms the row transformation matrix.
Further, the inverse quantization data is a matrix with 8 rows and 8 columns, and the target matrix is a matrix with 1 row and 8 columns;
the first operation is:
wherein Y _1C is a first operation matrix,
is an odd-numbered bit matrix, and da1, da3, da5 and da7 are odd-numbered bit data in the target matrix;the second operation is:
wherein Y _2C is a second operation matrix,
and da2, da4, da6 and da8 are even bit data in the target matrix.The beneficial effect of this application does: the image decompression method based on the integer dequantization factor has the advantages that the image compressed data is dequantized based on the integer dequantization factor to obtain dequantized data, and then DCT (discrete cosine transformation) inverse transformation is performed on the dequantized data based on the shift operation and the addition operation to obtain the image data, so that floating point operation and multiplication operation are not needed in the image decompression process, the decompression processing efficiency is effectively improved, and the real-time decompression processing is guaranteed.
Drawings
The technical solution and other advantages of the present application will become apparent from the detailed description of the embodiments of the present application with reference to the accompanying drawings.
Fig. 1 is a schematic flowchart of an image decompression method according to an embodiment of the present application;
fig. 2 is a schematic diagram of inverse quantization data to column transformation matrix in the image decompression method according to the embodiment of the present application;
fig. 3 is a schematic structural diagram of an image decompression apparatus according to an embodiment of the present application.
Detailed Description
Specific structural and functional details disclosed herein are merely representative and are provided for purposes of describing example embodiments of the present application. This application may, however, be embodied in many alternate forms and should not be construed as limited to only the embodiments set forth herein.
In the description of the present application, it is to be understood that the terms "center," "lateral," "upper," "lower," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," and the like are used in the orientation or positional relationship indicated in the drawings for convenience in describing the present application and for simplicity in description, and are not intended to indicate or imply that the referenced device or element must have a particular orientation, be constructed in a particular orientation, and be operated in a particular manner, and therefore should not be construed as limiting the present application. Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present application, "a plurality" means two or more unless otherwise specified. Furthermore, the term "comprises" and any variations thereof is intended to cover non-exclusive inclusions.
In the description of the present application, it is to be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as supporting connections, as well as detachably or integrally connected; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. The specific meaning of the above terms in the present application can be understood in a specific case by those of ordinary skill in the art.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of example embodiments. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used herein, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
The present application is further described below with reference to the accompanying drawings and examples.
As shown in fig. 1, an embodiment of the present application provides an image decompression method, including
101. Image compression data is acquired.
In this embodiment, the image compressed data refers to compressed data obtained by compressing original image data. The compression process may include DCT transformation, quantization and encoding. The DCT transform, also called discrete cosine transform, aims to transform a space domain signal to a frequency domain signal, effectively remove the correlation of the signal, concentrate most of the energy to a low frequency region, then selectively encode a part of significant low frequency domain signals, discard insignificant high frequency domain signals, and achieve the purpose of improving the compression efficiency.
The DCT transformation formula in nxm space is as follows:
two-dimensional DCT transformation is equivalent to performing row transformation and then column transformation on image data, that is, performing inner products on N elements in each row or each column and N transformation bases with different frequencies, so that a DCT transformation formula can be equivalent to: y ═ C ═ X ═ CTAnd C is a DCT transform base.
Wherein, DCT transformation base C is:
quantization refers to the process of approximating a continuous value (or a large number of possible discrete values) of a signal to a finite number (or fewer) of discrete values. And quantizing the data after DCT transformation based on a preset quantization factor Q.
Encoding is the process of converting information from one format or form to another. And coding the quantized data to obtain image compressed data.
102. Carrying out inverse quantization on the image compressed data based on a preset inverse quantization factor to obtain inverse quantization data; the inverse quantization factor is an integer.
In this embodiment, after the image compressed data is obtained, the image compressed data may be decoded first. Decoding is the process of restoring information from an already encoded form to its original state prior to encoding.
And then, the decoded image compressed data is subjected to inverse quantization based on a preset inverse quantization factor. The inverse quantization factor is calculated and set according to the DCT transformation base C and the quantization factor Q in the image compression process.
Specifically, the method for calculating the inverse quantization factor includes:
obtaining DCT transformation base and quantization factor in the image compression process;
acquiring a decimal part in the DCT transformation base;
shifting the decimal part left by a preset number to obtain an integer;
and multiplying the obtained integer by the quantization factor and then rounding to obtain the inverse quantization factor.
It should be noted that the DCT transformation base C and the quantization factor Q are both matrices, each data in the DCT transformation base C includes an integer part and a fractional part, and the fractional part of each data in the DCT transformation base C is extracted to form a fractional matrix a. And (3) moving the decimal matrix A by a preset digit f to the left, namely amplifying the decimal matrix A by the power f of 2 to obtain an integer, and combining the integer with the quantization factor Q to obtain an inverse quantization factor V. The decimal matrix a may be a matrix with 8 rows and 8 columns, the quantization factor Q may be a matrix with 8 rows and 8 columns, and the preset number f may be a matrix with 8 rows and 8 columns, which are as follows:
A11
A12
A13
A14
A15
A16
A17
A18
A21
A22
A23
A24
A25
A26
A27
A28
A31
A32
A33
A34
A35
A36
A37
A38
A41
A42
A43
A44
A45
A46
A47
A48
A51
A52
A53
A54
A55
A56
A57
A58
A61
A62
A63
A64
A65
A66
A67
A68
A71
A72
A73
A74
A75
A76
A77
A78
A81
A82
A83
A84
A85
A86
A87
A88
Q11
Q12
Q13
Q14
Q15
Q16
Q17
Q18
Q21
Q22
Q23
Q24
Q25
Q26
Q27
Q28
Q31
Q32
Q33
Q34
Q35
Q36
Q37
Q38
Q41
Q42
Q43
Q44
Q45
Q46
Q47
Q48
Q51
Q52
Q53
Q54
Q55
Q56
Q57
Q58
Q61
Q62
Q63
Q64
Q65
Q66
Q67
Q68
Q71
Q72
Q73
Q74
Q75
Q76
Q77
Q78
Q81
Q82
Q83
Q84
Q85
Q86
Q87
Q88
f11
f12
f13
f14
f15
f16
f17
f18
f21
f22
f23
f24
f25
f26
f27
f28
f31
f32
f33
f34
f35
f36
f37
f38
f41
f42
f43
f44
f45
f46
f47
f48
f51
f52
f53
f54
f55
f56
f57
f58
f61
f62
f63
f64
f65
f66
f67
f68
f71
f72
f73
f74
f75
f76
f77
f78
f81
f82
f83
f84
f85
f86
f87
f88
。
the formula for calculating the inverse quantization factor V is as follows:
V=floor(A*Q*2f);
wherein, is dot product and floor is rounded.
The decimal matrix A and the quantization factor Q are fixed values, so that the calculation of the inverse quantization factor V can be carried out on line, and the inverse quantization factor V obtained by calculation is written into a register and is directly read from the register for use during inverse quantization.
In inverse quantization, the present embodiment uses the inverse quantization factor V to replace the quantization factor Q in the prior art, and performs inverse quantization on the decoded image compressed data, so that the operation of inverse quantization is not increased.
103. Performing DCT inverse transformation on the inverse quantization data to obtain image data; the inverse DCT transform includes a shift operation and an addition operation.
In this embodiment, the dequantized data is a matrix of n rows and n columns, where n > 1, and each data in the matrix is an integer. The DCT inverse transformation of the integer matrix can only use shift operation and addition operation, and avoid multiplication operation, thereby effectively reducing the operation complexity and improving the processing efficiency of the DCT inverse transformation.
Specifically, the performing DCT inverse transform on the inverse quantization data to obtain image data specifically includes:
performing transformation operation on each row of data of the inverse quantization data to obtain a row transformation matrix; the transform operation comprises a shift operation and an add operation;
performing transformation operation on each column of data of the row transformation matrix to obtain a column transformation matrix;
and shifting the column transformation matrix to the right by the preset digit to obtain the image data.
In the matrix of n rows and n columns of inverse quantization data, transform operation is performed from the first row first, and then the matrix is sequentially transformed into the nth row. After the conversion of the n rows of data is completed, a row conversion matrix can be obtained, and the row conversion matrix is still a matrix with n rows and n columns. Then, for the row transformation matrix, transformation operation is performed from the first column to the nth column in order. After the N columns of data are transformed, a column transformation matrix is obtained, which is still a matrix of N rows and N columns. Wherein the transformation operation of each row is the same principle as the transformation operation of each column.
Specifically, the performing a transformation operation on each row of data of the dequantized data to obtain a row transformation matrix specifically includes:
respectively taking each row of data in the inverse quantization data as a target matrix, forming odd-numbered bit data in the target matrix into an odd-numbered bit matrix, and forming even-numbered bit data in the target matrix into an even-numbered bit matrix;
performing first operation on the odd digit matrix to obtain a first operation matrix; the first operation comprises a shift operation and an add operation;
performing second operation on the even-numbered bit matrix to obtain a second operation matrix; the second operation comprises a shift operation and an add operation;
calculating the sum of the first operation matrix and the second operation matrix to obtain a first transformation matrix;
calculating a difference value between the first operation matrix and the second operation matrix to obtain a second transformation matrix;
merging the data in the first transformation matrix and the data in the second transformation matrix into a target transformation matrix corresponding to the target matrix; and the target transformation matrix corresponding to the n rows of data in the dequantized data forms the row transformation matrix.
In this embodiment, the principle of the transform operation for each row of the dequantized data is the same as that of the transform operation for each column of the row transform matrix. As shown in fig. 2, first, for the dequantized data, the number i of lines of the dequantized data is set, i is made 1, the transform operation is performed from the first line, namely, the ith row of data in the inverse quantization data is obtained, the ith row of data is divided into an odd-numbered matrix and an even-numbered matrix, the odd-numbered matrix is respectively subjected to a first operation and the even-numbered matrix is respectively subjected to a second operation, the first operation and the second operation both comprise a shift operation and an addition operation, a first operation matrix and a second operation matrix are obtained correspondingly, further adding the first operation matrix and the second operation matrix, wherein the adding operation comprises two operations of adding and subtracting the first operation matrix and the second operation matrix, combining the operation results of the two operations, if the results of the addition operation are arranged in order and the results of the subtraction operation are arranged in reverse order after the results of the addition operation, the transformed ith row of data can be formed. Caching the transformed ith row of data, meanwhile, i + +, if i is less than or equal to 8 at the moment, continuing to obtain the ith row of data in the dequantized data, and performing transformation operation on the ith row of data; if i is greater than 8, arranging all the cached row data according to the original row sequence to form a row transformation matrix.
Furthermore, the row transformation matrix is provided with the column number j of the row transformation matrix, and the transformation operation is carried out from the first column when j is equal to 0, that is, the jth column data in the row transformation matrix is obtained, the jth column data is divided into an odd-numbered bit matrix and an even-numbered bit matrix, the odd-numbered bit matrix is subjected to a first operation and the even-numbered bit matrix is subjected to a second operation respectively, the first operation and the second operation both comprise a shift operation and an addition operation, a first operation matrix and a second operation matrix are obtained correspondingly, further adding the first operation matrix and the second operation matrix, wherein the adding operation comprises two operations of adding and subtracting the first operation matrix and the second operation matrix, alternately arranging the operation results of the two operations, if the results of the addition operation are arranged in order, and the results of the subtraction operation are arranged in reverse order after the results of the addition operation, then the transformed jth column data can be formed. Caching the transformed jth line of data, meanwhile j + +, if j is less than or equal to 8 at the moment, continuing to acquire jth line of data in the row transformation matrix, and performing transformation operation on the jth line of data; if j is greater than 8, arranging all the cached column data according to the original column sequence to form a column transformation matrix.
For example, the inverse quantization data is a matrix of 8 rows and 8 columns, and data in a certain row is taken as a target matrix, and the data in the target matrix is da1, da2, da3, da4, da5, da6, da7 and da8 in sequence. Wherein da1, da3, da5 and da7 are odd-numbered data and form an odd-numbered matrix
da2, da4, da6 and da8 are even bit data and form an even bit matrixPerforming a first operation on the odd-numbered matrix to obtain a first operation matrix Y _1C, wherein the first operation is as follows:
the data in the odd bit matrix multiplied by 2 means a shift to the left by one bit and the data multiplied by 1 means no shift, so that only shift and add operations are present in the first operation. And performing second operation on the even-numbered bit matrix to obtain a second operation matrix Y _2C, wherein the second operation is as follows:
the multiplication of the data by 4 in the even bit matrix means a shift by two bits to the left, the multiplication of the data by 2 means a shift by one bit to the left, and the multiplication of the data by 1 means no shift, so that only shift and addition operations are present in the second operation.
Further, the sum of the first operation matrix Y _1C and the second operation matrix Y _2C, i.e., the first transformation matrix I _1C ═ Y _1C + Y _2C, is calculated, and the difference between the first operation matrix Y _1C and the second operation matrix Y _2C, i.e., the second transformation matrix I _2C ═ Y _1C-Y _2C, is calculated. After arranging the data in the first transformation matrix I _1C as the sequence and arranging the data in the second transformation matrix I _2C in the reverse order after the data in the first transformation matrix I _1C, a target transformation matrix I _ y (I) corresponding to the target matrix is formed (I _1C (1) I _1C (2) I _1C (3) I _1C (4) I _2C (3) I _2C (2) I _2C (1)).
After the column transformation matrix is obtained, because the decimal part in the DCT transformation base is shifted to the left by the preset digit f when the inverse quantization factor is calculated, the data in the column transformation matrix needs to be shifted to the right by the preset digit f at the moment, namely, the data in the column transformation matrix is divided by 2fAnd original image data is obtained.
According to the embodiment of the application, the image compression data can be inversely quantized based on the inverse quantization factor of the integer to obtain the inverse quantization data, and then the inverse quantization data is subjected to DCT inverse transformation based on the shift operation and the addition operation to obtain the image data, so that floating point operation and multiplication operation are not required in the image decompression process, the decompression processing efficiency is effectively improved, and the real-time decompression processing is ensured.
Accordingly, an embodiment of the present application further provides an image decompression device, which is capable of implementing all the processes of the image decompression method in the foregoing embodiments.
As shown in fig. 3, an image decompression apparatus provided in an embodiment of the present application includes:
the
the
an
Further, the apparatus further comprises:
the factor acquisition module is used for acquiring a DCT transformation base and a quantization factor in the image compression process;
a decimal obtaining module for obtaining a decimal part in the DCT transformation base;
the left shift module is used for shifting the decimal part to the left by a preset number to obtain an integer; and the number of the first and second groups,
and the rounding module is used for rounding up the obtained integer multiplied by the quantization factor to obtain the inverse quantization factor.
Further, the inverse quantization data is a matrix with n rows and n columns, wherein n is greater than 1;
the inverse transform module specifically includes:
the row transformation unit is used for carrying out transformation operation on each row of data of the inverse quantization data to obtain a row transformation matrix; the transform operation comprises a shift operation and an add operation;
the column transformation unit is used for carrying out transformation operation on each column of data of the row transformation matrix to obtain a column transformation matrix;
and the right shifting unit is used for shifting the column transformation matrix by the preset digit to the right to obtain the image data.
Further, the line transformation unit specifically includes:
the matrix acquisition subunit is used for respectively taking each row of data in the inverse quantization data as a target matrix, forming odd-numbered data in the target matrix into an odd-numbered bit matrix, and forming even-numbered data in the target matrix into an even-numbered bit matrix;
the first operation subunit is used for performing first operation on the odd-numbered bit matrix to obtain a first operation matrix; the first operation comprises a shift operation and an add operation;
the second operation subunit is used for performing second operation on the even number bit matrix to obtain a second operation matrix; the second operation comprises a shift operation and an add operation;
the first calculation subunit is used for calculating the sum of the first operation matrix and the second operation matrix to obtain a first transformation matrix;
the second calculation subunit is used for calculating a difference value between the first operation matrix and the second operation matrix to obtain a second transformation matrix; and the number of the first and second groups,
a merging subunit, configured to merge data in the first transformation matrix and data in the second transformation matrix into a target transformation matrix corresponding to the target matrix; and the target transformation matrix corresponding to the n rows of data in the dequantized data forms the row transformation matrix.
Further, the inverse quantization data is a matrix with 8 rows and 8 columns, and the target matrix is a matrix with 1 row and 8 columns;
the first operation is:
wherein Y _1C is a first operation matrix,is an odd-numbered bit matrix, and da1, da3, da5 and da7 are odd-numbered bit data in the target matrix;
the second operation is:
wherein Y _2C is a second operation matrix,
and da2, da4, da6 and da8 are even bit data in the target matrix.According to the embodiment of the application, the image compression data can be inversely quantized based on the inverse quantization factor of the integer to obtain the inverse quantization data, and then the inverse quantization data is subjected to DCT inverse transformation based on the shift operation and the addition operation to obtain the image data, so that floating point operation and multiplication operation are not required in the image decompression process, the decompression processing efficiency is effectively improved, and the real-time decompression processing is ensured.
In summary, although the present application has been described with reference to the preferred embodiments, the above-described preferred embodiments are not intended to limit the present application, and those skilled in the art can make various changes and modifications without departing from the spirit and scope of the present application, so that the scope of the present application shall be determined by the appended claims.
- 上一篇:一种医用注射器针头装配设备
- 下一篇:游戏交互方法、直播系统、电子设备及存储装置