An image compression method and apparatus
By performing adaptive quantization processing on image blocks, the problem that cannot meet the visual needs of different image areas in JPEG compression technology is solved, and more efficient image compression effect is achieved and storage space occupation is reduced.
Patent Information
- Application Number
- CN202080105452.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-29
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2040-09-29
AI Technical Summary
The existing JPEG compression technology cannot meet the different visual needs of users for different image areas in different scenarios, resulting in a fixed compression rate and the inability to effectively reduce the storage space occupation.
By performing the first transformation of the image block to obtain a frequency domain coefficient set, performing a second quantization operation to remove high-frequency components and maintain or reduce the amplitude of the low-frequency components. Adaptive quantization is performed in combination with the characteristic values of the image block and the quantization matrix, so that different image blocks are quantized by different quantization steps.
It realizes that the size of the encoded JPEG format image is adjusted according to actual needs, to meet the visual needs of different scenarios, and at the same time, while ensuring the quality of the area of interest, the code rate of other areas is reduced, and the compression rate is further improved.
Smart Images

Figure CN116325752B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image processing, and in particular, to an image compression method and apparatus. Background Art
[0002] The Joint Photographic Expert Group (JPEG), as an image compression standard, has become the mainstream compression format for image storage and transmission and is widely used due to its simple implementation and wide compatibility.
[0003] During the JPEG compression process, a frame of image is first divided into a series of 16×16 image blocks, and each 16×16 image block is further divided into 4 8×8 image blocks. Then, for each 8×8 image block, the JPEG compression process shown in Figure 1 is used for compression.
[0004] Each luminance component and chrominance component in an 8×8 image block is respectively compressed through the process shown in Figure 1 to complete the compression of this 8×8 image block. As shown in Figure 1 , a component (luminance or chrominance) of an 8×8 image block first undergoes a discrete cosine transform (DCT) to transform the spatial data block into a frequency domain representation as an 8×8 DCT coefficient. In the frequency domain, different frequency components contained in the spatial data block are separated to obtain the direct current component (DC) in the upper left corner and the alternating current components (AC) in other positions of the DCT coefficient. Then, according to an externally input 8×8 quantization matrix, the DCT coefficients are divided by the element values at the corresponding positions in the quantization matrix (referred to as the quantization step) for quantization, and the quantized values are truncated or rounded to the nearest integer. By quantization, the amount of data in the frequency domain DCT coefficients is reduced to achieve the purpose of compression. Usually, according to the characteristic that the human eye is insensitive to high-frequency coefficients, as the frequency increases, the quantization step is gradually increased in the quantization matrix from low to high frequencies to achieve a better compression ratio. Finally, entropy coding is performed on the quantized data to obtain compressed data.
[0005] The core link of JPEG compression is the quantization process, but all image blocks in a frame of image can only be quantized according to the same set of quantization matrices (the same components of different image blocks can only be quantized according to the same quantization matrix), and the compression rate is fixed. Therefore, it cannot meet the different visual requirements of users for different image regions in an image. At the same time, the compression data obtained by the current compression scheme has a high bit rate and occupies a large storage space. Summary of the Invention
[0006] The embodiments of the present application provide an image compression method and apparatus, which can achieve quantization of different image blocks in a frame of image according to different quantization step sizes, and can meet different visual requirements of users for different image regions in different scenarios; for regions that are visually insensitive or not concerned by users, a larger quantization step size can be adopted to further improve the compression ratio, reduce the bit rate, and reduce the storage space of the picture.
[0007] To achieve the above object, the embodiments of the present application adopt the following technical solutions:
[0008] In a first aspect, an image compression method is provided, which may include: performing a first transformation on an image block in an image to be compressed to obtain a set of frequency domain coefficients of the image block; the image block is a continuous region including a plurality of pixel points in the image to be compressed; performing a second quantization operation on the set of frequency domain coefficients to obtain a set of second quantization coefficients; the second quantization operation is used to remove high-frequency components in the set of frequency domain coefficients and maintain or reduce the amplitude of low-frequency components in the set of frequency domain coefficients; the number of high-frequency components removed by the second quantization operation is related to the image block; the number of high-frequency components removed by the second quantization operation is greater than or equal to the number of high-frequency components removed by a first quantization operation based on a first quantization matrix; performing a first quantization operation on the set of second quantization coefficients based on the first quantization matrix to obtain a set of first quantization coefficients; performing entropy coding on the set of first quantization coefficients to obtain compressed data of the image block.
[0009] Through the image compression method provided by the embodiments of the present application, a set of frequency coefficients of a data block is first subjected to a second quantization operation related to the image block to remove high-frequency components and maintain or reduce the amplitude of low-frequency components, then a first quantization operation is performed based on the configured first quantization matrix, and then entropy coding is performed to complete the compression. In this way, the quantization related to different image blocks is different, and different image blocks in a frame of image can be quantized according to different quantization step sizes, which can meet different visual requirements of users for different image regions in different scenarios; the size of the encoded JPEG format image can be adjusted according to actual needs; at the same time, under the premise of meeting the JPEG standard, flexible coding can be performed on the region of interest, while ensuring the quality of the region of interest, reducing the bit rate consumed by other regions, thereby saving the bit rate (storage space) and further improving the compression ratio.
[0010] In a possible implementation, a second quantization operation is performed on the frequency-domain coefficient set to obtain a second quantization coefficient set, including: obtaining a region of interest (ROI) in the image to be compressed; if an image block is in the ROI of the image to be compressed, retaining the first N1 elements arranged in ZigZag order in the frequency-domain coefficient set of the image block and setting the remaining elements to zero to obtain the second quantization coefficient set of the image block; if an image block is in a non-ROI of the image to be compressed, retaining the first N2 elements arranged in ZigZag order in the frequency-domain coefficient set and setting the remaining elements to zero to obtain the second quantization coefficient set of the image block. N1 is greater than N2. By performing the second quantization operation through this implementation, the implementation process is simple, the computational complexity is low, and costs are saved.
[0011] In another possible implementation, N1 is 63 and N2 is 32.
[0012] In a possible implementation, the image compression method provided in this application may further include: obtaining an eigenvalue of an image block, where the eigenvalue is used to indicate any one of the following characteristics of the image block: spatial domain characteristic, frequency domain characteristic, or texture characteristic. Performing a second quantization operation on the frequency-domain coefficient set to obtain a second quantization coefficient set may include: determining a second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block, and performing a third operation on the frequency coefficient set based on the second quantization matrix to obtain the second quantization coefficient set of the image block.
[0013] Among them, the eigenvalue of the image block is used to reflect the complexity of the image block for the visual system. The higher the eigenvalue, the more complex and less sensitive the image block is for the visual system, and a larger quantization step can be used for quantization. In this implementation, after determining the first quantization matrix according to the quantization information of the first quantization matrix of the image block, the second quantization matrix of the image block is determined in combination with the eigenvalue of the image block, so that the determined second quantization matrix is related to the characteristics of the image block, and further the second quantization operation is related to the characteristics of the image block. In this way, the second quantization matrices of the same component set of image blocks with different characteristics are also different, and different image blocks in a frame of image can be quantized according to different quantization steps through the second quantization operation.
[0014] The first quantization matrix is the quantization matrix for performing the first quantization operation. The first quantization matrices of the same component set of different image blocks in a frame of image are the same. The quantization information of the first quantization matrix is used to uniquely determine the first quantization matrix. The quantization information of the first quantization matrix may be the first quantization matrix itself, or the quantization information of the first quantization matrix may be the quality factor for determining the first quantization matrix, and the first quantization matrix can be calculated according to the quality factor and the first relationship expression. The first relationship expression is the relationship expression between the quality factor and the standard quantization matrix QM S of.
[0015] Among them, the first relational expression satisfies the following relationship: QM qf = floor(S × QM s + 50).
[0016] QM qf is the calculated quantization matrix, floor(·) is the rounding operation, and S satisfies the following expression:
[0017]
[0018] In a possible implementation, the third operation may be to perform the first quantization operation and the inverse quantization operation of the first quantization operation successively.
[0019] In another possible implementation, the third operation may include comparing the elements in the frequency domain coefficient set of the image block with the elements at the corresponding positions in the second quantization matrix of the image block, and determining the second quantization coefficient set of the image block based on a preset rule. Among them, the preset rule may include: when the element at the first position in the frequency domain coefficient set is greater than the element at the first position in the second quantization matrix, retain the element at the first position in the frequency domain coefficient set; the first position is any position in the frequency domain coefficient set; when the element at the first position in the frequency domain coefficient set is less than the element at the first position in the second quantization matrix, set the element at the first position in the frequency domain coefficient set to zero; when the element at the first position in the frequency domain coefficient set is equal to the element at the first position in the second quantization matrix, retain or set the element at the first position in the frequency domain coefficient set to zero.
[0020] In another possible implementation, the image compression method provided in this application may further include: obtaining the eigenvalue of the image block, where the eigenvalue is used to indicate any one of the following characteristics of the image block: spatial domain characteristic, frequency domain characteristic, or texture characteristic. Performing a second quantization operation on the frequency domain coefficient set to obtain a second quantization coefficient set may include: determining the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block, and successively performing the first quantization operation and the inverse quantization operation of the first quantization operation on the frequency domain coefficient set of the image block based on the second quantization matrix of the image block to obtain the second quantization coefficient set of the image block.
[0021] In this implementation, by using the determined second quantization matrix related to the image block, the high-frequency components in the frequency domain coefficient set are removed, and the amplitude of the low-frequency components in the frequency domain coefficient set is maintained or reduced. By performing the first quantization operation with the determined second quantization matrix related to the image block, the high-frequency components in the frequency domain coefficient set are removed, and by performing the inverse quantization operation on the result after the first quantization operation, the amplitude of the low-frequency components in the frequency domain coefficient set is maintained or reduced, realizing compatibility with the JPEG compression standard.
[0022] In another possible implementation, the image compression method provided by this application may further include: obtaining the eigenvalue of an image block, where the eigenvalue is used to indicate any one of the following features of the image block: spatial domain feature, frequency domain feature, or texture feature. Performing a second quantization operation on the frequency domain coefficient set to obtain a second quantization coefficient set, which can be specifically implemented as: determining the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block; comparing the elements in the frequency domain coefficient set of the image block with the elements at the corresponding positions of the elements in the second quantization matrix of the image block, and determining the second quantization coefficient set of the image block based on a preset rule. Wherein, the preset rule may include: when the element at the first position in the frequency domain coefficient set is greater than the element at the first position in the second quantization matrix, retaining the element at the first position in the frequency domain coefficient set; the first position is any position in the frequency domain coefficient set; when the element at the first position in the frequency domain coefficient set is less than the element at the first position in the second quantization matrix, setting the element at the first position in the frequency domain coefficient set to zero; when the element at the first position in the frequency domain coefficient set is equal to the element at the first position in the second quantization matrix, retaining or setting the element at the first position in the frequency domain coefficient set to zero.
[0023] By replacing the first quantization operation and the inverse quantization operation with a comparison operation, multiplication and division operations are avoided, and the implementation cost of the hardware logic is reduced.
[0024] In another possible implementation, determining the second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue includes: determining QM2 according to the relationship between the second quantization matrix QM2, the first quantization matrix QM1, and the eigenvalue X. Wherein, the relationship between QM2, QM1, and the eigenvalue X satisfies the following expression: QM2 = QM1 + F1(X). Wherein, F1(·) is a first preset function.
[0025] In this implementation, the expression for determining the second quantization matrix can be configured according to actual experience, so that the determined quantization matrix can better reflect the characteristics of the image block, and then a second quantization operation matching the characteristics of the image block is realized, achieving the purpose of taking into account the visual experience, user experience, and image compression ratio during the image compression process.
[0026] In another possible implementation, the quantization information of the first quantization matrix may include a first quality factor QF1 for determining the first quantization matrix, and QF1 is used to calculate the first quantization matrix according to the first relational expression. Wherein, the first relational expression is the relationship between the quality factor and the standard quantization matrix QM SThe relational expression. Correspondingly, according to the quantization information of the first quantization matrix and the eigenvalue, the second quantization matrix of the image block is determined. Specifically, it can be implemented as follows: according to the eigenvalue X, the quality factor offset value ΔQF is determined; according to ΔQF and QF1, the second quality factor QF2 is calculated; according to QF2 and the first relational expression, the second quantization matrix is determined. Wherein, ΔQF satisfies the following expression: ΔQF = F2(X); F2(·) is the second preset function; QF2 satisfies the following expression: QF2 = |QF1| - F3(ΔQF), and F3(·) is the third preset function.
[0027] In the scenario of determining the quantization matrix through the quality factor, according to actual experience, the expression for determining the second quality factor is configured, and then the second quantization matrix is determined according to the second quality factor, so that the determined quantization matrix can better reflect the characteristics of the image block, and then the second quantization operation matching the characteristics of the image block is realized, achieving the purpose of taking into account the visual experience, user experience and image compression ratio during the image compression process.
[0028] In another possible implementation manner, the eigenvalue can be used to indicate the texture feature of the image block, and the eigenvalue X can be calculated according to the expression of the eigenvalue X and the pixel values in the image block. Wherein, the expression of the eigenvalue X and the pixel values in the image block satisfies the following relationship:
[0029]
[0030] Wherein, Pix i is the pixel value of the i-th pixel point in the image block to be processed, M is the width of the image block, and L is the height of the image block.
[0031] In another possible implementation manner, the image compression method provided by the present application may further include: obtaining the ROI in the image to be compressed; if the image block is outside the ROI, obtaining the eigenvalue of the image block and determining the second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue. Or, if the image block is within the ROI, the frequency domain coefficient set is subjected to the first quantization operation based on the first quantization matrix to obtain the first quantization coefficient set, and the first quantization coefficient set is subjected to entropy coding to obtain the compressed data of the image block.
[0032] Quantize the image blocks in the non-ROI area twice to increase the quantization step size, improve the compression ratio, and reduce the storage space. Quantize the image blocks in the ROI area according to the JPEG compression protocol, and flexibly encode the area of interest. While ensuring the quality of the area of interest, reduce the code rate consumed by other areas, thereby saving the code rate (storage space) and further improving the compression ratio.
[0033] In another possible implementation, obtaining the ROI in the image to be compressed can be specifically implemented as follows: receiving the input ROI region information, and determining the region indicated by the ROI region information in the image to be compressed as the ROI. The ROI region information is used to indicate the coordinate position of the ROI in the image to be compressed. In this implementation, by the user inputting the ROI region information to determine the position of the ROI in the image to be compressed, the user requirements can be better met.
[0034] In another possible implementation, obtaining the ROI in the image to be compressed can be specifically implemented as follows: receiving the input Map image information of the image to be compressed, and determining the region of interest ROI in the image to be compressed based on the Map image information. The Map image information is used to indicate whether each image block in the image to be compressed is in the ROI region. In this implementation, by the user inputting the Map image information of the image to be compressed to determine the position of the ROI in the image to be compressed, the user requirements can be better met.
[0035] In another possible implementation, obtaining the ROI in the image to be compressed can be specifically implemented as follows: obtaining the ROI in the image to be compressed through artificial intelligence (AI) recognition technology. By the machine automatically obtaining the ROI using AI recognition technology, the efficiency is high and it is easy to implement.
[0036] In a second aspect, there is provided an image compression apparatus, which may include: a transformation unit, a second quantization unit, a first quantization unit, and an encoding unit. Among them: the transformation unit is used to perform a first transformation on the image blocks in the image to be compressed to obtain a set of frequency domain coefficients of the image blocks; the image block is a continuous region including a plurality of pixel points in the image to be compressed. The second quantization unit is used to perform a second quantization operation on the set of frequency domain coefficients obtained by the transformation unit to obtain a set of second quantization coefficients. The second quantization operation is used to remove the high-frequency components in the set of frequency domain coefficients and maintain or reduce the amplitude of the low-frequency components in the set of frequency domain coefficients; the number of high-frequency components removed by the second quantization operation is related to the image block; the number of high-frequency components removed by the second quantization operation is greater than or equal to the number of high-frequency components removed by performing a first quantization operation based on the first quantization matrix. The first quantization unit is used to perform a first quantization operation on the set of second quantization coefficients based on the first quantization matrix to obtain a set of first quantization coefficients. The encoding unit is used to perform entropy encoding on the set of first quantization coefficients obtained by the first quantization unit to obtain the compressed data of the image block.
[0037] Through the image compression device provided by the embodiments of the present application, a second quantization operation related to the image block is first performed on the frequency coefficient set of the data block to remove the high-frequency components and keep or reduce the amplitude of the low-frequency components, and then a first quantization operation is performed based on the configured first quantization matrix, and then entropy coding is performed to complete the compression. In this way, the quantization related to different image blocks is different, and different image blocks in a frame of image can be quantized according to different quantization steps, which can meet the different visual requirements of users for different image regions in different scenarios; it realizes the adjustment of the size of the encoded JPEG format image according to actual needs; at the same time, on the premise of meeting the JPEG standard, the region of interest can be flexibly encoded, while ensuring the quality of the region of interest, reducing the bit rate consumed by other regions, thereby saving the bit rate (storage space) and further improving the compression rate.
[0038] In a possible implementation manner, the image compression device provided by the present application further includes a first acquisition unit for acquiring the ROI in the image to be compressed. The second quantization unit is specifically configured to: if the image block is in the ROI of the image to be compressed, retain the first N1 elements arranged in the ZigZag order in the frequency domain coefficient set, and set the remaining elements to zero to obtain a second quantization coefficient set; if the image block is in the non-ROI of the image to be compressed, retain the first N2 elements arranged in the ZigZag order in the frequency domain coefficient set, and set the remaining elements to zero to obtain a second quantization coefficient set. N1 is greater than N2. By performing the second quantization operation through this implementation manner, the implementation process is simple, the calculation complexity is low, and the cost is saved.
[0039] In another possible implementation manner, N1 is 63 and N2 is 32.
[0040] In a possible implementation manner, the image compression device provided by the embodiments of the present application may further include a second acquisition unit for acquiring the eigenvalue of the image block, and the eigenvalue is used to indicate any one of the following characteristics of the image block: spatial domain characteristic, frequency domain characteristic or texture characteristic. The second quantization unit is specifically configured to: determine the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block, and perform a third operation on the frequency coefficient set based on the second quantization matrix to obtain the second quantization coefficient set of the image block.
[0041] In a possible implementation manner, the third operation may be to perform the first quantization operation and the inverse quantization operation of the first quantization operation in sequence.
[0042] In another possible implementation manner, the third operation may include comparing the elements in the frequency-domain coefficient set of the image block with the elements at the corresponding positions in the second quantization matrix of the image block, and determining the second quantization coefficient set of the image block based on a preset rule. The preset rule may include: when the element at the first position in the frequency-domain coefficient set is greater than the element at the first position in the second quantization matrix, retaining the element at the first position in the frequency-domain coefficient set; the first position is any position in the frequency-domain coefficient set; when the element at the first position in the frequency-domain coefficient set is less than the element at the first position in the second quantization matrix, setting the element at the first position in the frequency-domain coefficient set to zero; when the element at the first position in the frequency-domain coefficient set is equal to the element at the first position in the second quantization matrix, retaining or setting the element at the first position in the frequency-domain coefficient set to zero.
[0043] In another possible implementation manner, the image compression device provided in the embodiment of the present application may further include a second acquisition unit, configured to acquire a feature value of the image block, where the feature value is used to indicate any one of the following features of the image block: spatial domain feature, frequency domain feature, or texture feature. The second quantization unit is specifically configured to: determine the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the feature value of the image block, and perform a first quantization operation and an inverse quantization operation of the first quantization operation on the frequency-domain coefficient set of the image block in sequence based on the second quantization matrix of the image block, so as to obtain the second quantization coefficient set of the image block.
[0044] In this implementation manner, high-frequency components in the frequency-domain coefficient set are removed by the determined second quantization matrix related to the image block, and the amplitude of the low-frequency components in the frequency-domain coefficient set is maintained or reduced. By performing the first quantization operation through the determined second quantization matrix related to the image block, high-frequency components in the frequency-domain coefficient set are removed, and by performing the inverse quantization operation on the result after the first quantization operation, the amplitude of the low-frequency components in the frequency-domain coefficient set is maintained or reduced, so as to achieve compatibility with the JPEG compression standard.
[0045] In another possible implementation, the image compression device provided in the embodiments of the present application may further include a second acquisition unit, configured to acquire the eigenvalue of an image block, where the eigenvalue is used to indicate any one of the following features of the image block: spatial domain feature, frequency domain feature, or texture feature. Specifically, the second quantization unit is configured to: determine the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block; compare the elements in the frequency domain coefficient set of the image block with the elements at the corresponding positions in the second quantization matrix of the image block, and determine the second quantization coefficient set of the image block based on a preset rule. Wherein, the preset rule may include: when the element at the first position in the frequency domain coefficient set is greater than the element at the first position in the second quantization matrix, retain the element at the first position in the frequency domain coefficient set; the first position is any position in the frequency domain coefficient set; when the element at the first position in the frequency domain coefficient set is less than the element at the first position in the second quantization matrix, set the element at the first position in the frequency domain coefficient set to zero; when the element at the first position in the frequency domain coefficient set is equal to the element at the first position in the second quantization matrix, retain or set the element at the first position in the frequency domain coefficient set to zero.
[0046] By replacing the first quantization operation and the inverse quantization operation with a comparison operation, multiplication and division operations are avoided, and the implementation cost of the hardware logic is reduced.
[0047] In another possible implementation, the second quantization unit determines the second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue, including: determining QM2 according to the relationship between the second quantization matrix QM2, the first quantization matrix QM1, and the eigenvalue X. Wherein, the relationship between QM2, QM1, and the eigenvalue X satisfies the following expression: QM2 = QM1 + F1(X). Wherein, F1(·) is a first preset function.
[0048] In this implementation, the expression for determining the second quantization matrix can be configured according to actual experience, so that the determined quantization matrix can better reflect the characteristics of the image block, and then a second quantization operation matching the characteristics of the image block can be realized, achieving the purpose of taking into account the visual experience, user experience, and image compression ratio during the image compression process.
[0049] In another possible implementation, the quantization information of the first quantization matrix may include a first quality factor QF1 for determining the first quantization matrix, and QF1 is used to calculate the first quantization matrix according to the first relationship expression. Wherein, the first relationship expression is the relationship between the quality factor and the standard quantization matrix QM SThe relational expression. The second quantization unit determines the second quantization matrix of the image block according to the quantization information and eigenvalue of the first quantization matrix, including: determining the quality factor offset value ΔQF according to the eigenvalue X; calculating the second quality factor QF2 according to ΔQF and QF1; and determining the second quantization matrix according to QF2 and the first relational expression. Wherein, ΔQF satisfies the following expression: ΔQF = F2(X); F2(·) is the second preset function; QF2 satisfies the following expression: QF2 = |QF1| - F3(ΔQF), and F3(·) is the third preset function.
[0050] In the scenario of determining the quantization matrix through the quality factor, the expression for determining the second quality factor is configured according to actual experience, and then the second quantization matrix is determined according to the second quality factor, so that the determined quantization matrix can better reflect the characteristics of the image block, and further realize the second quantization operation matching the characteristics of the image block, achieving the purpose of taking into account the visual experience, user experience and image compression ratio during the image compression process.
[0051] In another possible implementation manner, the image compression device provided in this application may further include a first acquisition unit, configured to acquire the ROI in the image to be compressed. The second quantization unit is specifically configured to: if the image block is outside the ROI, execute acquiring the eigenvalue of the image block and determining the second quantization matrix of the image block according to the quantization information and eigenvalue of the first quantization matrix; or, if the image block is within the ROI, the first quantization unit is further configured to perform a first quantization operation on the frequency domain coefficient set based on the first quantization matrix to obtain a first quantization coefficient set.
[0052] Perform two quantizations on the image blocks in the non-ROI area to achieve the purpose of increasing the quantization step size, improving the compression ratio and reducing the storage space. Perform quantization according to the JPEG compression protocol on the image blocks in the ROI area, and flexibly encode the area of interest. While ensuring the quality of the area of interest, reduce the bit rate consumed by other areas, thereby saving the bit rate (storage space) and further improving the compression ratio.
[0053] In another possible implementation manner, the first acquisition unit is specifically configured to: receive the input ROI area information and determine the area indicated by the ROI area information in the image to be compressed as the ROI. The ROI area information is used to indicate the coordinate position of the ROI in the image to be compressed. In this implementation manner, by inputting the ROI area information by the user to determine the position of the ROI in the image to be compressed, the user's needs can be better met.
[0054] In another possible implementation, the first acquisition unit is specifically configured to: receive the Map image information of the image to be compressed input, determine the region of interest (ROI) in the image to be compressed based on the Map image information, where the Map image information is used to indicate whether each image block in the image to be compressed is in the ROI region. In this implementation, by the user inputting the Map image information of the image to be compressed to determine the position of the ROI in the image to be compressed, the user requirements can be better met.
[0055] It should be noted that the image compression device provided in the second aspect is used to execute the image compression method provided in the first aspect or any possible implementation manner of the first aspect, and its specific implementation can refer to the first aspect or any possible implementation manner of the first aspect.
[0056] In a third aspect, the present application provides an image compression device, which can implement the functions in the method example described in the first aspect above. The functions can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions. The image compression device can exist in the form of a chip product.
[0057] In a possible implementation manner, the image compression device may include a processor and a transmission interface. Among them, the transmission interface is used to receive and send data. The processor is configured to call the program instructions stored in the memory so that the image compression device executes the functions in the method example described in the first aspect above.
[0058] In a fourth aspect, a computer-readable storage medium is provided. Program instructions are stored in the computer-readable storage medium. When the program instructions run on a computer or a processor, the computer or the processor is caused to execute the image compression method provided in the first aspect or the second aspect or any possible implementation manner thereof.
[0059] In a fifth aspect, a computer program product is provided. The computer program product includes program instructions. When the program instructions run on a computer or a processor, the computer or the processor is caused to execute the image compression method provided in the first aspect or any possible implementation manner thereof.
[0060] In a sixth aspect, a chip system is provided. The chip system includes a processor and may further include a memory for implementing the corresponding functions in the above method. The chip system may be composed of chips or may include chips and other discrete devices.
[0061] In a seventh aspect, an image compression system is provided. The system includes the image compression device in the second aspect or the third aspect.
[0062] Among them, it should be noted that various possible implementation manners of any one of the above aspects can be combined on the premise that the solutions do not conflict with each other. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 FIG. is a schematic diagram of an exemplary JPEG compression process provided by an embodiment of the present application;
[0064] Figure 2 FIG. is a schematic diagram of an exemplary matrix provided by an embodiment of the present application;
[0065] Figure 3 FIG. is a schematic diagram of an exemplary image compression and transmission scenario provided by an embodiment of the present application;
[0066] Figure 4 FIG. is a schematic diagram of the structure of an exemplary image compression device provided by an embodiment of the present application;
[0067] Figure 5 FIG. is a schematic diagram of the structure of an exemplary image block provided by an embodiment of the present application;
[0068] Figure 6 FIG. is a schematic diagram of the process of an exemplary image compression method provided by an embodiment of the present application;
[0069] Figure 7 FIG. is a schematic diagram of the process of an exemplary compressed image block provided by an embodiment of the present application;
[0070] Figure 8 FIG. is another schematic diagram of the process of an exemplary compressed image block provided by an embodiment of the present application;
[0071] Figure 9 FIG. is still another schematic diagram of the process of an exemplary compressed image block provided by an embodiment of the present application;
[0072] Figure 10 FIG. is still another schematic diagram of the process of an exemplary compressed image block provided by an embodiment of the present application;
[0073] Figure 11 FIG. is still another schematic diagram of the process of an exemplary compressed image block provided by an embodiment of the present application;
[0074] Figure 12 FIG. is still another schematic diagram of the process of an exemplary compressed image block provided by an embodiment of the present application;
[0075] Figure 13 FIG. is still another schematic diagram of the process of an exemplary compressed image block provided by an embodiment of the present application;
[0076] Figure 14Another schematic diagram of the process of compressing an image block provided by an embodiment of the present application;
[0077] Figure 15 Another schematic diagram of the process of compressing an image block provided by an embodiment of the present application;
[0078] Figure 16 Another schematic diagram of the structure of an image compression device provided by an embodiment of the present application;
[0079] Figure 17 Another schematic diagram of the structure of an image compression device provided by an embodiment of the present application;
[0080] Figure 18 Another schematic diagram of the structure of an image compression device provided by an embodiment of the present application. Detailed implementation manners
[0081] In the embodiments of the present application, in order to facilitate a clear description of the technical solutions of the embodiments of the present application, terms such as "first" and "second" are used to distinguish identical or similar items with basically the same functions and roles. Those skilled in the art can understand that the terms "first" and "second" do not limit the quantity and execution order, and the terms "first" and "second" do not necessarily mean different. There is no sequence or size order between the technical features described by the "first" and "second".
[0082] In the embodiments of the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the embodiments of the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplary" or "for example" is intended to present relevant concepts in a specific manner for easy understanding.
[0083] In the description of the present application, unless otherwise specified, " / " indicates that the objects associated before and after are in an "or" relationship. For example, A / B can represent A or B; "and / or" in the present application is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. These three situations, where A and B can be singular or plural. And, in the description of the present application, unless otherwise specified, "a plurality of" means two or more than two. "At least one (item)" or its similar expression below refers to any combination of these items, including any combination of a single item (item) or plural items (items). For example, at least one (item) of a, b, or c can represent: a, b, c, a - b, a - c, b - c, or a - b - c, where a, b, c can be single or multiple.
[0084] In the embodiments of the present application, at least one can also be described as one or more. The term "more than one" can refer to two, three, four, or more, and the present application does not impose any limitations in this regard.
[0085] Furthermore, the network architectures and scenarios described in the embodiments of the present application are for the purpose of more clearly explaining the technical solutions of the embodiments of the present application, and do not constitute limitations on the technical solutions provided by the embodiments of the present application. As is known to those of ordinary skill in the art, with the evolution of network architectures and the emergence of new service scenarios, the technical solutions provided by the embodiments of the present application are equally applicable to similar technical problems.
[0086] Before describing the embodiments of the present application, the terms related to the present application are first uniformly explained herein, and no further explanations will be provided hereinafter.
[0087] An image block (also referred to as a data block) is a continuous region in the image to be compressed that includes multiple pixel points. The image to be compressed can be segmented into multiple image blocks through segmentation. In the JPEG image compression standard, an image block can include 8×8 pixel points. A pixel point can include multiple components that the visual system is concerned with, such as a luminance component, a chrominance component, etc. The components included in a pixel point can be represented by component values.
[0088] The component set of an image block refers to the set of component values of this component included in the multiple pixel points of the image block. The component set can be embodied in the form of a matrix. For example, the set of numerical values of the pixel points in the image block in terms of the luminance component is called the luminance component set of the image block; the set of numerical values of the pixel points in the image block in terms of the chrominance component is called the chrominance component set of the image block. The size of a component set of an image block is the same as the size of the image block. For example, a YUV - formatted image block can include a luminance component set of this image block and two chrominance component sets of this image block (chrominance U - component set and chrominance V - component set).
[0089] It should be understood that an image block generally includes multiple component sets of this image block. For example, an RGB image includes an R - component set, a G - component set, and a B - component set of the image block; a YUV image includes a Y - component set, a U - component set, and a V - component set of the image block. Performing a first transformation on an image block includes performing a first transformation on the multiple component sets of the image block respectively to obtain multiple frequency - domain coefficient sets of the image block.
[0090] The frequency - domain coefficient set of the component set of an image block refers to the set of frequency - domain coefficients obtained after the component set of the image block is transformed from the spatial domain to the frequency domain. Each component set of an image block can have its corresponding frequency - domain coefficient set.
[0091] The high-frequency components in the frequency-domain coefficient set refer to the elements in the frequency-domain coefficient set that are preset to represent positions insensitive to the human visual system. For example, based on the ZigZag scanning order, all coefficients with position numbers in the frequency-domain coefficient set greater than Z are defined as high-frequency components. Z can be configured according to actual requirements.
[0092] The low-frequency components in the frequency-domain coefficient set refer to the elements in other positions in the frequency-domain coefficient set except for the positions of the high-frequency components. The human visual system is sensitive to the low-frequency components in the frequency-domain coefficient set.
[0093] Quantization means discretizing the amplitude. In image processing, the amplitudes in the component set of an image block are quantized, removing the unimportant (insensitive to the visual system) high-frequency components in the component set of the image block, and keeping or reducing the amplitudes of the important (sensitive to the visual system) low-frequency components.
[0094] The quantization step is the step used to reduce the amplitude during the quantization process. For example, when quantizing the component set of an image block by dividing by a quantization matrix, the values of the elements in the quantization matrix are the quantization steps.
[0095] The first quantization operation includes dividing the object to be processed by the quantization matrix to obtain an integer result. When the object to be processed is integer data, the first quantization operation divides the object to be processed by the quantization matrix to obtain an integer result; when the object to be processed is floating-point data, the first quantization operation takes the integer or truncates after dividing the object to be processed by the quantization matrix. For example, during image compression, when performing the first quantization operation on the frequency-domain coefficient set A based on the first quantization matrix B, the element in the i-th row and j-th column of the obtained result C is: C(i, j) = A(i, j). / B(i, j), where. / is the division operation.
[0096] The second quantization operation includes removing the high-frequency components from the frequency-domain coefficient set and keeping or reducing the amplitude of the low-frequency components. The number of high-frequency components removed in the second quantization operation is related to the image block. The sensitivity of the visual system to the image block can be reflected by the features of the image block (spatial domain features, frequency domain features, texture features, or other features), or whether the user is interested in the image block can be reflected by the area where the image block is located. In the second quantization operation, for image blocks that are visually insensitive or in areas where the user is not interested, more high-frequency components are removed to increase the compression ratio and reduce the size of the compressed image. For image blocks that are visually sensitive or in areas where the user is interested, fewer high-frequency components are removed to improve the visual effect. That is, image block-related quantization is achieved in different image blocks through the second quantization operation. For the specific process of the second quantization operation, see the content of the following embodiments, which will not be elaborated here.
[0097] The ZigZag order can refer to the scanning traversal order from the upper left corner to the lower right corner in a rectangular form set. For example, it can be as Figure 2In the schematic matrix, the numbers from 0 to 63 are in ascending order, that is Figure 2 the order indicated by the arrow in
[0098] Before describing the solution of this application, a brief description of JPEG image compression is given first.
[0099] For an ordinary 800×800-sized picture, if it is not compressed, its size is about 1.7 megabytes (MB). Such a size will occupy a large amount of space during storage or transmission. Therefore, image compression is crucial. Currently, most pictures use JPEG compression technology, that is, the commonly used JPEG image file. Because JPEG compression technology uses lossy compression technology, the JPEG file can achieve a compression ratio of 1 / 8 relative to the original image. Lossy compression is to remove the unimportant parts of the original data in order to reduce the space occupied by the data.
[0100] During the JPEG compression process, a frame (picture) of an image will first be divided into a series of 16×16 image blocks. The image block division method is as follows: starting from the upper left corner of the image, scan the first 16 rows of the image in the horizontal direction, and divide every 16 columns into 1 image block during the scanning process. After completing the scanning of the first 16 rows, continue to scan the next 16 rows of data in the first 16 rows of the image from left to right, and divide every 16 columns into 1 image block during the scanning process. Scan and divide every 16 rows in this order until a frame of the image is completed. Each 16×16 image block will be further divided into 4 8×8 image blocks, and then for each component set of each 8×8 image block, use the Figure 1 schematic JPEG compression process shown in the figure for compression. The image segmentation process of this application will not be elaborated further. The size of each image block after image segmentation can also be adjusted according to actual needs.
[0101] As Figure 1 shown, after a discrete cosine transform (DCT), quantization, and entropy coding of an 8×8 image block (each component set in the image block), the compressed data of the image block is obtained.
[0102] It should be noted that the operations on the image block described in the embodiments of this application can all be understood as operating on each component set in the image block respectively, and will not be elaborated one by one later.
[0103] For example, after a DCT, quantization, and entropy coding are performed on an 8×8 image block in the YUV format, the compressed data of the image block is obtained, which means that: a DCT, quantization, and entropy coding are performed on the 8×8 luminance component set of the image block to obtain the compressed data of the luminance component set of the image block; a DCT, quantization, and entropy coding are performed on the 8×8 chrominance U component set of the image block to obtain the compressed data of the chrominance U component set of the image block; and a DCT, quantization, and entropy coding are performed on the 8×8 chrominance V component set of the image block to obtain the compressed data of the chrominance V component set of the image block.
[0104] Next Figure 1 the steps in the schematic JPEG compression process will be described.
[0105] DCT is a matrix multiplication that separately performs an 8×8 row transformation and an 8×8 column transformation on an 8×8 image block to obtain 8×8 DCT coefficients. Since the image block has strong correlation in the spatial domain, its frequency components are limited and mainly distributed in the mid - and low - frequency regions. Therefore, DCT transforms the spatial data block into the frequency domain and represents it with DCT coefficients (a set of frequency domain coefficients), separating the different frequency components contained in the spatial data block in the frequency domain. After the transformation, the DCT coefficients are often 0 or small values in the high - frequency region. For example, the high - frequency coefficients corresponding to flat regions with less texture are often 0. The set of frequency coefficients can be embodied in the form of a matrix, a table, or other forms, which is not limited in this application. The transformed set of frequency domain coefficients can be divided into a direct current (DC) component in the upper left corner (the first element in the set of frequency domain coefficients according to the ZigZag scanning order) and alternating current (AC) components in other positions (the second element and all subsequent elements in the set of frequency domain coefficients according to the ZigZag scanning order).
[0106] Quantization: According to the quantization matrix input externally, the DCT coefficients are quantized to obtain quantized coefficients. The quantization operation is achieved by dividing the DCT coefficients by a non-zero integer (quantization step size), and the quantized values are truncated or rounded to the nearest integer. This quantization step is implemented using the aforementioned first quantization operation. In practice, according to the characteristic that the human eye is less sensitive to high-frequency coefficients, as the frequency increases, the quantization step size is gradually increased in the quantization matrix to achieve a better compression ratio. The luminance component set and the chrominance component set can use different quantization matrices to achieve compression. The luminance component contains more texture details and contour information. In the transform domain of DCT, the frequency distribution is relatively wide and contains more high-frequency information. Therefore, a larger quantization step size is usually used to quantize the luminance component set to achieve the effect of reducing the bit rate. The chrominance component contains less detail and contour information, but the human eye is more sensitive to chrominance. In the transform domain of DCT, the frequency distribution is relatively wide and contains less high-frequency information. Usually, during quantization, the quantization step size used for the chrominance component set is smaller than that of the luminance component set.
[0107] It should be noted that the fixed quantization matrix can be configured according to actual requirements, and the embodiments of the present application do not specifically limit this.
[0108] Exemplarily, a standard quantization matrix for the luminance component used in a JPEG compression can be shown as follows:
[0109]
[0110] Exemplarily, a standard quantization matrix for the chrominance component used in a JPEG compression can be shown as follows:
[0111]
[0112] In the above standard quantization matrices for the luminance component and the chrominance component, in the order of ZigZag from the upper left corner to the lower right corner, the quantization step size gradually increases to discard high-frequency components through a large quantization step size to improve the compression ratio and reduce the volume of the image after compression. In addition, it can be seen from the above standard quantization matrices for the luminance component and the chrominance component that the quantization step size used for the chrominance component is smaller than that of the luminance component to meet the requirement that the human eye is more sensitive to chrominance.
[0113] Entropy coding is the process of encoding the quantized coefficients obtained by quantization to obtain compressed data. During entropy coding, one-dimensional differential pulse coding modulation (DPCM) can be used for the DC component, and then entropy coding is performed. For the AC quantized coefficients, ZigZag scanning is performed, and Huffman coding is used for entropy coding of the number of consecutive zero coefficients and the non-zero coefficient amplitudes.
[0114] When compressing an image, the quantization matrix used during the compression process at the encoding end and the Huffman table used for the corresponding entropy encoding also need to be compressed into the bitstream and transmitted to the decoding end to facilitate the decoding end to restore the image.
[0115] As can be seen from the above JPEG compression process, in one frame (the entire) image, only one set of quantization matrices (the quantization matrix for the luminance component and the quantization matrix for the chrominance component) is used, and a single component only uses a unique quantization matrix, with a fixed compression ratio.
[0116] In practice, in application scenarios such as capturing data in security monitoring and mobile phone photography, certain target areas need to be particularly concerned about, and a finer quantization step is desired. For some insensitive areas, such as the background area, the visual characteristic that the human eye has different degrees of perception of the quantization of different texture characteristic areas can be utilized, and a coarser quantization accuracy is desired to achieve the purpose of reducing the bitrate. The current JPEG compression cannot meet the different visual requirements of users for different image areas in different scenarios.
[0117] Based on this, the embodiments of the present application provide an image compression method. Before performing the quantization operation in the existing JPEG compression standard, a quantization related to the image block is first performed on the frequency coefficient set of the component set of the image block, the high-frequency components are removed, and the low-frequency components are kept or their amplitudes are reduced. Then, quantization in the JPEG compression standard is performed based on the configured fixed quantization matrix, and then entropy encoding is performed to complete the compression. In this way, when the image blocks are different, the quantization related to the image blocks is different, and the same component of different image blocks in one frame image can be quantized according to different quantization steps, which can meet the different visual requirements of users for different image areas in different scenarios; it also realizes adjusting the size of the JPEG format image after encoding according to actual needs; at the same time, the function of region of interest encoding can be flexibly implemented on JPEG. While ensuring the quality of the region of interest, the bitrate consumed by other regions is reduced, thereby saving the bitrate (storage space), and the compression ratio can be further improved.
[0118] The image compression method provided by the embodiments of the present application can be applied to the scenario of image compression storage or the scenario of image compression transmission.
[0119] Such as Figure 3 illustrates a scenario of image compression transmission, which includes an encoding end device 301 and a decoding end device 302.
[0120] Among them, the encoding end device 301 can compress the image and transmit it to the decoding end device 302, and the decoding end device 202 decompresses it and then presents or saves it.
[0121] The encoding end device 301 or the decoding end device 302 may be in the form of a terminal device, a mobile phone, a personal digital assistant, etc., and the embodiments of the present application do not limit this.
[0122] In an image compression and storage scenario, the encoding end device may acquire an image, compress it, and store it in its corresponding memory.
[0123] Next, the embodiments of the present application will be specifically described with reference to the accompanying drawings.
[0124] On the one hand, an embodiment of the present application provides an image compression device for executing the image compression method provided by the present application.
[0125] Figure 4 Shown is an image compression device 40 related to the embodiments of the present application. As Figure 4 shown, the image compression device 40 may include a processor 401, a memory 402, and a transceiver 403.
[0126] Next, in conjunction with Figure 4 each component of the image compression device 40 will be specifically introduced:
[0127] Among them, the memory 402 may be a volatile memory, such as a random-access memory (RAM); or a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); or a combination of the above types of memories, for storing program codes, configuration files, or other content that can implement the method of the present application.
[0128] The processor 401 is the control center of the image compression device 40. For example, the processor 401 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application, such as: one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs).
[0129] The transceiver 403 is used to communicate with other devices. The transceiver 403 can be a communication port or others.
[0130] The processor 401 performs the following functions by running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402:
[0131] Perform a first transformation on the image blocks in the image to be compressed to obtain a set of frequency domain coefficients of the data block components; perform a second quantization operation on the set of frequency domain coefficients to obtain a set of second quantization coefficients; the second quantization operation is used to remove the high-frequency components in the set of frequency domain coefficients and maintain or reduce the amplitude of the low-frequency components in the set of frequency domain coefficients; the number of high-frequency components removed by the second quantization operation is related to the image block; the number of high-frequency components removed by the second quantization operation is greater than or equal to the number of high-frequency components removed by the first quantization operation based on the first quantization matrix; perform a first quantization operation on the set of second quantization coefficients based on the first quantization matrix to obtain a set of first quantization coefficients; perform entropy coding on the set of first quantization coefficients to obtain the compressed data of the image block.
[0132] On the other hand, an embodiment of the present application provides an image compression method, which is executed by an image compression device to compress the image to be compressed to obtain its compressed data. The image compression device can divide the image to be compressed into multiple image blocks, and perform the image compression method provided by the present application on each component set of each image block. Among them, the compression process of each component set of each image block by the image compression device is the same. The compression process of the image block by the image compression device described in the following embodiments of the present application should be understood as that the image compression device performs the following compression process on each component set of the image block, and will not be described separately. It should also be understood that the "image block" described in the embodiments of the present application can be equivalently replaced by the "chrominance component set of the image block" or the "luminance component set of the image block" or a "certain component set of the image block" to describe the solution protected by the present application.
[0133] It should be noted that the specific implementation of dividing the image to be compressed into image blocks has been described in the foregoing Figure 1 illustrated JPEG compression process and will not be elaborated here.
[0134] It should be noted that the image to be compressed can be an image in YUV format or other image formats containing chrominance components and luminance components, and the present application does not limit the format of the image to be compressed. When the format of the image to be compressed is an image format not supported by the image compression device, the image to be compressed can be first converted to an image format supported by the image compression device, and then the image compression method provided by the present application is executed.
[0135] Exemplarily, assume that the components included in the image blocks obtained by splitting a to-be-compressed image in YUV420 format can be as Figure 5 shown. The image block includes a 16×16 luminance component set, an 8×8 chrominance U component set, and an 8×8 chrominance V component set. The image compression device can split the 16×16 luminance component set into 4 8×8 luminance component sets, and then perform the image compression method provided in this application on each of the 4 8×8 luminance component sets, an 8×8 chrominance U component set, and an 8×8 chrominance V component set to obtain the compressed data of each component set as the compressed data of the image block.
[0136] As Figure 6 shown, the image compression method provided in the embodiments of this application may include:
[0137] S601. The image compression device performs a first transformation on the image block in the to-be-compressed image to obtain a frequency-domain coefficient set of the image block.
[0138] Wherein, the image block is any image block obtained by splitting the to-be-compressed image, and is also referred to as a to-be-processed image block in the following text.
[0139] Wherein, the first transformation is used to convert the spatial-domain data value representation of the image block into a frequency-domain representation. Each pixel point in the image block corresponds to an element at the same position in the frequency-domain coefficient set. The arrangement and the number of elements in the frequency-domain coefficient set of an image block are the same as those of the image block. For example, the first transformation may be a DCT transformation or other types of transformations, which are not limited in this application, and the process thereof is not elaborated either.
[0140] Specifically, the frequency-domain coefficient set of the image block obtained through the first transformation may be represented in the form of a matrix or other forms, which are not specifically limited in the embodiments of this application. It should be noted that representing the frequency-domain coefficient set in the form of a matrix in the embodiments of this application is only an example and does not constitute a specific limitation.
[0141] It should be noted that the specific implementation of S601 may refer to the JPEG compression standard and will not be elaborated here.
[0142] S602. The image compression device performs a second quantization operation on the frequency-domain coefficient set to obtain a second quantization coefficient set.
[0143] Wherein, the second quantization operation is used to remove the high-frequency components in the frequency-domain coefficient set and maintain or reduce the amplitude of the low-frequency components in the frequency-domain coefficient set; the number of high-frequency components removed by the second quantization operation is related to the image block. Adaptive quantization is performed on different image blocks in the to-be-compressed image through the second quantization operation, and the quantization effect on each image block matches the characteristics of the image block, so as to achieve different quantization effects on different regions in the to-be-compressed image.
[0144] For example, the sensitivity of the visual system to an image block can be reflected by the features of the image block (spatial domain features, frequency domain features, texture features, or other features), or whether the user is interested in the image block can be reflected by the region where the image block is located. In the second quantization operation, for image blocks that are visually insensitive or image blocks in regions that the user is not interested in, more high-frequency components are removed to increase the compression ratio and reduce the size of the compressed image. For image blocks that are visually sensitive or image blocks in regions that the user is interested in, fewer high-frequency components are removed to improve the visual effect.
[0145] In practical applications, the specific content of the second quantization operation can be configured according to actual needs to achieve the purpose of removing high-frequency components in the frequency domain coefficient set, maintaining or reducing the amplitude of low-frequency components in the frequency domain coefficient set, and the number of high-frequency components removed is related to the image block.
[0146] Among them, the number of high-frequency components removed by the second quantization operation is greater than or equal to the number of high-frequency components removed by the first quantization operation based on the first quantization matrix.
[0147] In a possible implementation, for image blocks in regions that the user is concerned about, or for image blocks in regions that are sensitive to the visual system, the number of high-frequency components removed by the second quantization operation can be equal to the number of high-frequency components removed by the first quantization operation based on the first quantization matrix.
[0148] In another possible implementation, for image blocks in regions with low user attention, or for image blocks in regions that are insensitive to the visual system, the number of high-frequency components removed by the second quantization operation can be greater than the number of high-frequency components removed by the first quantization operation based on the first quantization matrix.
[0149] In an optional case, the first quantization matrix is the fixed quantization matrix input in the JPEG compression standard. The first quantization matrix for the same component of different image blocks in a frame of the image to be compressed is the same.
[0150] S603. The image compression device performs a first quantization operation on the second quantization coefficient set based on the first quantization matrix to obtain a first quantization coefficient set.
[0151] Specifically, in S603, the image compression device performing the first quantization operation based on the first quantization matrix specifically includes dividing the second quantization coefficient set by the first quantization matrix to obtain the first quantization coefficient set with integer results.
[0152] For example, the element in the i-th row and j-th column of the first quantization coefficient set can be the integer result of the quotient obtained by dividing the element in the i-th row and j-th column of the second quantization coefficient set by the element in the i-th row and j-th column of the first quantization matrix.
[0153] S604. The image compression device performs entropy encoding on the first quantization coefficient set to obtain the compressed data of the image block.
[0154] Specifically, for performing entropy encoding on the first quantization coefficient set in S604 to obtain the compressed data of the image block, the entropy encoding process in the JPEG compression standard can be referred to, which will not be elaborated here.
[0155] For example, the process of compressing an image block by the image compression method provided by the above S601 to S604 can Figure 7 be shown as follows.
[0156] By the image compression method provided by the embodiments of the present application, the frequency coefficient set of the data block is first subjected to a second quantization operation related to the image block once to remove high-frequency components, keep or reduce the amplitude of low-frequency components, then a first quantization operation is performed based on the configured first quantization matrix, and then entropy encoding is performed to complete the compression. In this way, the quantization related to different image blocks is different, and different image blocks in a frame of image can be quantized according to different quantization steps, which can meet the different visual requirements of users for different image regions in different scenarios; it realizes adjusting the size of the JPEG format image after encoding according to actual needs; at the same time, on the premise of meeting the JPEG standard, flexible encoding can be performed on the region of interest, while ensuring the quality of the region of interest, reducing the bit rate consumed by other regions, thereby saving the bit rate (storage space) and further improving the compression ratio.
[0157] In a possible implementation manner, in practical applications, the image compression device can execute the above processes of S601 to S604 for each image block in the image to be compressed to obtain the compressed data of the image to be compressed.
[0158] In a possible implementation manner, in practical applications, the image compression device can execute the above processes of S601 to S604 for some image blocks in the image to be compressed, and compress the remaining image blocks according to the JPEG compression standard to obtain the compressed data of the image to be compressed.
[0159] For example, the image compression device can execute the above processes of S601 to S604 to compress the image blocks in the non-region of interest (ROI) in the image to be compressed, and compress the image blocks in the ROI region according to the JPEG compression standard.
[0160] Wherein, the ROI is the region with high user attention in the image to be compressed, and the specific implementation of the ROI in the image to be compressed can be configured and determined according to actual needs, which is not limited in the embodiments of the present application.
[0161] Optionally, the ROI in the image to be compressed can be obtained through AI recognition technology, or the ROI in the image to be compressed can be obtained according to the indication information of the ROI area input by the user. The embodiments of the present application do not limit this.
[0162] In a possible implementation, the ROI in the image to be compressed can be obtained through AI recognition technology, and the indication information of the ROI area can be output. The type of AI technology for obtaining the ROI is not limited in the embodiments of the present application.
[0163] For example, based on AI object detection, the objects in the image to be compressed can be detected in real time, such as human faces, human figures, license plates, vehicles, etc. The area where the recognized object is located is determined as the ROI, and other areas are non-ROIs. The coordinate information of the rectangular frame of each ROI area is used as the indication information of the ROI area.
[0164] In a possible implementation manner, the indication information of the ROI area output by AI recognition can be directly input into the image compression device. During the compression process, the image compression device can determine in real time whether the image block to be processed is in the ROI area according to the indication information of the ROI area.
[0165] Another possible processing method is: the indication information of the ROI area output by AI recognition can be used to generate a binary map for the entire frame of the image to be compressed in units of the size of the image block (it can also be processed according to a larger size), such as 16×16, according to its position in the image to be compressed. (The generation process of the binary map can be generated according to the results of AI analysis, such as the results of AI object detection). Different identifiers are used to identify whether each image block is in the ROI area. This binary map is used as the input of the image compression device. During the compression process, the image compression device determines whether the image block to be processed is in the ROI area according to the specific value of the image block to be processed in the binary map. For example, it can be identified by 0 and 1, where 1 indicates that the image block is inside the ROI area and 0 indicates that the image block is in the non-ROI area.
[0166] In another possible implementation manner, the image compression device can receive the input ROI area information, determine the area indicated by the ROI area information in the image to be compressed as the ROI, and other areas as non-ROIs. Among them, the ROI area information is used to indicate the coordinate position of the ROI in the image to be compressed. For example, the ROI area information can be input by the user of the image compression device through the human-computer interaction interface of the image compression device. Of course, the ROI area information can also be input by other entities through other means, which is not limited in the embodiments of the present application.
[0167] In another possible implementation, the image compression device may receive the Map image information of the input image to be compressed, determine the region of interest (ROI) in the image to be compressed based on the Map image information, and the other regions are non-ROI regions. Among them, the Map image information is used to indicate whether each image block in the image to be compressed is in the ROI region.
[0168] As described above, the specific implementation of performing the second quantization operation on the frequency domain coefficient set in S602 of this application to obtain the second quantization coefficient set can be configured according to actual requirements. The embodiments of this application provide the following two specific implementations of performing the second quantization operation on the frequency domain coefficient set to obtain the second quantization coefficient set, including the following first implementation and second implementation, but do not constitute a specific limitation.
[0169] The first implementation:
[0170] The image compression device obtains the ROI in the image to be compressed; if the image block to be processed is in the region of interest (ROI) of the image to be compressed, retain the first N1 elements arranged in the ZigZag order in the frequency domain coefficient set, and set the remaining elements to zero to obtain the second quantization coefficient set; if the image block to be processed is in the non-ROI region of the image to be compressed, retain the first N2 elements arranged in the ZigZag order in the frequency domain coefficient set, and set the remaining elements to zero to obtain the second quantization coefficient set.
[0171] Specifically, in the first implementation, considering the characteristics of the human visual system, which is sensitive to low-frequency information and insensitive to high-frequency information, and the frequency components in the frequency domain coefficient set gradually increase in the ZigZag order from the upper left corner to the lower right corner, the image compression device can perform the second quantization operation using the first implementation to obtain the second quantization coefficients.
[0172] Among them, N1 is greater than N2. The values of N1 and N2 can be configured according to actual requirements. N1 can be determined according to the degree of attention to the region of interest. The larger the value of N1, the lower the quantization degree of the region of interest, and the closer the compressed image is to the original image. N2 can be determined according to the degree of attention to the region outside the region of interest. The smaller the value of N2, the higher the quantization degree of the region outside the region of interest, the greater the loss of the compressed image, the higher the compression ratio, and the smaller the volume of the compressed image.
[0173] In one possible implementation, N1 can be much larger than N2. For example, N1 is 63 and N2 is 32.
[0174] In another possible implementation, among different component sets of the image block, the value of N1 can be different, and the value of N2 can also be different.
[0175] Exemplarily, when the image compression device performs a second quantization operation on the frequency domain coefficient set TC based on the ZigZag scan order to obtain the second quantization coefficient set TC′, the process of performing the second quantization operation on the idx-th coefficient in the ZigZag scan order can be implemented by the following expression:
[0176]
[0177] Among them, N corresponds to N1 of the ROI and N2 of the non-ROI. TC(i, j) is the value of the idx-th coefficient in the frequency domain coefficient set TC according to the ZigZag scan order.
[0178] Exemplarily, in the first implementation, the process of the image compression method provided by the embodiments of the present application for compressing an image block can Figure 8 be shown as follows. As Figure 8 shown, the image block undergoes a first transformation to obtain the frequency domain coefficient set of the image block. Then, a zeroing process is performed on the frequency domain coefficient set. The zeroing process refers to performing a second quantization operation through the first implementation, that is, if the data block component to be processed is in the region of interest ROI of the image to be compressed, the first N1 elements arranged in the ZigZag order in the frequency domain coefficient set are retained, and the remaining elements are set to zero to obtain the second quantization coefficient set; if the data block component to be processed is in the non-ROI of the image to be compressed, the first N2 elements arranged in the ZigZag order in the frequency domain coefficient set are retained, and the remaining elements are set to zero to obtain the second quantization coefficient set. Next, a first quantization operation is performed on the second quantization coefficient set based on the first quantization matrix according to the description of S603 above to obtain the first quantization coefficient set. Finally, entropy coding is performed on the first quantization coefficient set to obtain the compressed data of the image block.
[0179] The second implementation:
[0180] The image compression device first obtains the second quantization matrix of the image block to be processed, and completes the second quantization operation on the frequency domain coefficient set of the image block according to the second quantization matrix.
[0181] Among them, the first quantization matrix, the second quantization matrix, and the row and column sizes of the image block to be processed are the same, and the amplitude of an element in the second quantization matrix of a component set of an image block is greater than or equal to the amplitude of the element at the same position in the first quantization matrix of the component set of the image block.
[0182] It should be noted that the acquisition method of the second quantization matrix of the image block can be configured according to actual needs, and the embodiments of the present application do not limit this.
[0183] Exemplarily, in the second implementation, the process of the image compression method provided by the embodiments of the present application for compressing a data block component can Figure 9 be shown as follows. As Figure 9As shown, the image block undergoes a first transformation to obtain a set of frequency domain coefficients of the image block. A second quantization matrix of the image block is obtained, and then a second quantization operation is performed on the set of frequency domain coefficients based on the second quantization matrix to obtain a set of second quantization coefficients. Next, a first quantization operation is performed on the set of second quantization coefficients based on the first quantization matrix according to the description of S603 above to obtain a set of first quantization coefficients. Finally, entropy coding is performed on the set of first quantization coefficients to obtain the compressed data of the image block.
[0184] In a possible implementation, the second quantization matrix of the image block can be specified by the user.
[0185] In another possible implementation, the image compression device can obtain the second quantization matrix of the image block according to the characteristics of the image block.
[0186] Exemplarily, the image compression device can obtain the eigenvalue of the image block, and determine the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block. It should be understood that the image compression device can obtain the eigenvalue of a certain component set (luminance component set or chrominance component set) of the image block, and determine the second quantization matrix of the component set of the image block according to the quantization information of the first quantization matrix of the component set of the image block and the eigenvalue of the component set of the image block.
[0187] Exemplarily, in the second implementation, when the image compression device performs the second quantization operation, it obtains the eigenvalue of the image block, determines the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block, and then when completing the second quantization operation, the process of compressing the image block by the image compression method provided by the embodiments of the present application can Figure 10 as shown. As Figure 10 shown, the image block undergoes a first transformation to obtain a set of frequency domain coefficients of the image block. Through image feature analysis, the eigenvalue X of the image block is obtained. Then, the second quantization matrix of the image block is determined according to the eigenvalue X and the first quantization matrix of the image block. Next, a second quantization operation is performed on the set of frequency domain coefficients based on the second quantization matrix to obtain a set of second quantization coefficients. Next, a first quantization operation is performed on the set of second quantization coefficients based on the first quantization matrix according to the description of S603 above to obtain a set of first quantization coefficients. Finally, entropy coding is performed on the set of first quantization coefficients to obtain the compressed data of the image block.
[0188] Wherein, the eigenvalue of the image block is used to indicate any one of the following characteristics of the image block: spatial domain feature, frequency domain feature or texture feature. Of course, the eigenvalue of the image block can also indicate other characteristics of the image block, and the embodiments of the present application do not limit this.
[0189] Optionally, if the image block to be processed is outside the ROI, the image compression device may obtain the eigenvalue of the image block, and determine the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block, so as to complete the second quantization operation.
[0190] Optionally, if the image block to be processed is within the ROI, after S601, the image compression device may perform a first quantization operation on the frequency-domain coefficient set of the image block based on the first quantization matrix to obtain a first quantization coefficient set, and perform entropy coding on the first quantization coefficient set to obtain the compressed data of the image block.
[0191] In a possible implementation, the image compression device may obtain the spatial domain features of the image block to be processed through gradient or variance, edge detection means. Specifically, the spatial domain feature of the image block may be a spatial domain eigenvalue. Specifically, the Sobel edge detection operator may be used to detect the edge intensity of each point in the horizontal and vertical directions in the image block, sum up the horizontal and vertical edge intensities of all points and then take the average to obtain the edge intensity index within the image block. The edge intensity index may be used to indicate the characteristics of the image block in the spatial domain, and the edge intensity index may be used as the eigenvalue of the image block.
[0192] The larger the value of the edge intensity index, the stronger the texture or edge intensity in the image block. In practice, a larger quantization step size may be used for quantization without significantly reducing the quality of the compressed image. On the contrary, if the value of the edge intensity index is smaller, a smaller quantization step size is required to minimize the impact on the subjective quality of the image perceived by the human eye.
[0193] In another possible implementation, the image compression device may also analyze the frequency-domain features of the frequency-domain coefficient set of the image block to be processed. Specifically, the frequency-domain feature of the image block may be a frequency-domain eigenvalue, which is used to indicate the characteristics of the image block in the frequency domain. Specifically, in the frequency-domain coefficient set obtained by performing DCT transformation on the image block, the sum of all AC coefficients or medium-high frequency coefficients (for example, all coefficients with serial numbers greater than 16 based on the ZigZag scanning order) is averaged to obtain the intensity of the frequency-domain component. The intensity of the frequency-domain component is used as the eigenvalue of the image block. The greater the intensity of the frequency-domain component, the more complex the image. In practice, a larger quantization step size may be used for quantization without significantly reducing the quality of the compressed image. On the contrary, if the intensity of the frequency-domain component is smaller, a smaller quantization step size is required to minimize the impact on the subjective quality of the image perceived by the human eye.
[0194] In still another possible implementation, the eigenvalue is used to indicate the texture feature of the image block, and the image compression device may calculate the eigenvalue X according to the expression of the eigenvalue X and the pixel values in the image block.
[0195] Among them, the expression of the eigenvalue X and the pixel values in the image block satisfies the following relationship:
[0196]
[0197] Among them, Pix i is the pixel value of the i-th pixel point in the image block to be processed, M is the width of the image block, and L is the height of the image block.
[0198] It should be noted that the eigenvalue of the image block can also be obtained by other means, which will not be described one by one in the embodiments of this application.
[0199] After the image compression device obtains the eigenvalue of the image block, the image compression device can then determine the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block.
[0200] Since the human vision system (HVS) has different sensitivities to different feature (frequency feature, spatial domain feature, texture feature) regions of the image. For example, some regions are flat, such as the wall surface and the skin color region of the face, and HVS is more sensitive and requires a smaller quantization step for quantization. While some regions are more complex, such as grassland, HVS is not very sensitive and contains more high-frequency component information. Therefore, a larger quantization step can be used for quantization to achieve the effect of reducing the bit rate. Therefore, the second quantization matrix can be determined based on this principle.
[0201] Optionally, the process of the image compression device provided in the embodiments of this application determining the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block can be implemented by, but not limited to, the following first determination method or second determination method.
[0202] The first determination method: The quantization information of the first quantization matrix is the first quantization matrix, or the quantization information of the first quantization matrix includes the first quality factor QF1 for determining the first quantization matrix. The image compression device first determines the first quantization matrix according to the quantization information of the first quantization matrix, and then determines QM2 according to the relationship between the second quantization matrix QM2, the first quantization matrix QM1, and the eigenvalue X. Among them, the relationship between QM2, QM1, and the eigenvalue X satisfies the following expression: QM2 = QM1 + F1(X); F1(·) is the first preset function.
[0203] Among them, the content of the first preset function can be configured according to actual needs, which is not limited in the embodiments of this application. Exemplarily, the first preset function can be a log function. For example, the first preset function can be the log function with base 2, log2(X).
[0204] It should be noted that when calculating the second quantization matrix of a certain component set in an image block, the eigenvalues of other component sets of the image block can be used for the calculation.
[0205] For example, when calculating the second quantization matrix of the chrominance component set of an image block, the second quantization matrix of the chrominance component set of the image block can be calculated according to the eigenvalues of the luminance component set of the image block and the relationship between the second quantization matrix QM2, the first quantization matrix QM1, and the eigenvalue X.
[0206] Optionally, when the quantization information of the first quantization matrix can be QM1, the image compression device can directly determine QM1.
[0207] Optionally, the quantization information of the first quantization matrix can include the first quality factor QF1 for determining the first quantization matrix. QF1 is used to calculate the first quantization matrix QM1 according to the first relational expression. The image compression device can calculate QM1 according to the first relational expression.
[0208] Among them, the first relational expression is the relational expression between the quality factor QF and the standard quantization matrix QM S The first relational expression satisfies the following relationship: QM qf = floor(S × QM s + 50).
[0209] Among them, QM qf is the calculated quantization matrix, floor(·) is the rounding operation, and S satisfies the following expression:
[0210]
[0211] The first determination method: The quantization information of the first quantization matrix includes the first quality factor QF1 for determining the first quantization matrix. The image compression device first calculates the second quality factor QF2, and then determines the second quantization matrix according to the first relational expression and QF2.
[0212] In the first determination method, the image compression device specifically determines the second quantization matrix of the image block through the following steps 1 to 3:
[0213] Step 1: The image compression device determines the quality factor offset value ΔQF according to the eigenvalue X of the image block.
[0214] Among them, ΔQF satisfies the following expression: ΔQF = F2(X); F2(·) is the second preset function.
[0215] Among them, the content of the second preset function can be configured according to actual needs, and this application embodiment does not limit this.
[0216] Exemplarily, the second preset function can be α*log2(·), and ΔQF satisfies the following expression: ΔQF = α*log2(X), where α is an adjustment coefficient used to control the value range of ΔQF.
[0217] Step 2: The image compression device calculates a second quality factor QF2 based on ΔQF and QF1.
[0218] Among them, QF2 satisfies the following expression: QF2 = |QF1| - F3(ΔQF); F3(·) is a third preset function.
[0219] Among them, the content of the third preset function can be configured according to actual needs, and the embodiments of the present application do not limit this.
[0220] Exemplarily, the third preset function can be empty, and QF2 can satisfy the following expression: QF2 = |QF1| - ΔQF.
[0221] Exemplarily, the third preset function can be a clamping operation, and QF2 can satisfy the following expression: QF2 = |QF1| - clip(0, MaxΔQF, ΔQF).
[0222] Step 3: The image compression device determines a second quantization matrix according to QF2 and the first relational expression.
[0223] Through the process of the above steps 1 to 3, for a region with complex texture, the larger the calculated texture feature x is, the larger the corresponding ΔQF will be, and the smaller QF2 will be, and the quantization step of the determined second quantization matrix will be larger. Through the second quantization operation, more high-frequency details can be quantized away.
[0224] Optionally, the implementation of S602 in the second implementation may include but is not limited to the following two specific operations:
[0225] The first specific operation: The image compression device performs a first quantization operation and an inverse quantization operation of the first quantization operation on the frequency domain coefficient set based on the second quantization matrix to obtain a second quantization coefficient set.
[0226] Among them, for the first quantization operation, the above-mentioned glossary part has been described. Here, the first quantization operation is performed on the frequency domain coefficient set based on the second quantization matrix, that is, the frequency domain coefficient set is divided by the second quantization matrix to obtain an integer result, and then the integer result is multiplied by the second quantization matrix to obtain an integer result as the second quantization coefficient set.
[0227] Exemplarily, the image compression device determines the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block through the above first determination method, and completes the second quantization operation according to the first specific operation. The process of compressing the image block by the image compression method provided in the embodiments of the present application can Figure 11 as shown. As Figure 11 shown, the image block undergoes a first transformation to obtain a frequency domain coefficient set of the image block. Through image feature analysis, the eigenvalue X of the image block is obtained. Then, according to the eigenvalue X and the first quantization matrix of the image block, the second quantization matrix of the image block is determined. Next, based on the second quantization matrix, the frequency domain coefficient set is successively subjected to a quantization operation and an inverse quantization operation of the first quantization operation to obtain a second quantization coefficient set. Next, the first quantization operation is performed on the second quantization coefficient set based on the first quantization matrix according to the description of S603 above to obtain a first quantization coefficient set. Finally, entropy coding is performed on the first quantization coefficient set to obtain the compressed data of the image block.
[0228] Exemplarily, the image compression device determines the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block through the above second determination method, and completes the second quantization operation according to the first specific operation. The process of compressing the image block by the image compression method provided in the embodiments of the present application can Figure 12 as shown. As Figure 12 shown, the image block undergoes a first transformation to obtain a frequency domain coefficient set of the image block. Through image feature analysis, the eigenvalue X of the image block is obtained. The second quality factor is determined according to the first quality factor according to the above steps 1 to step 3. According to the eigenvalue X and the second quality factor, the second quantization matrix of the image block is determined. Next, based on the second quantization matrix, the frequency domain coefficient set is successively subjected to a first quantization operation and an inverse quantization operation of the first quantization operation to obtain a second quantization coefficient set. Next, the first quantization matrix of the image block is calculated according to the first quality factor, and the first quantization operation is performed on the second quantization coefficient set based on the first quantization matrix according to the description of S603 above to obtain a first quantization coefficient set. Finally, entropy coding is performed on the first quantization coefficient set to obtain the compressed data of the image block.
[0229] Exemplarily, the process by which the image compression device successively performs a first quantization operation and an inverse quantization operation of the first quantization operation on the frequency domain coefficient set TC based on the second quantization matrix QM2 to obtain a second quantization coefficient set TC' can be expressed as the following formulas (1) and (2). Formula (1) is the first quantization operation on the frequency domain coefficient set TC based on the second quantization matrix QM2 to obtain a result QC1, and formula (2) is the inverse quantization operation of the first quantization operation on the result QC2 of formula (1) based on the second quantization matrix QM2 to obtain a second quantization coefficient set TC' with high-frequency coefficients removed.
[0230] QC1 = TC / QM2 Equation (1).
[0231] TC' = QM2 * QC1 Equation (2).
[0232] Where ". / " is matrix point division operation, and ".*" is matrix point multiplication operation.
[0233] Exemplarily, in practical applications, if the image compression device performs the processes of S601 to S604 on each image block in the image to be compressed, the second quantization matrix of the image block in the ROI region can be the first quantization matrix of this image block, and the second quantization matrix of the image block in the non-ROI region can be obtained according to the method described in the second implementation above. If the second quantization operation is completed according to the first specific operation above, the process of compressing the image block by the image compression method provided by the embodiments of the present application can Figure 13 as shown. As Figure 13 shown, the image block undergoes the first transformation to obtain the frequency domain coefficient set of this image block. The image compression device obtains the quantization matrix (the first quantization matrix in the ROI region, the second quantization matrix in the non-ROI region) after completing the second quantization operation. Next, based on the quantization matrix after completing the second quantization operation, the frequency domain coefficient set is successively subjected to the first quantization operation and the inverse quantization operation of the first quantization operation to obtain the second quantization coefficient set. Next, the second quantization coefficient set is subjected to the first quantization operation based on the first quantization matrix according to the description of S603 above to obtain the first quantization coefficient set. Finally, entropy coding is performed on the first quantization coefficient set to obtain the compressed data of the image block.
[0234] Exemplarily, in practical applications, if the image compression device performs the processes of S601 to S604 on each image block in the image to be compressed, the second quantization matrix of the image block in the ROI region can be the first quantization matrix of this image block, the second quantization matrix of the image block in the non-ROI region can be obtained according to the method described in the second implementation above, and the ROI is determined by AI recognition based on target detection. The process of compressing the data block component by the image compression method provided by the embodiments of the present application can Figure 14 as shown. As Figure 14As shown, the input image is segmented into image blocks, and the frequency domain coefficient sets of the image blocks are obtained through a first transformation. For the AI-based object detection of the input image, ROI indication information is obtained. The image compression device acquires quantization matrices (the first quantization matrix for the ROI region and the second quantization matrix for the non-ROI region) that have completed the second quantization operation. Next, based on the quantization matrices that have completed the second quantization operation and in combination with the ROI indication information, the frequency domain coefficient sets are successively subjected to a first quantization operation and an inverse quantization operation of the first quantization operation to obtain a second quantization coefficient set. Next, the second quantization coefficient set is subjected to the first quantization operation based on the first quantization matrix according to the description in S603 above to obtain a first quantization coefficient set. Finally, entropy coding is performed on the first quantization coefficient set to obtain the compressed data of the image block.
[0235] Furthermore, for the first quantization operation and the inverse quantization operation of the first quantization operation in the first specific operation, they respectively correspond to division and multiplication operations. To save the hardware implementation cost, the first quantization operation and the inverse quantization operation of the first quantization operation can be implemented through comparison operations, avoiding multiplication and division operations, and hardly increasing the cost of hardware logic implementation. The comparison operation is as follows in the second specific operation.
[0236] Second specific operation: The image compression device determines the second quantization matrix of the image block according to the quantization information of the first quantization matrix of the image block and the eigenvalue of the image block; compares the elements in the frequency domain coefficient set with the elements at the corresponding positions in the second quantization matrix of the image block, and based on a preset rule, determines the second quantization coefficient set of the image block.
[0237] Among them, the preset rule may include: when the element at the first position in the frequency domain coefficient set of the image block is greater than the element at the first position in the second quantization matrix of the image block, retain the element at the first position in the frequency domain coefficient set of the image block; the first position is any position in the frequency domain coefficient set; when the element at the first position in the frequency domain coefficient set of the image block is less than the element at the first position in the second quantization matrix of the image block, set the element at the first position in the frequency domain coefficient set to zero; when the element at the first position in the frequency domain coefficient set of the image block is equal to the element at the first position in the second quantization matrix of the image block, retain or set to zero the element at the first position in the frequency domain coefficient set.
[0238] Exemplarily, in the second specific operation, in the process of performing the second quantization operation on the frequency domain coefficient set TC based on the second quantization matrix to obtain the second quantization coefficient set, the relationship between the element TC′(i, j) in the i-th row and j-th column of the second quantization coefficient set, the element TC(i, j) in the i-th row and j-th column of the frequency domain coefficient set TC, and the element QM2(i, j) in the i-th row and j-th column of the second quantization matrix satisfies the following expression:
[0239]
[0240] Exemplarily, in the second specific operation, the process of compressing an image block by the image compression method provided in the embodiments of the present application can be Figure 15 as shown. As Figure 15 shown, the image block undergoes a first transformation to obtain a frequency coefficient set of the image block. A comparison operation is performed on the frequency coefficient set based on a second quantization matrix, that is, the process of completing the second quantization operation in the above second specific operation, to obtain a second quantization coefficient set. Next, a first quantization operation is performed on the second quantization coefficient set based on the first quantization matrix according to the description of S603 above, to obtain a first quantization coefficient set. Finally, entropy coding is performed on the first quantization coefficient set to obtain the compressed data of the image block.
[0241] The image compression method provided in the embodiments of the present application will be described below through specific examples.
[0242] Assume that when the image compression device processes a certain component set of a certain image block to be processed, according to the second implementation above, the texture feature X = 1426 of the component set of the image block is calculated, and the adjustment coefficient α = 2 is taken. According to the above steps 1 to 3, ΔQF = α * log2(X) can be calculated to obtain ΔQF = 20. Assume that the user inputs QF1 = 90. According to the formula QF2 = |QF1| - clip(0, MaxΔQF, ΔQF), QF2 = 70 can be calculated. According to the above first relational expression, QF1, QF2, and the standard quantization matrix, the first quantization matrix QM1 and the second quantization matrix QM2 of the component set of the image block are obtained as follows:
[0243]
[0244] Assume that the component set of the image block is as follows:
[0245]
[0246] The frequency coefficient set TC after the DCT transformation of the component set of the image block is as follows:
[0247]
[0248] Based on the second quantization matrix QM2 of the component set of the image block, the result QC1 after the first quantization operation on the frequency coefficient set TC of the component set of the image block is as follows, QC1 = TC. / QM2.
[0249]
[0250] The result TC′ of the inverse quantization operation of the first quantization operation on QC1 of the component set of the image block based on the second quantization matrix QM2 of the component set of the image block is as follows: TC′ = QC1.*QM2. TC′ is essentially the frequency domain coefficient set after the second quantization operation. Compared with TC, more elements in TC′ are quantized to 0.
[0251]
[0252] Based on the first quantization matrix QM1 of the component set of the image block, the first quantization operation is performed on TC′ of the component set of the image block, and the final quantization result QC2 (the second quantization coefficient set) is obtained as follows: QC2 = TC′. / QM1.
[0253]
[0254] If the image compression device directly performs the first quantization operation on the frequency coefficient set TC of the component set of the image block based on the first quantization matrix QM1 of the component set of the image block, that is, the result QC3 after quantization in the JPEG compression standard is as follows: QC3 = TC. / QM1.
[0255]
[0256] Comparing QC3 and QC2, in QC2, more coefficients are quantized to 0, and the amplitudes of most low-frequency coefficients are also smaller. From the characteristics of entropy coding, it can be known that the number of bits required for encoding QC2 will be significantly less than the number of bits for encoding QC3.
[0257] The above mainly introduces the solution provided in the embodiments of the present application from the perspective of the working principle of the image compression device. It can be understood that in order to implement the above functions, the above image compression device includes the corresponding hardware structure and / or software module for executing each function. Those skilled in the art should easily realize that, combined with the units and algorithm steps of each example described in the embodiments disclosed in this article, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.
[0258] Embodiments of the present application can divide the functional modules of the image compression device provided in the present application according to the above method examples. For example, each functional module can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. It should be noted that the division of modules in the embodiments of the present application is illustrative, only a logical function division, and there can be other division methods in actual implementation.
[0259] In the case of dividing each functional module corresponding to each function, Figure 16 FIG. shows a possible structural schematic diagram of the image compression device 160 involved in the above embodiment. The image compression device 160 can be a functional module or a chip. As Figure 16 shown, the image compression device 160 can include: a transformation unit 1601, a second quantization unit 1602, a first quantization unit 1603, and an encoding unit 1604. Among them, the transformation unit 1601 is used to execute Figure 6 the process S601 in; the second quantization unit 1602 is used to execute Figure 6 the process S602 in; the first quantization unit 1603 is used to execute Figure 6 the process S603 in; the encoding unit 1604 is used to execute Figure 6 the process S604 in. Among them, all relevant contents of each step involved in the above method embodiment can be cited in the function description of the corresponding functional module, and will not be elaborated here.
[0260] Further, as Figure 17 shown, the image compression device 160 may further include a first acquisition unit 1605. The first acquisition unit 1605 is used to acquire the ROI in the image to be compressed.
[0261] Further, as Figure 17 shown, the image compression device 160 may further include a second acquisition unit 1606. The second acquisition unit 1606 is used to acquire the eigenvalue of the image block.
[0262] In the case of using an integrated unit, Figure 18 FIG. shows another possible structural schematic diagram of the image compression device involved in the above embodiment. As Figure 18 shown, the image compression device 180 can include: a processing module 1801, a communication module 1802. The processing module 1801 is used to control and manage the actions of the image compression device 180, and the communication module 1802 is used to communicate with other devices. For example, the processing module 1801 is used to execute Figure 3Any one of the processes S601 to S604. The image compression device 180 may further include a storage module 1803 for storing program codes and data of the image compression device 180.
[0263] Wherein, the processing module 1801 may be Figure 4 The processor 401 in the physical structure of the image compression device 40 shown, which may be a processor or a controller. For example, it may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA, or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logical blocks, modules, and circuits described in conjunction with the disclosure of the present application. The processing module 801 may also be a combination that implements computing functions, such as a combination including one or more microprocessors, a combination of a DSP and a microprocessor, and so on. The communication module 1802 may be Figure 4 The transceiver 403 in the physical structure of the image compression device 40 shown. The communication module 1802 may be a communication port, or may be a transceiver, a transceiver circuit, or a communication interface, etc. Alternatively, the above communication interface may implement communication with other devices through the above elements having transceiver functions. The above elements having transceiver functions may be implemented by an antenna and / or a radio frequency device. The storage module 1803 may be Figure 4 The memory 402 in the physical structure of the image compression device 40 shown.
[0264] When the processing module 1801 is a processor, the communication module 1802 is a transceiver, and the storage module 1803 is a memory, the image compression device 40 involved in the embodiments of the present application Figure 18 may be Figure 4 The image compression device 40 shown.
[0265] As described above, the image compression device 160 or the image compression device 180 provided in the embodiments of the present application may be used to implement the corresponding functions in the methods implemented in the above embodiments of the present application. For the sake of convenience of description, only the parts related to the embodiments of the present application are shown. For the specific technical details not disclosed, please refer to the embodiments of the present application.
[0266] As another form of this embodiment, a computer-readable storage medium is provided, on which instructions are stored, and when the instructions are executed, the image compression method in the above method embodiment is executed.
[0267] As another form of this embodiment, a computer program product containing instructions is provided. When the computer program product runs on a computer, the computer is caused to execute the image compression method in the above method embodiment when executed.
[0268] The embodiments of the present application further provide a chip system, which includes a processor for implementing the technical methods of the embodiments of the present invention. In a possible design, the chip system further includes a memory for storing the necessary program instructions and / or data of the embodiments of the present invention. In a possible design, the chip system further includes a memory for the processor to call the application program code stored in the memory. The chip system may be composed of one or more chips, or may include chips and other discrete devices, and the embodiments of the present application do not make specific limitations on this.
[0269] The steps of the methods or algorithms described in combination with the disclosure of the present application can be implemented in a hardware manner or by a processor executing software instructions. The software instructions may be composed of corresponding software modules, and the software modules may be stored in RAM, flash memory, ROM, erasable programmable ROM (EPROM), electrically EPROM (EEPROM), registers, hard disks, removable hard disks, CD-ROMs or any other form of storage medium well-known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium may also be a component of the processor. The processor and the storage medium may be located in an ASIC. In addition, the ASIC may be located in the core network interface device. Of course, the processor and the storage medium may also exist as discrete components in the core network interface device. Alternatively, the memory may be coupled to the processor, for example, the memory may exist independently and be connected to the processor through a bus. The memory may also be integrated with the processor. The memory may be used to store the application program code for implementing the technical solutions provided by the embodiments of the present application and be controlled by the processor to execute. The processor is used to execute the application program code stored in the memory, thereby implementing the technical solutions provided by the embodiments of the present application.
[0270] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
[0271] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of the devices or units can be in electrical, mechanical or other forms.
[0272] The units described as separate components may or may not be physically separated. The components displayed as units may be one physical unit or multiple physical units, that is, they can be located in one place, or they can be distributed to multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0273] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
[0274] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions for causing a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, optical disks, and other media that can store program codes.
[0275] As described above, it is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claimed rights.
Claims
1. An image compression method, characterized in that, The method includes: Performing a first transformation on an image block in the image to be compressed to obtain a set of frequency domain coefficients of the image block; the image block is a continuous region in the image to be compressed that includes a plurality of pixel points; Determining a second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue of the image block; the first quantization matrix, the second quantization matrix, and the row and column sizes of the image block are the same, and the magnitude of an element in the second quantization matrix is greater than the magnitude of the element in the same position in the first quantization matrix; the eigenvalue is used to indicate any one of the following characteristics of the image block: spatial domain characteristic, frequency domain characteristic, or texture characteristic; Based on the second quantization matrix, performing a second quantization operation on the set of frequency domain coefficients to obtain a set of second quantization coefficients; the second quantization operation is used to remove high-frequency components in the set of frequency domain coefficients and maintain or reduce the magnitude of low-frequency components in the set of frequency domain coefficients; the number of high-frequency components removed by the second quantization operation is related to the image block; the number of high-frequency components removed by the second quantization operation is greater than or equal to the number of high-frequency components removed by performing a first quantization operation based on the first quantization matrix; Performing a first quantization operation on the set of second quantization coefficients based on the first quantization matrix to obtain a set of first quantization coefficients; Performing entropy coding on the set of first quantization coefficients to obtain compressed data of the image block.
2. The method according to claim 1, wherein The performing, based on the second quantization matrix, a second quantization operation on the set of frequency domain coefficients to obtain a set of second quantization coefficients includes: Based on the second quantization matrix, performing the first quantization operation and the inverse quantization operation of the first quantization operation on the set of frequency domain coefficients in sequence to obtain the set of second quantization coefficients.
3. The method according to claim 1, wherein The performing, based on the second quantization matrix, a second quantization operation on the set of frequency domain coefficients to obtain a set of second quantization coefficients includes: Comparing the magnitudes of the elements in the set of frequency domain coefficients with the elements at the corresponding positions in the second quantization matrix, and determining the set of second quantization coefficients based on a preset rule; wherein the preset rule includes: when the element at the first position in the set of frequency domain coefficients is greater than the element at the first position in the second quantization matrix, retaining the element at the first position in the set of frequency domain coefficients; the first position is any position in the set of frequency domain coefficients; when the element at the first position in the set of frequency domain coefficients is less than the element at the first position in the second quantization matrix, setting the element at the first position in the set of frequency domain coefficients to zero; when the element at the first position in the set of frequency domain coefficients is equal to the element at the first position in the second quantization matrix, retaining or setting the element at the first position in the set of frequency domain coefficients to zero.
4. The method according to claim 2 or 3, characterized in that, The determining the second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue includes: Determining the QM2 according to the relationship between the second quantization matrix QM2, the first quantization matrix QM1, and the eigenvalue X; Among them, the relationship between the QM2, the QM1, and the eigenvalue X satisfies the following expression: QM2 = QM1 + F1(X); where the F1(·) is a first preset function.
5. The method according to claim 2 or 3, characterized in that, The quantization information of the first quantization matrix includes a first quality factor QF1 for determining the first quantization matrix, and the QF1 is used to calculate the first quantization matrix according to a first relational expression; wherein, the first relational expression is a relational expression between the quality factor and a standard quantization matrix QM S of; The determining of the second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue includes: Determining a quality factor offset value ΔQF according to the eigenvalue X; where the ΔQF satisfies the following expression: ΔQF = F2(X); the F2(·) is a second preset function; Calculating a second quality factor QF2 according to the ΔQF and the QF1; where the QF2 satisfies the following expression: QF2 = |QF1| - F3(ΔQF); the F3(·) is a third preset function; Determining the second quantization matrix according to the QF2 and the first relationship expression.
6. The method according to any one of claims 1 to 3, characterized in that The method further includes: Obtaining a region of interest ROI in the image to be compressed; If the image block is outside the ROI, performing the determining of the second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue.
7. The method according to claim 6, wherein The obtaining of the region of interest ROI in the image to be compressed includes: Receiving input ROI region information, and determining the region indicated by the ROI region information in the image to be compressed as the ROI; the ROI region information is used to indicate the coordinate position of the ROI in the image to be compressed; Or, Receiving input Map image information of the image to be compressed, and determining the region of interest ROI in the image to be compressed based on the Map image information, where the Map image information is used to indicate whether each image block in the image to be compressed is in the ROI region.
8. An image compression device, characterized in that, The apparatus includes: A transformation unit, configured to perform a first transformation on an image block in the image to be compressed to obtain a set of frequency domain coefficients of the image block; the image block is a continuous region including multiple pixel points in the image to be compressed; A second quantization unit, configured to determine a second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue of the image block; the first quantization matrix, the second quantization matrix, and the row and column sizes of the image block are the same, and the magnitude of an element in the second quantization matrix is greater than the magnitude of the element at the same position in the first quantization matrix; the eigenvalue is used to indicate any one of the following features of the image block: spatial domain feature, frequency domain feature, or texture feature; based on the second quantization matrix, performing a second quantization operation on the set of frequency domain coefficients obtained by the transformation unit to obtain a set of second quantization coefficients; the second quantization operation is used to remove high-frequency components in the set of frequency domain coefficients, and maintain or reduce the magnitude of low-frequency components in the set of frequency domain coefficients; the number of high-frequency components removed by the second quantization operation is related to the image block; the number of high-frequency components removed by the second quantization operation is greater than or equal to the number of high-frequency components removed by performing a first quantization operation based on the first quantization matrix. A first quantization unit, configured to perform a first quantization operation on the second quantization coefficient set based on a first quantization matrix to obtain a first quantization coefficient set; An encoding unit, configured to perform entropy encoding on the first quantization coefficient set obtained by the first quantization unit to obtain compressed data of the image block.
9. The apparatus according to claim 8, wherein: The second quantization unit is specifically configured to: Based on the second quantization matrix, perform the first quantization operation and the inverse quantization operation of the first quantization operation on the frequency-domain coefficient set successively to obtain the second quantization coefficient set.
10. The apparatus according to claim 8, wherein: The second quantization unit is specifically configured to: Compare the magnitudes of the elements in the frequency-domain coefficient set with the elements at the corresponding positions in the second quantization matrix, and determine the second quantization coefficient set based on a preset rule; wherein, the preset rule includes: when the element at a first position in the frequency-domain coefficient set is greater than the element at the first position in the second quantization matrix, retain the element at the first position in the frequency-domain coefficient set; the first position is any position in the frequency-domain coefficient set; when the element at the first position in the frequency-domain coefficient set is less than the element at the first position in the second quantization matrix, set the element at the first position in the frequency-domain coefficient set to zero; when the element at the first position in the frequency-domain coefficient set is equal to the element at the first position in the second quantization matrix, retain or set the element at the first position in the frequency-domain coefficient set to zero.
11. The device according to claim 9 or 10, characterized in that, The second quantization unit determines the second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue, including: Determine the QM2 according to the relationship between the second quantization matrix QM2, the first quantization matrix QM1, and the eigenvalue X; wherein, the relationship between the QM2, the QM1, and the eigenvalue X satisfies the following expression: QM2 = QM1 + F1(X); where, the F1(·) is a first preset function.
12. The device according to claim 9 or 10, characterized in that, The quantization information of the first quantization matrix includes a first quality factor QF1 for determining the first quantization matrix, where the QF1 is used to calculate the first quantization matrix according to a first relational expression; wherein, the first relational expression is a relational expression between a quality factor and a standard quantization matrix QM S of; The second quantization unit determines the second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue, including: Determine a quality factor offset value ΔQF according to the eigenvalue X; wherein, the ΔQF satisfies the following expression: ΔQF = F2(X); the F2(·) is a second preset function; Calculate a second quality factor QF2 according to the ΔQF and the QF1; wherein, the QF2 satisfies the following expression: QF2 = |QF1| - F3(ΔQF); the F3(·) is a third preset function; Determine the second quantization matrix according to the QF2 and the first relational expression.
13. The apparatus according to any one of claims 8-10, wherein: The apparatus further includes: a first obtaining unit, configured to obtain a region of interest ROI in the image to be compressed; The second quantization unit is specifically configured to: if the image block is outside the ROI, determine the second quantization matrix of the image block according to the quantization information of the first quantization matrix and the eigenvalue.
14. The device according to claim 13, characterized in that, The first obtaining unit is specifically configured to: receive the input ROI region information, and determine the region indicated by the ROI region information in the image to be compressed as the ROI; the ROI region information is used to indicate the coordinate position of the ROI in the image to be compressed; or receive the input Map image information of the image to be compressed, and determine the region of interest ROI in the image to be compressed based on the Map image information, where the Map image information is used to indicate whether each image block in the image to be compressed is in the ROI region.
15. An image compression device, characterized in that, The image compression device includes: a memory, a processor, and a transmission interface; The transmission interface is used to receive and send data; The processor is configured to call the program instructions stored in the memory, so that the image compression device executes the image compression method according to any one of claims 1 to 7.
16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions, and when the program instructions run on a computer or a processor, the computer or the processor is caused to execute the image compression method according to any one of claims 1 to 7.
17. A computer program product, characterized in that, including program instructions, and when the program instructions run on a computer or a processor, the computer or the processor is caused to execute the image compression method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Image compression method and device, and server
CN105407352A
Visual perception correction image compression method based on DCT transform
CN106612436A