WO2022067526A1 - 一种图像压缩方法及装置 - Google Patents

一种图像压缩方法及装置 Download PDF

Info

Publication number
WO2022067526A1
WO2022067526A1 PCT/CN2020/118910 CN2020118910W WO2022067526A1 WO 2022067526 A1 WO2022067526 A1 WO 2022067526A1 CN 2020118910 W CN2020118910 W CN 2020118910W WO 2022067526 A1 WO2022067526 A1 WO 2022067526A1
Authority
WO
WIPO (PCT)
Prior art keywords
quantization
image
coefficient set
image block
quantization matrix
Prior art date
Application number
PCT/CN2020/118910
Other languages
English (en)
French (fr)
Inventor
陈绍林
付洋
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2020/118910 priority Critical patent/WO2022067526A1/zh
Priority to CN202080105452.XA priority patent/CN116325752A/zh
Publication of WO2022067526A1 publication Critical patent/WO2022067526A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/60Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using transform coding
    • H04N19/625Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using transform coding using discrete cosine transform [DCT]

Definitions

  • the embodiments of the present application relate to the field of image processing, and in particular, to an image compression method and apparatus.
  • JPEG Joint Photographic Expert Group
  • a frame of image is first divided into a series of 16 ⁇ 16 image blocks, each 16 ⁇ 16 image block is further divided into four 8 ⁇ 8 image blocks, and then for each 8 ⁇ 8 image block
  • the image blocks are compressed using the JPEG compression process shown in Figure 1.
  • Each luminance component and chrominance component in an 8 ⁇ 8 image block are respectively subjected to a compression process as shown in FIG. 1 to complete the compression of the 8 ⁇ 8 image block.
  • a component (luminance or chrominance) of an 8 ⁇ 8 image block is first subjected to discrete cosine transform (DCT), and the spatial data block is transformed into the frequency domain and expressed as 8 ⁇ 8 DCT coefficients, In the frequency domain, the different frequency components contained in the spatial data block are separated to obtain the direct current component (DC) in the upper left corner of the DCT coefficient and the alternating current component (AC) in other positions.
  • DCT discrete cosine transform
  • the DCT coefficients are divided by the element value at the corresponding position in the quantization matrix (called the quantization step size) for quantization, and the quantized value will be truncated or rounded to the nearest integer.
  • the purpose of compression is achieved by reducing the amount of data in the frequency domain DCT coefficients through quantization.
  • the quantization step size is gradually increased in the quantization matrix according to the frequency from low to high to achieve a better compression ratio.
  • entropy encoding is performed on the quantized data to obtain compressed data.
  • the core link of JPEG compression is the quantization process, but all image blocks in an 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, so It cannot meet the different visual requirements of users for different image areas in one image, and at the same time, the compressed data bit rate obtained by the current compression scheme occupies a high storage space.
  • the embodiments of the present application provide an image compression method and device, which realizes that different image blocks in a frame of image are quantized according to different quantization step sizes, which can meet the different visual needs of users for different image areas in different scenes; For areas that the user does not pay attention to, a larger quantization step can be used to further improve the compression rate, and reduce the bit rate to reduce the storage space of the picture.
  • a first aspect provides an image compression method, the method may include: performing a first transformation on an image block in an image to be compressed to obtain a frequency domain coefficient set of the image block; the image block is an image to be compressed including a plurality of pixels in the image block The continuous area of the points; the second quantization operation is performed on the frequency domain coefficient set to obtain the second quantization coefficient set; the second quantization operation is used to remove the high frequency components in the frequency domain coefficient set, and maintain or reduce the frequency domain coefficient set.
  • Amplitude size; 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 high frequency components removed by the first quantization operation based on the first quantization matrix The number of components; the first quantization operation is performed on the second quantization coefficient set based on the first quantization matrix to obtain the first quantization coefficient set; the entropy encoding is performed on the first quantization coefficient set to obtain the compressed data of the image block.
  • a second quantization operation related to the image block is first performed on the frequency coefficient set of the data block, the high-frequency components are removed, the low-frequency components are maintained or reduced in amplitude, and then based on the configuration
  • the first quantization matrix of performs the first quantization operation, and then performs entropy encoding to complete the compression.
  • the quantization related to different image blocks is different, and different image blocks in one frame of image can be quantized according to different quantization step sizes, which can meet the different visual needs of users for different image areas in different scenes; realize the adjustment according to actual needs.
  • 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) to further improve the compression ratio.
  • the second quantization operation is performed on the frequency domain coefficient set to obtain the second quantized coefficient set, including: obtaining a region of interest (Region Of Interest, ROI) in the image to be compressed; In the ROI of the image to be compressed, the first N1 elements in the frequency domain coefficient set of the image block arranged in ZigZag order are retained, and the remaining elements are set to zero to obtain the second quantization coefficient set of the image block; if the image block is in the non-compressed image. ROI, the first N2 elements in the frequency domain coefficient set arranged in ZigZag order are reserved, and the remaining elements are set to zero to obtain the second quantized coefficient set of the image block. N1 is greater than N2.
  • the second quantization operation is performed in this implementation manner, the implementation process is simple, the computational complexity is low, and the cost is saved.
  • N1 is 63 and N2 is 32.
  • the image compression method provided by the present application may further include: acquiring 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 features.
  • Perform a second quantization operation on the frequency domain coefficient set to obtain a second quantization coefficient set which 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 eigenvalues of the image block, and based on the first quantization matrix of the image block.
  • the binary quantization matrix performs the third operation on the frequency coefficient set to obtain the second quantized coefficient set of the image block.
  • the eigenvalue of the image block is used to reflect the complexity of the image block to the visual system.
  • the second quantization matrix of the image block is determined in combination with the eigenvalues of the image block, so that the determined second quantization matrix is consistent with the characteristics of the image block. correlation, thereby making the second quantization operation related to the characteristics of the image block.
  • the second quantization matrices of the same component set of image blocks with different characteristics are also different.
  • the first quantization matrix is a quantization matrix for performing a first quantization operation, and the first quantization matrices of the same component set of different image blocks in one 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 used to determine the quality factor of the first quantization matrix, and the first quantization can be calculated according to the quality factor and the first relational expression. matrix.
  • the first relational expression is the relational expression of the quality factor and the standard quantization matrix QMS .
  • QM qf is the calculated quantization matrix
  • floor( ) is the rounding operation
  • S satisfies the following expression:
  • the third operation may be an inverse quantization operation in which the first quantization operation and the first quantization operation are sequentially performed.
  • the third operation may include comparing the size of the element in the frequency domain coefficient set of the image block with the element at the position corresponding to the element in the second quantization matrix of the image block, and based on a preset rule, A second set of quantized coefficients for the image block is determined.
  • the preset rule may include: when the element at the first position in the frequency domain coefficient set is larger 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 the frequency domain coefficient set When the element in the first position in the frequency domain coefficient set is smaller than the element in the first position in the second quantization matrix, set the element in the first position in the frequency domain coefficient set to zero; when the element in the first position in the frequency domain coefficient set is zero; When the element is equal to the element at the first position in the second quantization matrix, the element at the first position in the frequency domain coefficient set is reserved or set to zero.
  • the image compression method provided by the present application may further include: acquiring 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 features.
  • Performing a second quantization operation on the frequency domain coefficient set to obtain a second quantization coefficient set which 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 eigenvalues of the image block, and based on the image block
  • the second quantization matrix of the block performs the first quantization operation and the inverse quantization operation of the first quantization operation successively on the frequency domain coefficient set of the image block to obtain the second quantization coefficient set of the image block.
  • the 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.
  • the first quantization operation is performed by the determined second quantization matrix related to the image block to remove the high frequency components in the frequency domain coefficient set, and the inverse quantization operation after the first quantization operation is performed on the result after the first quantization operation, keeping or Reduce the amplitude of the low frequency components in the frequency domain coefficient set to achieve compatibility with the JPEG compression standard.
  • the image compression method provided by the present application may further include: acquiring 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 features.
  • the second quantization operation is performed on the frequency domain coefficient set to obtain the 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; The size of the element in the frequency domain coefficient set of the image block is compared with the element at the corresponding position of the element in the second quantization matrix of the image block, and the second quantization coefficient set of the image block is determined based on a preset rule.
  • the preset rule may include: when the element at the first position in the frequency domain coefficient set is larger 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 the frequency domain coefficient set When the element in the first position in the frequency domain coefficient set is smaller than the element in the first position in the second quantization matrix, set the element in the first position in the frequency domain coefficient set to zero; when the element in the first position in the frequency domain coefficient set is zero; When the element is equal to the element at the first position in the second quantization matrix, the element at the first position in the frequency domain coefficient set is reserved or set to zero.
  • determining the second quantization matrix of the image block according to the quantization information and eigenvalues of the first quantization matrix includes: according to the second quantization matrix QM 2 and the first quantization matrix QM 1 , the eigenvalues The relationship of X, to determine QM 2 .
  • F 1 ( ⁇ ) is the first preset function.
  • the expression of the second quantization matrix can be determined according to actual experience configuration, so that the determined quantization matrix can better reflect the characteristics of the image block, and then realize the second quantization operation matching the characteristics of the image block, so as to achieve the In the process of image compression, the purpose of visual experience, user experience and image compression rate is taken into account.
  • the quantization information of the first quantization matrix may include determining a first quality factor QF 1 of the first quantization matrix, and QF 1 is used to calculate the first quantization matrix according to the first relational expression.
  • the first relational expression is the relational expression of the quality factor and the standard quantization matrix QMS .
  • the second quantization matrix of the image block is determined according to the quantization information of the first quantization matrix and the eigenvalue, which can be specifically implemented as: according to the eigenvalue X, the quality factor offset value ⁇ QF is determined; according to ⁇ QF and QF 1 , Calculate the second quality factor QF 2 ; determine the second quantization matrix according to QF 2 and the first relational expression.
  • the expression of the second quality factor is determined according to actual experience configuration, 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 realize the second quantization operation that matches the characteristics of the image block, so as to achieve the purpose of taking into account the visual experience, the user experience and the image compression rate in the image compression process.
  • the feature value may be used to indicate the texture feature of the image block, and the feature value X may be calculated according to the expression of the feature value X and the pixel value in the image block.
  • the expression of the feature value X and the pixel value in the image block satisfies the following relationship:
  • Pix i is the pixel value of the ith pixel in the image block to be processed
  • M is the width of the image block
  • L is the height of the image block.
  • the image compression method provided by the present application may further include: acquiring the ROI in the image to be compressed; if the image block is outside the ROI, acquiring the feature value of the image block and obtaining the feature value of the image block according to the first quantization matrix The quantization information and eigenvalues of , determine the second quantization matrix of the image block.
  • the image block is in the ROI, perform a first quantization operation on the frequency domain coefficient set based on the first quantization matrix to obtain a first quantized coefficient set, and perform entropy encoding on the first quantized coefficient set to obtain compressed data of the image block.
  • the image blocks in the non-ROI area are quantized twice to achieve the purpose of increasing the quantization step size, improving the compression rate and reducing the storage space.
  • the image blocks in the ROI area are quantized by the JPEG compression protocol, and the area of interest is flexibly encoded. While improving the quality of the area of interest, the code rate consumed by other areas is reduced, thereby saving the code rate (storage space) and further improving the compression rate.
  • acquiring the ROI in the to-be-compressed image may specifically be implemented as: receiving the input ROI area information, and determining the area indicated by the ROI area information in the to-be-compressed image as the ROI.
  • the ROI area information is used to indicate the coordinate position of the ROI in the image to be compressed.
  • the position of the ROI in the to-be-compressed image is determined by inputting the ROI area information by the user, which can better meet the user's needs.
  • acquiring the ROI in the to-be-compressed image can be specifically implemented as: receiving the input Map image information of the to-be-compressed image, determining the ROI of the region of interest in the to-be-compressed image based on the Map image information, and the Map The image information is used to indicate whether each image block in the image to be compressed is in the ROI area.
  • the location of the ROI in the to-be-compressed image is determined by inputting the Map image information of the to-be-compressed image by the user, which can better meet the user's needs.
  • acquiring the ROI in the to-be-compressed image may be specifically implemented as: acquiring the ROI in the to-be-compressed image through artificial intelligence (artificial intelligence, AI) recognition technology.
  • AI artificial intelligence
  • the machine uses AI recognition technology to automatically obtain ROI, which is efficient and easy to implement.
  • an image compression apparatus may include: a transformation unit, a second quantization unit, a first quantization unit, and an encoding unit.
  • a transformation unit configured to perform a first transformation on an image block in the to-be-compressed image to obtain a frequency domain coefficient set of the image block;
  • the image block is a continuous area including a plurality of pixel points in the to-be-compressed image.
  • the second quantization unit is configured to perform a second quantization operation on the frequency domain coefficient set obtained by the transform unit to obtain a second quantized coefficient set.
  • the second quantization operation is used to remove 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; the second quantization operation The number of high-frequency components removed by the 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; the first quantization unit is used to perform the first quantization coefficient set on the second quantization coefficient set based on the first quantization matrix.
  • a quantization operation is performed to obtain a first set of quantized coefficients.
  • the encoding unit is 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.
  • a second quantization operation related to the image block is first performed on the frequency coefficient set of the data block, the high-frequency components are removed, the low-frequency components are maintained or reduced in amplitude, and then based on the configuration
  • the first quantization matrix of performs the first quantization operation, and then performs entropy encoding to complete the compression.
  • the quantization related to different image blocks is different, and different image blocks in one frame of image can be quantized according to different quantization step sizes, which can meet the different visual needs of users for different image areas in different scenes; realize the adjustment according to actual needs.
  • 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) to further improve the compression ratio.
  • the image compression apparatus further includes a first acquiring unit, configured to acquire the ROI in the image to be compressed.
  • the second quantization unit is specifically used to: if the image block is in the ROI of the image to be compressed, retain the first N1 elements in the frequency domain coefficient set arranged in ZigZag order, and set the remaining elements to zero to obtain the second quantization coefficient set; For the non-ROI of the image to be compressed, the first N2 elements in the frequency domain coefficient set arranged in ZigZag order are reserved, and the remaining elements are set to zero to obtain the second quantized coefficient set.
  • N1 is greater than N2.
  • the second quantization operation is performed in this implementation manner, the implementation process is simple, the computational complexity is low, and the cost is saved.
  • N1 is 63 and N2 is 32.
  • the image compression apparatus may further include a second obtaining unit, configured to obtain 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 eigenvalues of the image block, and perform a third operation on the frequency coefficient set based on the second quantization matrix to obtain A second set of quantized coefficients for the image block.
  • the third operation may be an inverse quantization operation in which the first quantization operation and the first quantization operation are sequentially performed.
  • the third operation may include comparing the size of the element in the frequency domain coefficient set of the image block with the element at the position corresponding to the element in the second quantization matrix of the image block, and based on a preset rule, A second set of quantized coefficients for the image block is determined.
  • the preset rule may include: when the element at the first position in the frequency domain coefficient set is larger 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 the frequency domain coefficient set When the element in the first position in the frequency domain coefficient set is smaller than the element in the first position in the second quantization matrix, set the element in the first position in the frequency domain coefficient set to zero; when the element in the first position in the frequency domain coefficient set is zero; When the element is equal to the element at the first position in the second quantization matrix, the element at the first position in the frequency domain coefficient set is reserved or set to zero.
  • the image compression apparatus may further include a second obtaining unit, configured to obtain 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 Type: 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 eigenvalues of the image block, and determine the frequency domain of the image block based on the second quantization matrix of the image block
  • the first quantization operation and the inverse quantization operation of the first quantization operation are successively performed on the coefficient set to obtain the second quantization coefficient set of the image block.
  • the 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.
  • the first quantization operation is performed by the determined second quantization matrix related to the image block to remove the high frequency components in the frequency domain coefficient set, and the inverse quantization operation after the first quantization operation is performed on the result after the first quantization operation, keeping or Reduce the amplitude of the low frequency components in the frequency domain coefficient set to achieve compatibility with the JPEG compression standard.
  • the image compression apparatus may further include a second obtaining unit, configured to obtain 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 Type: spatial domain feature, frequency domain feature or texture feature.
  • the second quantization unit is specifically used 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 eigenvalues of the image block; and compare the elements in the frequency domain coefficient set of the image block with the image block The size of the element at the corresponding position of the element in the second quantization matrix is compared, and the second quantization coefficient set of the image block is determined based on a preset rule.
  • the preset rule may include: when the element at the first position in the frequency domain coefficient set is larger 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 the frequency domain coefficient set When the element in the first position in the frequency domain coefficient set is smaller than the element in the first position in the second quantization matrix, set the element in the first position in the frequency domain coefficient set to zero; when the element in the first position in the frequency domain coefficient set is zero; When the element is equal to the element at the first position in the second quantization matrix, the element at the first position in the frequency domain coefficient set is reserved or set to zero.
  • the second quantization unit determines the second quantization matrix of the image block according to the quantization information and eigenvalues of the first quantization matrix, including: according to the second quantization matrix QM 2 and the first quantization matrix QM 1.
  • F 1 ( ⁇ ) is the first preset function.
  • the expression of the second quantization matrix can be determined according to actual experience configuration, so that the determined quantization matrix can better reflect the characteristics of the image block, and then realize the second quantization operation matching the characteristics of the image block, so as to achieve the In the process of image compression, the purpose of visual experience, user experience and image compression rate is taken into account.
  • the quantization information of the first quantization matrix may include determining a first quality factor QF 1 of the first quantization matrix, and QF 1 is used to calculate the first quantization matrix according to the first relational expression.
  • the first relational expression is the relational expression of the quality factor and the standard quantization matrix QMS .
  • the second quantization unit determines the second quantization matrix of the image block according to the quantization information and eigenvalues of the first quantization matrix, including: according to the eigenvalue X, determining the quality factor offset value ⁇ QF; according to ⁇ QF and QF 1 , calculating the second quality Factor QF 2 ; according to QF 2 and the first relational expression, determine the second quantization matrix.
  • the expression of the second quality factor is determined according to actual experience configuration, 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 realize the second quantization operation that matches the characteristics of the image block, so as to achieve the purpose of taking into account the visual experience, the user experience and the image compression rate in the image compression process.
  • the image compression apparatus may further include a first acquiring unit, configured to acquire the ROI in the to-be-compressed image.
  • the second quantization unit is specifically configured to: if the image block is outside the ROI, perform the acquisition of the eigenvalues of the image block and determine the second quantization matrix of the image block according to the quantization information and eigenvalues of the first quantization matrix;
  • 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 quantized coefficient set.
  • the image blocks in the non-ROI area are quantized twice to achieve the purpose of increasing the quantization step size, improving the compression rate and reducing the storage space.
  • the image blocks in the ROI area are quantized by the JPEG compression protocol, and the area of interest is flexibly encoded. While improving the quality of the area of interest, the code rate consumed by other areas is reduced, thereby saving the code rate (storage space) and further improving the compression rate.
  • the first obtaining 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.
  • the position of the ROI in the to-be-compressed image is determined by inputting the ROI area information by the user, which can better meet the user's needs.
  • the first acquisition unit is specifically configured to: receive the input Map image information of the image to be compressed, determine the ROI of the region of interest in the image to be compressed based on the Map image information, and the Map image information is used to indicate Whether each image block in the image to be compressed is in the ROI area.
  • the location of the ROI in the to-be-compressed image is determined by inputting the Map image information of the to-be-compressed image by the user, which can better meet the user's needs.
  • the image compression apparatus provided in the second aspect is configured to execute the image compression method provided by the first aspect or any possible implementation manner of the first aspect, and for specific implementation, refer to the foregoing first aspect or the first aspect. any possible implementation of the aspect.
  • the present application provides an image compression apparatus, which can implement the functions in the method examples described in the first aspect above, and the functions can be implemented by hardware or by executing corresponding software in hardware.
  • the hardware or software includes one or more modules corresponding to the above functions.
  • the image compression device may exist in the form of a chip product.
  • the image compression apparatus may include a processor and a transmission interface.
  • the transmission interface is used to receive and send data.
  • the processor is configured to invoke program instructions stored in the memory to cause the image compression apparatus to perform the functions in the method examples described in the first aspect above.
  • a computer-readable storage medium is provided, and program instructions are stored in the computer-readable storage medium, and when the program instructions are executed on a computer or a processor, the computer or the processor is made to execute the above-mentioned first aspect or The image compression method provided by the second aspect or any possible implementation manner thereof.
  • a computer program product includes program instructions that, when the program instructions are run on a computer or processor, cause the computer or processor to execute the first aspect or any possible implementation thereof The image compression method provided by the method.
  • a chip system in a sixth aspect, includes a processor, and may also include a memory, for implementing the corresponding functions in the above method.
  • the chip system can be composed of chips, and can also include chips and other discrete devices.
  • an image compression system comprising the image compression apparatus of the second aspect or the third aspect.
  • FIG. 1 is a schematic diagram of an exemplary JPEG compression process provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of an exemplary matrix provided by an embodiment of the present application.
  • FIG. 3 is a schematic diagram of an exemplary image compression transmission scenario provided by an embodiment of the present application.
  • FIG. 4 is a schematic structural diagram of an exemplary image compression apparatus provided by an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of an exemplary image block provided by an embodiment of the present application.
  • FIG. 6 is a schematic flowchart of an exemplary image compression method provided by an embodiment of the present application.
  • FIG. 7 is a schematic diagram of an exemplary process of compressing an image block provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of another exemplary process of compressing image blocks provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of another exemplary process of compressing an image block provided by an embodiment of the present application.
  • FIG. 10 is a schematic diagram of another exemplary process of compressing image blocks provided by an embodiment of the present application.
  • FIG. 11 is a schematic diagram of still another exemplary process of compressing an image block provided by an embodiment of the present application.
  • FIG. 12 is a schematic diagram of still another exemplary process of compressing image blocks provided by an embodiment of the present application.
  • FIG. 13 is a schematic diagram of still another exemplary process of compressing image blocks provided by an embodiment of the present application.
  • FIG. 14 is a schematic diagram of still another exemplary process of compressing an image block provided by an embodiment of the present application.
  • FIG. 15 is a schematic diagram of still another exemplary process of compressing image blocks provided by an embodiment of the present application.
  • FIG. 16 is a schematic structural diagram of another exemplary image compression apparatus provided by an embodiment of the present application.
  • FIG. 17 is a schematic structural diagram of still another exemplary image compression apparatus provided by an embodiment of the present application.
  • FIG. 18 is a schematic structural diagram of still another exemplary image compression apparatus provided by an embodiment of the present application.
  • words such as “exemplary” or “for example” are used to represent examples, illustrations or illustrations. Any embodiments or designs described in the embodiments of the present application as “exemplary” or “such as” should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as “exemplary” or “such as” is intended to present the related concepts in a specific manner to facilitate understanding.
  • At least one (a) of a, b, or c can represent: a, b, c, a-b, a-c, b-c, or a-b-c, where a, b, c may be single or multiple .
  • At least one may also be described as one or more, and the multiple may be two, three, four or more, which is not limited in this application.
  • the network architecture and scenarios described in the embodiments of the present application are for the purpose of illustrating the technical solutions of the embodiments of the present application more clearly, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application.
  • the evolution of the network architecture and the emergence of new service scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
  • An image block (also referred to as a data block) is a continuous area including a plurality of pixel points in the image to be compressed.
  • the image to be compressed may be divided into multiple image blocks by means of division.
  • an image block can include 8 ⁇ 8 pixels.
  • a pixel can include multiple components of interest to the visual system, such as luminance components, chrominance components, and the like.
  • the components included in the pixel point can be represented by component values.
  • a component set of an image block refers to a set of component values of the component included in multiple pixels in the image block.
  • a component set can be represented in the form of a matrix.
  • the set of values of pixels in the image block on the luminance component is called the set of luminance components of the image block;
  • the set of values of the pixels in the image block on the chrominance component is called the set of chrominance components of the image block.
  • the size of an image block component set is the same as the size of the image block.
  • an image block in YUV format may include one luminance component set of the image block and two chrominance component sets (chroma U component set and chrominance V component set) of the image block.
  • an image block usually includes a plurality of component sets of the image block.
  • 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 B component set of the image block.
  • V component set, performing the first transformation on the image block includes performing the first transformation on multiple component sets of the image block respectively to obtain multiple frequency domain coefficient sets of the image block.
  • the frequency domain coefficient set of the component set of the image block refers to the set of frequency domain coefficients obtained after the component set of the image block is converted from the spatial domain to the frequency domain.
  • Each component set of an image block may have its corresponding frequency domain coefficient set.
  • the high-frequency components in the frequency-domain coefficient set refer to the elements preset in the frequency-domain coefficient set to represent the positions where the human visual system is insensitive. For example, based on the ZigZag sequential scanning method, all coefficients whose position number is greater than Z in the frequency domain coefficient set are defined as high frequency components. Z can be configured according to actual needs.
  • the low-frequency components in the frequency-domain coefficient set refer to elements in the frequency-domain coefficient set that represent other positions than the positions of the high-frequency components.
  • the human visual system is sensitive to low frequency components in the frequency domain coefficient set.
  • Quantization refers to the discrete amplitude.
  • the magnitude of the component set of the image block is quantized, the high-frequency components that are not important (the visual system is insensitive) are removed from the component set of the image block, and the important (visual system-sensitive) low-frequency components are kept. or lower.
  • the quantization step size refers to the step size used to reduce the amplitude during the quantization process.
  • the quantization matrix is quantized for the component set of the image block, and the value of the element in the quantization matrix is the quantization step size.
  • the first quantization operation includes the object to be processed, and dot-dividing the quantization matrix to obtain an integer result.
  • the first quantization operation divides the point to be processed by the quantization matrix to obtain an integer result;
  • the object to be processed is floating-point data, the first quantization operation rounds or truncates the point to be processed after dividing the quantization matrix by the object to be processed .
  • the second quantization operation includes removing high frequency components from the set of frequency domain coefficients, and maintaining or reducing the magnitude of the low frequency components.
  • the number of high-frequency components removed by the second quantization operation is related to the image block, which can reflect the sensitivity of the visual system to the image block through the features of the image block (spatial domain features, frequency domain features, texture features or other features), or, through the image
  • the area where the block is located reflects whether the user is interested in the image block.
  • more high-frequency components are removed to improve the compression rate.
  • image block-dependent quantization is implemented in different image blocks through the second quantization operation.
  • image block-dependent quantization operation refer to the following embodiments for details, and details are not repeated here.
  • ZigZag order may refer to the scan traversal order from the upper left corner to the lower right corner of the collection in the form of a rectangle.
  • the numbers 0 to 63 may be in ascending order, that is, the order shown by the arrows in FIG. 2 .
  • a frame (frame) image is first divided into a series of 16 ⁇ 16 image blocks.
  • the image blocks are divided in such a way that, starting from the upper left corner of the image, the first 16 lines of the image are scanned in the horizontal direction, and each 16 columns are divided into one image block during the scanning process. After completing the first 16 lines of scanning, continue to scan the first 16 lines and the next 16 lines of data in the image from left to right. During the scanning process, every 16 columns is divided into 1 image block. Divide every 16 lines in this order until one frame of image is completed.
  • Each 16 ⁇ 16 image block is further divided into four 8 ⁇ 8 image blocks, and then the component sets of each 8 ⁇ 8 image block are compressed using the JPEG compression process shown in FIG. 1 .
  • the image segmentation process is not repeated in this application. The size of each image block after image segmentation can also be adjusted according to actual needs.
  • an 8 ⁇ 8 image block (each component set in the image block) is subjected to discrete cosine transform (discrete cosine transform, DCT), quantization, and entropy coding to obtain the compressed data of the image block.
  • discrete cosine transform discrete cosine transform, DCT
  • quantization quantization
  • entropy coding entropy coding
  • the compressed data of the image block is obtained, which means: the 8 ⁇ 8 luminance component set of the image block undergoes DCT, quantization, entropy encoding Coding to obtain the compressed data of the luminance component set of the image block, and the 8 ⁇ 8 chrominance U component set of the image block is subjected to DCT, quantization, and entropy encoding to obtain the compressed data of the chrominance U component set of the image block.
  • the 8 ⁇ 8 chrominance V component set of the image block is subjected to DCT, quantization, and entropy coding to obtain the compressed data of the chrominance V component set of the image block.
  • DCT is a matrix multiplication of 8 ⁇ 8 row transform and 8 ⁇ 8 column transform on 8 ⁇ 8 image blocks, to obtain 8 ⁇ 8 DCT coefficients.
  • the image block has strong correlation in the spatial domain, its frequency components are limited, and it is mainly distributed in the middle and low frequency regions. Therefore, DCT transforms the spatial data block into the frequency domain in image compression, and uses the DCT coefficients (frequency domain coefficients).
  • the different frequency components contained in the spatial data block are separated in the frequency domain, and the coefficients of the transformed DCT are often 0 or smaller at high frequencies. For example, the high frequency coefficient corresponding to the flat area with less texture is often 0.
  • the frequency coefficient set may be embodied in a matrix, a table, or other forms, which are not limited in this application.
  • the transformed frequency domain coefficient set can be divided into the direct current (DC) component in the upper left corner (the first element of the frequency domain coefficient set in the ZigZag order scanning method) and the alternating current (AC) component at other positions ( The second element and all subsequent elements in the frequency domain coefficient set are scanned according to the ZigZag order).
  • DC direct current
  • AC alternating current
  • Quantization According to the quantization matrix input from the outside, the DCT coefficients are quantized to obtain quantized coefficients.
  • the quantization operation is performed by dividing the DCT coefficients by a non-zero integer (quantization step size), and the quantized value is truncated or rounded to the nearest integer.
  • the quantization step is implemented by using the aforementioned first quantization operation.
  • 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 be compressed using different quantization matrices.
  • the luminance component contains more texture details and contour information.
  • the frequency distribution is relatively wide and contains more high-frequency information. Therefore, a larger quantization step is usually used to quantize the luminance component set to achieve lower bit rate effect.
  • the chrominance component contains less detail and contour information, but the human eye is more sensitive to chrominance.
  • the frequency distribution is relatively wide and contains less high-frequency information.
  • the quantization step size used for the component set is smaller than the quantization step size for the luma component set.
  • the fixed quantization matrix may be configured according to actual requirements, which is not specifically limited in this embodiment of the present application.
  • a standard quantization matrix of luminance components used in JPEG compression can be shown as follows:
  • a standard quantization matrix of chrominance components used in JPEG compression can be shown as follows:
  • the quantization step size is gradually increased from the upper left corner to the lower right corner according to the ZigZag order, so that the high-frequency components are discarded through a large quantization step size to improve the compression rate and reduce the image compression rate. volume of.
  • the quantization step size used for the chrominance component is smaller than that of the luminance component, so as to meet the requirement that the human eye is more sensitive to chrominance.
  • Entropy encoding is the process of encoding the quantized coefficients obtained by quantization to obtain compressed data.
  • DPCM differential pulse coding modulation
  • ZigZag scanning is performed for the AC quantized coefficients
  • Huffman coding is used for entropy coding for the number of consecutive zero coefficients and the amplitude of non-zero coefficients.
  • the quantization matrix used in the compression process at the encoding end and the Huffman table used in the corresponding entropy encoding also need to be compressed into the code stream and transmitted to the decoding end, so that the decoding end can restore the image.
  • an embodiment of the present application provides an image compression method.
  • the frequency coefficient set of the component set of the image block is first quantized in relation to the image block, and the high-frequency components are quantized first.
  • the quantization related to the image blocks is different, and the same component of different image blocks in one frame of image can be quantized according to different quantization step sizes, which can satisfy the user's different image areas in different scenes.
  • the size of the encoded JPEG image can be adjusted according to the actual needs; at the same time, the function of encoding of interest can be flexibly implemented on JPEG, while ensuring the quality of the area of interest, while reducing the code consumed by other areas. It can save the code rate (storage space) and further improve the compression rate.
  • the image compression method provided in the embodiment of the present application may be applied to an image compression storage scenario, or an image compression transmission scenario.
  • FIG. 3 illustrates a scene of image compression transmission, and the scene includes an encoding end device 301 and a decoding end device 302 .
  • the encoding end device 301 may compress the image and transmit it to the decoding end device 302, and the decoding end device 202 decompresses the image and then presents or saves it.
  • the encoding end device 301 or the decoding end device 302 may be in the form of a terminal device, a mobile phone, a palmtop computer, or the like, which is not limited in this embodiment of the present application.
  • the encoding end device can obtain the image and compress it and store it in its corresponding memory.
  • an embodiment of the present application provides an image compression apparatus for executing the image compression method provided by the present application.
  • FIG. 4 shows an image compression apparatus 40 related to various embodiments of the present application.
  • the image compression apparatus 40 may include a processor 401 , a memory 402 and a transceiver 403 .
  • the memory 402 may be a volatile memory (volatile memory), such as random-access memory (RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (read-only memory).
  • volatile memory such as random-access memory (RAM); or a non-volatile memory (non-volatile memory), such as a read-only memory (read-only memory).
  • ROM read-only memory
  • flash memory flash memory
  • HDD hard disk drive
  • solid-state drive solid-state drive
  • the processor 401 is the control center of the image compression apparatus 40 .
  • the processor 401 may be a central processing unit (CPU), an application specific integrated circuit (ASIC), or an integrated circuit configured to implement one or more of the embodiments of the present application.
  • Circuits such as: one or more microprocessors (digital singnal processor, DSP), or, one or more field programmable gate array (field programmable gate array, FPGA).
  • Transceiver 403 is used to communicate with other devices.
  • Transceiver 403 may be a communication port or otherwise.
  • 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:
  • the first transformation is performed on the image block in the image to be compressed to obtain the frequency domain coefficient set of the data block component; the second quantization operation is performed on the frequency domain coefficient set to obtain the second quantization coefficient set; the second quantization operation is used to remove the frequency domain
  • the high-frequency components in the coefficient set 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; the number of high-frequency components removed by the second quantization operation, greater than or equal to the number of high-frequency components removed by the first quantization operation based on the first quantization matrix; perform the first quantization operation on the second quantization coefficient set based on the first quantization matrix to obtain the first quantization coefficient set; Entropy encoding is performed on the set to obtain the compressed data of the image block.
  • an embodiment of the present application provides an image compression method.
  • the method is executed by an image compression apparatus, and compressed data is obtained by compressing a to-be-compressed image.
  • the image compression apparatus may divide the image to be compressed into a plurality of image blocks, and perform the image compression method provided by the present application on each component set of each image block. Wherein, the image compression apparatus performs the same compression process for each component set of each image block.
  • the compression process of the image block by the image compression apparatus described in the following embodiments of the present application should be understood as that the image compression apparatus performs the following compression process on each component set of the image block, which will not be repeated separately.
  • image block described in the embodiments of the present application may be equivalently replaced with "a chrominance component set of an image block” or "a luminance component set of an image block” or "a certain component set of an image block” to The scheme protected by this application is described.
  • the to-be-compressed image may be an image in YUV format, or other image formats including chrominance components and luminance components, and the format of the to-be-compressed image is not limited in this application.
  • the format of the image to be compressed is an image format not supported by the image compression device
  • the format of the to-be-compressed image can be converted first to obtain an image format supported by the image compression device, and then the image compression method provided in this application is executed.
  • a segmented image block of a YUV420 format to be compressed contains components as shown in FIG. 5 , and the image block includes a 16 ⁇ 16 luminance component set and an 8 ⁇ 8 chrominance U component set. and an 8x8 set of chroma V components.
  • the image compression device can divide the 16 ⁇ 16 luminance component set into 4 8 ⁇ 8 luminance component sets, and then divide the 4 8 ⁇ 8 luminance component sets, an 8 ⁇ 8 chrominance U component set and an 8 ⁇ 8 luminance component set.
  • the image compression method provided by the present application is performed on each component set of the chrominance V component set of 8, and the compressed data of each component set is obtained as the compressed data of the image block.
  • the image compression method provided by the embodiment of the present application may include:
  • the image compression apparatus performs a first transformation on an image block in the to-be-compressed image to obtain a frequency domain coefficient set of the image block.
  • the image block is any image block obtained by dividing the image to be compressed, which is also referred to as the image block to be processed hereinafter.
  • the first transformation is used to convert the spatial domain data value representation of the image block into a frequency domain representation.
  • Each pixel in the image block corresponds to an element at the same position in the frequency domain coefficient set.
  • the arrangement and number of elements in the frequency domain coefficient set of an image block are the same as those of the image block.
  • the first transformation may be a DCT transformation or other types of transformations, which are not limited in this application, and the process thereof will not be described in detail.
  • the frequency domain coefficient set of the image block obtained through the first transformation may be represented in a matrix or in other forms, which is not specifically limited in this embodiment of the present application. It should be noted that, in the embodiment of the present application, the frequency domain coefficient set is represented in the form of a matrix, which is only an example and does not constitute a specific limitation.
  • the image compression apparatus performs a second quantization operation on the frequency domain coefficient set to obtain a second quantized coefficient set.
  • the second quantization operation is used to remove 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, Different image blocks in the image to be compressed are adaptively quantized through the second quantization operation, and the quantization effect performed on each image block matches the characteristics of the image block, thereby achieving different quantization effects in different regions of the image to be compressed.
  • the sensitivity of the visual system to the image block can be reflected by the features (spatial domain features, frequency domain features, texture features or other features) of the image block, or whether the user is interested in the image block can be reflected by the region where the image block is located.
  • the features spatial domain features, frequency domain features, texture features or other features
  • the compression ratio is increased to reduce the size of the compressed image.
  • image patches in areas of interest to the user removing fewer high-frequency components to improve the visual effect.
  • the specific content of the second quantization operation can be configured according to actual requirements, so as to remove the high-frequency components in the frequency domain coefficient set, maintain or reduce the amplitude of the low-frequency components in the frequency domain coefficient set, and remove the high-frequency components.
  • the number of pieces associated with this image block is for this purpose.
  • 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.
  • the number of high-frequency components removed by the second quantization operation may be equal to the first quantization matrix.
  • the number of high frequency components removed by the first quantization operation may be equal to the first quantization matrix.
  • the number of high-frequency components removed by the second quantization operation may be greater than that based on the first quantization operation.
  • a quantization matrix is the number of high frequency components removed by the first quantization operation.
  • the first quantization matrix is a fixed quantization matrix input in the JPEG compression standard.
  • the first quantization matrices of the same components of different image blocks in one frame of the image to be compressed are the same.
  • the image compression apparatus performs a first quantization operation on the second quantized coefficient set based on the first quantization matrix, to obtain a first quantized coefficient set.
  • the first quantization operation performed by the image compression apparatus based on the first quantization matrix in S603 specifically includes dividing the second quantization coefficient set by the first quantization matrix to obtain an integer result of the first quantization coefficient set.
  • the element in the i-th row and the j-th column in the first quantization coefficient set may be the element in the i-th row and the j-th column in the second quantization coefficient set, divided by the element in the i-th row and the j-th column of the first quantization matrix. whole result.
  • the image compression apparatus performs entropy coding on the first quantized coefficient set to obtain compressed data of the image block.
  • entropy coding is performed on the first quantized coefficient set to obtain the compressed data of the image block, which can be referred to the entropy coding process in the JPEG compression standard, which will not be repeated here.
  • the process of compressing an image block by the image compression method provided by the above S601 to S604 may be shown in FIG. 7 .
  • a second quantization operation related to the image block is first performed on the frequency coefficient set of the data block, the high-frequency components are removed, the low-frequency components are maintained or reduced in amplitude, and then based on the configuration
  • the first quantization matrix of performs the first quantization operation, and then performs entropy encoding to complete the compression.
  • the quantization related to different image blocks is different, and different image blocks in an image can be quantized according to different quantization step sizes, which can meet the different visual needs of users for different image areas in different scenes; realize adjustment according to actual needs.
  • 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) to further improve the compression ratio.
  • the image compression apparatus may perform the above-mentioned processes of S601 to S604 for each image block in the image to be compressed to obtain compressed data of the image to be compressed.
  • the image compression apparatus may perform the above-mentioned processes of S601 to S604 on some image blocks in the image to be compressed, and compress the remaining image blocks according to the JPEG compression standard to obtain the compression of the image to be compressed. data.
  • the image compression apparatus may perform the above-mentioned processes of S601 to S604 to compress the image blocks in the region of interest (ROI) in the to-be-compressed image, and compress the image blocks in the ROI region according to the JPEG compression standard.
  • ROI region of interest
  • the ROI is an area with a high degree of user attention in the to-be-compressed image
  • the specific implementation of the ROI in the to-be-compressed image can be configured and determined according to actual requirements, which is not limited in the embodiments of the present application.
  • the ROI in the to-be-compressed image may be acquired through AI recognition technology, or the ROI in the to-be-compressed image may be acquired according to the indication information of the ROI area input by the user. This is not limited in the embodiments of the present application.
  • the ROI in the to-be-compressed image can be obtained through AI recognition technology, and the indication information of the ROI area can be output.
  • AI technology for obtaining ROI is not limited in this embodiment of the present application.
  • AI-based target detection can detect targets in the image to be compressed in real time, such as faces, human shapes, license plates, cars, etc., and determine the area where the identified target is located as ROI, and other areas are non-ROIs.
  • the rectangular frame coordinate information of each ROI area is used as the indication information of the ROI area.
  • the indication information of the ROI region output by AI recognition can be directly input into the image compression device, and the image compression device can determine in real time whether the image block to be processed is in the compression process according to the indication information of the ROI region. ROI area.
  • the indication information of the ROI area output by AI can be recognized according to its position in the image to be compressed, with the size of the image block as the unit (it can also be processed according to a larger size) ), such as 16 ⁇ 16, generate a binary image for the entire frame of the image to be compressed (the generation process of the binary image can be generated according to the results of AI analysis, such as the results of AI target detection), and use different identifiers to identify each Whether each image block is an ROI area, the binary image is used as the input of the image compression device.
  • the image compression device determines whether the image block to be processed is in the ROI according to the specific value of the image block to be processed in the binary image. area. For example, it can be identified by 0 and 1, 1 indicates that the image block is inside the ROI area, and 0 indicates that the image block is in the non-ROI area.
  • the image compression apparatus may receive the input ROI area information, and determine that the area indicated by the ROI area information in the image to be compressed is an ROI, and other areas are non-ROIs.
  • the ROI area information is used to indicate the coordinate position of the ROI in the image to be compressed.
  • the ROI area information may be input by the user of the image compression apparatus on the human-computer interaction interface of the image compression apparatus.
  • the ROI area information may also be input by other subjects in other ways, which is not limited in the embodiment of the present application.
  • the image compression apparatus may receive the input Map image information of the image to be compressed, and determine the ROI of the region of interest in the image to be compressed based on the Map image information, and other regions are non-ROIs.
  • the Map image information is used to indicate whether each image block in the image to be compressed is in the ROI area.
  • the second quantization operation is performed on the frequency domain coefficient set in S602 of the present application, and the specific implementation of obtaining the second quantized coefficient set can be configured according to actual requirements.
  • the embodiment of the present application provides the following two methods for performing the second quantization on the frequency domain coefficient set operation to obtain a specific implementation of the second quantized coefficient set, including the following first implementation and second implementation, but it does not constitute a specific limitation.
  • the first implementation is a first implementation:
  • the image compression device obtains the ROI in the image to be compressed; if the image block to be processed is in the ROI of the region of interest of the image to be compressed, the first N1 elements arranged in the order of ZigZag in the frequency domain coefficient set are reserved, and the remaining elements are set to zero to obtain the second.
  • Quantization coefficient set if the image block to be processed is in the non-ROI of the image to be compressed, the first N2 elements in the frequency domain coefficient set arranged in ZigZag order are reserved, and the remaining elements are set to zero to obtain the second quantized coefficient set.
  • the image compression apparatus may use the first implementation to perform a second quantization operation to obtain a second quantization coefficient.
  • 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 attention degree of 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 of the area outside the area of interest. The smaller the value of N2, the higher the quantization degree of the area outside the area of interest, the greater the loss of the compressed image, the higher the compression rate, the higher the compression rate. The smaller the image size.
  • N1 may be much larger than N2.
  • N1 is 63 and N2 is 32.
  • the value of N1 may be different, and the value of N2 may also be different.
  • the image compression apparatus performs a second quantization operation on the frequency domain coefficient set TC based on the ZigZag sequential scanning method, and in the process of obtaining the second quantized coefficient set TC', the idx coefficient in the ZigZag sequential scanning is subjected to the second quantization operation.
  • the process can be realized by the following expression:
  • N corresponds to N1 of ROI and N2 of non-ROI.
  • TC(i,j) is the value of the idxth coefficient of the frequency domain coefficient set TC according to the ZigZag order scanning method.
  • the process of compressing an image block by the image compression method provided in this embodiment of the present application may be shown in FIG. 8 .
  • an image block is subjected to a first transformation to obtain a frequency domain coefficient set of the image block.
  • zeroing is performed on the frequency domain coefficient set.
  • the zeroing process refers to performing the second quantization operation through the first implementation, that is, if the data block component to be processed is located in the ROI of the region of interest of the image to be compressed, the frequency domain coefficients are concentrated.
  • the first N1 elements arranged in ZigZag order are retained, and the remaining elements are set to zero to obtain the second quantized coefficient set; if the data block component to be processed is in the non-ROI of the to-be-compressed image, the frequency domain coefficients are set according to the ZigZag order. A number of elements are reserved, and the remaining elements are set to zero to obtain a second set of quantized coefficients.
  • entropy encoding is performed on the first quantized coefficient set to obtain compressed data of the image block.
  • the image compression apparatus 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.
  • the row and column sizes of the first quantization matrix, the second quantization matrix, and the image block to be processed are the same, and the magnitude of an element in the second quantization matrix of a component set of an image block is greater than or equal to the component set of the image block.
  • the acquisition manner of the second quantization matrix of the image block may be configured according to actual requirements, which is not limited in this embodiment of the present application.
  • FIG. 9 the process of compressing data block components by the image compression method provided in the embodiment of the present application may be shown in FIG. 9 .
  • an image block is subjected to a first transformation to obtain a frequency domain coefficient set of the image block.
  • a second quantization matrix of the image block is obtained, and then a second quantization operation is performed on the frequency domain coefficient set based on the second quantization matrix to obtain a second quantization coefficient set.
  • entropy encoding is performed on the first quantized coefficient set to obtain compressed data of the image block.
  • the second quantization matrix of the image block may be specified by the user.
  • the image compression apparatus may obtain the second quantization matrix of the image block according to the characteristics of the image block.
  • the image compression apparatus may acquire the feature value 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 feature value of the image block. It should be understood that the image compressing apparatus may obtain the feature value of a certain component set (a luminance component set or a chrominance component set) of an image block, according to the quantization information of the first quantization matrix of the component set of the image block, and the image block The eigenvalues of the component set of , determine the second quantization matrix of the component set of the image block.
  • a certain component set a luminance component set or a chrominance component set
  • the image compression apparatus when the image compression apparatus performs the second quantization operation, the eigenvalues of the image blocks are acquired, and the quantization information of the first quantization matrix of the image blocks and the eigenvalues of the image blocks are determined to determine the eigenvalues of the image blocks.
  • the second quantization matrix and then when the second quantization operation is completed, the process of compressing the image block by the image compression method provided in the embodiment of the present application may be shown in FIG. 10 .
  • an image block is subjected to a first transformation to obtain a frequency domain coefficient set of the image block.
  • the feature value X of the image block is obtained.
  • the second quantization matrix of the image block is determined.
  • a second quantization operation is performed on the frequency domain coefficient set based on the second quantization matrix to obtain a second quantized coefficient set.
  • entropy encoding is performed on the first quantized coefficient set to obtain compressed data of the image block.
  • the feature value of the image block is used to indicate any one of the following features of the image block: spatial domain feature, frequency domain feature or texture feature.
  • the feature value of the image block may also indicate other features of the image block, which are not limited in this embodiment of the present application.
  • the image compression apparatus may obtain the feature value of the image block, and determine the second quantization 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. matrix to complete the second quantization operation.
  • the image compression apparatus 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 a first quantization coefficient set for the first quantization coefficient set. Entropy encoding is performed on the set to obtain the compressed data of the image block.
  • the image compressing apparatus may acquire the spatial feature of the image block to be processed by means of gradient or variance, and edge detection.
  • the spatial feature of the image block can be a spatial feature value.
  • the Sobel edge detection operator can be used to detect the edge strength of each point in the image block in the horizontal and vertical directions, and the horizontal and vertical directions of all points can be detected. Accumulate and average the edge intensities of the image block to obtain the edge intensity index in the image block.
  • the edge intensity index can be used to indicate the characteristics of the image block in the spatial domain, and the edge intensity index can be used as the feature value of the image block.
  • a larger quantization step size can be used for quantization without significantly reducing the compressed image quality.
  • a smaller quantization step size needs to be used, so as to minimize the impact on the subjective quality of the image by the human eye.
  • the image compression apparatus may also analyze the frequency domain characteristics of the image block in the frequency domain coefficient set of the image block to be processed.
  • the frequency domain feature of the image block may be a frequency domain feature value, which is used to indicate the feature of the image block in the frequency domain.
  • the frequency domain coefficients obtained by performing DCT transformation on the image block can be concentrated, and all AC coefficients or medium and high frequency coefficients (for example, all coefficients with serial numbers greater than 16 based on the ZigZag sequential scanning method) are summed and averaged to obtain the intensity of the frequency domain components. .
  • the intensity of the frequency domain component is used as the feature value of the image block.
  • the eigenvalue is used to indicate the texture feature of the image block, and the image compression apparatus may calculate the eigenvalue X according to the expression of the eigenvalue X and the pixel value in the image block.
  • the expression of the feature value X and the pixel value in the image block satisfies the following relationship:
  • Pix i is the pixel value of the ith pixel in the image block to be processed
  • M is the width of the image block
  • L is the height of the image block.
  • the image compression apparatus may 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 eigenvalues of the image block.
  • HVS human vision system
  • image features frequency features, spatial features, texture features
  • HVS is more sensitive and needs to be quantized with a smaller quantization step size, and some areas are more complex, such as grass, HVS is not very sensitive, and contains more high-frequency component information, so a larger quantization step can be used
  • Quantization is carried out for a long time to achieve the effect of reducing the code rate. Therefore, the second quantization matrix can be determined based on this principle.
  • the process of 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 eigenvalues of the image block by the image compression apparatus provided in the embodiment of the present application may be performed through but not limited to the following: The first way to determine or the second way to determine.
  • 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 determining the first quality factor QF 1 of the first quantization matrix.
  • the quantization information of the matrix determine the first quantization matrix, and then determine QM 2 according to the relationship between the second quantization matrix QM 2 , the first quantization matrix QM 1 , and the eigenvalue X.
  • the content of the first preset function may be configured according to actual requirements, which is not limited in this embodiment of the present application.
  • the first preset function may be a log function.
  • the first preset function may be a base-2 log function log 2 (X).
  • the eigenvalues of the luminance component set of the image block and the relationship between the second quantization matrix QM 2 and the first quantization matrix QM 1 and the eigenvalue X may be used. relationship, a second quantization matrix for the set of chrominance components of the image block is calculated.
  • the image compression apparatus may directly determine QM 1 .
  • the quantization information of the first quantization matrix may include determining a first quality factor QF 1 of the first quantization matrix, where QF 1 is used to calculate the first quantization matrix QM 1 according to the first relational expression.
  • the image compression apparatus can obtain QM 1 by calculation according to the first relational expression.
  • QM qf is the calculated quantization matrix
  • floor( ) is the rounding operation
  • S satisfies the following expression:
  • the first determination method the quantization information of the first quantization matrix includes determining the first quality factor QF 1 of the first quantization matrix, and the image compression device first calculates the second quality factor QF 2 , and then determines it according to the first relational expression and QF 2 The second quantization matrix.
  • the image compression apparatus specifically determines the second quantization matrix of the image block through the following steps 1 to 3:
  • Step 1 The image compression apparatus determines the quality factor offset value ⁇ QF according to the characteristic value X of the image block.
  • the content of the second preset function may be configured according to actual requirements, which is not limited in this embodiment of the present application.
  • Step 2 The image compression apparatus calculates the second quality factor QF 2 according to ⁇ QF and QF 1 .
  • the content of the third preset function may be configured according to actual requirements, which is not limited in this embodiment of the present application.
  • Step 3 The image compression apparatus determines a second quantization matrix according to QF 2 and the first relational expression.
  • step 3 for the area with complex texture, the larger the calculated texture feature X is, the larger the corresponding ⁇ QF will be, and the smaller QF 2 will be, and the quantization step size of the second quantization matrix is determined. will be larger, and more high-frequency details can be quantized by the second quantization operation.
  • implementing S602 in the second implementation may include but not limited to the following two specific operations:
  • the first specific operation the image compression apparatus sequentially performs a first quantization operation on the frequency domain coefficient set based on the second quantization matrix, and an inverse quantization operation of the first quantization operation to obtain a second quantized coefficient set.
  • 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 dot-multiplied by the second quantization matrix to obtain the integer result, which is used as the second quantization coefficient set.
  • the image compression apparatus 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 by the above-mentioned first determination method, and completes the first quantization matrix according to the first specific operation.
  • the process of compressing image blocks by the image compression method provided in the embodiment of the present application may be shown in FIG. 11 .
  • an image block is subjected to a first transformation to obtain a frequency domain coefficient set of the image block.
  • the feature value X of the image block is obtained.
  • the second quantization matrix of the image block is determined.
  • the first quantization operation and the inverse quantization operation of the first quantization operation are sequentially performed on the frequency domain coefficient set based on the second quantization matrix to obtain a second quantized coefficient set.
  • entropy encoding is performed on the first quantized coefficient set to obtain compressed data of the image block.
  • the image compression apparatus 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-mentioned second determination method, and completes the first quantization matrix according to the first specific operation.
  • the process of compressing an image block by the image compression method provided in this embodiment of the present application may be shown in FIG. 12 .
  • an image block is subjected to a first transformation to obtain a frequency domain coefficient set of the image block.
  • the feature value 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 3, and the second quantization matrix of the image block is determined according to the eigenvalue X and the second quality factor.
  • a first quantization operation and an inverse quantization operation of the first quantization operation are sequentially performed on the frequency domain coefficient set based on the second quantization matrix to obtain a second quantized coefficient set.
  • a first quantization matrix of the image block is calculated according to the first quality factor, and 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.
  • entropy encoding is performed on the first quantized coefficient set to obtain compressed data of the image block.
  • Equation (1) and Equation (2) are as follows, Equation (1) is based on the second quantization matrix QM 2 to perform the first quantization operation on the frequency domain coefficient set TC to obtain the result QC 1 , Equation (2) is based on the second quantization matrix QM 2. Perform the inverse quantization operation of the first quantization operation on the result QC 2 of the formula (1) to obtain a second quantization coefficient set TC′ from which high-frequency coefficients are removed.
  • the second quantization matrix of the image block in the ROI area may be the first quantization matrix of the image block.
  • the second quantization matrix of the image block in the non-ROI area can be obtained according to the method described in the second implementation above. If the second quantization operation is completed according to the above-mentioned first specific operation, the process of compressing the image block by the image compression method provided in the embodiment of the present application may be shown in FIG. 13 . As shown in FIG. 13 , an image block is subjected to a first transformation to obtain a frequency domain coefficient set of the image block.
  • the image compressing apparatus acquires a quantization matrix (a first quantization matrix in the ROI area, a second quantization matrix in a non-ROI area) on which the second quantization operation is completed. Next, based on the quantization matrix that has completed the second quantization operation, the first quantization operation and the inverse quantization operation of the first quantization operation are successively performed on the frequency domain coefficient set to obtain a second quantization coefficient set. Next, perform the first quantization operation on the second quantized coefficient set based on the first quantization matrix according to the description of S603 above, to obtain the first quantized coefficient set. Finally, entropy encoding is performed on the first quantized coefficient set to obtain compressed data of the image block.
  • a quantization matrix a first quantization matrix in the ROI area, a second quantization matrix in a non-ROI area
  • the second quantization matrix of the image block in the ROI area may be the first quantization matrix of the image block.
  • the second quantization matrix of the image block in the non-ROI area 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, and the image compression method provided in the embodiment of the present application compresses the data block component.
  • the process can be shown in Figure 14. As shown in FIG. 14 , the input image is divided into image blocks, and the image block is subjected to a first transformation to obtain a frequency domain coefficient set of the image block.
  • AI-based target detection is performed on the input image to obtain ROI indication information
  • the image compression apparatus obtains a quantization matrix for completing the second quantization operation (a first quantization matrix in the ROI area, and a second quantization matrix in the non-ROI area).
  • 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 a second quantization coefficient set.
  • entropy encoding is performed on the first quantized coefficient set to obtain compressed data of the image block.
  • the first quantization operation and the inverse quantization operation of the first quantization operation in the first specific operation correspond to division and multiplication operations respectively.
  • the first quantization operation and the first quantization operation can be combined.
  • the inverse quantization operation is implemented through a comparison operation, which avoids multiplication and division operations, and hardly increases the cost of hardware logic implementation.
  • the comparison operation is as follows in the 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 eigenvalues of the image block; Elements at positions corresponding to the elements in the binary quantization matrix are compared in size, and based on a preset rule, the second quantization coefficient set of the image block is determined.
  • the preset rule may include: when the element at the first position in the frequency domain coefficient set of the image block is larger than the element at the first position in the second quantization matrix of the image block, retaining the first position in the frequency domain coefficient set of the image block.
  • the element of the position; the first position is any position in the frequency domain coefficient set; when the element in the first position in the frequency domain coefficient set of the image block is smaller than the element in the first position in the second quantization matrix of the image block, the frequency The element at the first position in the domain coefficient set is 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, the frequency domain coefficient set is set at the first position. The elements of are retained or zeroed.
  • the elements in the i-th row and the j-th column in the second quantization coefficient set are: TC′(i,j) and the element TC(i,j) of the ith row and jth column in the frequency domain coefficient set TC and the element QM 2 (i,j) of the ith row and jth column in the second quantization matrix
  • FIG. 15 the process of compressing an image block by the image compression method provided in this embodiment of the present application may be shown in FIG. 15 .
  • an image block is subjected to a first transformation to obtain a frequency domain coefficient set of the image block.
  • a comparison operation is performed on the frequency coefficient set based on the second quantization matrix, that is, the process of completing the second quantization operation in the above-mentioned second specific operation, to obtain a second quantized coefficient set.
  • entropy encoding is performed on the first quantized coefficient set to obtain compressed data of the image block.
  • -clip(0, Max ⁇ QF, ⁇ QF) can be Calculated to obtain QF 2 70, according to the above-mentioned first relational expression and QF 1 , QF 2 and the standard quantization matrix, the first quantization matrix QM 1 and the second quantization matrix QM 2 of the component set of the image block are obtained as follows:
  • the frequency coefficient set TC of the component set of the image block after DCT transformation is as follows:
  • TC' is essentially a set of frequency domain coefficients subjected to the second quantization operation. Compared with TC, more elements in TC' are quantized to 0.
  • the above-mentioned image compression apparatus includes corresponding hardware structures and/or software modules for executing each function.
  • the present application can be implemented in hardware or a combination of hardware and computer software with the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein. Whether a function is performed by hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementations should not be considered beyond the scope of this application.
  • each functional module may be divided corresponding to each function, or two or more functions may be integrated into one process. in the module.
  • the above-mentioned integrated modules can be implemented in the form of hardware, and can also be implemented in the form of software function modules. It should be noted that, the division of modules in the embodiments of the present application is schematic, and is only a logical function division, and there may be other division manners in actual implementation.
  • FIG. 16 shows a possible schematic structural diagram of the image compression apparatus 160 involved in the above embodiment.
  • the image compression device 160 may be a functional module or a chip.
  • the image compression apparatus 160 may include: a transformation unit 1601 , a second quantization unit 1602 , a first quantization unit 1603 , and an encoding unit 1604 .
  • the transformation unit 1601 is used to perform the process S601 in FIG. 6; the second quantization unit 1602 is used to perform the process S602 in FIG. 6; the first quantization unit 1603 is used to perform the process S603 in FIG. 6; the encoding unit 1604 is used to perform the process S603 in FIG. Process S604 in FIG. 6 is performed.
  • all relevant contents of the steps involved in the above method embodiments can be cited in the functional descriptions of the corresponding functional modules, which will not be repeated here.
  • the image compression apparatus 160 may further include a first obtaining unit 1605 .
  • the first obtaining unit 1605 is configured to obtain the ROI in the image to be compressed.
  • the image compression apparatus 160 may further include a second obtaining unit 1606 .
  • the second obtaining unit 1606 is configured to obtain the feature value of the image block.
  • FIG. 18 shows another possible schematic structural diagram of the image compression apparatus involved in the above embodiment.
  • the image compression apparatus 180 may include: a processing module 1801 and a communication module 1802 .
  • the processing module 1801 is used to control and manage the actions of the image compression apparatus 180, and the communication module 1802 is used to communicate with other devices.
  • the processing module 1801 is configured to execute any one of the processes S601 to S604 in FIG. 3 .
  • the image compression apparatus 180 may further include a storage module 1803 for storing program codes and data of the image compression apparatus 180 .
  • the processing module 1801 may be the processor 401 in the physical structure of the image compression apparatus 40 shown in FIG. 4 , and 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 may implement or execute the various exemplary logical blocks, modules and circuits described in connection with this disclosure.
  • the processing module 801 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
  • the communication module 1802 may be the transceiver 403 in the physical structure of the image compression apparatus 40 shown in FIG.
  • the communication module 1802 may be a communication port, or may be a transceiver, a transceiver circuit, a communication interface, or the like.
  • the above-mentioned communication interface may implement communication with other devices through the above-mentioned components with a transceiving function.
  • the above-mentioned components with transceiving functions may be implemented by antennas and/or radio frequency devices.
  • the storage module 1803 may be the memory 402 in the physical structure of the image compression apparatus 40 shown in FIG. 4 .
  • the image compression apparatus 40 involved in FIG. 18 in the embodiment of the present application may be the image compression apparatus 40 shown in FIG. 4 .
  • the image compression apparatus 160 or the image compression apparatus 180 provided by the embodiments of the present application may be used to implement the corresponding functions in the methods implemented by the above embodiments of the present application.
  • the image compression apparatus 160 or the image compression apparatus 180 provided by the embodiments of the present application may be used to implement the corresponding functions in the methods implemented by the above embodiments of the present application.
  • the image compression apparatus 160 or the image compression apparatus 180 provided by the embodiments of the present application may be used to implement the corresponding functions in the methods implemented by the above embodiments of the present application.
  • the image compression apparatus 160 or the image compression apparatus 180 provided by the embodiments of the present application may be used to implement the corresponding functions in the methods implemented by the above embodiments of the present application.
  • the image compression apparatus 160 or the image compression apparatus 180 provided by the embodiments of the present application may be used to implement the corresponding functions in the methods implemented by the above embodiments of the present application.
  • only those related to the embodiments of the present application are shown. If the specific technical details are not disclosed, please refer to the embodiments
  • a computer-readable storage medium on which an instruction is stored, and when the instruction is executed, the image compression method in the above method embodiment is performed.
  • a computer program product containing instructions is provided, when the computer program product runs on a computer, the computer executes the image compression method in the above method embodiments when executed.
  • An embodiment of the present application further provides a chip system, where the chip system includes a processor for implementing the technical method of the embodiment of the present invention.
  • the chip system further includes a memory for storing necessary program instructions and/or data in the embodiments of the present invention.
  • the system-on-a-chip also includes memory for the processor to invoke the application code stored in the memory.
  • the chip system may be composed of one or more chips, and may also include chips and other discrete devices, which are not specifically limited in this embodiment of the present application.
  • the steps of the method or algorithm described in conjunction with the disclosure of the present application may be implemented in a hardware manner, or may be implemented in a manner of a processor executing software instructions.
  • Software instructions can be composed of corresponding software modules, and software modules can be stored in RAM, flash memory, ROM, erasable programmable read-only memory (erasable programmable read-only memory, EPROM), electrically erasable programmable read-only memory (electrically EPROM, EEPROM), registers, hard disk, removable hard disk, compact disk read only (CD-ROM), or any other form of storage medium known in the art.
  • An exemplary storage medium is coupled to the processor, such that the processor can read information from, and write information to, the storage medium.
  • the storage medium can also be an integral part of the processor.
  • the processor and storage medium may reside in an ASIC.
  • the ASIC may be located in the core network interface device.
  • the processor and the storage medium may also exist in the core network interface device as discrete components.
  • the memory may be coupled to the processor, eg, the memory may exist independently and be connected to the processor through a bus.
  • the memory can also be integrated with the processor.
  • the memory may be used to store application code for executing the technical solutions provided by the embodiments of the present application, and the execution is controlled by the processor.
  • the processor is configured to execute the application program code stored in the memory, thereby implementing the technical solutions provided by the embodiments of the present application.
  • the disclosed apparatus and method may be implemented in other manners.
  • the device embodiments described above are only illustrative.
  • the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components may be Incorporation may either be integrated into another device, or some features may be omitted, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place, or may be distributed to multiple different places . Some or all of the units may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it may be stored in a readable storage medium.
  • the technical solutions of the embodiments of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, which are stored in a storage medium , including several instructions to make a device (may be a single chip microcomputer, a chip, etc.) or a processor (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: a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk and other mediums that can store program codes.

Landscapes

  • Physics & Mathematics (AREA)
  • Discrete Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

本申请实施例提供一种图像压缩方法及装置,涉及图像处理领域,实现一帧图像中不同图像块按照不同的量化步长进行量化,满足用户在不同场景对不同图像区域的不同视觉需求,降低码率以减少图片的存储空间。具体包括:对待压缩图像中的图像块进行第一变换,得到该图像块的频域系数集;对频域系数集进行第二量化操作,得到第二量化系数集;第二量化操作用于去除频域系数集中的高频分量,保持或减小频域系数集中低频分量的幅值大小;第二量化操作去除的高频分量的数量与该图像块相关;基于第一量化矩阵对第二量化系数集进行第一量化操作,得到第一量化系数集;对第一量化系数集进行熵编码,得到图像块的压缩数据。

Description

一种图像压缩方法及装置 技术领域
本申请实施例涉及图像处理领域,尤其涉及一种图像压缩方法及装置。
背景技术
联合图像专家组(joint photographic expert group,JPEG)作为一种图像压缩标准,由于其实现简单且具有广泛的兼容性,成为图像存储和传输的主流压缩格式并广泛应用。
在JPEG压缩的过程中,一帧图像先被分割成一系列16×16的图像块,每一个16×16的图像块会进一步分割成4个8×8的图像块,然后对于每一个8×8的图像块使用如图1示意的JPEG压缩流程进行压缩。
一个8×8的图像块中的每个亮度分量、色度分量分别进行如图1示意的压缩过程完成这个8×8的图像块的压缩。如图1示意,8×8的图像块的一个分量(亮度或色度)先进行离散余弦变换(discrete cosine transform,DCT),将空间数据块变换到频域表示为8×8的DCT系数,在频域将空间数据块中含有的不同频率成分分开得到DCT系数中左上角的直流分量(DC)和其他位置的交流分量(AC)。然后,根据外部输入8×8的量化矩阵,将DCT系数除以量化矩阵中对应位置的元素值(称为量化步长)进行量化,量化后的值会被截断或舍入到最近整数。通过量化减少频域DCT系数中的数据量,实现压缩的目的。通常会根据人眼对高频系数不敏感的特性,随着频率的增加,在量化矩阵中按照频率从低到高逐渐增加量化步长,来达到更好的压缩比。最后,对量化后的数据进行熵编码得到压缩数据。
JPEG压缩的核心环节是量化过程,但对一帧图像中所有图像块只能按照同一套量化矩阵进行量化(不同图像块的相同分量只能按照同一个量化矩阵进行量化),压缩率固定,因此不能满足用户在在一副图像中对不同图像区域的不同视觉需求,同时目前的压缩方案获取的压缩数据码率高占用存储空间。
发明内容
本申请实施例提供一种图像压缩方法及装置,实现一帧图像中不同图像块按照不同的量化步长进行量化,可以满足用户在不同场景对不同图像区域的不同视觉需求;对于视觉不敏感或者用户不关注的区域,可以采用更大的量化步长进一步的提高压缩率,降低码率以减少图片的存储空间。
为达到上述目的,本申请实施例采用如下技术方案:
第一方面,提供一种图像压缩方法,该方法可以包括:对待压缩图像中的图像块进行第一变换,得到该图像块的频域系数集;该图像块为待压缩图像中包括多个像素点的连续区域;对频域系数集进行第二量化操作,得到第二量化系数集;第二量化操作用于去除频域系数集中的高频分量,保持或减小频域系数集中低频分量的幅值大小;第二量化操作去除的高频分量的数量与该图像块相关;第二量化操作去除的高频分量的数量,大于或等于基于第一量化矩阵进行第一量化操作去除的高频分量的数量;基 于第一量化矩阵对第二量化系数集进行第一量化操作,得到第一量化系数集;对第一量化系数集进行熵编码,得到图像块的压缩数据。
通过本申请实施例提供的图像压缩方法,对数据块的频率系数集先进行一次与图像块相关的第二量化操作,将高频分量去除,将低频分量保持或减小幅值,再基于配置的第一量化矩阵进行第一量化操作,之后再进行熵编码完成压缩。这样一来,不同图像块相关的量化不同,一帧图像中不同图像块可以按照不同的量化步长进行量化,可以满足用户在不同场景对不同图像区域的不同视觉需求;实现了根据实际需求调整编码后JPEG格式图像的大小;同时,可以在满足JPEG标准的前提下,对感兴趣区域进行灵活编码,在保证感兴趣区域质量的同时,减少其他区域所耗费的码率,进而节省码率(存储空间),进一步提高压缩率。
在一种可能的实现方式中,对频域系数集进行第二量化操作,得到第二量化系数集,包括:获取待压缩图像中的感兴趣区域(Region Of Interest,ROI);若图像块处于待压缩图像的ROI,将图像块的频域系数集中按照ZigZag顺序排列的前N1个元素保留,其余元素置零,得到该图像块的第二量化系数集;若图像块处于待压缩图像的非ROI,将频域系数集中按照ZigZag顺序排列的前N2个元素保留,其余元素置零,得到该图像块的第二量化系数集。N1大于N2。通过该实现方式进行第二量化操作,实现过程简单,计算复杂度低,节约成本。
在另一种可能的实现方式中,N1为63,N2为32。
在一种可能的实现方式中,本申请提供的图像压缩方法还可以包括:获取图像块的特征值,特征值用于指示图像块的下述特征中任一种:空域特征、频域特征或纹理特征。对频域系数集进行第二量化操作,得到第二量化系数集,可以包括:根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定图像块的第二量化矩阵,基于第二量化矩阵对频率系数集进行第三操作,得到该图像块的第二量化系数集。
其中,图像块的特征值用于反映图像块对于视觉系统的复杂程度,特征值越高,图像块对于视觉系统来说越复杂越不敏感,就可以采用更大的量化步长进行量化。该实现方式中根据图像块的第一量化矩阵的量化信息确定出第一量化矩阵后,结合图像块的特征值确定图像块的第二量化矩阵,使得确定的第二量化矩阵与图像块的特点相关,进而使得第二量化操作与图像块的特点相关。这样一来,不同特征的图像块同一分量集的第二量化矩阵也就不同,通过第二量化操作就实现了一帧图像中不同图像块可以按照不同的量化步长进行量化。
第一量化矩阵是进行第一量化操作的量化矩阵,一帧图像中不同图像块相同分量集的第一量化矩阵相同。第一量化矩阵的量化信息用于唯一确定第一量化矩阵。第一量化矩阵的量化信息可以为第一量化矩阵本身,或者,第一量化矩阵的量化信息可以为确定第一量化矩阵的质量因子,根据质量因子及第一关系表达式就可以计算第一量化矩阵。第一关系表达式为质量因子与标准量化矩阵QM S的关系表达式。
其中,第一关系表达式满足如下关系:QM qf=floor(S×QM s+50)。
QM qf为计算的量化矩阵,floor(·)为取整操作,S满足如下表达式:
Figure PCTCN2020118910-appb-000001
一种可能的实现方式中,第三操作可以为先后进行第一量化操作和第一量化操作的反量化操作。
另一种可能的实现方式中,第三操作可以包括将图像块的频域系数集中的元素,与该图像块的第二量化矩阵中该元素对应位置处的元素比较大小,基于预设规则,确定该图像块的第二量化系数集。其中,预设规则可以包括:当频域系数集中第一位置的元素大于第二量化矩阵中第一位置的元素时,保留频域系数集中第一位置的元素;第一位置为频域系数集中的任一位置;当频域系数集中第一位置的元素小于第二量化矩阵中第一位置的元素时,将频域系数集中第一位置的元素置零;当频域系数集中第一位置的元素等于第二量化矩阵中第一位置的元素时,将频域系数集中第一位置的元素保留或置零。
在另一种可能的实现方式中,本申请提供的图像压缩方法还可以包括:获取图像块的特征值,特征值用于指示图像块的下述特征中任一种:空域特征、频域特征或纹理特征。对频域系数集进行第二量化操作,得到第二量化系数集,可以包括:根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定图像块的第二量化矩阵,基于图像块的第二量化矩阵对该图像块的频域系数集先后进行第一量化操作,和第一量化操作的反量化操作,得到该图像块的第二量化系数集。
在该实现方式中,通过确定的与图像块相关的第二量化矩阵,去除频域系数集中的高频分量,保持或减小频域系数集中低频分量的幅值大小。通过确定的与图像块相关的第二量化矩阵进行第一量化操作,去除频域系数集中的高频分量,通过对第一量化操作后的结果进行第一量化操作后的反量化操作,保持或减小频域系数集中低频分量的幅值大小,实现与JPEG压缩标准的兼容。
在另一种可能的实现方式中,本申请提供的图像压缩方法还可以包括:获取图像块的特征值,特征值用于指示图像块的下述特征中任一种:空域特征、频域特征或纹理特征。对频域系数集进行第二量化操作,得到第二量化系数集,具体可以实现为:根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定图像块的第二量化矩阵;将图像块的频域系数集中的元素,与该图像块的第二量化矩阵中该元素对应位置处的元素比较大小,基于预设规则,确定该图像块的第二量化系数集。其中,预设规则可以包括:当频域系数集中第一位置的元素大于第二量化矩阵中第一位置的元素时,保留频域系数集中第一位置的元素;第一位置为频域系数集中的任一位置;当频域系数集中第一位置的元素小于第二量化矩阵中第一位置的元素时,将频域系数集中第一位置的元素置零;当频域系数集中第一位置的元素等于第二量化矩阵中第一位置的元素时,将频域系数集中第一位置的元素保留或置零。
通过比较操作替代第一量化操作与反量化操作,避免了乘法和除法操作,降低了硬件逻辑的实现成本。
在另一种可能的实现方式中,根据第一量化矩阵的量化信息及特征值,确定图像块的第二量化矩阵,包括:根据第二量化矩阵QM 2与第一量化矩阵QM 1、特征值X的 关系,确定QM 2。其中,QM 2与QM 1、特征值X的关系满足如下表达式:QM 2=QM 1+F 1(X)。其中,F 1(·)为第一预设函数。
在该实现方式中,可以根据实际经验配置确定第二量化矩阵的表达式,使得确定的量化矩阵可以更好的体现图像块的特点,进而实现与图像块特点匹配的第二量化操作,达到在图像压缩过程中兼顾视觉体验、用户体验以及图像压缩率的目的。
在另一种可能的实现方式中,第一量化矩阵的量化信息可以包括确定第一量化矩阵的第一质量因子QF 1,QF 1用于根据第一关系表达式计算第一量化矩阵。其中,第一关系表达式为质量因子与标准量化矩阵QM S的关系表达式。相应的,根据第一量化矩阵的量化信息及所述特征值,确定图像块的第二量化矩阵,具体可以实现为:根据特征值X,确定质量因子偏移值ΔQF;根据ΔQF及QF 1,计算第二质量因子QF 2;根据QF 2以及第一关系表达式,确定第二量化矩阵。其中,ΔQF满足如下表达式:ΔQF=F 2(X);F 2(·)为第二预设函数;QF 2满足如下表达式:QF 2=|QF 1|-F 3(ΔQF),F 3(·)为第三预设函数。
在通过质量因子确定量化矩阵的场景中,根据实际经验配置确定第二质量因子的表达式,再根据第二质量因子确定第二量化矩阵,使得确定的量化矩阵可以更好的体现图像块的特点,进而实现与图像块特点匹配的第二量化操作,达到在图像压缩过程中兼顾视觉体验、用户体验以及图像压缩率的目的。
在另一种可能的实现方式中,特征值可以用于指示图像块的纹理特征,可以根据特征值X与该图像块中像素值的表达式,计算特征值X。其中,特征值X与图像块中像素值的表达式满足如下关系:
Figure PCTCN2020118910-appb-000002
其中,
Figure PCTCN2020118910-appb-000003
Pix i为待处理图像块中第i个像素点的像素值,M为该图像块的宽,L为该图像块的高。
在另一种可能的实现方式中,本申请提供的图像压缩方法还可以包括:获取待压缩图像中的ROI;若图像块处于ROI之外,执行获取图像块的特征值以及根据第一量化矩阵的量化信息及特征值,确定图像块的第二量化矩阵。或者,若图像块处于ROI,将频域系数集基于第一量化矩阵进行第一量化操作得到第一量化系数集,对第一量化系数集进行熵编码,得到图像块的压缩数据。
对非ROI区域的图像块进行两次量化,达到加大量化步长提高压缩率降低存储空间的目的,对ROI区域的图像块进行JPEG压缩协议的量化,对感兴趣区域进行灵活编码,在保证感兴趣区域质量的同时,减少其他区域所耗费的码率,进而节省码率(存储空间),进一步提高压缩率。
在另一种可能的实现方式中,获取待压缩图像中的ROI,具体可以实现为:接收输入的ROI区域信息,确定待压缩图像中ROI区域信息指示的区域为ROI。ROI区域信息用于指示ROI在待压缩图像中的坐标位置。在该实现方式中,通过用户输入ROI区域信息,确定待压缩图像中ROI的位置,可以更好的满足用户需求。
在另一种可能的实现方式中,获取待压缩图像中的ROI,具体可以实现为:接收输入的待压缩图像的Map图像信息,基于Map图像信息确定待压缩图像中的感兴趣 区域ROI,Map图像信息用于指示待压缩图像中每个图像块是否处于ROI区域。在该实现方式中,通过用户输入待压缩图像的Map图像信息,确定待压缩图像中ROI的位置,可以更好的满足用户需求。
在另一种可能的实现方式中,获取待压缩图像中的ROI,具体可以实现为:通过人工智能(artificial intelligence,AI)识别技术,获取待压缩图像中的ROI。通过机器采用AI识别技术自动获取ROI,效率高且易实现。
第二方面,提供一种图像压缩装置,该装置可以包括:变换单元、第二量化单元、第一量化单元及编码单元。其中:变换单元,用于对待压缩图像中的图像块进行第一变换,得到图像块的频域系数集;该图像块为待压缩图像中包括多个像素点的连续区域。第二量化单元,用于对变换单元得到的频域系数集进行第二量化操作,得到第二量化系数集。第二量化操作用于去除频域系数集中的高频分量,保持或减小频域系数集中低频分量的幅值大小;第二量化操作去除的高频分量的数量与图像块相关;第二量化操作去除的高频分量的数量,大于或等于基于第一量化矩阵进行第一量化操作去除的高频分量的数量;第一量化单元,用于基于第一量化矩阵对第二量化系数集进行第一量化操作,得到第一量化系数集。编码单元,用于对第一量化单元得到的第一量化系数集进行熵编码,得到图像块的压缩数据。
通过本申请实施例提供的图像压缩装置,对数据块的频率系数集先进行一次与图像块相关的第二量化操作,将高频分量去除,将低频分量保持或减小幅值,再基于配置的第一量化矩阵进行第一量化操作,之后再进行熵编码完成压缩。这样一来,不同图像块相关的量化不同,一帧图像中不同图像块可以按照不同的量化步长进行量化,可以满足用户在不同场景对不同图像区域的不同视觉需求;实现了根据实际需求调整编码后JPEG格式图像的大小;同时,可以在满足JPEG标准的前提下,对感兴趣区域进行灵活编码,在保证感兴趣区域质量的同时,减少其他区域所耗费的码率,进而节省码率(存储空间),进一步提高压缩率。
在一种可能的实现方式中,本申请提供的图像压缩装置还包括第一获取单元,用于获取待压缩图像中的ROI。第二量化单元具体用于:若图像块处于待压缩图像的ROI,将频域系数集中按照ZigZag顺序排列的前N1个元素保留,其余元素置零,得到第二量化系数集;若图像块处于待压缩图像的非ROI,将频域系数集中按照ZigZag顺序排列的前N2个元素保留,其余元素置零,得到第二量化系数集。N1大于N2。通过该实现方式进行第二量化操作,实现过程简单,计算复杂度低,节约成本。
在另一种可能的实现方式中,N1为63,N2为32。
在一种可能的实现方式中,本申请实施例提供的图像压缩装置还可以包括第二获取单元,用于获取图像块的特征值,特征值用于指示图像块的下述特征中任一种:空域特征、频域特征或纹理特征。第二量化单元具体用于:根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定图像块的第二量化矩阵,基于第二量化矩阵对频率系数集进行第三操作,得到该图像块的第二量化系数集。
一种可能的实现方式中,第三操作可以为先后进行第一量化操作和第一量化操作的反量化操作。
另一种可能的实现方式中,第三操作可以包括将图像块的频域系数集中的元素, 与该图像块的第二量化矩阵中该元素对应位置处的元素比较大小,基于预设规则,确定该图像块的第二量化系数集。其中,预设规则可以包括:当频域系数集中第一位置的元素大于第二量化矩阵中第一位置的元素时,保留频域系数集中第一位置的元素;第一位置为频域系数集中的任一位置;当频域系数集中第一位置的元素小于第二量化矩阵中第一位置的元素时,将频域系数集中第一位置的元素置零;当频域系数集中第一位置的元素等于第二量化矩阵中第一位置的元素时,将频域系数集中第一位置的元素保留或置零。
在另一种可能的实现方式中,本申请实施例提供的图像压缩装置还可以包括第二获取单元,用于获取图像块的特征值,特征值用于指示图像块的下述特征中任一种:空域特征、频域特征或纹理特征。第二量化单元具体用于:根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定图像块的第二量化矩阵,基于图像块的第二量化矩阵对该图像块的频域系数集先后进行第一量化操作,和第一量化操作的反量化操作,得到该图像块的第二量化系数集。
在该实现方式中,通过确定的与图像块相关的第二量化矩阵,去除频域系数集中的高频分量,保持或减小频域系数集中低频分量的幅值大小。通过确定的与图像块相关的第二量化矩阵进行第一量化操作,去除频域系数集中的高频分量,通过对第一量化操作后的结果进行第一量化操作后的反量化操作,保持或减小频域系数集中低频分量的幅值大小,实现与JPEG压缩标准的兼容。
在另一种可能的实现方式中,本申请实施例提供的图像压缩装置还可以包括第二获取单元,用于获取图像块的特征值,特征值用于指示图像块的下述特征中任一种:空域特征、频域特征或纹理特征。第二量化单元具体用于:根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定图像块的第二量化矩阵;将图像块的频域系数集中的元素,与该图像块的第二量化矩阵中该元素对应位置处的元素比较大小,基于预设规则,确定该图像块的第二量化系数集。其中,预设规则可以包括:当频域系数集中第一位置的元素大于第二量化矩阵中第一位置的元素时,保留频域系数集中第一位置的元素;第一位置为频域系数集中的任一位置;当频域系数集中第一位置的元素小于第二量化矩阵中第一位置的元素时,将频域系数集中第一位置的元素置零;当频域系数集中第一位置的元素等于第二量化矩阵中第一位置的元素时,将频域系数集中第一位置的元素保留或置零。
通过比较操作替代第一量化操作与反量化操作,避免了乘法和除法操作,降低了硬件逻辑的实现成本。
在另一种可能的实现方式中,第二量化单元根据第一量化矩阵的量化信息及特征值,确定图像块的第二量化矩阵,包括:根据第二量化矩阵QM 2与第一量化矩阵QM 1、特征值X的关系,确定QM 2。其中,QM 2与QM 1、特征值X的关系满足如下表达式:QM 2=QM 1+F 1(X)。其中,F 1(·)为第一预设函数。
在该实现方式中,可以根据实际经验配置确定第二量化矩阵的表达式,使得确定的量化矩阵可以更好的体现图像块的特点,进而实现与图像块特点匹配的第二量化操作,达到在图像压缩过程中兼顾视觉体验、用户体验以及图像压缩率的目的。
在另一种可能的实现方式中,第一量化矩阵的量化信息可以包括确定第一量化矩 阵的第一质量因子QF 1,QF 1用于根据第一关系表达式计算第一量化矩阵。其中,第一关系表达式为质量因子与标准量化矩阵QM S的关系表达式。第二量化单元根据第一量化矩阵的量化信息及特征值,确定图像块的第二量化矩阵,包括:根据特征值X,确定质量因子偏移值ΔQF;根据ΔQF及QF 1,计算第二质量因子QF 2;根据QF 2以及第一关系表达式,确定第二量化矩阵。其中,ΔQF满足如下表达式:ΔQF=F 2(X);F 2(·)为第二预设函数;QF 2满足如下表达式:QF 2=|QF 1|-F 3(ΔQF),F 3(·)为第三预设函数。
在通过质量因子确定量化矩阵的场景中,根据实际经验配置确定第二质量因子的表达式,再根据第二质量因子确定第二量化矩阵,使得确定的量化矩阵可以更好的体现图像块的特点,进而实现与图像块特点匹配的第二量化操作,达到在图像压缩过程中兼顾视觉体验、用户体验以及图像压缩率的目的。
在另一种可能的实现方式中,本申请提供的图像压缩装置还可以包括第一获取单元,用于获取待压缩图像中的ROI。第二量化单元具体用于:若图像块处于ROI之外,执行获取图像块的特征值以及根据第一量化矩阵的量化信息及特征值,确定图像块的第二量化矩阵;或者,若图像块处于所述ROI,第一量化单元,还用于基于第一量化矩阵对频域系数集进行第一量化操作得到第一量化系数集。
对非ROI区域的图像块进行两次量化,达到加大量化步长提高压缩率降低存储空间的目的,对ROI区域的图像块进行JPEG压缩协议的量化,对感兴趣区域进行灵活编码,在保证感兴趣区域质量的同时,减少其他区域所耗费的码率,进而节省码率(存储空间),进一步提高压缩率。
在另一种可能的实现方式中,第一获取单元具体用于:接收输入的ROI区域信息,确定待压缩图像中ROI区域信息指示的区域为ROI。ROI区域信息用于指示ROI在待压缩图像中的坐标位置。在该实现方式中,通过用户输入ROI区域信息,确定待压缩图像中ROI的位置,可以更好的满足用户需求。
在另一种可能的实现方式中,第一获取单元具体用于:接收输入的待压缩图像的Map图像信息,基于Map图像信息确定待压缩图像中的感兴趣区域ROI,Map图像信息用于指示待压缩图像中每个图像块是否处于ROI区域。在该实现方式中,通过用户输入待压缩图像的Map图像信息,确定待压缩图像中ROI的位置,可以更好的满足用户需求。
需要说明的是,第二方面提供的图像压缩装置用于执行上述第一方面或第一方面的任一种可能的实现方式提供的图像压缩方法,其具体实现可以参照前述第一方面或第一方面的任一种可能的实现方式。
第三方面,本申请提供了一种图像压缩装置,该图像压缩装置可以实现上述第一方面描述的方法示例中的功能,所述功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。所述硬件或软件包括一个或多个上述功能相应的模块。该图像压缩装置可以以芯片的产品形态存在。
在一种可能的实现方式中,该图像压缩装置可以包括处理器和传输接口。其中,传输接口用于接收和发送数据。处理器被配置为调用存储在存储器中的程序指令,以使得该图像压缩装置执行上述第一方面描述的方法示例中的功能。
第四方面,提供一种计算机可读存储介质,该计算机可读存储介质中存储有程序 指令,当该程序指令在计算机上或处理器上运行时,使得计算机或处理器执行上述第一方面或第二方面或其任一种可能的实现方式提供的图像压缩方法。
第五方面,提供一种计算机程序产品,该计算机程序产品包括程序指令,当该程序指令在计算机或处理器上运行时,使得计算机或处理器执行上述第一方面或其任一种可能的实现方式提供的图像压缩方法。
第六方面,提供一种芯片系统,该芯片系统包括处理器,还可以包括存储器,用于实现上述方法中相应的功能。该芯片系统可以由芯片构成,也可以包含芯片和其他分立器件。
第七方面,提供一种图像压缩系统,该系统包括第二方面或第三方面的图像压缩装置。
其中,需要说明的是,上述各个方面中的任意一个方面的各种可能的实现方式,在方案不矛盾的前提下,均可以进行组合。
附图说明
图1为本申请实施例提供的一种示例性的JPEG压缩流程示意图;
图2为本申请实施例提供的一种示例性的矩阵示意图;
图3为本申请实施例提供的一种示例性的图像压缩传输的场景示意图;
图4为本申请实施例提供的一种示例性的图像压缩装置的结构示意图;
图5为本申请实施例提供的一种示例性的图像块的结构示意图;
图6为本申请实施例提供的一种示例性的图像压缩方法的流程示意图;
图7为本申请实施例提供的一种示例性的压缩图像块的过程示意图;
图8为本申请实施例提供的另一种示例性的压缩图像块的过程示意图;
图9为本申请实施例提供的再一种示例性的压缩图像块的过程示意图;
图10为本申请实施例提供的再一种示例性的压缩图像块的过程示意图;
图11为本申请实施例提供的再一种示例性的压缩图像块的过程示意图;
图12为本申请实施例提供的再一种示例性的压缩图像块的过程示意图;
图13为本申请实施例提供的再一种示例性的压缩图像块的过程示意图;
图14为本申请实施例提供的再一种示例性的压缩图像块的过程示意图;
图15为本申请实施例提供的再一种示例性的压缩图像块的过程示意图;
图16为本申请实施例提供的另一种示例性的图像压缩装置的结构示意图;
图17为本申请实施例提供的再一种示例性的图像压缩装置的结构示意图;
图18为本申请实施例提供的再一种示例性的图像压缩装置的结构示意图。
具体实施方式
在本申请实施例中,为了便于清楚描述本申请实施例的技术方案,采用了“第一”、“第二”等字样对功能和作用基本相同的相同项或相似项进行区分。本领域技术人员可以理解“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同。该“第一”、第二”描述的技术特征间无先后顺序或者大小顺序。
在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不 应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念,便于理解。
在本申请的描述中,除非另有说明,“/”表示前后关联的对象是一种“或”的关系,例如,A/B可以表示A或B;本申请中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况,其中A,B可以是单数或者复数。并且,在本申请的描述中,除非另有说明,“多个”是指两个或多于两个。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。
在本申请实施例中,至少一个还可以描述为一个或多个,多个可以是两个、三个、四个或者更多个,本申请不做限制。
此外,本申请实施例描述的网络架构以及场景是为了更加清楚的说明本申请实施例的技术方案,并不构成对于本申请实施例提供的技术方案的限定,本领域普通技术人员可知,随着网络架构的演变和新业务场景的出现,本申请实施例提供的技术方案对于类似的技术问题,同样适用。
在描述本申请的实施例之前,此处先对本申请涉及的名词统一进行解释说明,后续不再一一进行说明。
图像块(也可称为数据块),为待压缩图像中包括多个像素点的连续区域。可以通过分割的方式,将待压缩图像分割为多个图像块。在JPEG图像压缩标准中,一个图像块可以包括8×8个像素点。一个像素点可以包括多个视觉系统关注的分量,例如亮度分量、色度分量等。可以将像素点包括的分量用分量值表示。
图像块的分量集,是指图像块中的多个像素点包括的该分量的分量值的集合。分量集可以以矩阵的形式体现。例如,图像块中的像素点在亮度分量上的数值集合,称为图像块的亮度分量集;图像块中的像素点在色度分量上的数值集合,称为图像块的色度分量集。一个图像块分量集的尺寸与该图像块的尺寸相同。例如,一个YUV格式的图像块可以包括一个该图像块的亮度分量集和两个该图像块的色度分量集(色度U分量集和色度V分量集)。
应当理解,一个图像块通常包括多个该图像块的分量集,例如RGB图像包括图像块的R分量集,G分量集以及B分量集;YUV图像包括图像块的Y分量集,U分量集和V分量集,对图像块进行第一变换,包括对图像块的多个分量集分别进行第一变换,得到图像块的多个频域系数集。
图像块的分量集的频域系数集,是指图像块的分量集经过空域向频域转换后,得到的频域系数的集合。图像块的每一个分量集,可以有其对应的频域系数集。
频域系数集中的高频分量,是指频域系数集中预设的表示人眼视觉系统不敏感的位置的元素。例如,基于ZigZag顺序扫描方式,频域系数集的位置序号大于Z的所有系数定义为高频分量。Z可以根据实际需求配置。
频域系数集中的低频分量,是指频域系数集中表示高频分量位置之外的其他位置的元素。人眼视觉系统对于频域系数集中的低频分量敏感。
量化,是指将幅度离散。在图像处理中,对图像块的分量集中的幅值进行量化,将图像块的分量集中不重要(视觉系统不敏感)的高频分量去除,将重要的(视觉系统敏感)低频分量幅值保持或降低。
量化步长,是指量化过程中用于降低幅值的步长。例如,对图像块的分量集点除量化矩阵进行量化,量化矩阵中元素的值即为量化步长。
第一量化操作包括对待处理对象,点除量化矩阵得到整数结果。当待处理对象为整型数据,第一量化操作对待处理对象点除量化矩阵得到整数结果;当待处理对象为浮点型数据,第一量化操作对待处理对象点除量化矩阵后取整或截断。例如,在图像压缩过程中,对频域系数集A基于第一量化矩阵B进行第一量化操作,得到的结果C中第i行第j列的元素为:C(i,j)=A(i,j)./B(i,j),其中./为点除操作。
第二量化操作包括对频域系数集去除高频分量,保持或减小低频分量的幅值大小。第二量化操作去除的高频分量的数量与图像块相关,可以通过图像块的特征(空域特征、频域特征、纹理特征或其他特征)反映视觉系统对图像块的敏感程度,或者,通过图像块所处的区域反映用户是否对该图像块感兴趣,在第二量化操作中对将视觉不敏感的图像块或者用户不感兴趣的区域中的图像块,去除更多的高频分量提高压缩率降低压缩后图像的大小,对将视觉敏感的图像块或者用户感兴趣的区域中的图像块,去除更少的高频分量提高视觉效果。也就是通过第二量化操作在不同图像块中实现图像块相关的量化。对于第二量化操作的具体过程,详见下述实施例内容,此处不再赘述。
ZigZag顺序可以指从矩形形式的集合中左上角到右下角的扫描遍历顺序。例如,可以如图2示意的矩阵中,数字0至数字63的由小到大的顺序,即图2中箭头所示的顺序。
在描述本申请方案之前,先对JPEG图像压缩进行简单描述。
一张800×800大小的普通图片,如果未经压缩,其大小为1.7兆比特(MegaByte,MB)左右,该大小在存储或传输的过程中都会占据很大的空间,因此,图像压缩至关重要。当前,图片大多使用JPEG压缩技术,也就是常用的jpeg图像文件。JPEG压缩技术因为使用了有损压缩技术,JPEG文件相对于原始图像能够达到1/8的压缩比。有损压缩就是把原始数据中不重要的部分去掉,以便减小数据所占用的空间。
在JPEG压缩的过程中,一帧(幅)图像先会被分割成一系列16×16的图像块。图像块的划分方式是,从图像的左上角开始,按照水平方向扫描图像的前16行,扫描过程中每16列分割为1个图像块。在完成前16行扫描之后,继续从左到右扫描图像中前16行接下来的16行数据,扫描过程中每16列分割为1个图像块。按照该顺序每16行扫描分割,直到一帧图像完成。对于每一个16×16的图像块会进一步分割成4个8×8的图像块,然后对于每一个8×8的图像块的各个分量集使用如图1示意的JPEG压缩流程进行压缩。对于图像分割过程本申请不再赘述。对于图像分割后每个图像块的大小也可以根据实际需求调整。
如图1所示,一个8×8的图像块(图像块中每个分量集)经过离散余弦变换(discrete cosine transform,DCT)、量化、熵编码之后,得到该图像块的压缩数据。
需要说明的是,本申请实施例中描述的对图像块进行的操作,均可以理解为对图 像块中每个分量集分别进行操作,后续不再一一赘述。
例如,对一个8×8的YUV格式的图像块经过DCT、量化、熵编码之后,得到该图像块的压缩数据,是指:对该图像块8×8的亮度分量集经过DCT、量化、熵编码,得到该图像块的亮度分量集的压缩数据,对该图像块8×8的色度U分量集经过DCT、量化、熵编码,得到该图像块的色度U分量集的压缩数据,对该图像块8×8的色度V分量集经过DCT、量化、熵编码,得到该图像块的色度V分量集的压缩数据。
下面图1示意的JPEG压缩流程中的各个步骤进行说明。
DCT是对8×8的图像块分别进行8×8的行变换和8×8的列变换的矩阵乘法,得到8×8的DCT系数。由于图像块在空间域具有很强的相关性,其含有的频率成分有限,且主要分布在中低频区域,因此DCT在图像压缩中将空间数据块变换到频域,以DCT系数(频域系数集)进行表示,在频域将空间数据块中含有的不同的频率成分分开,变换后DCT的系数在高频常常为0或较小值。比如对于纹理较少的平坦区域对应的高频系数常常为0。频率系数集可以采用矩阵或者表格或者其他形式体现,本申请对此不予限定。变换后的频域系数集可以分为左上角的直流(direct current,DC)分量(频域系数集中按照ZigZag顺序扫描方式的第一个元素)和其他位置的交流(alternating current,AC)分量(频域系数集中按照ZigZag顺序扫描方式的第二个元素及之后的所有元素)。
量化,根据外部输入的量化矩阵,对DCT系数进行量化,得到量化系数。量化操作是通过对DCT系数除一个非0的整数(量化步长)来实现,量化后的值会被截断或舍入到最近整数。该量化步骤采用前述第一量化操作实现。在实际中,会根据人眼对高频系数不敏感的特性,随着频率的增加,在量化矩阵中逐渐增加量化步长,来达到更好的压缩比。亮度分量集和色度分量集可以采用不同的量化矩阵来实现压缩。亮度分量包含较多的纹理细节及轮廓信息,在DCT的变换域上,频率分布比较广泛,包含较多的高频信息,因此通常使用更大的量化步长对亮度分量集进行量化,实现降低码率的效果。而色度分量包含细节和轮廓信息较少,但是人眼对色度更敏感,在DCT的变换域上,频率分布比较广泛,包含较少的高频信息,通常在量化的过程中,色度分量集使用的量化步长比亮度分量集的量化步长更小。
需要说明的是,固定量化矩阵可以根据实际需求配置,本申请实施例对此不进行具体限定。
示例性的,一种JPEG压缩采用的亮度分量的标准量化矩阵可以如下示意:
Figure PCTCN2020118910-appb-000004
示例性的,一种JPEG压缩采用的色度分量的标准量化矩阵可以如下示意:
Figure PCTCN2020118910-appb-000005
上述亮度分量、色度分量的标准量化矩阵中,从左上角到右下角按照ZigZag顺序,量化步长逐渐增大,以通过大的量化步长舍弃高频分量提高压缩率,减小图像压缩后的体积。另外,由上述亮度分量、色度分量的标准量化矩阵可以看出,色度分量使用的量化步长比亮度分量的量化步长更小,以满足人眼对色度更敏感的需求。
熵编码,是对量化得到的量化系数进行编码,得到压缩数据的过程。熵编码时,可以对DC分量使用一维差分脉冲编码调制(differential pulse coding modulation,DPCM),然后再进行熵编码。对于AC量化系数进行ZigZag扫描,对于连续零系数的个数和非零系数幅值使用哈夫曼(Huffman)编码进行熵编码。
在压缩一副图像时,编码端压缩的过程中使用的量化矩阵和对应熵编码使用的Huffman表也需压缩到码流中传输到解码端,以便于解码端还原图像。
从上述JPEG压缩流程可知,在一帧(整幅)图像中,只使用一套量化矩阵(亮度分量的量化矩阵、色度分量的量化矩阵),单个分量只使用一个唯一的量化矩阵,压缩率固定。
而实际中,在安防监控中抓拍数据、手机拍照等应用场景,需要对某些目标区域尤其关注,希望使用更精细的量化步长,对其他一些不敏感的区域,比如背景区域,可以利用人眼对不同纹理特性区域的量化程度感知度不同的这一视觉特性,希望使用更粗的量化精度,来达到降低码率的目的。当前的JPEG压缩,无法满足用户在不同场景对不同图像区域的不同视觉需求。
基于此,本申请实施例提供一种图像压缩方法,在现有JPEG压缩标准中进行量化操作之前,对图像块的分量集的频率系数集先进行一次与图像块相关的量化,将高频分量去除,将低频分量保持或减小幅值,再基于配置的固定量化矩阵进行JPEG压缩标准中的量化,之后再进行熵编码完成压缩。这样一来,图像块不同时,图像块相关的量化就不同,可以实现一帧图像中不同图像块的同一分量按照不同的量化步长进行量化,可以满足用户在不同场景对不同图像区域的不同视觉需求;也就实现了根据实际需求调整编码后JPEG格式图像的大小;同时,可以在JPEG上灵活的实现感兴趣编码的功能,在保证感兴趣区域质量的同时,减少其他区域所耗费的码率,进而节省码率(存储空间),可以进一步提高压缩率。
本申请实施例提供的图像压缩方法可以应用于图像压缩存储场景,或者,图像压缩传输的场景中。
如图3示意了一种图像压缩传输的场景,该场景中包括编码端设备301及译码端设备302。
其中,编码端设备301可以将图像压缩后传输至译码端设备302,由译码端设备202解压缩后呈现或保存。
编码端设备301或者译码端设备302可以为终端设备、手机、掌上电脑等产品形态,本申请实施例对此不予限定。
在图像压缩存储场景中,编码端设备可以获取图像并压缩后存储于自身对应的存储器中。
下面结合附图,对本申请的实施例进行具体阐述。
一方面,本申请实施例提供一种图像压缩装置,用于执行本申请提供的图像压缩方法。
图4示出的是与本申请各实施例相关的一种图像压缩装置40。如图4所示,图像压缩装置40可以包括处理器401、存储器402以及收发器403。
下面结合图4对图像压缩装置40的各个构成部件进行具体的介绍:
其中,存储器402可以是易失性存储器(volatile memory),例如随机存取存储器(random-access memory,RAM);或者非易失性存储器(non-volatile memory),例如只读存储器(read-only memory,ROM),快闪存储器(flash memory),硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD);或者上述种类的存储器的组合,用于存储可实现本申请方法的程序代码、配置文件或其他内容。
处理器401是图像压缩装置40的控制中心。例如,处理器401可以是一个中央处理器(central processing unit,CPU),也可以是特定集成电路(application specific integrated circuit,ASIC),或者是被配置成实施本申请实施例的一个或多个集成电路,例如:一个或多个微处理器(digital singnal processor,DSP),或,一个或者多个现场可编程门阵列(field programmable gate array,FPGA)。
收发器403用于与其他设备进行通信。收发器403可以为通信端口或者其他。
处理器401通过运行或执行存储在存储器402内的软件程序和/或模块,以及调用存储在存储器402内的数据,执行如下功能:
对待压缩图像中的图像块进行第一变换,得到该数据块分量的频域系数集;对频域系数集进行第二量化操作,得到第二量化系数集;第二量化操作用于去除频域系数集中的高频分量,保持或减小频域系数集中低频分量的幅值大小;第二量化操作去除的高频分量的数量与图像块相关;第二量化操作去除的高频分量的数量,大于或等于基于第一量化矩阵进行第一量化操作去除的高频分量的数量;基于第一量化矩阵对第二量化系数集进行第一量化操作,得到第一量化系数集;对第一量化系数集进行熵编码,得到图像块的压缩数据。
另一方面,本申请实施例提供一种图像压缩方法,由图像压缩装置执行该方法,对待压缩图像进行压缩得到其压缩数据。图像压缩装置可以将待压缩图像分割为多个图像块,对每个图像块的各个分量集,进行本申请提供的图像压缩方法。其中,图像压缩装置对于每个图像块的每个分量集的压缩过程相同。本申请下述实施例描述的图像压缩装置对图像块的压缩过程,应理解为,图像压缩装置对图像块的每个分量集执行下述压缩过程,不再分别进行赘述。还应理解,本申请实施例中描述的“图像块”,可以等价替换为“图像块的色度分量集”或“图像块的亮度分量集”或“图像块的某 一分量集”来描述本申请所保护的方案。
需要说明的是,对于将待压缩图像分割为图像块的具体实现,已在前述图1示意的JPEG压缩过程中进行了说明,此处不再赘述。
需要说明的是,该待压缩图像可以为YUV格式的图像,或者其他包含色度分量、亮度分量的图像格式,本申请对于待压缩图像的格式不予限定。当待压缩图像的格式为图像压缩装置不支持的图像格式,可以先将待压缩图像进行格式转换,得到图像压缩装置支持的图像格式,再执行本申请提供的图像压缩方法。
示例性的,假设一个YUV420格式的待压缩图像分割后的图像块包含的分量可以如图5所示,该图像块包括一个16×16的亮度分量集、一个8×8的色度U分量集和一个8×8的色度V分量集。图像压缩装置可以将16×16的亮度分量集分割为4个8×8的亮度分量集,然后对4个8×8的亮度分量集、一个8×8的色度U分量集和一个8×8的色度V分量集中每个分量集执行本申请提供的图像压缩方法,得到每个分量集的压缩数据,作为该图像块的压缩数据。
如图6所示,本申请实施例提供的图像压缩方法可以包括:
S601、图像压缩装置对待压缩图像中的图像块进行第一变换,得到该图像块的频域系数集。
其中,该图像块为待压缩图像分割得到的任一图像块,后文中也称之为待处理图像块。
其中,第一变换用于将图像块的空域数据值表示转换为频域表示。图像块中每个像素点对应频域系数集中相同位置的元素。一个图像块的频域系数集中的元素排列以及元素数量,与该图像块相同。例如,第一变换可以为DCT变换或者其他类型的变换,本申请对此不予限定,对于其过程也不予赘述。
具体的,对于通过第一变换得到的图像块的频域系数集,可以采用矩阵或者其他形式表示,本申请实施例对此也不进行具体限定。需要说明的是,本申请实施例中采用矩阵形式表示频域系数集,仅作为示例,不构成具体限定。
需要说明的是,S601的具体实现可以参照JPEG压缩标准,此处不再赘述。
S602、图像压缩装置对频域系数集进行第二量化操作,得到第二量化系数集。
其中,第二量化操作用于去除频域系数集中的高频分量,保持或减小频域系数集中低频分量的幅值大小;第二量化操作去除的高频分量的数量与该图像块相关,通过第二量化操作对待压缩图像中不同图像块进行自适应量化,对每个图像块进行的量化效果与该图像块的特点相匹配,从而实现了对待压缩图像中不同区域达到不同的量化效果。
例如,可以通过图像块的特征(空域特征、频域特征、纹理特征或其他特征)反映视觉系统对图像块的敏感程度,或者,通过图像块所处的区域反映用户是否对该图像块感兴趣,在第二量化操作中对将视觉不敏感的图像块或者用户不感兴趣的区域中的图像块,去除更多的高频分量提高压缩率降低压缩后图像的大小,对将视觉敏感的图像块或者用户感兴趣的区域中的图像块,去除更少的高频分量提高视觉效果。
在实际应用中,可以根据实际需求配置第二量化操作的具体内容,达到去除频域系数集中的高频分量,保持或减小频域系数集中低频分量的幅值大小,且去除的高频 分量的数量与该图像块相关这一目的。
其中,第二量化操作去除的高频分量的数量,大于或等于基于第一量化矩阵进行第一量化操作去除的高频分量的数量。
一种可能的实现方式中,对于用户关注的区域中的图像块,或者对于视觉系统敏感的区域中的图像块,第二量化操作去除的高频分量的数量,可以等于基于第一量化矩阵进行第一量化操作去除的高频分量的数量。
另一种可能的实现方式中,对于用户关注度不高的区域中的图像块,或者对于视觉系统不敏感的区域的图像块,第二量化操作去除的高频分量的数量,可以大于基于第一量化矩阵进行第一量化操作去除的高频分量的数量。
在一种可选的情况中,第一量化矩阵是JPEG压缩标准中输入的固定量化矩阵。一帧待压缩图像中不同图像块的同一分量的第一量化矩阵相同。
S603、图像压缩装置基于第一量化矩阵对第二量化系数集进行第一量化操作,得到第一量化系数集。
具体的,S603中图像压缩装置基于第一量化矩阵进行第一量化操作具体包括将第二量化系数集点除第一量化矩阵,得到整数结果的第一量化系数集。
例如,第一量化系数集中第i行第j列的元素,可以为第二量化系数集中第i行第j列的元素,除以第一量化矩阵第i行第j列的元素的商的取整结果。
S604、图像压缩装置对第一量化系数集进行熵编码,得到图像块的压缩数据。
具体的,S604中对第一量化系数集进行熵编码,得到图像块的压缩数据,可以参照JPEG压缩标准中的熵编码过程,此处不再赘述。
例如,通过上述S601至S604提供的图像压缩方法压缩图像块的过程可以图7所示。
通过本申请实施例提供的图像压缩方法,对数据块的频率系数集先进行一次与图像块相关的第二量化操作,将高频分量去除,将低频分量保持或减小幅值,再基于配置的第一量化矩阵进行第一量化操作,之后再进行熵编码完成压缩。这样一来,不同图像块相关的量化不同,一帧图像中不同图像块可以按照不同的量化步长进行量化,可以满足用户在不同场景对不同图像区域的不同视觉需求;实现了根据实际需求调整编码后JPEG格式图像的大小;同时,可以在满足JPEG标准的前提下,对感兴趣区域进行灵活编码,在保证感兴趣区域质量的同时,减少其他区域所耗费的码率,进而节省码率(存储空间),进一步提高压缩率。
一种可能的实现方式中,在实际应用中,图像压缩装置可以对待压缩图像中的每个图像块执行上述S601至S604的过程,得到待压缩图像的压缩数据
一种可能的实现方式中,在实际应用中,图像压缩装置可以对待压缩图像中的部分图像块执行上述S601至S604的过程,对其余图像块按照JPEG压缩标准进行压缩,得到待压缩图像的压缩数据。
例如,图像压缩装置可以对待压缩图像中非感兴趣区域(region of interest,ROI)中的图像块执行上述S601至S604的过程进行压缩,对ROI区域的图像块按照JPEG压缩标准进行压缩。
其中,ROI为待压缩图像中用户关注度高的区域,可以根据实际需求配置确定待 压缩图像中ROI的具体实现,本申请实施例不予限定。
可选的,可以通过AI识别技术,获取待压缩图像中的ROI,或者,根据用户输入的ROI区域的指示信息获取待压缩图像中的ROI。本申请实施例对此不予限定。
一种可能的实现中,可以通过AI识别技术,获取待压缩图像中的ROI,输出ROI区域的指示信息。获取ROI的AI技术的类型本申请实施例不予限定。
例如,可以基于AI的目标检测,实时检测出待压缩图像中的目标,比如人脸、人形、车牌、车等,将识别出的目标所处的区域确定为ROI,其他区域则为非ROI,将一个个ROI区域的矩形框坐标信息作为ROI区域的指示信息。
一种可能的实现方式中,可以将AI识别输出的ROI区域的指示信息直接输入图像压缩装置,图像压缩装置在压缩过程中,可以根据ROI区域的指示信息实时的确定待处理的图像块是否处于ROI区域。
另一种可能的处理方式是:可以将AI识别输出的ROI区域的指示信息,根据其在待压缩图像中所处的位置,以图像块的大小为单位(也可以按照更大的尺寸来处理),比如16×16,针对整帧待压缩图像生成一个二值图(二值图的生成过程,可以根据AI分析的结果,比如AI目标检测的结果来生成),使用不同的标识来标识每个图像块是否为ROI区域,将这个二值图作为图像压缩装置的输入,图像压缩装置在压缩过程中,根据待处理图像块在二值图中的具体值,确定待处理图像块是否处于ROI区域。例如,可以通过0和1来标识,1标识图像块处于ROI区域内部,0标识图像块处于非ROI区域。
另一种可能的实现方式中,图像压缩装置可以接收输入的ROI区域信息,确定待压缩图像中ROI区域信息指示的区域为ROI,其他区域为非ROI。其中,ROI区域信息用于指示ROI在待压缩图像中的坐标位置。例如,ROI区域信息可以由图像压缩装置的用户在图像压缩装置的人机交互界面输入。当然,ROI区域信息也可以通过其他方式由其他主体输入,本申请实施例不予限定。
再一种可能的实现方式中,图像压缩装置可以接收输入的待压缩图像的Map图像信息,基于Map图像信息确定待压缩图像中的感兴趣区域ROI,其他区域为非ROI。其中,该Map图像信息用于指示待压缩图像中每个图像块是否处于ROI区域。
如前述,本申请S602中对频域系数集进行第二量化操作,得到第二量化系数集的具体实现可以根据实际需求配置,本申请实施例提供如下两种对频域系数集进行第二量化操作,得到第二量化系数集的具体实现,包括下述第一种实现及第二种实现,但并不构成具体限定。
第一种实现:
图像压缩装置获取待压缩图像中的ROI;若待处理图像块处于待压缩图像的感兴趣区域ROI,将频域系数集中按照ZigZag顺序排列的前N1个元素保留,其余元素置零,得到第二量化系数集;若待处理图像块处于待压缩图像的非ROI,将频域系数集中按照ZigZag顺序排列的前N2个元素保留,其余元素置零,得到第二量化系数集。
具体的,在第一种实现中,结合人眼视觉系统的特性,对低频信息敏感,对高频信息不敏感特性,而频域系数集从左上角到右下角,按照ZigZag顺序,频率成分逐渐升高,图像压缩装置可以采用第一种实现进行第二量化操作,得到第二量化系数。
其中,N1大于N2。可以根据实际需求配置N1、N2的取值。N1可以根据感兴趣区域关注程度确定,N1取值越大,感兴趣区域的量化程度越低,压缩后的图像越接近原始图像。N2可以根据感兴趣区域之外的区域的关注程度确定,N2取值越小,感兴趣区域之外的区域的量化程度越高,压缩后的图像损失越大,压缩率越高,压缩后的图像体积越小。
一种可能的实现方式中,N1可以远大于N2。例如,N1为63,N2为32。
另一种可能的实现方式中,图像块的不同分量集中,N1的取值可以不同,N2的取值也可以不同。
示例性的,图像压缩装置对频域系数集TC,基于ZigZag顺序扫描方式进行第二量化操作,得到第二量化系数集TC′的过程中,ZigZag顺序扫描中第idx个系数进行第二量化操作的过程可以通过如下表达式实现:
Figure PCTCN2020118910-appb-000006
其中,N对应ROI的N1、非ROI的N2。TC(i,j)为频域系数集TC按照ZigZag顺序扫描方式第idx个系数的值。
示例性的,在第一种实现中,本申请实施例提供的图像压缩方法压缩图像块的过程可以图8所示。如图8所示,图像块经过第一变换得到该图像块的频域系数集。然后对频域系数集进行置零处理,置零处理是指通过第一种实现进行第二量化操作,即若待处理的数据块分量处于待压缩图像的感兴趣区域ROI,将频域系数集中按照ZigZag顺序排列的前N1个元素保留,其余元素置零,得到第二量化系数集;若待处理的数据块分量处于待压缩图像的非ROI,将频域系数集中按照ZigZag顺序排列的前N2个元素保留,其余元素置零,得到第二量化系数集。接下来对第二量化系数集基于第一量化矩阵按照上述S603的描述进行第一量化操作,得到第一量化系数集。最后,对第一量化系数集进行熵编码得到图像块的压缩数据。
第二种实现:
图像压缩装置先获取待处理图像块的第二量化矩阵,根据第二量化矩阵完成对图像块的频域系数集的第二量化操作。
其中,第一量化矩阵、第二量化矩阵以及待处理图像块的行列大小相同,一个图像块的一个分量集的第二量化矩阵中一个元素的幅值,大于或等于该图像块的该分量集的第一量化矩阵中相同位置元素的幅值。
需要说明的是,可以根据实际需求配置图像块的第二量化矩阵的获取方式,本申请实施例对此不予限定。
示例性的,在第二种实现中,本申请实施例提供的图像压缩方法压缩数据块分量的过程可以图9所示。如图9所示,图像块经过第一变换得到该图像块的频域系数集。获取该图像块的第二量化矩阵,然后基于第二量化矩阵对频域系数集完成第二量化操作,得到第二量化系数集。接下来对第二量化系数集基于第一量化矩阵按照上述S603的描述进行第一量化操作,得到第一量化系数集。最后,对第一量化系数集进行熵编码得到图像块的压缩数据。
一种可能的实现方式中,图像块的第二量化矩阵可以由用户指定。
另一种可能的实现方式中,可以由图像压缩装置根据图像块的特点,获取图像块的第二量化矩阵。
示例性的,图像压缩装置可以获取图像块的特征值,根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定图像块的第二量化矩阵。应理解,图像压缩装置可以获取图像块的某一分量集(亮度分量集或色度分量集)的特征值,根据该图像块的该分量集的第一量化矩阵的量化信息,及该图像块的该分量集的特征值,确定该图像块的该分量集的第二量化矩阵。
示例性的,在第二种实现中,图像压缩装置进行第二量化操作时,获取图像块的特征值,根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定图像块的第二量化矩阵,然后完成第二量化操作时,本申请实施例提供的图像压缩方法压缩图像块的过程可以图10所示。如图10所示,图像块经过第一变换得到该图像块的频域系数集。通过图像特征分析,获取该图像块的特征值X。然后根据特征值X及该图像块的第一量化矩阵,确定该图像块的第二量化矩阵。接下来,基于第二量化矩阵对频域系数集完成第二量化操作,得到第二量化系数集。接下来对第二量化系数集基于第一量化矩阵按照上述S603的描述进行第一量化操作,得到第一量化系数集。最后,对第一量化系数集进行熵编码得到图像块的压缩数据。
其中,图像块的特征值用于指示图像块的下述特征中任一种:空域特征、频域特征或纹理特征。当然,图像块的特征值还可以指示图像块的其他特征,本申请实施例对此不予限定。
可选的,若待处理图像块处于ROI之外,图像压缩装置可以获取图像块的特征值,以及根据图像块的第一量化矩阵的量化信息及图像块特征值,确定图像块的第二量化矩阵,以完成第二量化操作。
可选的,若待处理图像块处于ROI,在S601之后,图像压缩装置可以将图像块的频域系数集基于第一量化矩阵进行第一量化操作得到第一量化系数集,对第一量化系数集进行熵编码,得到该图像块的压缩数据。
一种可能的实现方式中,图像压缩装置可以通过梯度或方差、边缘检测手段,来获取待处理图像块的空域特征。具体的,图像块的空域特征可以为一个空域特征值,具体的,可以通过Sobel边缘检测算子,检测图像块中每一个点在水平和垂直方向的边缘强度,将所有点的水平和垂直方向的边缘强度做累加和再取平均,得到该图像块内边缘强度指标,该边缘强度指标可以用于指示该图像块在空域上的特点,该边缘强度指标可以作为该图像块的特征值。
边缘强度指标的值越大,说明图像块中纹理或边缘强度越强,在实际中可以使用更大的量化步长进行量化,而不会显著降低压缩后的图像质量。反之,若边缘强度指标的值越小,则需要使用更小的量化步长,尽量少的影响人眼对图像的主观质量。
另一种可能的实现方式中,图像压缩装置也可以对待处理图像块的频域系数集,分析图像块的频域特征。具体的,图像块的频域特征可以为一个频域特征值,用于指示该图像块在频域上的特点。具体的,可以对图像块进行DCT变换得到的频域系数集中,所有的AC系数或中高频系数(例如基于ZigZag顺序扫描方式,序号大于16的所有系数)求和取平均得到频域成分的强度。将频域成分的强度作为图像块的特征值。 频域成分的强度越大,表示图像越复杂,在实际中可以使用更大的量化步长进行量化,而不会显著降低压缩后的图像质量。反之,若频域成分的强度越小,则需要使用更小的量化步长,尽量少的影响人眼对图像的主观质量。
再一种可能的实现方式中,特征值用于指示图像块的纹理特征,图像压缩装置可以根据特征值X与该图像块中像素值的表达式,计算特征值X。
其中,特征值X与图像块中像素值的表达式满足如下关系:
Figure PCTCN2020118910-appb-000007
其中,
Figure PCTCN2020118910-appb-000008
Pix i为待处理图像块中第i个像素点的像素值,M为该图像块的宽,L为该图像块的高。
需要说明的是,还可以通过其他方式获取图像块的特征值,本申请实施例不再一一描述。
在图像压缩装置获取到图像块的特征值后,图像压缩装置接下来可以根据图像块的第一量化矩阵的量化信息及该图像块的特征值,确定该图像块的第二量化矩阵。
由于人类视觉系统(human vision system,HVS)对图像的不同特征(频率特征、空域特征、纹理特征)区域的敏感程度不一样,比如有的区域是平坦的,比如墙面、人脸的肤色区域,HVS比较敏感,需要采用更小的量化步长进行量化,而有的区域比较复杂,比如草地,HVS并不是很敏感,而且包含较多的高频分量信息,因此可以使用更大的量化步长进行量化,达到降低码率的效果,因此可以基于该原则确定第二量化矩阵。
可选的,本申请实施例提供的图像压缩装置根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定该图像块的第二量化矩阵的过程,可以通过但不限于下述第一种确定方式或第二种确定方式。
第一种确定方式:第一量化矩阵的量化信息为第一量化矩阵,或者,第一量化矩阵的量化信息包括确定第一量化矩阵的第一质量因子QF 1,图像压缩装置先根据第一量化矩阵的量化信息,确定第一量化矩阵,然后根据第二量化矩阵QM 2与第一量化矩阵QM 1、特征值X的关系,确定QM 2。其中,QM 2与QM 1、特征值X的关系满足如下表达式:QM 2=QM 1+F 1(X);F 1(·)为第一预设函数。
其中,第一预设函数的内容可以根据实际需求配置,本申请实施例对此不予限定。示例性的,第一预设函数可以为log函数。例如,第一预设函数可以为以2为底的log函数log 2(X)。
需要说明的是,计算一个图像块中某一分量集的第二量化矩阵时,可以采用该图像块的其他分量集的特征值进行计算。
例如,在计算图像块的色度分量集的第二量化矩阵时,可以根据该图像块的亮度分量集的特征值,以及第二量化矩阵QM 2与第一量化矩阵QM 1、特征值X的关系,计算该图像块的色度分量集的第二量化矩阵。
可选的,当第一量化矩阵的量化信息可以为QM 1,图像压缩装置则直接可以确定QM 1
可选的,第一量化矩阵的量化信息可以包括确定第一量化矩阵的第一质量因子 QF 1,QF 1用于根据第一关系表达式计算第一量化矩阵QM 1。图像压缩装置可以根据及第一关系表达式,计算得到QM 1
其中,第一关系表达式为质量因子QF与标准量化矩阵QM S的关系表达式,第一关系表达式满足如下关系:QM qf=floor(S×QM s+50)。
其中,QM qf为计算的量化矩阵,floor(·)为取整操作,S满足如下表达式:
Figure PCTCN2020118910-appb-000009
第一种确定方式:第一量化矩阵的量化信息包括确定第一量化矩阵的第一质量因子QF 1,图像压缩装置先计算第二质量因子QF 2,再根据第一关系表达式及QF 2确定第二量化矩阵。
在第一种确定方式中,图像压缩装置具体通过如下步骤1至步骤3确定图像块的第二量化矩阵:
步骤1、图像压缩装置根据图像块的特征值X,确定质量因子偏移值ΔQF。
其中,ΔQF满足如下表达式:ΔQF=F 2(X);F 2(·)为第二预设函数。
其中,第二预设函数的内容可以根据实际需求配置,本申请实施例对此不予限定。
示例性的,第二预设函数可以为α*log 2(·),ΔQF满足如下表达式:ΔQF=α*log 2(X),其中,α为调整系数,用于控制ΔQF的值域。
步骤2、图像压缩装置根据ΔQF及QF 1,计算第二质量因子QF 2
其中,QF 2满足如下表达式:QF 2=|QF 1|-F 3(ΔQF);F 3(·)为第三预设函数。
其中,第三预设函数的内容可以根据实际需求配置,本申请实施例对此不予限定。
示例性的,第三预设函数可以为空,QF 2可以满足如下表达式:QF 2=|QF 1|-ΔQF。
示例性的,第三预设函数可以为钳位操作,QF 2可以满足如下表达式:QF 2=|QF 1|-clip(0,MaxΔQF,ΔQF)。
步骤3、图像压缩装置根据QF 2以及第一关系表达式,确定第二量化矩阵。
通过上述步骤1至步骤3的过程,对于纹理复杂的区域,计算得到的纹理特征X越大,对应ΔQF也会越大,而QF 2就会越小,确定的第二量化矩阵的量化步长就会更大,通过第二量化操作可以将更多的高频细节量化掉。
可选的,第二种实现中实现S602可以包括但不限于如下两种具体操作:
第一种具体操作:图像压缩装置基于第二量化矩阵对频域系数集先后进行第一量化操作,和第一量化操作的反量化操作,得到第二量化系数集。
其中,对于第一量化操作,前述名词解释部分已经进行了说明,此处基于第二量化矩阵对频域系数集进行第一量化操作,即将频域系数集点除第二量化矩阵,得到整数结果,然后对该整数结果点乘第二量化矩阵得到整数结果,作为第二量化系数集。
示例性的,图像压缩装置通过上述第一种确定方式,根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定图像块的第二量化矩阵,根据第一种具体操作完成第二量化操作,本申请实施例提供的图像压缩方法压缩图像块的过程可以图11所示。如图11所示,图像块经过第一变换得到该图像块的频域系数集。通过图像特征分析,获取该图像块的特征值X。然后根据特征值X及该图像块的第一量化矩阵,确定该图 像块的第二量化矩阵。接下来,基于第二量化矩阵对频域系数集先后进行第量化操作以及第一量化操作的反量化操作,得到第二量化系数集。接下来对第二量化系数集基于第一量化矩阵按照上述S603的描述进行第一量化操作,得到第一量化系数集。最后,对第一量化系数集进行熵编码得到图像块的压缩数据。
示例性的,图像压缩装置通过上述第二种确定方式,根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定图像块的第二量化矩阵,根据第一种具体操作完成第二量化操作,本申请实施例提供的图像压缩方法压缩图像块的过程可以图12所示。如图12所示,图像块经过第一变换得到该图像块的频域系数集。通过图像特征分析,获取该图像块的特征值X。根据第一质量因子按照上述步骤1至步骤3确定第二质量因子,根据特征值X及第二质量因子,确定图像块的第二量化矩阵。接下来,基于第二量化矩阵对频域系数集先后进行第一量化操作以及第一量化操作的反量化操作,得到第二量化系数集。接下来根据第一质量因子计算该图像块的第一量化矩阵,对第二量化系数集基于第一量化矩阵按照上述S603的描述进行第一量化操作,得到第一量化系数集。最后,对第一量化系数集进行熵编码得到图像块的压缩数据。
示例性的,图像压缩装置基于第二量化矩阵QM 2对频域系数集TC先后进行第一量化操作,和第一量化操作的反量化操作,得到第二量化系数集TC′的过程可以表示为如下式(1)和式(2),式(1)为基于第二量化矩阵QM 2对频域系数集TC进行第一量化操作得到结果QC 1,式(2)为基于第二量化矩阵QM 2对式(1)的结果QC 2进行第一量化操作的反量化操作,得到去除高频系数的第二量化系数集TC′。
QC 1=TC./QM 2   式(1)。
TC′=QM 2.*QC 1   式(2)。
其中“./”为矩阵点除运算,“.*”为矩阵的点乘运算。
示例性的,在实际应用中,若图像压缩装置对待压缩图像中的每个图像块执行上述S601至S604的过程,ROI区域的图像块的第二量化矩阵可以为该图像块的第一量化矩阵,非ROI区域的图像块的第二量化矩阵可以按照上述第二种实现中描述的方法获取。若按照上述第一种具体操作完成第二量化操作,本申请实施例提供的图像压缩方法压缩图像块的过程可以图13所示。如图13所示,图像块经过第一变换得到该图像块的频域系数集。图像压缩装置获取完成第二量化操作的量化矩阵(ROI区域的第一量化矩阵,非ROI区域的第二量化矩阵)。接下来,基于完成第二量化操作的量化矩阵,对频域系数集先后进行第一量化操作以及第一量化操作的反量化操作,得到第二量化系数集。接下来对第二量化系数集基于第一量化矩阵按照上述S603的描述进行第一量化操作,得到第一量化系数集。最后,对第一量化系数集进行熵编码得到图像块的压缩数据。
示例性的,在实际应用中,若图像压缩装置对待压缩图像中的每个图像块执行上述S601至S604的过程,ROI区域的图像块的第二量化矩阵可以为该图像块的第一量化矩阵,非ROI区域的图像块的第二量化矩阵可以按照上述第二种实现中描述的方法获取,且通过基于目标检测的AI识别确定ROI,本申请实施例提供的图像压缩方法压缩数据块分量的过程可以图14所示。如图14所示,输入图像分割为图像块,图像块经过第一变换得到该图像块的频域系数集。对输入图像基于AI的目标检测,得到ROI 指示信息,图像压缩装置获取完成第二量化操作的量化矩阵(ROI区域的第一量化矩阵,非ROI区域的第二量化矩阵)。接下来,基于完成第二量化操作的量化矩阵,结合ROI指示信息,对频域系数集先后进行第一量化操作以及第一量化操作的反量化操作,得到第二量化系数集。接下来对第二量化系数集基于第一量化矩阵按照上述S603的描述进行第一量化操作,得到第一量化系数集。最后,对第一量化系数集进行熵编码得到图像块的压缩数据。
进一步的,对于第一种具体操作中的第一量化操作和第一量化操作的反量化操作,分别对应着除法和乘法操作,为了节省硬件实现成本,可以将第一量化操作和第一量化操作的反量化操作通过比较操作出来实现,避免了乘法和除法操作,几乎不增加硬件逻辑实现的成本,该比较操作如下述第二种具体操作。
第二种具体操作:图像压缩装置根据图像块的第一量化矩阵的量化信息及图像块的特征值,确定该图像块的第二量化矩阵;将频域系数集中的元素,与图像块的第二量化矩阵中该元素对应位置处的元素比较大小,基于预设规则,确定该图像块的第二量化系数集。
其中,预设规则可以包括:当图像块的频域系数集中第一位置的元素,大于该图像块的第二量化矩阵中第一位置的元素时,保留该图像块的频域系数集中第一位置的元素;第一位置为频域系数集中的任一位置;当图像块的频域系数集中第一位置的元素,小于该图像块的第二量化矩阵中第一位置的元素时,将频域系数集中第一位置的元素置零;当图像块的频域系数集中第一位置的元素,等于该图像块的第二量化矩阵中第一位置的元素时,将频域系数集中第一位置的元素保留或置零。
示例性的,第二种具体操作中,对频域系数集TC基于第二量化矩阵进行第二量化操作得到第二量化系数集的过程中,第二量化系数集中第i行第j列的元素TC′(i,j)与频域系数集TC中第i行第j列的元素TC(i,j)以及第二量化矩阵中第i行第j列的元素QM 2(i,j)的关系满足如下表达式:
Figure PCTCN2020118910-appb-000010
示例性的,在第二种具体操作中,本申请实施例提供的图像压缩方法压缩图像块的过程可以图15所示。如图15所示,图像块经过第一变换得到该图像块的频域系数集。对频率系数集基于第二量化矩阵进行比较操作,即上述第二种具体操作中完成第二量化操作的过程,得到第二量化系数集。接下来对第二量化系数集基于第一量化矩阵按照上述S603的描述进行第一量化操作,得到第一量化系数集。最后,对第一量化系数集进行熵编码得到图像块的压缩数据。
下面通过具体示例,对本申请实施例提供的图像压缩方法进行描述。
假设图像压缩装置处理某一待处理图像块的某一分量集时,按照上述第二种实现,计算该图像块的分量集的纹理特征X=1426,取调整系数α=2,根据上述步骤1至步骤3,由公式ΔQF=α*log 2(X)可以计算得到ΔQF=20,假设用户输入的QF 1=90,根据公式QF 2=|QF 1|-clip(0,MaxΔQF,ΔQF)可以计算得到QF 2=70,根据上述第一关系表达式及QF 1、QF 2以及标准量化矩阵,得到该图像块的分量集的第一量化矩阵QM 1、第二量化 矩阵QM 2如下:
Figure PCTCN2020118910-appb-000011
Figure PCTCN2020118910-appb-000012
假设该图像块的分量集如下:
Figure PCTCN2020118910-appb-000013
该图像块的分量集经过DCT变换后的频率系数集TC如下:
Figure PCTCN2020118910-appb-000014
基于该图像块的分量集的第二量化矩阵QM 2,对该图像块的分量集的频率系数集TC进行第一量化操作后的结果QC 1如下,QC 1=TC./QM 2
Figure PCTCN2020118910-appb-000015
基于该图像块的分量集的第二量化矩阵QM 2,对该图像块的分量集的QC 1进行第一量化操作的反量化操作的结果TC′如下,TC′=QC 1./*QM 2。TC′其本质为经过第二量化操作的频域系数集,相比于TC,TC′中更多的元素被量化为0。
Figure PCTCN2020118910-appb-000016
基于该图像块的分量集的第一量化矩阵QM 1,对该图像块的分量集的TC′进行第一量化操作,得到最终的量化结果QC 2(第二量化系数集)如下,QC 2=TC′./QM 1
Figure PCTCN2020118910-appb-000017
若图像压缩装置基于该图像块的分量集的第一量化矩阵QM 1,对该图像块的分量集的频率系数集TC直接进行第一量化操作,即进行JPEG压缩标准中的量化后的结果QC 3如下,QC 3=TC./QM 1
Figure PCTCN2020118910-appb-000018
比较QC 3和QC 2,在QC 2中,更多的系数被量化为0,并且大部分低频系数幅值也更小,由熵编码的特性可知,QC 2编码所需要的比特数会显著小于编码QC 3的比特数。
上述主要从图像压缩装置的工作原理角度对本申请实施例提供的方案进行了介绍。可以理解的是,上述图像压缩装置为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例可以根据上述方法示例对执行本申请提供的图像压缩装置进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
在采用对应各个功能划分各个功能模块的情况下,图16示出了上述实施例中所涉及的图像压缩装置160的一种可能的结构示意图。该图像压缩装置160可以为功能模块或者芯片。如图16所示,图像压缩装置160可以包括:变换单元1601、第二量化单元1602、第一量化单元1603及编码单元1604。其中,变换单元1601用于执行图6中的过程S601;第二量化单元1602用于执行图6中的过程S602;第一量化单元1603用于执行图6中的过程S603;编码单元1604用于执行图6中的过程S604。其中,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。
进一步的,如图17所示,图像压缩装置160还可以包括第一获取单元1605。第一获取单元1605用于获取待压缩图像中的ROI。
进一步的,如图17所示,图像压缩装置160还可以包括第二获取单元1606。第二获取单元1606用于获取图像块的特征值。
在采用集成的单元的情况下,图18示出了上述实施例中所涉及的图像压缩装置的另一种可能的结构示意图。如图18所示,图像压缩装置180可以包括:处理模块1801、通信模块1802。处理模块1801用于对图像压缩装置180的动作进行控制管理,通信模块1802用于与其他设备通信。例如,处理模块1801用于执行图3中的过程S601 至S604中任一过程。图像压缩装置180还可以包括存储模块1803,用于存储图像压缩装置180的程序代码和数据。
其中,处理模块1801可以为图4所示的图像压缩装置40的实体结构中的处理器401,可以是处理器或控制器。例如可以是CPU,通用处理器,DSP,ASIC,FPGA或者其他可编程逻辑器件、晶体管逻辑器件、硬件部件或者其任意组合。其可以实现或执行结合本申请公开内容所描述的各种示例性的逻辑方框,模块和电路。处理模块801也可以是实现计算功能的组合,例如包含一个或多个微处理器组合,DSP和微处理器的组合等等。通信模块1802可以为图4所示的图像压缩装置40的实体结构中的收发器403,通信模块1802可以是通信端口,或者可以是收发器、收发电路或通信接口等。或者,上述通信接口可以通过上述具有收发功能的元件,实现与其他设备的通信。上述具有收发功能的元件可以由天线和/或射频装置实现。存储模块1803可以是图4所示的图像压缩装置40的实体结构中的存储器402。
当处理模块1801为处理器,通信模块1802为收发器,存储模块1803为存储器时,本申请实施例图18所涉及的图像压缩装置40可以为图4所示的图像压缩装置40。
如前述,本申请实施例提供的图像压缩装置160或图像压缩装置180可以用于实施上述本申请各实施例实现的方法中相应的功能,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请各实施例。
作为本实施例的另一种形式,提供一种计算机可读存储介质,其上存储有指令,该指令被执行时执行上述方法实施例中的图像压缩方法。
作为本实施例的另一种形式,提供一种包含指令的计算机程序产品,当该计算机程序产品在计算机上运行时,使得该计算机执行时执行上述方法实施例中的图像压缩方法。
本申请实施例再提供一种芯片系统,该芯片系统包括处理器,用于实现本发明实施例的技术方法。在一种可能的设计中,该芯片系统还包括存储器,用于保存本发明实施例必要的程序指令和/或数据。在一种可能的设计中,该芯片系统还包括存储器,用于处理器调用存储器中存储的应用程序代码。该芯片系统,可以由一个或多个芯片构成,也可以包含芯片和其他分立器件,本申请实施例对此不作具体限定。
结合本申请公开内容所描述的方法或者算法的步骤可以硬件的方式来实现,也可以是由处理器执行软件指令的方式来实现。软件指令可以由相应的软件模块组成,软件模块可以被存放于RAM、闪存、ROM、可擦除可编程只读存储器(erasable programmable ROM,EPROM)、电可擦可编程只读存储器(electrically EPROM,EEPROM)、寄存器、硬盘、移动硬盘、只读光盘(CD-ROM)或者本领域熟知的任何其它形式的存储介质中。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于ASIC中。另外,该ASIC可以位于核心网接口设备中。当然,处理器和存储介质也可以作为分立组件存在于核心网接口设备中。或者,存储器可以与处理器耦合,例如存储器可以是独立存在,通过总线与处理器相连接。存储器也可以和处理器集成在一起。存储器可以用于存储执行本申请实施例提供的技术方案的应用程序代码,并由处理器来控制执行。处理器用于执行存储器中存 储的应用程序代码,从而实现本申请实施例提供的技术方案。
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。

Claims (21)

  1. 一种图像压缩方法,其特征在于,所述方法包括:
    对待压缩图像中的图像块进行第一变换,得到所述图像块的频域系数集;所述图像块为所述待压缩图像中包括多个像素点的连续区域;
    对所述频域系数集进行第二量化操作,得到第二量化系数集;所述第二量化操作用于去除所述频域系数集中的高频分量,保持或减小所述频域系数集中低频分量的幅值大小;所述第二量化操作去除的高频分量的数量与所述图像块相关;所述第二量化操作去除的高频分量的数量,大于或等于基于第一量化矩阵进行第一量化操作去除的高频分量的数量;
    基于第一量化矩阵对所述第二量化系数集进行第一量化操作,得到第一量化系数集;
    对所述第一量化系数集进行熵编码,得到所述图像块的压缩数据。
  2. 根据权利要求1所述的方法,其特征在于,所述对所述频域系数集进行第二量化操作,得到第二量化系数集,包括:
    获取所述待压缩图像中的感兴趣区域ROI;
    若所述图像块处于所述待压缩图像的感兴趣区域ROI,将所述频域系数集中按照ZigZag顺序排列的前N1个元素保留,其余元素置零,得到所述第二量化系数集;若所述图像块处于所述待压缩图像的非ROI,将所述频域系数集中按照ZigZag顺序排列的前N2个元素保留,其余元素置零,得到所述第二量化系数集;所述N1大于所述N2。
  3. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    获取所述图像块的特征值,所述特征值用于指示所述图像块的下述特征中任一种:空域特征、频域特征或纹理特征;
    所述对所述频域系数集进行第二量化操作,得到第二量化系数集,包括:
    根据所述第一量化矩阵的量化信息及所述特征值,确定所述图像块的第二量化矩阵;所述第一量化矩阵、所述第二量化矩阵以及所述图像块的行列大小相同,所述第二量化矩阵中一个元素的幅值大于所述第一量化矩阵中相同位置元素的幅值;
    基于所述第二量化矩阵对所述频域系数集先后进行所述第一量化操作,和所述第一量化操作的反量化操作,得到所述第二量化系数集。
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    获取所述图像块的特征值,所述特征值用于指示所述图像块的下述特征中任一种:空域特征、频域特征或纹理特征;
    所述对所述频域系数集进行第二量化操作,得到第二量化系数集,包括:
    根据所述第一量化矩阵的量化信息及所述特征值,确定所述图像块的第二量化矩阵;所述第一量化矩阵、所述第二量化矩阵以及所述图像块的行列大小相同,所述第二量化矩阵中一个元素的幅值大于或等于所述第一量化矩阵中相同位置元素的幅值;
    将所述频域系数集中的元素,与所述第二量化矩阵中所述元素对应位置处的元素比较大小,基于预设规则,确定所述第二量化系数集;
    其中,所述预设规则包括:当所述频域系数集中第一位置的元素大于所述第二量 化矩阵中所述第一位置的元素时,保留所述频域系数集中所述第一位置的元素;所述第一位置为所述频域系数集中的任一位置;当所述频域系数集中所述第一位置的元素小于所述第二量化矩阵中所述第一位置的元素时,将所述频域系数集中所述第一位置的元素置零;当所述频域系数集中所述第一位置的元素等于所述第二量化矩阵中所述第一位置的元素时,将所述频域系数集中所述第一位置的元素保留或置零。
  5. 根据权利要求3或4所述的方法,其特征在于,所述根据所述第一量化矩阵的量化信息及所述特征值,确定所述图像块的第二量化矩阵,包括:
    根据所述第二量化矩阵QM 2与所述第一量化矩阵QM 1、所述特征值X的关系,确定所述QM 2
    其中,所述QM 2与所述QM 1、所述特征值X的关系满足如下表达式:QM 2=QM 1+F 1(X);其中,所述F 1(·)为第一预设函数。
  6. 根据权利要求3或4所述的方法,其特征在于,所述第一量化矩阵的量化信息包括确定所述第一量化矩阵的第一质量因子QF 1,所述QF 1用于根据第一关系表达式计算所述第一量化矩阵;其中,所述第一关系表达式为质量因子与标准量化矩阵QM S的关系表达式;
    所述根据所述第一量化矩阵的量化信息及所述特征值,确定所述图像块的第二量化矩阵,包括:
    根据所述特征值X,确定质量因子偏移值ΔQF;其中,所述ΔQF满足如下表达式:ΔQF=F 2(X);所述F 2(·)为第二预设函数;
    根据所述ΔQF及所述QF 1,计算第二质量因子QF 2;其中,所述QF 2满足如下表达式:QF 2=|QF 1|-F 3(ΔQF);所述F 3(·)为第三预设函数;
    根据所述QF 2以及所述第一关系表达式,确定所述第二量化矩阵。
  7. 根据权利3-6任一项所述的方法,其特征在于,所述方法还包括:
    获取所述待压缩图像中的感兴趣区域ROI;
    若所述图像块处于所述ROI之外,执行所述获取所述图像块的特征值以及所述根据第一量化矩阵的量化信息及所述特征值,确定所述图像块的第二量化矩阵;
    或者,
    若所述图像块处于所述ROI,将所述频域系数集基于所述第一量化矩阵进行所述第一量化操作得到所述第一量化系数集。
  8. 根据权利要求2或7所述的方法,其特征在于,所述获取所述待压缩图像中的感兴趣区域ROI,包括:
    接收输入的ROI区域信息,确定所述待压缩图像中所述ROI区域信息指示的区域为所述ROI;所述ROI区域信息用于指示所述ROI在所述待压缩图像中的坐标位置;
    或者,
    接收输入的所述待压缩图像的Map图像信息,基于所述Map图像信息确定所述待压缩图像中的所述感兴趣区域ROI,所述Map图像信息用于指示所述待压缩图像中每个图像块是否处于所述ROI区域。
  9. 根据权利要求2所述的方法,其特征在于,所述N1为63,所述N2为32。
  10. 一种图像压缩装置,其特征在于,所述装置包括:
    变换单元,用于对待压缩图像中的图像块进行第一变换,得到所述图像块的频域系数集;所述图像块为所述待压缩图像中包括多个像素点的连续区域;
    第二量化单元,用于对所述变换单元得到的所述频域系数集进行第二量化操作,得到第二量化系数集;所述第二量化操作用于去除所述频域系数集中的高频分量,保持或减小所述频域系数集中低频分量的幅值大小;所述第二量化操作去除的高频分量的数量与所述图像块相关;所述第二量化操作去除的高频分量的数量,大于或等于基于第一量化矩阵进行第一量化操作去除的高频分量的数量;
    第一量化单元,用于基于第一量化矩阵对所述第二量化系数集进行第一量化操作,得到第一量化系数集;
    编码单元,用于对所述第一量化单元得到的所述第一量化系数集进行熵编码,得到所述图像块的压缩数据。
  11. 根据权利要求10所述的装置,其特征在于,
    所述装置还包括第一获取单元,用于获取所述待压缩图像中的感兴趣区域ROI;
    所述第二量化单元具体用于:若所述图像块处于所述待压缩图像的感兴趣区域ROI,将所述频域系数集中按照ZigZag顺序排列的前N1个元素保留,其余元素置零,得到所述第二量化系数集;若所述图像块处于所述待压缩图像的非ROI,将所述频域系数集中按照ZigZag顺序排列的前N2个元素保留,其余元素置零,得到所述第二量化系数集;所述N1大于所述N2。
  12. 根据权利要求10所述的装置,其特征在于,所述装置还包括:
    第二获取单元,用于获取所述图像块的特征值,所述特征值用于指示所述图像块的下述特征中任一种:空域特征、频域特征或纹理特征;
    所述第二量化单元具体用于:
    根据所述第一量化矩阵的量化信息及所述特征值,确定所述图像块的第二量化矩阵;所述第一量化矩阵、所述第二量化矩阵以及所述图像块的行列大小相同,所述第二量化矩阵中一个元素的幅值大于所述第一量化矩阵中相同位置元素的幅值;
    基于所述第二量化矩阵对所述频域系数集先后进行所述第一量化操作,和所述第一量化操作的反量化操作,得到所述第二量化系数集。
  13. 根据权利要求10所述的装置,其特征在于,所述装置还包括:
    第二获取单元,用于获取所述图像块的特征值,所述特征值用于指示所述图像块的下述特征中任一种:空域特征、频域特征或纹理特征;
    所述第二量化单元具体用于:
    根据所述第一量化矩阵的量化信息及所述特征值,确定所述图像块的第二量化矩阵;所述第一量化矩阵、所述第二量化矩阵以及所述图像块的行列大小相同,所述第二量化矩阵中一个元素的幅值大于或等于所述第一量化矩阵中相同位置元素的幅值;
    将所述频域系数集中的元素,与所述第二量化矩阵中所述元素对应位置处的元素比较大小,基于预设规则,确定所述第二量化系数集;
    其中,所述预设规则包括:当所述频域系数集中第一位置的元素大于所述第二量化矩阵中所述第一位置的元素时,保留所述频域系数集中所述第一位置的元素;所述第一位置为所述频域系数集中的任一位置;当所述频域系数集中所述第一位置的元素 小于所述第二量化矩阵中所述第一位置的元素时,将所述频域系数集中所述第一位置的元素置零;当所述频域系数集中所述第一位置的元素等于所述第二量化矩阵中所述第一位置的元素时,将所述频域系数集中所述第一位置的元素保留或置零。
  14. 根据权利要求12或13所述的装置,其特征在于,所述第二量化单元根据所述第一量化矩阵的量化信息及所述特征值,确定所述图像块的第二量化矩阵,包括:
    根据所述第二量化矩阵QM 2与所述第一量化矩阵QM 1、所述特征值X的关系,确定所述QM 2
    其中,所述QM 2与所述QM 1、所述特征值X的关系满足如下表达式:QM 2=QM 1+F 1(X);其中,所述F 1(·)为第一预设函数。
  15. 根据权利要求12或13所述的装置,其特征在于,所述第一量化矩阵的量化信息包括确定所述第一量化矩阵的第一质量因子QF 1,所述QF 1用于根据第一关系表达式计算所述第一量化矩阵;其中,所述第一关系表达式为质量因子与标准量化矩阵QM S的关系表达式;
    所述第二量化单元根据所述第一量化矩阵的量化信息及所述特征值,确定所述图像块的第二量化矩阵,包括:
    根据所述特征值X,确定质量因子偏移值ΔQF;其中,所述ΔQF满足如下表达式:ΔQF=F 2(X);所述F 2(·)为第二预设函数;
    根据所述ΔQF及所述QF 1,计算第二质量因子QF 2;其中,所述QF 2满足如下表达式:QF 2=|QF 1|-F 3(ΔQF);所述F 3(·)为第三预设函数;
    根据所述QF 2以及所述第一关系表达式,确定所述第二量化矩阵。
  16. 根据权利12-15任一项所述的装置,其特征在于,所述装置还包括:
    第一获取单元,用于获取所述待压缩图像中的感兴趣区域ROI;
    所述第二量化单元具体用于:若所述图像块处于所述ROI之外,执行所述获取所述图像块的特征值以及所述根据第一量化矩阵的量化信息及所述特征值,确定所述图像块的第二量化矩阵;
    或者,
    若所述图像块处于所述ROI,所述第一量化单元,还用于基于所述第一量化矩阵对所述频域系数集进行所述第一量化操作得到所述第一量化系数集。
  17. 根据权利要求11或16所述的装置,其特征在于,所述第一获取单元具体用于:
    接收输入的ROI区域信息,确定所述待压缩图像中所述ROI区域信息指示的区域为所述ROI;所述ROI区域信息用于指示所述ROI在所述待压缩图像中的坐标位置;
    或者,
    接收输入的所述待压缩图像的Map图像信息,基于所述Map图像信息确定所述待压缩图像中的所述感兴趣区域ROI,所述Map图像信息用于指示所述待压缩图像中每个图像块是否处于所述ROI区域。
  18. 根据权利要求11所述的装置,其特征在于,所述N1为63,所述N2为32。
  19. 一种图像压缩装置,其特征在于,所述图像压缩装置包括:处理器和传输接口;
    所述传输接口用于接收和发送数据;
    所述处理器被配置为调用存储在存储器中的程序指令,以使得所述图像压缩装置执行如权利要求1至9中任一项所述的图像压缩方法。
  20. 一种计算机可读存储介质,所述计算机可读存储介质中存储有程序指令,当所述程序指令在计算机或处理器上运行时,使得所述计算机或所述处理器执行如权利要求1至9中任一项所述的图像压缩方法。
  21. 一种计算机程序产品,其特征在于,包括程序指令,当所述程序指令在计算机或处理器上运行时,使得所述计算机或所述处理器执行如权利要求1至9中任一项所述的图像压缩方法。
PCT/CN2020/118910 2020-09-29 2020-09-29 一种图像压缩方法及装置 WO2022067526A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2020/118910 WO2022067526A1 (zh) 2020-09-29 2020-09-29 一种图像压缩方法及装置
CN202080105452.XA CN116325752A (zh) 2020-09-29 2020-09-29 一种图像压缩方法及装置

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2020/118910 WO2022067526A1 (zh) 2020-09-29 2020-09-29 一种图像压缩方法及装置

Publications (1)

Publication Number Publication Date
WO2022067526A1 true WO2022067526A1 (zh) 2022-04-07

Family

ID=80949278

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/118910 WO2022067526A1 (zh) 2020-09-29 2020-09-29 一种图像压缩方法及装置

Country Status (2)

Country Link
CN (1) CN116325752A (zh)
WO (1) WO2022067526A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115396670A (zh) * 2022-07-28 2022-11-25 西安空间无线电技术研究所 一种局域处理的图像数据压缩方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104683801A (zh) * 2013-11-29 2015-06-03 华为技术有限公司 图像压缩方法和装置
CN105100810A (zh) * 2014-05-16 2015-11-25 中国科学院声学研究所 一种成像声纳实时处理系统中的图像压缩解压方法及系统
CN105407352A (zh) * 2015-11-23 2016-03-16 小米科技有限责任公司 图像压缩方法、装置及服务器
CN106612436A (zh) * 2016-01-28 2017-05-03 四川用联信息技术有限公司 一种基于dct变换下的视觉感知修正图像压缩方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104683801A (zh) * 2013-11-29 2015-06-03 华为技术有限公司 图像压缩方法和装置
CN105100810A (zh) * 2014-05-16 2015-11-25 中国科学院声学研究所 一种成像声纳实时处理系统中的图像压缩解压方法及系统
CN105407352A (zh) * 2015-11-23 2016-03-16 小米科技有限责任公司 图像压缩方法、装置及服务器
CN106612436A (zh) * 2016-01-28 2017-05-03 四川用联信息技术有限公司 一种基于dct变换下的视觉感知修正图像压缩方法

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115396670A (zh) * 2022-07-28 2022-11-25 西安空间无线电技术研究所 一种局域处理的图像数据压缩方法
CN115396670B (zh) * 2022-07-28 2024-05-03 西安空间无线电技术研究所 一种局域处理的图像数据压缩方法

Also Published As

Publication number Publication date
CN116325752A (zh) 2023-06-23

Similar Documents

Publication Publication Date Title
US11438618B2 (en) Method and apparatus for residual sign prediction in transform domain
US8817884B2 (en) Techniques for perceptual encoding of video frames
WO2017133660A1 (en) Method and apparatus of non-local adaptive in-loop filters in video coding
US9152875B2 (en) Preserving text quality in video encoding
CN108028941B (zh) 用于通过超像素编码和解码数字图像的方法和装置
US9478017B2 (en) Guided image filtering for image content
US20080159387A1 (en) Entropy deficiency based image
JPH07154798A (ja) 画像符号化装置および画像符号化方法
US20200404339A1 (en) Loop filter apparatus and method for video coding
US7657108B2 (en) Encoding of digital data combining a plurality of encoding modes
US11765351B2 (en) Method and apparatus for image filtering with adaptive multiplier coefficients
JP2004533181A (ja) デジタルイメージに対する選択的なクロミナンスデシメーション
WO2022067526A1 (zh) 一种图像压缩方法及装置
EP3180910B1 (en) Method for optimized chroma subsampling, apparatus for optimized chroma subsampling and storage device
EP2684158A1 (en) Method for efficient representation and processing of color pixel data in digital pathology images
US6895122B2 (en) Method and system for determining DCT block boundaries
Kahu et al. JPEG-based variable block-size image compression using CIE La* b* color space
EP0974932A2 (en) Adaptive video compression
US7657110B2 (en) Image compression using a color visual model
EP1367835A2 (en) Method and arrangement for compressing digital color images
JP3222780B2 (ja) 画像圧縮装置
Hall et al. Digital color image compression in a perceptual space
WO2020063552A1 (en) Method and apparatus for image filtering with adaptive multiplier coefficients, and terminal device
JP3986219B2 (ja) マルチスペクトル画像の画像圧縮方法および画像圧縮装置
Yang et al. Low bit-rate cloud-based image coding in the wavelet transform domain

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20955552

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20955552

Country of ref document: EP

Kind code of ref document: A1