Image compression method and device, image decompression method and device, equipment and storage medium
By determining the quantization step size according to the frequency level of each pixel, the image is transformed and compressed in the frequency domain, which solves the problem of inflexible quantization step size in the existing technology and achieves efficient image compression and decompression effects.
Patent Information
- Application Number
- CN202410881380.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-02
AI Technical Summary
In existing image compression technology, the quantization step setting corresponding to pixels is not flexible enough, resulting in deficiencies in balancing compression rate and fidelity.
By transforming the image from the spatial domain to the frequency domain, the target quantization step is determined according to the frequency level of each pixel, and the transformation coefficients are compressed and decompressed to achieve flexible quantization step setting.
It improves the flexibility in the image compression process, takes into account the overall compression rate requirements and fidelity requirements of the image, reduces the compression loss of high-frequency components, and improves the compression rate and fidelity of the image.
Smart Images

Figure CN118741121A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to, but is not limited to, the field of image processing, and in particular to an image compression and image decompression method, device, equipment, and storage medium. Background Art
[0002] In the field of images, a subjective visual lossless lossy compression scheme can be used to reduce image bandwidth and image memory. Subjective visual losslessness means that after the image is compressed and decompressed through lossy compression technology, the human eye cannot distinguish the difference between the image before and after compression. In related technologies, the quantization step size corresponding to each pixel in the process of compressing the image is not flexible enough. Summary of the invention
[0003] In view of this, the embodiments of the present disclosure at least provide an image compression and image decompression method, apparatus, device, and storage medium.
[0004] The technical solution of the embodiment of the present disclosure is implemented as follows:
[0005] The present disclosure provides an image compression method, the method comprising:
[0006] acquiring a first image;
[0007] Transform the first image from the spatial domain to the frequency domain to obtain first transformation coefficients corresponding to each pixel in the first image;
[0008] The first transform coefficients corresponding to the pixels are compressed using the target quantization step sizes corresponding to the pixels to obtain first image compression data; the target quantization step sizes corresponding to the pixels are determined according to the frequency levels corresponding to the pixels.
[0009] The present disclosure provides an image decompression method, the method comprising:
[0010] Acquire first image compression data; the first image compression data includes compression values corresponding to each pixel in the first restored image to be restored;
[0011] Decompressing the corresponding compressed value using the target quantization step size corresponding to each pixel to obtain a second transform coefficient corresponding to each pixel; the target quantization step size corresponding to each pixel is determined according to the frequency level corresponding to the pixel;
[0012] The second transformation coefficient corresponding to each of the pixels is transformed from the frequency domain to the spatial domain to obtain the first restored image.
[0013] The present disclosure provides an image compression device, the device comprising:
[0014] A first acquisition module, used to acquire a first image;
[0015] A first transformation module, used to transform the first image from a spatial domain to a frequency domain, and obtain first transformation coefficients corresponding to each pixel in the first image;
[0016] The compression module is used to compress the corresponding first transform coefficient using the target quantization step corresponding to each pixel to obtain first image compression data; the target quantization step corresponding to each pixel is determined according to the frequency level corresponding to the pixel.
[0017] The present disclosure provides an image decompression device, the device comprising:
[0018] A second acquisition module is used to acquire first image compression data; the first image compression data includes a compression value corresponding to each pixel in the first restored image to be restored;
[0019] A decompression module, configured to decompress the corresponding compressed value using the target quantization step size corresponding to each pixel, so as to obtain a second transform coefficient corresponding to each pixel; the target quantization step size corresponding to each pixel is determined according to the frequency level corresponding to the pixel;
[0020] The second transformation module is used to transform the second transformation coefficient corresponding to each pixel from the frequency domain to the space domain to obtain a first restored image.
[0021] An embodiment of the present disclosure provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.
[0022] An embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, some or all of the steps in the above method are implemented.
[0023] An embodiment of the present disclosure provides a computer program product, including a computer program or instructions, which implements some or all of the steps in the above method when executed by a processor.
[0024] In the disclosed embodiment, a first image is acquired, and the first image is transformed from the spatial domain to the frequency domain to obtain first transform coefficients corresponding to each pixel in the first image; the corresponding first transform coefficients are compressed using the target quantization step corresponding to each pixel to obtain first image compressed data; the target quantization step corresponding to each pixel is determined according to the frequency level corresponding to the pixel. In this way, different quantization steps can be designed according to the frequency level corresponding to each pixel to compress the corresponding first transform coefficients, thereby improving the flexibility of the image compression process, and further, the overall image compression rate requirements and fidelity requirements can be taken into account by flexibly setting the quantization step.
[0025] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and are not intended to limit the technical solutions of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used to illustrate the technical solutions of the present disclosure together with the specification.
[0027] Figure 1 A schematic diagram of an implementation process of an image compression method provided in an embodiment of the present disclosure Figure 1 ;
[0028] Figure 2 A schematic diagram of an implementation process of an image compression method provided in an embodiment of the present disclosure Figure 2 ;
[0029] Figure 3 A schematic diagram of an implementation process of an image decompression method provided in an embodiment of the present disclosure Figure 1 ;
[0030] Figure 4 A schematic flow chart of a compression method combining a subjective lossless compression method of an image based on frequency domain segmented quantization and a compression method based on dither compression coding provided by an embodiment of the present disclosure;
[0031] Figure 5 A schematic diagram of transforming an image from a spatial domain to a frequency domain along a horizontal direction provided by an embodiment of the present disclosure;
[0032] Figure 6 A schematic diagram of transforming an image along a vertical direction provided by an embodiment of the present disclosure;
[0033] Figure 7 A schematic diagram of the correspondence between a quantization step size and an image block position provided in an embodiment of the present disclosure;
[0034] Figure 8A schematic diagram of an implementation process of an image decompression method provided in an embodiment of the present disclosure Figure 2 ;
[0035] Fig. 9A A schematic diagram of the structure of an image compression device provided by an embodiment of the present disclosure;
[0036] Fig. 9B A schematic diagram of the structure of an image decompression device provided by an embodiment of the present disclosure;
[0037] Fig.10 A hardware entity schematic diagram of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solutions and advantages of the present disclosure clearer, the technical solutions of the present disclosure are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present disclosure. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.
[0039] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0040] The terms "first / second / third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It is understandable that "first / second / third" can be interchanged with a specific order or sequence where permitted so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0041] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present disclosure belongs. The terms used herein are only for the purpose of describing the present disclosure and are not intended to limit the present disclosure.
[0042] In view of this, an embodiment of the present disclosure provides an image compression method. Figure 1 A schematic diagram of an implementation process of an image compression method provided in an embodiment of the present disclosure Figure 1 ,like Figure 1 As shown, the method includes the following steps S101 to S103:
[0043] Step S101: Acquire a first image;
[0044] Here, the first image may be any suitable image to be compressed, which is not limited in the embodiment of the present disclosure.
[0045] In some implementations, the first image is an original image to be compressed.
[0046] In some embodiments, the first image is one of the multiple image blocks divided from the original image. For example, the original image may be divided into multiple 4*4 image blocks, and the first image may be one 4*4 image block; or the original image may be divided into multiple 8*8 image blocks, and the first image may be one 8*8 image block.
[0047] Step S102: transforming the first image from the spatial domain to the frequency domain to obtain first transformation coefficients corresponding to each pixel in the first image;
[0048] Here, the first image is transformed from the spatial domain to the frequency domain to obtain a first transformation coefficient corresponding to each pixel in the first image.
[0049] In some embodiments, the first image may be transformed from the spatial domain to the frequency domain by using a Haar algorithm, and the transformation of the first image from the spatial domain to the frequency domain includes performing frequency separation processing on the first image in the horizontal direction and / or in the vertical direction. For example, the first image may be subjected to frequency separation processing in the horizontal direction, and then subjected to frequency separation processing in the vertical direction on this basis, to obtain first transformation coefficients corresponding to each pixel in the first image.
[0050] In some embodiments, the first image may be transformed from the spatial domain to the frequency domain by discrete cosine transform (DCT) and / or discrete wavelet transform (DWT).
[0051] Step S103: compressing the first transform coefficients corresponding to the pixels to obtain first image compression data using the target quantization step corresponding to the pixels. The target quantization step corresponding to each pixel is determined according to the frequency level corresponding to the pixel.
[0052] In some implementations, the target quantization step size corresponding to each pixel is determined based on a target compression rate and a frequency level corresponding to each pixel.
[0053] In some implementations, the quantization step size may be adaptively adjusted according to local or global characteristics of the image, and the target quantization step size corresponding to each pixel may be ultimately determined.
[0054] In some implementations, the target quantization step size corresponding to each pixel may be preset by those skilled in the art according to actual needs.
[0055] In some embodiments, for a pixel in the first image, the higher the frequency level corresponding to the pixel, the smaller the target quantization step size corresponding to the pixel. For example, a smaller target quantization step size is used for a pixel with a higher frequency level, and a larger target quantization step size is used for a pixel with a lower frequency level.
[0056] In some embodiments, the higher the frequency level corresponding to the pixel in the first image, the smaller the target quantization step corresponding to the pixel. In this way, the high-frequency components in the image can be effectively protected from being over-compressed, compression loss can be reduced, and image fidelity can be improved. At the same time, the compression rate of the low-frequency components in the image can be improved, thereby taking into account the overall compression rate requirements and fidelity requirements of the image.
[0057] In some embodiments, for a pixel in the first image, a target quantization step size corresponding to the pixel may be determined according to a frequency level corresponding to the pixel and a scene type of the first image. The scene type of the first image represents a scene corresponding to the content contained in the first image, for example, the scene type may include at least one of a text type, a natural texture type, etc.
[0058] In some embodiments, a target quantization step size corresponding to the scene type can be set for pixels of each frequency level according to the scene type of the first image. For example, for the first image of text type, since the subjective vision of the human eye is usually more sensitive to high-frequency information in the image of this type, that is, the pixels corresponding to the higher frequency levels in the first image of text type are more easily perceived by the human eye, therefore, in the first image of text type, for pixels whose corresponding frequency levels are higher than the first target level, the target quantization step size corresponding to the pixel is less than the first step size threshold, so that for pixels corresponding to the higher frequency levels in the first image of text type, by setting a smaller target quantization step size, the compression loss of the pixel can be reduced, thereby improving the subjective visual effect of the compressed and decompressed image. For another example, for a scene type with natural texture, since the subjective vision of the human eye is not very sensitive to the high-frequency information in this type of image, that is, the pixels corresponding to the higher frequency levels in the first image of the natural texture type are less likely to be perceived, in the first image of the natural texture type, for pixels whose corresponding frequency levels are higher than the first target level, the target quantization step corresponding to the pixel is greater than the first step threshold. In this way, for pixels corresponding to the higher frequency levels in the first image of the natural texture type, by setting a larger target quantization step, the compression rate of the image can be improved, thereby improving the transmission speed of the image and reducing the transmission bandwidth of the image.
[0059] In some embodiments, when the scene type of the first image is a text type, the target quantization step size of the pixels corresponding to the first frequency level is greater than the target quantization step size of the pixels corresponding to the second frequency level; when the scene type of the first image is a natural texture type, the target quantization step size of the pixels corresponding to the first frequency level is less than the target quantization step size of the pixels corresponding to the second frequency level; wherein the second frequency level is higher than the first frequency level. In this way, different target quantization step sizes are designed for different frequency levels according to the scene type of the first image, and more appropriate target quantization step sizes are designed for each pixel in the first image of different scene types, so that the compression effect of the first image is better.
[0060] In some embodiments, compressing each first transform coefficient includes quantizing each first transform coefficient to obtain a first quantization value corresponding to each first transform coefficient, and encoding the first quantization value corresponding to each first transform coefficient to obtain first image compression data.
[0061] In the disclosed embodiment, a first image is acquired, and the first image is transformed from the spatial domain to the frequency domain to obtain first transform coefficients corresponding to each pixel in the first image; the corresponding first transform coefficients are compressed using the target quantization step corresponding to each pixel to obtain first image compressed data; the target quantization step corresponding to each pixel is determined according to the frequency level corresponding to the pixel. In this way, different quantization step sizes can be designed according to the frequency level corresponding to each pixel to compress the corresponding first transform coefficients, thereby improving the flexibility of the image compression process, and then by flexibly setting different target quantization step sizes corresponding to the pixels according to the different frequency levels corresponding to the pixels, different quantization step sizes can take into account the overall compression rate requirements and fidelity requirements of the image.
[0062] In some embodiments, step S102 may include the following step S111:
[0063] Step S111: performing frequency separation processing on the first image along the horizontal direction and / or the vertical direction to obtain first transformation coefficients corresponding to each pixel in the first image.
[0064] In some implementations, the first image is subjected to frequency separation processing in the horizontal direction to obtain first transform coefficients corresponding to respective pixels in the first image.
[0065] In some implementations, the first image is subjected to frequency separation processing in a vertical direction to obtain first transform coefficients corresponding to respective pixels in the first image.
[0066] In some embodiments, the first image is subjected to frequency separation processing along the horizontal direction, and on this basis, the image subjected to frequency separation processing along the horizontal direction is subjected to frequency separation processing along the vertical direction to obtain first transformation coefficients corresponding to each pixel in the first image.
[0067] In some embodiments, the first image is subjected to frequency separation processing in the vertical direction, and on this basis, the image subjected to frequency separation processing in the vertical direction is subjected to frequency separation processing in the horizontal direction to obtain first transformation coefficients corresponding to each pixel in the first image.
[0068] In the embodiment of the present disclosure, the first image is subjected to frequency separation processing in the horizontal direction and / or the vertical direction to obtain the first transformation coefficients corresponding to the pixels in the first image, so that the first transformation coefficients corresponding to different frequency levels can be better separated in the frequency domain.
[0069] In some embodiments, step S111 may include the following steps S121 and S122:
[0070] Step S121: performing frequency separation processing on the first image along the horizontal direction to obtain a first transformed image;
[0071] In some embodiments, the first image and the first transformed image have the same size, and both the first image and the first transformed image have N columns, where N is greater than 3;
[0072] The pixel value of the 1st column of pixels in the first transformed image is equal to the pixel value of the 1st column of pixels in the first image, the pixel value of the N-1th column of pixels in the first transformed image is determined based on the pixel value of the N-1th column of pixels in the first image and the pixel value of the 1st column of pixels in the first image, the pixel value of the Nth column of pixels in the first transformed image is determined based on the pixel value of the Nth column of pixels in the first image and the pixel value of the N-1th column of pixels in the first image, and the pixel value of the i-th column of pixels in the first transformed image is determined based on the pixel value of the i-th column of pixels in the first image and the pixel values of at least two reference pixel columns corresponding to the i-th column of pixels in the first image, where i is greater than 1 and less than N-1.
[0073] In some embodiments, the frequency level corresponding to the pixels in the i-th column is not lower than the frequency level corresponding to the pixels in the 1st column; the frequency level corresponding to the pixels in the N-1th column is higher than the frequency level corresponding to the pixels in the i-th column, and the frequency level corresponding to the pixels in the N-1th column is higher than the frequency level corresponding to the pixels in the i-th column.
[0074] In some embodiments, the frequency level corresponding to the pixels in the Nth column in the first transformed image is higher than the frequency level corresponding to the pixels in the N-1th column; in some embodiments, the frequency level corresponding to the pixels in the Nth column in the first transformed image is the same as the frequency level corresponding to the pixels in the N-1th column.
[0075] Exemplarily, assuming that both the first image and the first transformed image are 4*4 image blocks, the first pixel of each row in the first image is taken as the basic pixel without any processing, that is, the first pixel of each row in the first transformed image is equal to the first pixel of each row in the first image; the difference between the third pixel of each row in the first image and the first pixel of each row in the first image is taken as the third pixel of each row in the first transformed image; the difference between the fourth pixel of each row in the first image and the third pixel of each row in the first image is taken as the fourth pixel of each row in the first transformed image; the difference between the average of the first pixel and the third pixel of each row in the first image and the second pixel of each row in the first image is taken as the second pixel of each row in the first transformed image.
[0076] In some embodiments, in the first transformed image, the frequency level of the second column of pixels is not lower than the frequency level of the first column of pixels; the frequency level of the third column of pixels is higher than the frequency level of the second column of pixels; the frequency level of the fourth column of pixels is higher than the frequency level of the second column of pixels.
[0077] Step S122: performing frequency separation processing on the first transformed image along the vertical direction to obtain first transform coefficients corresponding to each pixel in the first image.
[0078] In some embodiments, the first image and the first transformed image have the same size, and both the first image and the first transformed image have M rows, where M is greater than 3;
[0079] The first transformation coefficients of the first row corresponding to the first row of pixels in the first image are equal to the pixel values of the first row of pixels in the first transformation image, the first transformation coefficients of the M-1th row corresponding to the M-1th row of pixels in the first image are determined based on the pixel values of the M-1th row of pixels in the first transformation image and the pixel values of the first row of pixels in the first transformation image, the first transformation coefficients of the Mth row corresponding to the Mth row of pixels in the first image are determined based on the pixel values of the Mth row of pixels in the first transformation image and the pixel values of the M-1th row of pixels in the first transformation image, the first transformation coefficients of the jth row corresponding to the jth row of pixels in the first image are determined based on the pixel values of the jth row of pixels in the first transformation image and the pixel values of at least two reference pixel rows corresponding to the jth row of pixels in the first transformation image, where j is greater than 1 and less than M-1.
[0080] In some embodiments, the frequency level corresponding to the j-th row of pixels is not lower than the frequency level corresponding to the 1-th row of pixels, the frequency level corresponding to the M-1-th row of pixels is higher than the frequency level corresponding to the j-th row of pixels, and the frequency level corresponding to the M-th row of pixels is higher than the frequency level corresponding to the j-th row of pixels.
[0081] In some embodiments, the frequency level corresponding to the pixels in the Mth row is higher than the frequency level corresponding to the pixels in the M-1th row; in some embodiments, the frequency level corresponding to the pixels in the Mth row is the same as the frequency level corresponding to the pixels in the M-1th row.
[0082] Exemplarily, assuming that both the first image and the first transformed image are 4*4 image blocks, the first pixel in each column of the first transformed image is taken as the basic pixel without any processing, that is, the first transformation coefficient corresponding to the first pixel in each column of the first image is equal to the first pixel in each column of the first transformed image; the difference between the third pixel in each column of the first transformed image and the first pixel in each column of the first transformed image is taken as the first transformation coefficient corresponding to the third pixel in each column of the first image; the difference between the fourth pixel in each column of the first transformed image and the third pixel in each column of the first transformed image is taken as the first transformation coefficient corresponding to the fourth pixel in each column of the first image; the difference between the average of the first pixel and the third pixel in each column of the first transformed image and the second pixel in each column of the first transformed image is taken as the first transformation coefficient corresponding to the second pixel in each column of the first image.
[0083] In some embodiments, in the first image, the frequency level corresponding to the second row of pixels is not lower than the frequency level corresponding to the first row of pixels; the frequency level corresponding to the third row of pixels is higher than the frequency level corresponding to the second row of pixels; and the frequency level corresponding to the fourth row of pixels is higher than the frequency level corresponding to the second row of pixels.
[0084] In the disclosed embodiment, the first image is subjected to frequency separation processing in the horizontal direction to obtain a first transformed image; the first transformed image is subjected to frequency separation processing in the vertical direction to obtain first transformation coefficients corresponding to each pixel in the first image. In this way, the frequency separation processing is performed in the horizontal direction and the vertical direction respectively, so that the frequency level corresponding to the pixel obtained after the frequency separation is clearer and more accurate.
[0085] In some embodiments, after the first image is subjected to frequency separation processing in the horizontal direction and / or the vertical direction, the distribution of the frequency levels corresponding to each pixel may be as follows: Figure 7 As shown, the frequency levels corresponding to parts b, c, and d are higher than the frequency levels corresponding to part a; the frequency levels corresponding to parts e, f, and g are higher than the frequency levels corresponding to parts b, c, and d.
[0086] In some embodiments, step S103 may include the following steps S131 and S132:
[0087] Step S131: quantizing the first transform coefficients corresponding to the pixels based on the target quantization step sizes corresponding to the pixels, to obtain first quantization values corresponding to the first transform coefficients;
[0088] Here, the target quantization step size is the quantization step size corresponding to each pixel in the target quantization step size group, and the corresponding relationship is determined by the frequency level corresponding to each pixel.
[0089] Here, the first quantization value is a result of dividing each first transform coefficient by the corresponding target quantization step and rounding off.
[0090] Step S132: Encode each of the first quantization values to obtain first image compression data.
[0091] In some implementations, each first quantization value may be encoded using an exponential Golomb coding method to obtain first image compression data.
[0092] In some implementations, each first quantization value may be encoded by Huffman coding to obtain first image compression data.
[0093] In the disclosed embodiment, based on the target quantization step size corresponding to each pixel, the corresponding first transform coefficient is quantized to obtain the first quantization value corresponding to each first transform coefficient; each first quantization value is encoded to obtain the first image compression data. In this way, the corresponding target quantization step size can be flexibly selected for each pixel to perform quantization, and a quantization result that meets actual needs can be obtained.
[0094] In some embodiments, the above method may further include the following steps S141 and S142:
[0095] Step S141: based on the target compression rate, selecting a target quantization step group from a quantization step group sequence; the quantization step group sequence includes at least two quantization step groups;
[0096] Here, the target compression ratio may be preset.
[0097] In some embodiments, the later the position of the quantization step group in the quantization step group sequence, the greater the compression rate corresponding to the quantization step group. Therefore, when traversing the quantization step group sequence, if there is a first compression rate corresponding to a first quantization step group in the quantization step group sequence that is greater than or equal to the target compression rate, the traversal is stopped and the first quantization step group is determined as the target quantization step group. In this way, the compression rate requirement can be met without over-compression, thereby ensuring image quality.
[0098] Each quantization step length group in the quantization step length group sequence can be preset according to actual conditions. For example, the quantization step length group sequence can be obtained through experiments and calculations, or can be analyzed and determined using mathematical or statistical models.
[0099] It can be understood that the quantization step groups in the quantization step group sequence are traversed, each first transform coefficient is quantized using each quantization step group, and encoding is performed based on the quantized result. The compression rate corresponding to each quantization step group is obtained; when the compression rate corresponding to the quantization step group is greater than or equal to the target compression rate, the quantization step group is determined as the target quantization step group.
[0100] Step S142: based on the frequency level corresponding to each of the pixels, determine the target quantization step corresponding to each of the pixels from the target quantization step group.
[0101] In some embodiments, the target quantization step size group may include at least one target quantization step size corresponding to each frequency level, so that for each pixel, the target quantization step size corresponding to the frequency level in the target quantization step size group can be determined as the target quantization step size corresponding to the pixel based on the frequency level corresponding to the pixel.
[0102] In some implementations, the higher the frequency level corresponding to the pixel, the smaller the target quantization step size corresponding to the pixel;
[0103] In some implementations, to ensure the effect of compression processing on the first image, the target quantization step size corresponding to the pixel may be adjusted according to the actual scene.
[0104] In the disclosed embodiment, based on the target compression rate, a target quantization step group is selected from the quantization step group sequence; based on the frequency level corresponding to each pixel, the target quantization step corresponding to each pixel is determined from the target quantization step group. In this way, according to the set target compression rate, a target quantization step group is selected from the quantization step group sequence, and the result of compressing the corresponding first transform coefficient according to the target quantization step group can meet the compression rate requirement.
[0105] In some embodiments, step S141 may include the following steps S151 and S152:
[0106] Step S151: determining a first compression rate corresponding to a first quantization step size group in the quantization step size group sequence;
[0107] Here, the first compression rate is a compression rate corresponding to the compression process of the corresponding first transform coefficient using the first quantization step size group; each group of quantization step size groups corresponds to a first compression rate.
[0108] Step S152: when the first compression rate is greater than or equal to the target compression rate, determine the first quantization step size group as a target quantization step size group.
[0109] In some implementations, the quantization step size group sequence is traversed, and when there is a first quantization step size group corresponding to a first compression rate that is greater than or equal to the target compression rate, the first quantization step size group is determined as the target quantization step size group.
[0110] In the embodiment of the present disclosure, a first compression rate corresponding to a first quantization step group in a quantization step group sequence is determined; when the first compression rate is less than a target compression rate, the first quantization step group is determined as a target quantization step group. In this way, the compression rate after compression processing using the target quantization step group can meet the set target compression rate requirement.
[0111] The present disclosure provides an image compression method. Figure 2 A schematic diagram of an implementation process of an image compression method provided in an embodiment of the present disclosure Figure 2 ,like Figure 2 As shown, the method may include the following steps S201 to S206:
[0112] Step S201: Acquire a first image;
[0113] Step S202: transforming the first image from the spatial domain to the frequency domain to obtain first transformation coefficients corresponding to each pixel in the first image;
[0114] Step S203: based on the target compression rate, selecting a target quantization step group from a quantization step group sequence; the quantization step group sequence includes at least two quantization step groups;
[0115] Step S204: determining the target quantization step size corresponding to each pixel from the target quantization step size group based on the frequency level corresponding to each pixel;
[0116] Step S205: using the target quantization step size corresponding to each pixel, compressing the corresponding first transform coefficient to obtain first image compression data; the target quantization step size corresponding to each pixel is determined according to the frequency level corresponding to the pixel;
[0117] Step S206: When there is no target quantization step group in the quantization step group sequence, perform dithering compression encoding on the pixel value of each pixel in the first image to obtain second image compression data.
[0118] In some implementations, when the compression rates corresponding to all quantization step size groups in the quantization step size group sequence do not meet the target compression rate requirement, dithering compression coding is used.
[0119] The above step S206 may include the following steps S241 to S244:
[0120] Step S241: right-shifting a pixel value of a pixel in the first image by a first bit number to obtain a first compression value corresponding to the pixel; the first bit number is determined based on the target compression rate;
[0121] Here, the first number of bits is the number of bits required to right-shift pixels in the first image when a set target compression rate requirement is met.
[0122] Step S242: determining a first reference pixel value and a second reference pixel value corresponding to the pixel based on the first bit number and the first compression value corresponding to the pixel;
[0123] In some embodiments, the first reference pixel value is obtained by shifting the first compressed value corresponding to the pixel left by the first bit number, the second reference pixel value is obtained by shifting the second compressed value corresponding to the pixel left by the first bit number, and the second compressed value corresponding to the pixel is obtained by adding one to the first compressed value corresponding to the pixel.
[0124] In some embodiments, the first reference pixel value is a lower boundary value after the first image is restored, and the second reference pixel value is an upper boundary value after the first image is restored.
[0125] Step S243: determining a target compression value corresponding to the pixel based on the pixel value of the pixel and the first reference pixel value and the second reference pixel value corresponding to the pixel, wherein the target compression value is the first compression value or the second compression value corresponding to the pixel;
[0126] Here, the target compression value is the final result after compressing the first image.
[0127] In some embodiments, a jitter value corresponding to a pixel is found from a jitter code table through the coordinates of the pixel in the first image; the difference between the first reference pixel value and the second reference pixel value corresponding to the pixel is used as the jitter error coefficient, and the jitter median is calculated based on the jitter value and the jitter error coefficient; and the target compression value is determined by comparing the difference between the pixel value of the pixel and the first reference pixel value corresponding to the pixel and the size relationship of the jitter median.
[0128] Here, the jitter median is used to determine whether the pixel value of each pixel in the first image is closer to the upper boundary value or the lower boundary value; when the difference between the pixel value of the pixel and the lower boundary value is greater than the jitter median, it means that the pixel value of the pixel is closer to the upper boundary value; when the difference between the pixel value of the pixel and the lower boundary value is not greater than the jitter median, it means that the pixel value of the pixel is closer to the lower boundary value.
[0129] In some embodiments, when the difference between the pixel value of a pixel and the first reference pixel value corresponding to the pixel is greater than the jitter median, the second reference pixel value corresponding to the pixel is determined as the target compression value corresponding to the pixel; when the difference between the pixel value of the pixel and the first reference pixel value corresponding to the pixel is not greater than the jitter median, the first reference pixel value corresponding to the pixel is determined as the target compression value corresponding to the pixel.
[0130] Step S244: Determine second image compression data based on the target compression value corresponding to each pixel in the first image.
[0131] In the embodiment of the present disclosure, when there is no target quantization step table in the quantization step group sequence, the compression method corresponding to the second compression identifier is used for compression processing. In this way, when the first image is not suitable for compression processing by the compression method corresponding to the first compression identifier, the compression method corresponding to the second compression identifier is used for compression processing, taking into account the advantages of both compression methods.
[0132] In some embodiments, step S243 may include the following steps S211 to S213:
[0133] Step S211: determining a target reference value corresponding to the pixel based on a first difference between a first reference pixel value corresponding to the pixel and a second reference pixel value;
[0134] Here, the first difference is the jitter error coefficient, which represents the range between the upper boundary value and the lower boundary value; the target reference value is the jitter median, which serves as a criterion for selecting the target compression value.
[0135] Step S212: when the second difference value corresponding to the pixel is greater than the target reference value corresponding to the pixel, determining the second compression value corresponding to the pixel as the target compression value corresponding to the pixel, and the second difference value corresponding to the pixel is the difference between the pixel value of the pixel and the first reference pixel value corresponding to the pixel;
[0136] In some implementations, when the second difference value corresponding to a pixel is greater than the target reference value corresponding to the pixel, it indicates that the pixel is closer to the upper boundary value, and thus the target compression value corresponding to the pixel selects the second compression value.
[0137] Step S213: when the second difference value corresponding to the pixel is not greater than the target reference value corresponding to the pixel, determine the first compression value corresponding to the pixel as the target compression value corresponding to the pixel.
[0138] In some implementations, when the second difference value corresponding to the pixel is not greater than the target reference value corresponding to the pixel, it indicates that the pixel is closer to the lower boundary value, and thus the target compression value corresponding to the pixel selects the first compression value.
[0139] In some embodiments, step S211 may include the following steps S221 and S222:
[0140] Step S221: determining a jitter value corresponding to a pixel in the first image;
[0141] In some embodiments, when the first image is an image to be compressed, the jitter value corresponding to the pixel in the jitter code table is determined according to the coordinates of the pixel in the first image; in other embodiments, when the first image is an image block obtained by dividing the image to be compressed into a plurality of image blocks, the jitter value corresponding to the pixel in the jitter code table is determined according to the coordinates of the pixel in the first image and the coordinates of the first image in the image to be compressed.
[0142] Step S222: determining a target reference value corresponding to the pixel based on the jitter value corresponding to the pixel and the first difference value.
[0143] In some embodiments, in order to ensure accuracy, the jitter value corresponding to the pixel is shifted left by 1 bit, and the rightmost bit is made not 0 by means of OR 1; the jitter value corresponding to the pixel is shifted left by 1 bit and the result of OR 1 is multiplied by the first difference (i.e., the jitter error coefficient), and the result after the multiplication is shifted right by 5 bits to obtain the jitter median.
[0144] In some embodiments, the jitter median is used to compare with the difference between the pixel value of the pixel and the first reference pixel value corresponding to the pixel to determine the target compression value.
[0145] In some embodiments, the above method may further include the following steps S231 and S232:
[0146] Step S231: when there is a target quantization step group in the quantization step group sequence, writing a first compression identifier, the first image compression data, and a group identifier corresponding to the target quantization step group into a transmission data stream;
[0147] Here, the group identifier corresponding to the target quantization step size group represents the index of the target quantization step size group in the quantization step size group sequence.
[0148] In some embodiments, when there is a target quantization step group in the quantization step group sequence, exponential Golomb coding is used; the first compression identifier indicates the use of exponential Golomb coding; the first image compression data is image data after quantization using the target quantization step group and exponential Golomb coding of the quantized data.
[0149] In some embodiments, when there is a target quantization step group in the quantization step group sequence, Huffman coding is used; the first compression identifier indicates the use of Huffman coding; the first image compression data is image data after quantization using the target quantization step group and Huffman coding the quantized data.
[0150] In some implementations, the first compression identifier, the first image compression data, and the group identifier corresponding to the target quantization step size group are written into a transmission data stream, and the data is transmitted to a device that needs to be decompressed via the transmission data stream.
[0151] In some implementations, the first compression identifier, the first image compression data, and the group identifier corresponding to the target quantization step size group may be packaged into a data packet, and the data packet may be sent to a device that needs to be decompressed.
[0152] Step S232: When there is no target quantization step group in the quantization step group sequence, a second compression identifier, the second image compression data, and the first number of bits are written into the transmission data stream.
[0153] In some embodiments, when there is no target quantization step group in the quantization step group sequence, dithering compression coding is used; the second compression identifier indicates the use of dithering compression coding; the second image compression data indicates the image data compressed using the dithering compression coding method; the first number of bits is the number of bits required to right-shift the pixels of the first image to meet the set compression rate.
[0154] In some implementations, the second compression identifier, the second image compression data, and the first bit number are written into a transmission data stream, and the data is transmitted to a device that needs to be decompressed via the transmission data stream.
[0155] In some implementations, the second compression identifier, the second image compression data, and the first bit number may be packaged into a data packet, and the data packet may be sent to a device that needs to be decompressed.
[0156] The present disclosure provides an image decompression method. Figure 3 A schematic diagram of an implementation process of an image decompression method provided in an embodiment of the present disclosure Figure 1 ,like Figure 3 As shown, the method may include the following steps S301 to S303:
[0157] Step S301: obtaining first image compression data; the first image compression data includes compression values corresponding to each pixel in the first restored image to be restored;
[0158] In some implementations, when the first compression identifier is read from the transmission data stream, the first image compression data is obtained from the transmission data stream.
[0159] In some implementations, when the first compression identifier is read from the data packet, the first image compression data is obtained from the data packet.
[0160] Step S302: using the target quantization step size corresponding to each pixel, decompressing the corresponding compressed value to obtain the second transform coefficient corresponding to each pixel; the target quantization step size corresponding to each pixel is determined according to the frequency level corresponding to the pixel;
[0161] Here, the target quantization step size corresponding to each pixel is the target quantization step size when the first image is compressed;
[0162] In some implementations, decompressing each compressed value includes decoding each compressed value to obtain a second quantized value corresponding to each compressed value, and dequantizing each second quantized value to obtain a second transform coefficient.
[0163] Step S303: transform the second transformation coefficient corresponding to each pixel from the frequency domain to the spatial domain to obtain the first restored image.
[0164] In some implementations, the second transform coefficient corresponding to each compression value in the first image compression data is transformed from the frequency domain to the spatial domain to obtain a restored first restored image.
[0165] In some embodiments, transforming the second transform coefficients corresponding to each compression value in the first image compression data from the frequency domain to the spatial domain includes an inverse transform along the horizontal direction and / or the vertical direction. First, the second transform coefficients corresponding to each compression value in the first image compression data are inversely transformed along the vertical direction to obtain a second transformed image; then, each pixel in the second transformed image is inversely transformed along the horizontal direction to obtain a restored first restored image.
[0166] In the disclosed embodiment, the first image compression data is obtained; the corresponding compression value is decompressed using the target quantization step corresponding to each pixel in the first image compression data to obtain the second transformation coefficient corresponding to each pixel in the first image compression data; the target quantization step corresponding to each pixel is determined according to the frequency level corresponding to the pixel; the second transformation coefficient corresponding to each pixel is transformed from the frequency domain to the spatial domain to obtain a first restored image. In this way, on the one hand, different quantization steps can be determined for decompression processing according to the frequency level corresponding to each pixel, thereby improving the flexibility in the image decompression process; on the other hand, since the frequency level corresponding to each pixel is different, the target quantization step corresponding to each pixel is also different. In this way, the loss of high-frequency components in the decompression process can be reduced and the image fidelity can be improved, and the compression rate of low-frequency components in the image can be improved, thereby taking into account the overall compression rate and fidelity requirements of the image.
[0167] In some embodiments, the above step S302 may include the following steps S311 and S312:
[0168] Step S311: decoding the first image compression data to obtain a second quantized value corresponding to each pixel;
[0169] In some implementations, the first image compression data may be parsed according to Exponential Golomb to obtain a second quantized value corresponding to each pixel.
[0170] In some implementations, the first image compression data may be parsed according to Huffman coding to obtain a second quantized value corresponding to each pixel.
[0171] Step S312: Based on the target quantization step size corresponding to each of the pixels, dequantize the corresponding second quantization value to obtain a second transform coefficient corresponding to each of the pixels.
[0172] In some embodiments, the above method may further include the following steps S321 to S323:
[0173] Step S321: Obtaining a group identifier;
[0174] Here, the group identifier is the index of the target quantization step size group in the quantization step size group sequence.
[0175] In some implementations, the group identifier is obtained from the transmission data stream.
[0176] Step S322: determining a target quantization step size group from the quantization step size group sequence based on the group identifier;
[0177] In some implementations, the index of the target quantization step size group in the quantization step size group sequence is determined according to the group identifier, and the corresponding target quantization step size group is found from the quantization step size group sequence according to the index.
[0178] Step S323: based on the frequency level corresponding to each of the pixels, determine the target quantization step size corresponding to each of the pixels from the target quantization step size group.
[0179] In some embodiments, the first restored image has M rows, where M is greater than 3;
[0180] The frequency level corresponding to the pixels in the jth row in the first restored image is not lower than the frequency level corresponding to the pixels in the 1st row, the frequency level corresponding to the pixels in the M-1th row is higher than the frequency level corresponding to the pixels in the jth row, and the frequency level corresponding to the pixels in the Mth row is higher than the frequency level corresponding to the pixels in the jth row.
[0181] In some embodiments, the first restored image has N columns, where N is greater than 3;
[0182] The frequency level corresponding to the pixels in the i-th column in the first restored image is not lower than the frequency level corresponding to the pixels in the 1st column; the frequency level corresponding to the pixels in the N-1-th column is higher than the frequency level corresponding to the pixels in the i-th column, and the frequency level corresponding to the pixels in the N-th column is higher than the frequency level corresponding to the pixels in the i-th column.
[0183] In some embodiments, the above step S303 may include the following step S331:
[0184] Step S331: inversely transform the second transformation coefficient corresponding to each pixel along the horizontal direction and / or the vertical direction to obtain a first restored image.
[0185] In some implementations, the second transformation coefficient corresponding to each pixel is inversely transformed in the vertical direction to obtain a second transformation image; and the second transformation image is inversely transformed in the horizontal direction to obtain a first restored image.
[0186] In some embodiments, the second transformation coefficient corresponding to each pixel is the same size as the second transformation image, and both the first restored image and the second transformation image have M rows, where M is greater than 3;
[0187] The pixel values of the pixels in the 1st row of the second transformed image are equal to the second transform coefficients in the 1st row corresponding to the pixels in the 1st row, the pixel values of the pixels in the M-1th row of the second transformed image are determined based on the second transform coefficients in the M-1th row corresponding to the pixels in the M-1th row and the second transform coefficients in the 1st row corresponding to the pixels in the 1st row, the pixel values of the pixels in the Mth row of the second transformed image are determined based on the second transform coefficients in the Mth row corresponding to the pixel values in the Mth row and the second transform coefficients in the M-1th row corresponding to the pixels in the M-1th row, and the pixel values of the pixels in the jth row of the second transformed image are determined based on the second transform coefficients in the jth row corresponding to the pixels in the jth row and at least two reference transform coefficient rows corresponding to the second transform coefficients in the jth row corresponding to the pixels in the jth row, where j is greater than 1 and less than M-1.
[0188] In some embodiments, the first restored image and the second transformed image have the same size, and both the first restored image and the second transformed image have N columns, where N is greater than 3;
[0189] The pixel value of the 1st column of pixels in the first restored image is equal to the pixel value of the 1st column of pixels in the second transformed image; the pixel value of the N-1th column of pixels in the first restored image is determined based on the pixel value of the N-1th column of pixels in the second transformed image and the pixel value of the 1st column of pixels in the second transformed image; the pixel value of the Nth column of pixels in the first restored image is determined based on the pixel value of the Nth column of pixels in the second transformed image and the pixel value of the N-1th column of pixels in the second transformed image; the pixel value of the i-th column of pixels in the first restored image is determined based on the pixel value of the i-th column of pixels in the second transformed image and the pixel values of at least two reference pixel columns corresponding to the i-th column of pixels in the second transformed image, where i is greater than 1 and less than N-1.
[0190] In some embodiments, the above step S301 may include the following step S341:
[0191] Step S341: when a first compression identifier is read from a transmission data stream, the first image compression data is read from the transmission data stream.
[0192] In some implementations, the device that needs to decompress receives a transmission data stream, reads a compression identifier from the transmission data stream, and acquires first image compression data from the transmission data stream when the compression identifier is a first compression identifier.
[0193] In some implementations, the device that needs to decompress receives a data packet and reads a compression identifier from the data packet; when the compression identifier is a first compression identifier, the first image compression data is obtained from the data packet.
[0194] In some implementations, the first compression identifier indicates that the first image compression data is image data obtained by Exponential Golomb encoding.
[0195] In some implementations, the first compression identifier indicates that the first image compression data is image data obtained through Huffman coding.
[0196] In some embodiments, the above method may further include the following steps S351 and S352:
[0197] Step S351: when a second compression identifier is read from the transmission data stream, obtaining second image compression data and a first bit number;
[0198] In some embodiments, the second compression identifier indicates that the second image compression data is image data obtained using dither compression encoding; the first bit number is the number of bits required to right shift pixels in the first image in the encoding bit stream required to meet the set compression rate during image compression.
[0199] In some implementations, when the second compression identifier is read from the data packet, the second image compression data and the first bit number are obtained from the data packet.
[0200] Step S352: Shift each compression value in the second image compression data left by a first number of bits to obtain a second restored image.
[0201] The following describes the application of the image compression and image decompression methods provided by the embodiments of the present disclosure in actual scenarios, taking an image compression method that combines a subjective lossless compression method based on frequency domain segmented quantization and a compression method based on dither compression coding as an example.
[0202] Image bandwidth compression technology has always been an effective solution to reduce the communication bandwidth between IPs of hardware image processors. Image bandwidth compression can compress redundant information of two-dimensional or multi-dimensional images in the spatial domain, reduce the amount of image data in transmission, and reduce the bandwidth of hardware devices. Image bandwidth compression can solve the bandwidth problem, but it cannot reduce the image bandwidth in all scenarios. In addition, when designing hardware, the largest space needs to be opened up to store data. Therefore, lossless bandwidth compression technology cannot reduce the memory cost of the device.
[0203] In the field of images, a subjective visual lossless lossy compression solution can be used to solve the compression problem of maximum bandwidth and memory. Subjective visual losslessness means that after the image is compressed and decompressed through lossy compression technology, the human eye cannot distinguish the difference between the image before and after compression. This technology is often used in device display links.
[0204] Commonly used subjective visual lossless technologies include lossy compression with controllable line-level bit rate and lossy compression technology with intra-image block prediction residual quantization.
[0205] The lossy compression with controllable line-level code rate is to obtain the coding bit of the current pixel by subtracting the predicted value of the combination of the left and upper pixels, quantizing and entropy coding the residual (such as Huffman coding or arithmetic coding). A certain number of pixels are fixed in each row as coding units, and a quantization parameter is used in one coding unit. The code rate control part is to allocate the excess bits to the pre-allocated bits of the subsequent coding unit by comparing the difference between the bits used in the coding completion block and the pre-allocated bits, thereby reducing the quantization parameter of the subsequent coding unit. The quantization parameter is refreshed to the set value at the beginning of each row, so that each row can have a fixed compression rate. This compression method has two disadvantages: 1) It is necessary to cache the data of one row of pixels in a frame of image; 2) The minimum unit of code rate control is a row, which is only effective for the raster scanning output mode.
[0206] The method of intra-block prediction residual quantization is similar to the intra-frame prediction module of h264 / h265. The reference value of each pixel in the current image block is predicted by calculating the encoded pixels in the row above and the column to the left of the current image block. The interpolation of the reference value and the current pixel is calculated, the interpolation is DCT transformed, and quantized with a quantization coefficient. The compression rate of the coding block is controlled by the quantization coefficient. This compression method has the following disadvantages: it is necessary to cache the image data of the previous row, and at the same time, one quantization coefficient is used for one image block. The high-frequency signal corresponding to the detail texture and the low-frequency signal corresponding to the flat area are quantized at the same scale. It is impossible to take into account both high-frequency and low-frequency signals at the same time. After quantization, the high-frequency component may be severely damaged, resulting in problems in the reconstruction of the image detail texture, and may also cause low compression rate problems.
[0207] Therefore, the disclosed embodiment provides a subjective lossless compression method for images based on frequency domain segmented quantization, which splits the image block into high-frequency components and low-frequency components, and designs a quantization step table sequence corresponding to the high-frequency and low-frequency components; the low-frequency components are assigned a larger quantization step, and the high-frequency components are assigned a smaller quantization step. The quantization step table that meets the set compression rate requirement is selected from the quantization step table sequence, and each image block is compressed to obtain compressed image data.
[0208] Figure 4 The schematic diagram of the compression method flow of the image subjective lossless compression method based on frequency domain segmented quantization and the compression method based on dither compression coding is shown as follows: Figure 4 As shown, the specific steps may include step S401 to step S411:
[0209] Step S401: transforming the image block from the spatial domain to the frequency domain;
[0210] Transforming an image block from the spatial domain to the frequency domain includes horizontal transformation and vertical transformation.
[0211] First, the 4*4 image block is transformed into the frequency domain in the horizontal direction. Figure 5 It shows that the 4*4 image block is transformed into the frequency domain in the horizontal direction, such as Figure 5 As shown, the subscript of each column starts from 0, and the first pixel of each row of the image block is taken as the basic pixel without processing, that is, the first pixel of each row after horizontal transformation is equal to the first pixel of each row of the image block; the difference between the third pixel of each row of the image block and the first pixel of each row of the image block is taken as the third pixel of each row after horizontal transformation; the difference between the fourth pixel of each row of the image block and the third pixel of each row of the image block is taken as the fourth pixel of each row after horizontal transformation; the difference between the second pixel of each row of the image block and the average value (that is, pre) of the first pixel of each row of the image block and the third pixel of each row is taken as the second pixel of each row after horizontal transformation.
[0212] The data after horizontal transformation is transformed vertically to separate the high and low frequency components of the image block. Figure 6 It shows that the horizontally transformed pixels are transformed in the vertical frequency domain, such as Figure 6 As shown, the subscript of each row starts from 0, and the first pixel of each column after the horizontal transformation is used as the basic pixel without any processing, that is, the first transformation coefficient of each column after the vertical transformation is equal to the first pixel of each column after the horizontal transformation; the difference between the third pixel of each column after the horizontal transformation and the first pixel of each column after the horizontal transformation is used as the third transformation coefficient of each column after the vertical transformation; the difference between the fourth pixel of each column after the horizontal transformation and the third pixel of each column after the horizontal transformation is used as the fourth transformation coefficient of each column after the vertical transformation; the difference between the second pixel of each column after the horizontal transformation and the average value (that is, pre) of the first pixel of each column after the horizontal transformation and the third pixel of each column is used as the second transformation coefficient of each column after the vertical transformation.
[0213] Step S402: Select a set of quantization step length tables from the quantization step length table sequence to quantize the image block;
[0214] The quantization step table sequence is obtained through experiments and calculations: QpList[8][7] = {{0,0,0,0,0,0,0}{1,0,0,1,0,0,1}{2,1,0,2,1,1,2}{3,0,2,2,0,1,0}{4,2,3,1,1,2,1}{5,4,5,4,2,4,2}{6,5,6,5,4,4,5}{7,6,6,6,7,7,7}}.
[0215] In a set of quantization step tables, the image block position corresponding to each quantization step is as follows: Figure 7As shown in the figure, the frequency level corresponding to parts b, c, and d is higher than the frequency level corresponding to part a, and the quantization step selected for parts b, c, and d is smaller than the quantization step selected for part a; the frequency level corresponding to parts e, f, and g is higher than the frequency level corresponding to parts b, c, and d, and the quantization step selected for parts e, f, and g is smaller than the quantization step selected for parts b, c, and d. In the actual image compression process, the corresponding quantization step will be adjusted according to the image type. For example, when the image is a text data type, the frequency level corresponding to parts e, f, and g is higher than the frequency level corresponding to parts b, c, and d; when the image is a natural texture type, the frequency level corresponding to parts b, c, and d is higher than the frequency level corresponding to parts e, f, and g.
[0216] Quantization is performed based on the quantization step size corresponding to each pixel in the image block determined by the above process.
[0217] Step S403: performing exponential Golomb coding on the quantized value;
[0218] Step S404: whether the encoding code stream is smaller than the encoding code stream required by the set compression rate; if the encoding code stream is smaller than the encoding code stream required by the set compression rate, proceed to step S406; otherwise, proceed to step S405;
[0219] A set of quantization step length tables in the quantization step length table sequence is used for quantization, and the quantized value is subjected to exponential Golomb coding, and the coded bit stream corresponding to the quantization step length table after coding is calculated. If the coded bit stream is less than the coded bit stream required by the set compression rate, step S406 is entered; otherwise, step S405 is entered.
[0220] Step S405: whether the quantization step length table sequence has been traversed; if the quantization step length table sequence has been traversed, proceed to step S409; otherwise, proceed to step S402;
[0221] Step S406: writing 1 bit 0 into the bit stream as a compression flag, indicating that the quantization table compression mode is adopted;
[0222] Step S407: writing the index of the selected quantization step table into the bitstream;
[0223] The index corresponding to the group of quantization step length tables in the quantization step length table sequence is written into the bitstream.
[0224] Step S408: writing the quantized Exponential Columbus encoding result into the bitstream;
[0225] Quantization is performed using this set of quantization step tables, and exponential Golomb coding is performed based on the quantized image data; the encoded result is written into the bitstream.
[0226] Step S409: writing 1 bit 1 into the bit stream as a compression flag, indicating that the jitter compression mode is adopted;
[0227] Step S410: jitter compression coding;
[0228] The step of performing dithering compression encoding on the image block may include steps S451 to S455:
[0229] Step S451: design a dithering code table, and determine the dithering value corresponding to each pixel in the image block in the dithering code table;
[0230] Based on a large number of experiments and calculations, a 4x4 dither code table is designed: {{10, 2, 8, 0}, {6, 14, 4, 12}, {9, 1, 11, 3}, {5, 13, 7, 15}}. Calculate the coordinates of the current image block in the image (posx, posy), calculate the coordinates of the current pixel in the image block (x, y), then the dither coefficient corresponding to the current pixel is the dither value (dither_val) at the position ((posx+x)%4, (posy+y)%4) in the dither code table.
[0231] Step S452: Calculate the number of bits n required to right-shift each original pixel in order to achieve the required compression rate, and right-shift the image block by the number of bits n to obtain a compressed image block (low_prec);
[0232] Step S453: shift low_prec left by n bits to obtain the lower boundary value (mapped_back) of the restored image block, shift low_prec+1 left by n bits to obtain the upper boundary value (higher_bound) of the restored image block, and calculate the jitter error coefficient: range = higher_bound - mapped_back;
[0233] Step S454: Calculate the dither median (mid_dither_val) according to the dither value of each pixel in the image block and the dither error coefficient, referring to formula (1);
[0234] mid_dither_val=(((dither_val<<1)|1)*range)>>5 (1);
[0235] In formula (1), in order to ensure accuracy, the jitter value corresponding to the pixel is shifted left by 1 bit, and the rightmost bit is not 0 by means of OR 1.
[0236] Step S455: Calculate whether the difference between the current pixel and mapped_back is greater than the jitter median. If the difference between the current pixel and mapped_back is greater than the jitter median, the compressed value of the current pixel selects low_prec+1; otherwise, the compressed value of the current pixel selects low_prec.
[0237] Step S411: writing the compressed pixels into the code stream output pixel by pixel.
[0238] The process of decompressing the above compressed result is as follows.
[0239] Figure 8 FIG. 4 shows a schematic diagram of a process for decompressing compressed data, such as Figure 8 As shown, the specific steps may include step S801 to step S807:
[0240] Step S801: Read a 1-bit compression flag;
[0241] Read 1 bit from the code stream indicating the compression flag.
[0242] Step S802: whether the compression flag is 1;
[0243] Determine whether the read compression flag is 1. If the compression flag is 1, it indicates that the dithering compression encoding method is adopted, and the process goes to step S807 for decompression. If the compression flag is 0, it indicates that the quantization table compression mode is adopted, and the process goes to step S803 for decompression.
[0244] Step S803: determining a target quantization step length table in the quantization step length table sequence;
[0245] The serial number corresponding to the quantization step length table is read from the bit stream, and the corresponding target quantization step length table is found in the quantization step length table sequence.
[0246] Step S804: parsing all code streams of the current image block according to Exponential Columbus;
[0247] Step S805: Shift the result after the Exponential Golomb parsing to the left by the corresponding number of bits according to the target quantization step length table to obtain the transformed block data;
[0248] Step S806: performing high- and low-frequency inverse transformation on the transformed block data to obtain output image data;
[0249] Step S807: decompression corresponding to the jitter compression coding method.
[0250] Read the compressed image data from the bitstream, and calculate the number of bits n that each image pixel needs to shift right to meet the set compression rate. Shift the compressed image data left by the number of bits n to obtain the output decompressed image data.
[0251] In the disclosed embodiment, the image block is split into a high-frequency component and a low-frequency component, and a larger quantization step size is used for the low-frequency component; a smaller quantization step size is used for the high-frequency component. Under the premise of meeting the set compression rate, a target quantization step size table is selected from the quantization step size table sequence, and the image block is compressed according to the target quantization step size table. In this way, the high-frequency component can be effectively protected from being over-compressed, and the compression rate of the low-frequency component can be guaranteed. In the disclosed embodiment, when the target quantization step size table does not exist in the quantization step size table sequence, dithering compression coding is used. In this way, when the quantization table compression mode is not applicable to the image block, dithering compression coding can be used, while taking into account the advantages of the quantization table compression mode and dithering compression coding.
[0252] Based on the foregoing embodiments, the embodiments of the present disclosure provide an image compression and an image compression device, which includes the units included and the modules included in the units, which can be implemented by a processor in a computer device; of course, it can also be implemented by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor (MPU), a digital signal processor (DSP) or a field programmable gate array (FPGA), etc.
[0253] Fig. 9A A schematic diagram of the structure of an image compression device provided by an embodiment of the present disclosure is shown in FIG. Fig. 9A As shown, the image compression device 900 includes: a first acquisition module 901, a first transformation module 902 and a compression module 903, wherein:
[0254] A first acquisition module 901, configured to acquire a first image;
[0255] A first transformation module 902, configured to transform the first image from a spatial domain to a frequency domain, and obtain first transformation coefficients corresponding to each pixel in the first image;
[0256] The compression module 903 is used to compress the first transform coefficients corresponding to the pixels using the target quantization step corresponding to the pixels to obtain first image compression data; the target quantization step corresponding to the pixels is determined according to the frequency level corresponding to the pixels.
[0257] In some embodiments, the first transformation module includes: a frequency separation unit, configured to perform frequency separation processing on the first image along a horizontal direction and / or a vertical direction to obtain first transformation coefficients corresponding to each pixel in the first image.
[0258] In some embodiments, the frequency separation unit includes: a first frequency separation subunit, used to perform frequency separation processing on the first image along the horizontal direction to obtain a first transformed image; a second frequency separation subunit, used to perform frequency separation processing on the first transformed image along the vertical direction to obtain first transformation coefficients corresponding to each pixel in the first image.
[0259] In some embodiments, the compression module includes: a quantization unit, used to quantize the corresponding first transform coefficients based on the target quantization step corresponding to each pixel, to obtain first quantization values corresponding to each first transform coefficient; an encoding unit, used to encode each first quantization value to obtain first image compression data.
[0260] In some embodiments, the device also includes: a selection module, used to select a target quantization step group from a quantization step group sequence based on a target compression rate; the quantization step group sequence includes at least two quantization step groups; a first determination module, used to determine the target quantization step corresponding to each of the pixels from the target quantization step group based on the frequency level corresponding to each of the pixels.
[0261] In some embodiments, the selection module includes: a first determination unit, used to determine a first compression rate corresponding to a first quantization step group in the quantization step group sequence; the first compression rate is the compression rate after compressing each of the first transform coefficients using the first quantization step group; and a second determination unit, used to determine the first quantization step group as a target quantization step group when the first compression rate is greater than or equal to the target compression rate.
[0262] In some embodiments, the device further includes: an encoding module for performing dithering compression encoding on the pixel value of each pixel in the first image to obtain second image compressed data when the target quantization step group does not exist in the quantization step group sequence.
[0263] In some embodiments, the encoding module includes: a right shift unit, which is used to shift the pixel value of a pixel in the first image right by a first bit number when there is no target quantization step group in the quantization step group sequence, so as to obtain a first compression value corresponding to the pixel; the first bit number is determined based on a target encoding code stream; a third determination unit, which is used to determine a first reference pixel value and a second reference pixel value corresponding to the pixel based on the first bit number and the first compression value corresponding to the pixel; the first reference pixel value is obtained by shifting the first compression value corresponding to the pixel left by the first bit number, the second reference pixel value is obtained by shifting the second compression value corresponding to the pixel left by the first bit number, and the second compression value corresponding to the pixel is obtained by adding one to the first compression value corresponding to the pixel; a fourth determination unit, which is used to determine a target compression value corresponding to the pixel based on the pixel value of the pixel, and the first reference pixel value and the second reference pixel value corresponding to the pixel, the target compression value being the first compression value or the second compression value corresponding to the pixel; a fifth determination unit, which is used to determine the second image compression data based on the target compression value corresponding to each pixel in the first image.
[0264] In some embodiments, the fifth determination unit includes: a first determination subunit, used to determine the target reference value corresponding to the pixel based on a first difference between the first reference pixel value and the second reference pixel value corresponding to the pixel; a second determination subunit, used to determine the second compression value corresponding to the pixel as the target compression value corresponding to the pixel when the second difference corresponding to the pixel is greater than the target reference value corresponding to the pixel, and the second difference corresponding to the pixel is the difference between the pixel value of the pixel and the first reference pixel value corresponding to the pixel; and a third determination subunit, used to determine the first compression value corresponding to the pixel as the target compression value corresponding to the pixel when the second difference corresponding to the pixel is not greater than the target reference value corresponding to the pixel.
[0265] In some embodiments, the first determining subunit is used to: determine a jitter value corresponding to a pixel in the first image; and determine a target reference value corresponding to the pixel based on the jitter value corresponding to the pixel and the first difference.
[0266] In some embodiments, the encoding module also includes: a first writing unit, used to write a first compression identifier, the first image compression data, and a group identifier corresponding to the target quantization step group in the transmission data stream when there is a target quantization step group in the quantization step group sequence; a second writing unit, used to write a second compression identifier, the second image compression data, and the first number of bits in the transmission data stream when there is no target quantization step group in the quantization step group sequence.
[0267] Fig. 9B A schematic diagram of the structure of an image decompression device provided by an embodiment of the present disclosure is shown in FIG. Fig. 9B As shown, the image decompression device 910 includes: a second acquisition module 911, a decompression module 912 and a second transformation module 913, wherein:.
[0268] The second acquisition module 911 is used to acquire first image compression data; the first image compression data includes a compression value corresponding to each pixel in the first restored image to be restored;
[0269] A decompression module 912 is used to decompress the corresponding compressed value using the target quantization step size corresponding to each pixel to obtain a second transform coefficient corresponding to each pixel; the target quantization step size corresponding to each pixel is determined according to the frequency level corresponding to the pixel;
[0270] The second transformation module 913 is used to transform the second transformation coefficient corresponding to each pixel from the frequency domain to the space domain to obtain the first restored image.
[0271] In some embodiments, the decompression module includes: a decoding unit, used to decode the first image compression data to obtain a second quantization value corresponding to each pixel; and an inverse quantization unit, used to inverse quantize the corresponding second quantization value based on a target quantization step size corresponding to each pixel to obtain a second transform coefficient corresponding to each pixel.
[0272] In some embodiments, the device also includes: a third acquisition module for acquiring a group identifier; a fifth determination module for determining a target quantization step group from a quantization step group sequence based on the group identifier; and a sixth determination module for determining a target quantization step corresponding to each pixel from the target quantization step group based on a frequency level corresponding to each pixel.
[0273] In some embodiments, the second transformation module includes: an inverse transformation unit, configured to inversely transform the second transformation coefficient corresponding to each of the pixels along a horizontal direction and / or a vertical direction to obtain a first restored image.
[0274] In some embodiments, the second acquisition module includes: a reading unit, configured to read the first image compression data from the transmission data stream when a first compression identifier is read from the transmission data stream.
[0275] In some embodiments, the second acquisition module also includes: an acquisition unit, used to acquire second image compression data and a first bit number when a second compression identifier is read from the transmission data stream; a left shift unit, used to left-shift each compression value in the second image compression data by a first bit number to obtain a second restored image.
[0276] The description of the above device embodiment is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. In some embodiments, the functions or modules included in the device provided in the embodiments of the present disclosure can be used to execute the method described in the above method embodiment. For technical details not disclosed in the device embodiment of the present disclosure, please refer to the description of the method embodiment of the present disclosure for understanding.
[0277] It should be noted that in the embodiments of the present disclosure, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present disclosure is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk. In this way, the embodiments of the present disclosure are not limited to any specific hardware, software or firmware, or any combination of hardware, software, and firmware.
[0278] An embodiment of the present disclosure provides a computer device, including a memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the program, some or all of the steps in the above method are implemented.
[0279] The embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, some or all of the steps in the above method are implemented. The computer-readable storage medium can be transient or non-transient.
[0280] An embodiment of the present disclosure provides a computer program, including a computer-readable code. When the computer-readable code is executed in a computer device, a processor in the computer device executes some or all of the steps for implementing the above method.
[0281] The present disclosure provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, some or all of the steps in the above method are implemented. The computer program product can be implemented specifically by hardware, software or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium, and in other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.
[0282] It should be noted here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can be referenced to each other. The description of the above device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment. For technical details not disclosed in the embodiments of the device, storage medium, computer program and computer program product disclosed in the present invention, please refer to the description of the method embodiment disclosed in the present invention for understanding.
[0283] It should be noted that Fig.10 is a schematic diagram of a hardware entity of a computer device in an embodiment of the present disclosure, such as Fig.10 As shown, the hardware entity of the computer device 1000 includes: a processor 1001, a communication interface 1002 and a memory 1003, wherein:
[0284] Processor 1001 generally controls the overall operation of computer device 1000 .
[0285] The communication interface 1002 enables the computer device to communicate with other terminals or servers through a network.
[0286] The memory 1003 is configured to store instructions and applications executable by the processor 1001, and can also cache data to be processed or processed by the processor 1001 and various modules in the computer device 1000 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented by flash memory (FLASH) or random access memory (Random Access Memory, RAM). Data transmission can be performed between the processor 1001, the communication interface 1002, and the memory 1003 through the bus 1004.
[0287] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present disclosure. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in the various embodiments of the present disclosure, the size of the serial numbers of the above-mentioned steps / processes does not mean the order of execution. The execution order of each step / process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure. The serial numbers of the embodiments of the present disclosure are for description only and do not represent the advantages and disadvantages of the embodiments.
[0288] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0289] In the several embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.
[0290] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, the functional units in the various embodiments of the present disclosure may all be integrated into one processing unit, or each unit may be separately used as a unit, or two or more units may be integrated into one unit; the above integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0291] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: mobile storage devices, read-only memories (ROM), magnetic disks or optical disks, etc., various media that can store program codes.
[0292] Alternatively, if the above-mentioned integrated unit of the present disclosure is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure can essentially or in other words, the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0293] The above description is only an implementation mode of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed in the present disclosure should be included in the protection scope of the present disclosure.
Claims
1. An image compression method, characterized in that: The method comprises: acquiring a first image; Transform the first image from the spatial domain to the frequency domain to obtain first transformation coefficients corresponding to each pixel in the first image; The first transform coefficients corresponding to the pixels are compressed using the target quantization step sizes corresponding to the pixels to obtain first image compression data; the target quantization step sizes corresponding to the pixels are determined according to the frequency levels corresponding to the pixels.
2. The method according to claim 1, characterized in that The step of transforming the first image from the spatial domain to the frequency domain to obtain first transform coefficients corresponding to each pixel in the first image includes: The first image is subjected to frequency separation processing in a horizontal direction and / or a vertical direction to obtain first transformation coefficients corresponding to each pixel in the first image.
3. The method according to claim 2, characterized in that The step of performing frequency separation processing on the first image along a horizontal direction and / or a vertical direction to obtain first transform coefficients corresponding to respective pixels in the first image includes: Performing frequency separation processing on the first image along the horizontal direction to obtain a first transformed image; The first transformed image is subjected to frequency separation processing in a vertical direction to obtain first transform coefficients corresponding to each pixel in the first image.
4. The method according to claim 3, characterized in that The first image and the first transformed image have the same size, and both the first image and the first transformed image have N columns, where N is greater than 3; The pixel value of the 1st column of pixels in the first transformed image is equal to the pixel value of the 1st column of pixels in the first image, the pixel value of the N-1th column of pixels in the first transformed image is determined based on the pixel value of the N-1th column of pixels in the first image and the pixel value of the 1st column of pixels in the first image, the pixel value of the Nth column of pixels in the first transformed image is determined based on the pixel value of the Nth column of pixels in the first image and the pixel value of the N-1th column of pixels in the first image, and the pixel value of the i-th column of pixels in the first transformed image is determined based on the pixel value of the i-th column of pixels in the first image and the pixel values of at least two reference pixel columns corresponding to the i-th column of pixels in the first image, where i is greater than 1 and less than N-1.
5. The method according to claim 4, characterized in that The frequency level corresponding to the pixels in the i-th column is not lower than the frequency level corresponding to the pixels in the 1st column; the frequency level corresponding to the pixels in the N-1th column is higher than the frequency level corresponding to the pixels in the i-th column, and the frequency level corresponding to the pixels in the N-1th column is higher than the frequency level corresponding to the pixels in the i-th column.
6. The method according to claim 3, characterized in that The first image and the first transformed image have the same size, and both the first image and the first transformed image have M rows, where M is greater than 3; The first transformation coefficients of the first row corresponding to the first row of pixels in the first image are equal to the pixel values of the first row of pixels in the first transformation image, the first transformation coefficients of the M-1th row corresponding to the M-1th row of pixels in the first image are determined based on the pixel values of the M-1th row of pixels in the first transformation image and the pixel values of the first row of pixels in the first transformation image, the first transformation coefficients of the Mth row corresponding to the Mth row of pixels in the first image are determined based on the pixel values of the Mth row of pixels in the first transformation image and the pixel values of the M-1th row of pixels in the first transformation image, the first transformation coefficients of the jth row corresponding to the jth row of pixels in the first image are determined based on the pixel values of the jth row of pixels in the first transformation image and the pixel values of at least two reference pixel rows corresponding to the jth row of pixels in the first transformation image, where j is greater than 1 and less than M-1.
7. The method according to claim 6, characterized in that The frequency level corresponding to the j-th row of pixels is not lower than the frequency level corresponding to the 1-th row of pixels, the frequency level corresponding to the M-1-th row of pixels is higher than the frequency level corresponding to the j-th row of pixels, and the frequency level corresponding to the M-th row of pixels is higher than the frequency level corresponding to the j-th row of pixels.
8. The method according to claim 1, characterized in that The compressing the corresponding first transform coefficients by using the target quantization step sizes corresponding to the pixels to obtain first image compression data includes: quantizing the first transform coefficients based on the target quantization step sizes corresponding to the pixels to obtain first quantization values corresponding to the first transform coefficients; Each of the first quantized values is encoded to obtain first image compression data.
9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: Based on the target compression rate, selecting a target quantization step group from a quantization step group sequence; the quantization step group sequence includes at least two quantization step groups; Based on the frequency level corresponding to each of the pixels, the target quantization step size corresponding to each of the pixels is determined from the target quantization step size group.
10. The method according to claim 9, characterized in that The step of selecting a target quantization step size group from a quantization step size group sequence based on a target compression rate comprises: Determine a first compression rate corresponding to a first quantization step group in the quantization step group sequence; the first compression rate is a compression rate after compressing each of the first transform coefficients using the first quantization step group; When the first compression rate is greater than or equal to the target compression rate, the first quantization step size group is determined as a target quantization step size group.
11. The method according to claim 9, characterized in that The method further comprises: In the case that the target quantization step size group does not exist in the quantization step size group sequence, dithering compression encoding is performed on the pixel value of each pixel in the first image to obtain second image compression data.
12. The method according to claim 11, characterized in that The step of performing dithering compression encoding on the pixel value of each pixel in the first image to obtain second image compressed data includes: Shifting a pixel value of a pixel in the first image rightward by a first bit number to obtain a first compressed value corresponding to the pixel; the first bit number is determined based on the target compression rate; Determine a first reference pixel value and a second reference pixel value corresponding to the pixel based on the first number of bits and a first compression value corresponding to the pixel; Determine a target compression value corresponding to the pixel based on the pixel value of the pixel and the first reference pixel value and the second reference pixel value corresponding to the pixel, wherein the target compression value is the first compression value or the second compression value corresponding to the pixel; The second image compression data is determined based on the target compression value corresponding to each pixel in the first image.
13. The method according to claim 12, characterized in that The first reference pixel value is obtained by shifting the first compressed value corresponding to the pixel left by the first bit number, the second reference pixel value is obtained by shifting the second compressed value corresponding to the pixel left by the first bit number, and the second compressed value corresponding to the pixel is obtained by adding one to the first compressed value corresponding to the pixel.
14. The method according to claim 12, characterized in that The determining, based on the pixel value of the pixel and the first reference pixel value and the second reference pixel value corresponding to the pixel, a target compression value corresponding to the pixel comprises: Determining a target reference value corresponding to the pixel based on a first difference between a first reference pixel value and a second reference pixel value corresponding to the pixel; In a case where the second difference value corresponding to the pixel is greater than the target reference value corresponding to the pixel, determining the second compression value corresponding to the pixel as the target compression value corresponding to the pixel, and the second difference value corresponding to the pixel is the difference between the pixel value of the pixel and the first reference pixel value corresponding to the pixel; In a case where the second difference value corresponding to the pixel is not greater than the target reference value corresponding to the pixel, the first compression value corresponding to the pixel is determined as the target compression value corresponding to the pixel.
15. The method according to claim 14, characterized in that The determining, based on a first difference between a first reference pixel value and a second reference pixel value corresponding to the pixel, a target reference value corresponding to the pixel comprises: Determining a jitter value corresponding to a pixel in the first image; Based on the jitter value corresponding to the pixel and the first difference value, a target reference value corresponding to the pixel is determined.
16. The method according to claim 12, characterized in that The method further comprises: When a target quantization step size group exists in the quantization step size group sequence, writing a first compression identifier, the first image compression data, and a group identifier corresponding to the target quantization step size group into a transmission data stream; When there is no target quantization step group in the quantization step group sequence, a second compression identifier, the second image compression data, and the first number of bits are written into the transmission data stream.
17. An image decompression method, characterized in that: The method comprises: Acquire first image compression data; the first image compression data includes compression values corresponding to each pixel in the first restored image to be restored; Decompressing the corresponding compressed value using the target quantization step size corresponding to each pixel to obtain a second transform coefficient corresponding to each pixel; the target quantization step size corresponding to each pixel is determined according to the frequency level corresponding to the pixel; The second transformation coefficient corresponding to each of the pixels is transformed from the frequency domain to the spatial domain to obtain the first restored image.
18. The method according to claim 17, characterized in that The decompressing the corresponding compressed value by using the target quantization step size corresponding to each pixel to obtain the second transform coefficient corresponding to each pixel includes: Decoding the first image compression data to obtain a second quantized value corresponding to each pixel; Based on the target quantization step size corresponding to each of the pixels, the corresponding second quantization value is dequantized to obtain the second transform coefficient corresponding to each of the pixels.
19. The method according to claim 17, characterized in that The method further comprises: Get the group ID; Based on the group identifier, determining a target quantization step size group from a quantization step size group sequence; Based on the frequency level corresponding to each of the pixels, a target quantization step size corresponding to each of the pixels is determined from the target quantization step size group.
20. The method according to claim 17, characterized in that The step of transforming the second transform coefficients corresponding to each pixel bit from the frequency domain to the spatial domain to obtain a first restored image includes: The second transformation coefficient corresponding to each pixel is inversely transformed along the horizontal direction and / or the vertical direction to obtain a first restored image.
21. The method according to claim 17, characterized in that The obtaining of the first image compression data comprises: When the first compression identifier is read from the transmission data stream, the first image compression data is read from the transmission data stream.
22. The method according to claim 21, characterized in that The method further comprises: When a second compression identifier is read from the transmission data stream, obtaining second image compression data and a first bit number; Each compression value in the second image compression data is shifted left by a first bit number to obtain a second restored image.
23. An image compression device, characterized in that: include: A first acquisition module, used for acquiring a first image; A first transformation module, used to transform the first image from a spatial domain to a frequency domain, and obtain first transformation coefficients corresponding to each pixel in the first image; A compression module, configured to compress the first transform coefficients corresponding to the pixels using the target quantization step sizes corresponding to the pixels, to obtain first image compression data; The target quantization step size corresponding to each of the pixels is determined according to the frequency level corresponding to the pixel.
24. An image decompression device, characterized in that: include: A second acquisition module, used for acquiring first image compression data; The first image compression data includes a compression value corresponding to each pixel in the first restored image to be restored; A decompression module, configured to decompress the corresponding compressed value using the target quantization step size corresponding to each pixel, so as to obtain a second transform coefficient corresponding to each pixel; the target quantization step size corresponding to each pixel is determined according to the frequency level corresponding to the pixel; The second transformation module is used to transform the second transformation coefficient corresponding to each pixel from the frequency domain to the space domain to obtain the first restored image.
25. A computer device comprising a memory and a processor, wherein the memory stores a computer program executable on the processor, wherein: When the processor executes the program, the steps in the method according to any one of claims 1 to 22 are implemented.
26. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 22 are implemented.
27. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the steps in the method according to any one of claims 1 to 22 are implemented.
Citation Information
Patent Citations
Image noise reduction method and device and computer readable storage medium
CN111429383A
Method for compression quantization and anti-quantization of video-frequency data
CN1816145A
Device and method for image processing
JP2001145105A
Image processing apparatus, image processing method, and recording medium recorded with image processing method
JP2004112712A
Control device, control method, encoder, and program
JP2008061122A
