CN115086683A - Image compression method and device, electronic equipment and computer readable storage medium - Google Patents

Image compression method and device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN115086683A
CN115086683A CN202111118136.9A CN202111118136A CN115086683A CN 115086683 A CN115086683 A CN 115086683A CN 202111118136 A CN202111118136 A CN 202111118136A CN 115086683 A CN115086683 A CN 115086683A
Authority
CN
China
Prior art keywords
image
quantization parameter
preset
roi
data
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202111118136.9A
Other languages
Chinese (zh)
Inventor
蒋平帆
付桂鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xinyuan Microelectronics Nanjing Co ltd
VeriSilicon Microelectronics Shanghai Co Ltd
VeriSilicon Microelectronics Beijing Co Ltd
VeriSilicon Microelectronics Chengdu Co Ltd
Original Assignee
Xinyuan Microelectronics Nanjing Co ltd
VeriSilicon Microelectronics Shanghai Co Ltd
VeriSilicon Microelectronics Beijing Co Ltd
VeriSilicon Microelectronics Chengdu Co Ltd
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 Xinyuan Microelectronics Nanjing Co ltd, VeriSilicon Microelectronics Shanghai Co Ltd, VeriSilicon Microelectronics Beijing Co Ltd, VeriSilicon Microelectronics Chengdu Co Ltd filed Critical Xinyuan Microelectronics Nanjing Co ltd
Priority to CN202111118136.9A priority Critical patent/CN115086683A/en
Publication of CN115086683A publication Critical patent/CN115086683A/en
Pending legal-status Critical Current

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/85Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using pre-processing or post-processing specially adapted for video compression
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/117Filters, e.g. for pre-processing or post-processing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/13Adaptive entropy coding, e.g. adaptive variable length coding [AVLC] or context adaptive binary arithmetic coding [CABAC]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/167Position within a video image, e.g. region of interest [ROI]

Landscapes

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

Abstract

The application relates to an image compression method, an image compression device, electronic equipment and a computer readable storage medium, and belongs to the technical field of image processing. The method comprises the steps of obtaining an image to be compressed, wherein the image to be compressed is an image subjected to discrete cosine transform; determining an ROI (region of interest) region and a non-ROI region in an image to be compressed; quantizing the data in the ROI area based on a preset first quantization parameter, and quantizing the data in the non-ROI area based on a preset second quantization parameter, wherein the first quantization parameter and the second quantization parameter are different; and entropy coding the quantized data to obtain compressed image data. The original image is subjected to discrete cosine transform to reduce redundant data and improve the processing efficiency, and meanwhile, different quantization coefficients are adopted for quantization when an ROI area and a non-ROI area are quantized, so that the effect of region-of-interest coding is achieved on the premise of not improving the operation complexity.

Description

Image compression method and device, electronic equipment and computer readable storage medium
Technical Field
The present application belongs to the field of image processing technologies, and in particular, to an image compression method, an image compression apparatus, an electronic device, and a computer-readable storage medium.
Background
The purpose of image compression is to reduce redundant information in image data so that the data is stored and transmitted in a more efficient format. For the JPEG (Joint Photographic Experts Group) compression coding standard, the compression rate is high, but the JPEG standard can only provide global quantization parameters for the whole frame image, which limits the application scenarios Of JPEG, and there is no specific flow for coding the ROI (Region Of Interest) in the JPEG standard.
Disclosure of Invention
In view of this, an object of the present application is to provide an image compression method, an apparatus, an electronic device, and a computer-readable storage medium, so as to solve the problem that the existing compression encoding method can only provide global quantization parameters for an entire frame of image and cannot encode a region of interest (ROI).
The embodiment of the application is realized as follows:
in a first aspect, an embodiment of the present application provides an image compression method, including: acquiring an image to be compressed, wherein the image to be compressed is an image subjected to discrete cosine transform; determining the ROI area and the non-ROI area in the image to be compressed; quantizing the data in the ROI area based on a preset first quantization parameter, and quantizing the data in the non-ROI area based on a preset second quantization parameter, wherein the first quantization parameter is different from the second quantization parameter, and the second quantization parameter is related to the characteristics of the data after discrete cosine transform; and entropy coding the quantized data to obtain compressed image data. In the embodiment of the application, redundant data are reduced and processing efficiency is improved by performing discrete cosine transform on an original image, meanwhile, different quantization coefficients are adopted for quantization when an ROI region and a non-ROI region are quantized, so that the effect of region-of-interest coding is achieved on the premise that operation complexity is not improved, and the second quantization parameter is related to the characteristics of data after the discrete cosine transform, so that the balance between compression efficiency and image quality is achieved.
With reference to one possible implementation manner of the embodiment of the first aspect, the determining the ROI and the non-ROI in the image to be compressed includes: determining the region type of each image block in the image to be compressed according to a preset configuration file, wherein the region type is an ROI region or a non-ROI region; wherein the configuration file contains the area type of each image block in the image to be compressed. In the embodiment of the application, the ROI area and the non-ROI area in the image are rapidly identified through the preset configuration file, and the area type of each image block in the image to be compressed is set in advance, so that the ROI area in the image can be accurately identified, and the processing efficiency can be improved.
With reference to one possible implementation manner of the embodiment of the first aspect, the determining the second quantization parameter includes: and determining the second quantization parameter according to a preset filter coefficient table, a preset first quantization parameter table and a preset calculation formula, wherein elements in the first quantization parameter table correspond to elements in the filter coefficient table one by one, each element in the first quantization parameter table is used for determining one second quantization parameter, and filter coefficients in the filter coefficient table are related to the characteristics of the data after discrete cosine transform. In the embodiment of the application, the coefficient after the discrete cosine is filtered, the unimportant coefficient is lost to achieve a larger compression ratio, meanwhile, the filtering coefficient and the quantization parameter are combined to reduce the algorithm complexity, and a new quantization parameter (used for quantizing a non-ROI area) is generated, so that the quantization of the whole image by adopting different quantization parameters according to the ROI area coding requirement is realized, and the effect of region-of-interest coding is achieved on the premise of not improving the operation complexity.
With reference to a possible implementation manner of the embodiment of the first aspect, determining the second quantization parameter according to a preset filter coefficient table, a preset first quantization parameter table, and a preset calculation formula includes: the serial number of i is 1 to N in sequence, the element value with the serial number of i in the first quantization parameter table is amplified by M times, and the quotient of the amplified value of the element with the serial number of i and the element with the serial number of i in the filter coefficient table is determined; and comparing the quotient with a preset threshold value to obtain the minimum value in the quotient and the preset threshold value, wherein the minimum value is the second quantization parameter corresponding to the element with the number i, M is a non-0 integer, and N is the maximum number of the element in the first quantization parameter table.
With reference to a possible implementation manner of the embodiment of the first aspect, before determining a quotient of the amplified value of the element numbered i and the element numbered i in the filter coefficient table, the method further includes: determining that the value of an element numbered i in the filter coefficient table is not 0; and if the value of the element numbered i in the filter coefficient table is 0, the second quantization parameter corresponding to the element numbered i is the preset threshold value. In the embodiment of the application, before determining the quotient of the amplified value of the element numbered i and the element numbered i in the filter coefficient table, it is determined that the value of the element numbered i in the filter coefficient table is not 0, and if the value of the element numbered i in the filter coefficient table is 0, the second quantization parameter corresponding to the element numbered i is directly determined to be the preset threshold, so that the efficiency can be further improved.
With reference to a possible implementation manner of the embodiment of the first aspect, the filter coefficient table includes 28 × 8 matrices, each element in each matrix has a value of [0, 255], and an element located at the upper left corner of the matrix has the largest value and an element located at the lower right corner of the matrix has the smallest value. In the embodiment of the present application, when setting the filter coefficient, the following principle is followed: because DCT transform is transformed into the transformation from a data space domain to a frequency domain, most information in the image after DCT transform is concentrated in the low-frequency coefficient at the upper left corner, and most images contain more low-frequency components, and human eyes are relatively insensitive to the high-frequency details of the image, therefore, when designing the filter coefficient, more coefficients (with larger values) are reserved at the upper left corner of a filter coefficient matrix, and less coefficients (with smaller values) are reserved at the lower right corner, thereby reducing the size of the image, realizing the loss of unimportant coefficients to achieve a larger compression ratio, and achieving the balance of compression efficiency and image quality.
With reference to one possible implementation manner of the embodiment of the first aspect, the method further includes: acquiring a target filter coefficient selected by a user from a plurality of preset groups of filter coefficients, wherein second quantization parameters corresponding to different filter parameters are different; accordingly, quantizing the data in the non-ROI region based on a preset second quantization parameter includes: and quantizing the data in the non-ROI area based on a preset second quantization parameter corresponding to the target filter coefficient. In the embodiment of the application, a plurality of groups of filter coefficients are preset for a user to select, so that different compression efficiencies are presented.
In a second aspect, an embodiment of the present application further provides an image compression apparatus, including: the device comprises an acquisition module and a processing module; the device comprises an acquisition module, a compression module and a compression module, wherein the acquisition module is used for acquiring an image to be compressed, and the image to be compressed is an image subjected to discrete cosine transform; a processing module, configured to determine the ROI region and the non-ROI region in the image to be compressed, quantize data in the ROI region based on a preset first quantization parameter, and quantize data in the non-ROI region based on a preset second quantization parameter, where the first quantization parameter and the second quantization parameter are different, and the second quantization parameter is related to a feature of the data after discrete cosine transform; and the image compression unit is also used for entropy coding the quantized data to obtain compressed image data.
In a third aspect, an embodiment of the present application further provides an electronic device, including: a memory and a processor, the processor coupled to the memory; the memory is used for storing programs; the processor is configured to invoke a program stored in the memory to perform the method according to the first aspect embodiment and/or any possible implementation manner of the first aspect embodiment.
In a fourth aspect, this application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the method in the foregoing first aspect and/or any possible implementation manner of the first aspect.
Additional features and advantages of the present application will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by the practice of the embodiments of the present application. The objectives and other advantages of the application may be realized and attained by the structure particularly pointed out in the written description and drawings.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings without creative efforts. The foregoing and other objects, features and advantages of the application will be apparent from the accompanying drawings. Like reference numerals refer to like parts throughout the drawings. The drawings are not intended to be to scale as practical, emphasis instead being placed upon illustrating the subject matter of the present application.
Fig. 1 shows a flowchart of an image compression method provided in an embodiment of the present application.
Fig. 2 is a schematic flowchart illustrating another image compression method provided in an embodiment of the present application.
Fig. 3 shows an image effect diagram before compression of an image to be compressed.
Fig. 4 is a diagram illustrating an image effect obtained by compressing the image shown in fig. 3 by applying the image compression method according to the embodiment of the present application.
Fig. 5 shows a block diagram of an image compression apparatus according to an embodiment of the present application.
Fig. 6 shows a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures. Meanwhile, relational terms such as "first," "second," and the like may be used solely in the description herein to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Further, the term "and/or" in the present application is only one kind of association relationship describing the associated object, and means that three kinds of relationships may exist, for example, a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone.
Aiming at the problems that the current compression coding method can only provide global quantization parameters for the whole frame of image and can not realize coding on a region of interest (ROI), namely, the image quality of a non-ROI region can not be sacrificed, and only the image quality of the ROI region is reserved, so that the size of the coded image is reduced. The image compression method provided by the embodiment of the present application will be described below with reference to fig. 1.
S1: and acquiring an image to be compressed, wherein the image to be compressed is an image subjected to discrete cosine transform.
When the image to be compressed needs to be compressed, the image to be compressed is obtained, and in an embodiment, the image to be compressed may be obtained from a database. In one embodiment, the acquired image to be compressed is an image subjected to Discrete Cosine Transform (DCT), that is, an image subjected to Discrete Cosine Transform in advance, so that the image processing efficiency can be improved. Of course, DCT transformation may also be performed in real time, and at this time, discrete cosine transformation may be performed on the obtained original image to be compressed, so as to obtain transformed image data.
Among them, DCT-based encoding is lossy encoding, and thus substantial compression can be achieved while generating a reconstructed image with high visual fidelity to a source image of an encoder, and processing efficiency can be improved by reducing redundant data.
S2: determining the ROI area and the non-ROI area in the image to be compressed.
After an image to be compressed after DCT transformation is acquired, an ROI region and a non-ROI region in the image to be compressed need to be determined, so that differential compression encoding is performed when compression encoding is performed.
In one embodiment, the process of determining the ROI and non-ROI in the image to be compressed may be to, for each image block (i.e., macroblock) in the image to be compressed, determine a region type of the image block according to a preset configuration file, where the region type is the ROI or non-ROI, and the configuration file includes the region type of each image block in the image to be compressed. In this embodiment, a user may divide an ROI region and a non-ROI region in an image to be compressed in advance, for example, divide the image to be compressed into a plurality of image blocks, such as an 8 × 8 image block, where each image block may use at least one bit to represent a region type of the image block, and if one bit is used to represent the region type of the image block, the bit with 1 represents that the region type of the image block is an ROI region, and the bit with 0 represents that the region type of the image block is a non-ROI region, which may be the reverse of that, that is, the bit with 0 represents that the region type of the image block is an ROI region, and the bit with 1 represents that the region type of the image block is a non-ROI region.
In a specific macro block mapping process, the ROI area of each macro block is judged in a progressive scanning mode, bit corresponding to the macro block of the ROI area can be set to 1, bit corresponding to the macro block of a non-ROI area can be set to 0, and when 8 macro blocks are counted, 8-bit data are formed into a byte to be sequentially written into a memory which is allocated in advance so as to be used for subsequently determining the ROI area and the non-ROI area in an image to be compressed. In addition, the configuration file also comprises a frame number of the image to be compressed so as to distinguish the image to be compressed, and also comprises a start coordinate of a rectangular area and a width and a height of each image block area in the image to be compressed so as to define an ROI area and a non-ROI area. It should be noted that, only the start coordinates and width of the ROI or the non-ROI in the image to be compressed may be configured, instead of configuring the start coordinates and width of the rectangular region of each image block region, which may save time and improve efficiency. For example, the configuration file configures only the ROI region in the image to be compressed, and the format of the configuration file may be as follows:
#pic=X;
ROI=(left,top,width,height);
wherein, X is a non-negative integer and represents the frame number of the image to be compressed, left and top are the initial coordinates of the ROI rectangular region, which respectively correspond to the width and height of the region, and the width and height jointly determine the size of the rectangular region and cannot exceed the image coding region. Where left and top need to be non-negative integer multiples of the macroblock size corresponding to the current coding mode. The macroblock size of the coding modes supported by the present application may be: 420 coding mode, macroblock size 16x 16; 422 coding mode, macroblock size 16x 8; 400 coding mode, macroblock size 8x8, etc.
When an ROI (region of interest) region and a non-ROI region in an image to be compressed are determined, a mapping value P of a current macro block is obtained for each image block, namely the macro block, in the image to be compressed according to a preset configuration file, if the P is 1, the current macro block is indicated to be the ROI region, and then quantization is carried out based on a preset first quantization parameter during quantization; if P is 0, it indicates that the current macroblock is a non-ROI region, and then quantization is performed based on a preset second quantization parameter during quantization. This achieves separate quantization processing for ROI and non-ROI regions. In addition, the region type of the image block may also be represented by a plurality of bits, so that not only the region type of the image block may be represented, but also the weights of the region of interest or the region of non-interest may be differentiated, and assuming that the region of interest has 2 weights and the region of non-interest has 2 weights, the region type of the image block and the weights of the region of interest or the region of non-interest may be represented by 2 bits per image block. For example, the non-ROI region is represented by a bit value of 0 or 1, and the ROI region is represented by a bit value of 2 or 3, but the reverse may be true. The image blocks of the regions of interest or the regions of non-interest with different weights have different bit values, and the image blocks of the regions of interest or the regions of non-interest with the same weight have the same bit values. For example, although the values 0 and 1 of the bit bits both represent the non-ROI region, the weights representing the non-ROI region are different due to the difference in the values of the two.
For another example, assuming that the region of interest has 3 weights and the region of non-interest has 1 weight, it is still possible to use 2 bits per image block to represent the region type of the image block and the weight of the region of interest or the region of non-interest. For example, the ROI region is represented by a bit value of 0, 1, or 2, and the non-ROI region is represented by a bit value of 3, but the reverse can be used. The image blocks of the regions of interest or the regions of non-interest with different weights have different bit values, and the image blocks of the regions of interest or the regions of non-interest with the same weight have the same bit values.
When the regions of interest with different weights are quantized, different quantization parameters can be used for quantization, so that the difference is embodied. Similarly, when the non-interesting regions with different weights are quantized, different quantization parameters can be used for quantization. The regions of interest with the same weight are quantized by using the same quantization parameter, and the regions of non-interest with the same weight are quantized by using the same quantization parameter.
In an alternative embodiment, the determining the ROI and the non-ROI in the image to be compressed may be based on a neural network model trained in advance, for example, for an image containing an animal, such as a cat or a dog, the ROI may be a region where the animal is located, and the non-ROI may be a region where the non-animal is located. In such an embodiment, the neural network model needs to be trained in advance to be able to identify ROI regions or non-ROI regions in the image.
It should be noted that, in an alternative embodiment, discrete cosine transform may not be performed on the image to be compressed, and at this time, after the image to be compressed (equivalent to the original image) is acquired, the ROI region and the non-ROI region in the image to be compressed are directly determined.
S3: quantizing the data in the ROI area based on a preset first quantization parameter, and quantizing the data in the non-ROI area based on a preset second quantization parameter.
After the ROI region and the non-ROI region are determined, the data in the ROI region may be quantized based on a preset first quantization parameter, and the data in the non-ROI region may be quantized based on a preset second quantization parameter, where the first quantization parameter is different from the second quantization parameter, and the second quantization parameter is related to a feature of the data after discrete cosine transform, so as to implement differential compression on the ROI region and the non-ROI region, and achieve a balance between compression efficiency and image quality.
The principle of quantizing the data in the ROI region based on the preset first quantization parameter is consistent with the principle of quantizing the data in the non-ROI region based on the second quantization parameter, and is consistent with the principle used in the prior art when the ROI region is quantized by JPEG compression coding, which is well known to those skilled in the art and will not be described herein.
The preset first quantization parameter may be obtained from a preset first quantization parameter table, and the preset first quantization parameter may be consistent with a quantization parameter used when the ROI region is quantized by JPEG compression coding in the prior art. For example, the first quantization parameter table contains 2 matrices of 8 × 8, one matrix being a luminance matrix and one matrix being a chrominance matrix, each matrix containing 64 first quantization parameters. Of course, the two matrices can be combined into a matrix comprising 128 elements, wherein the first 64 elements are elements in the luminance matrix and the last 64 elements are elements in the chrominance matrix.
The preset second quantization parameter may be obtained from a preset second quantization parameter table, and the preset second quantization parameter may be different from a quantization parameter used when the non-ROI area is quantized by JPEG compression coding in the related art.
In addition, the regions of interest or regions of non-interest with different weights can be quantized by using different quantization parameters, so as to embody the difference. In this embodiment, each image block needs to use a plurality of bits to represent the weight of the region of interest or the region of non-interest of the image block, for example, it is assumed that two kinds of first quantization parameters (first quantization parameter 1 and first quantization parameter 2) exist for the ROI region, one kind of second quantization parameter exists for the non-ROI region, each image block may use 2 bits to represent the weight of the region of interest or the region of non-interest of the image block, for example, if the value of the bit corresponding to the image block is 0, then quantization is performed using a first quantization parameter 1, the value of the bit corresponding to the image block is 1, then, the first quantization parameter 2 is used to perform quantization, and if the value of the bit corresponding to the image block is 2, the quantization is performed using the second quantization parameter, so that regions of interest or regions of non-interest with different weights are quantized using different quantization parameters.
In the embodiment of the application, when the non-ROI is compressed and coded, the coefficient after DCT is filtered, unimportant coefficients are lost to achieve a large compression ratio, and meanwhile, the filtering and quantization processes are effectively combined, so that the complexity of the algorithm is reduced, and the effect of coding the region of interest can be achieved on the premise of not improving the operation complexity by the algorithm. The merging principle is as follows:
DCT(u,v)*filter(u,v)/QTb(u,v)=DCT(u,v)/QTbNonRoi(u,v);
DCT (u, v) is a DCT coefficient, filter (u, v) is a filter coefficient, QTb (u, v) is a first quantization parameter, QTbNonRoi (u, v) is a second quantization parameter used for a non-ROI region, and QTbNonRoi (u, v) is QTb (u, v)/filter (u, v).
After the filter coefficient is introduced, in general, when the non-ROI region is compressed and encoded, the processing logic on the left side of the above formula is adopted, that is, the DCT-transformed coefficient needs to be multiplied by the filter coefficient and then divided by the first quantization parameter, and in order to reduce the complexity of the algorithm, the filtering and quantization are combined to generate a new quantization parameter (second quantization parameter), and then the processing logic on the right side of the above formula can be adopted to perform processing, that is, the DCT-transformed coefficient is divided by the processing logic of the second quantization parameter generated by combining the filtering and quantization, so that the effect of region-of-interest encoding can be achieved without increasing the complexity of the operation. Meanwhile, because the processing logic on the right side of the formula is consistent with the processing logic used by the existing image compression mode, the code stream generated by the coding of the application can be decoded by adopting a general decoder without a special decoder.
Therefore, when determining the second quantization parameter, the process may be to determine the second quantization parameter according to the preset filter coefficient table, the preset first quantization parameter table, and the preset calculation formula. The elements in the first quantization parameter table are in one-to-one correspondence with the elements in the filter coefficient table, and each element in the first quantization parameter table is used for determining a second quantization parameter.
For example, the filter coefficient table also includes 2 matrices of 8 × 8, one matrix is a luminance matrix, one matrix is a chrominance matrix, each matrix includes 64 filter coefficients, each element (filter coefficient) in each matrix has a value of [0, 255], and the element located at the upper left corner of the matrix has the largest value, e.g., 255, and the element located at the lower right corner of the matrix has the smallest value, e.g., 0. Of course, the two matrices may also be merged together.
In the embodiment of the present application, the filter coefficients in the filter coefficient table are related to the characteristics of the data after discrete cosine transform, and the design principle of the filter coefficients is as follows: according to the distribution relation of high and low frequency information of image data after DCT transformation and the characteristic that human eyes are insensitive to the high frequency information, the low frequency information is reserved as much as possible, and the high frequency information is reduced. Due to the fact that DCT is transformed into transformation from a data space domain to a frequency domain, most information in an image after DCT transformation is concentrated in a low-frequency coefficient at the upper left corner, most images contain more low-frequency components, and human eyes are relatively insensitive to high-frequency details of the image.
The specific process of determining the second quantization parameter according to the preset filter coefficient table, the preset first quantization parameter table and the preset calculation formula may be: the serial number of i is 1 to N in sequence, the element value with the serial number of i in the first quantization parameter table is amplified by M times, and the quotient of the amplified value of the element with the serial number of i in the first quantization parameter table and the element with the serial number of i in the filter coefficient table is determined; and comparing the quotient with a preset threshold value to obtain the minimum value of the quotient and the preset threshold value, wherein the minimum value is the second quantization parameter corresponding to the element with the number i, M is a non-0 integer, and N is the maximum number of the element in the first quantization parameter table, and can be 64, for example. For example, the number of i is 1 to 64 in sequence, the value of the element with the number i in the first quantization parameter table is amplified by 255 times, and the quotient of the amplified value of the element with the number i and the element with the number i in the filter coefficient table is determined; and comparing the quotient with 255 to obtain the minimum value of the quotient and 255, wherein the minimum value is the second quantization parameter corresponding to the element numbered as i, and M is a non-0 integer.
Since the filter coefficient in the filter coefficient table may be 0, before determining the quotient of the amplified value of the element numbered i and the element numbered i in the filter coefficient table, it is further required to determine that the value of the element numbered i in the filter coefficient table is not 0; if the value of the element numbered i in the filter coefficient table is 0, the second quantization parameter corresponding to the element numbered i is a preset threshold, for example, 255.
The preset calculation formula is as follows:
qTableLumaNonRoi[i]=(filter[i]==0)?(255):(Min(255,qTable.pQlumi[i]*255/filter[i]));
qTableChromaNonRoi[i]=(filter[i+64]==0)?(255):(Min(255,qTable.pQchro mi[i]*255/filter[i+64]));
wherein, qTableLumaNonRoi [ i ] and qTableChromaNonRoi [ i ] are a luminance matrix and a chrominance matrix for quantization of the non-ROI area, respectively; the filter [ i ] is a brightness coefficient matrix in the filter coefficients, and the filter [ i +64] is a chrominance coefficient matrix in the filter coefficients; qTable. pQlumi [ i ] and qTable. pQchromai [ i ] are respectively a luminance matrix and a chrominance matrix in the first quantization parameter table; i ranges from an integer of 1 to 64. The entire operation keeps the result value in an integer range of 0 to 255.
The above formula is explained as follows, if the value of the filter coefficient is 0, 255 is taken as the current second quantization parameter, if the value of the filter coefficient is not 0, each coefficient of the luminance matrix and the chrominance matrix in the first quantization parameter table is enlarged by 255 times, and then divided by the corresponding filter coefficient, and then compared with 255, and the smaller value of the two is taken as the corresponding second quantization parameter.
After each second quantization parameter is obtained, it may be stored in the second quantization parameter table in a certain order (e.g., in a numbering order) for subsequent use. The second quantization parameter table may also include 2 matrices of 8 × 8, one matrix being a luminance matrix and one matrix being a chrominance matrix, each matrix including 64 second quantization parameters.
It should be noted that, in an embodiment, multiple sets of filter coefficients may be set in advance according to multiple experimental results, for example, 10 sets (10 levels) of filter coefficients of luminance and chrominance are set, the difference of image compression ratios of each level is about 5%, and the second quantization parameters corresponding to the filter parameters of different levels are different. When the method is used, a user can select a required target filter coefficient from a plurality of preset groups of filter coefficients, and at this time, data in the non-ROI area should be quantized based on a preset second quantization parameter corresponding to the target filter coefficient. The multiple groups of filter coefficients are set in advance to facilitate selection of a user, for example, a required target coefficient can be set through a parameter selection item in software, the value range of the parameter selection item is an integer from 0 to 9, and the smaller the value is, the higher the compression ratio is.
In addition, besides selecting the required filter coefficient through a parameter selection item in software, the filter coefficient can be configured autonomously, and the filter coefficients of brightness and chrominance can be configured respectively, so that the fixed image compression rate is not needed, and the flexibility and the autonomy of the image compression rate are improved.
S4: and entropy coding the quantized data to obtain compressed image data.
The method comprises the steps of quantizing data in the ROI area based on a preset first quantization parameter, and then entropy coding the quantized data to obtain compressed image data, or quantizing data in the non-ROI area based on a preset second quantization parameter, and then entropy coding the quantized data to obtain the compressed image data. The specific process of entropy encoding data is well known to those skilled in the art and will not be described here.
It should be noted that, in the process of image compression, the processes of S2, S3, and S4 may be performed multiple times, and are not only performed once, and when determining the ROI region and the non-ROI region in the image to be compressed, all ROI regions and non-ROI regions in the image to be compressed may not be determined at one time, but may exist in a sequential order; similarly, when the data in the ROI region is quantized based on the preset first quantization parameter and the data in the non-ROI region is quantized based on the preset second quantization parameter, all the ROI regions and the non-ROI regions may not be quantized at one time, but may have a sequential order; similarly, when entropy coding is performed on quantized data, the quantized data may not be entropy coded at one time, but may be in a sequential order. For example, each image block in the image to be compressed may be sequentially obtained from left to right and from top to bottom, then the region type of the image block is determined, if the region type is the ROI region, the data in the ROI region is quantized based on a preset first quantization parameter, then the quantized data is entropy-encoded, if the region type is the non-ROI region, the data in the non-ROI region is quantized based on a preset second quantization parameter, then the quantized data is entropy-encoded, and then the next image block is similarly compression-encoded (that is, the region type of the image block is determined, if the region type is the ROI region, the data in the ROI region is quantized based on a preset first quantization parameter, then the quantized data is entropy-encoded, if the region type is the non-ROI region, the data in the non-ROI region is quantized based on a preset second quantization parameter, then entropy coding is performed on the quantized data), and so on until the compression coding of all image blocks is completed, so that the compressed image data can be obtained, and a schematic diagram of the compressed image data is shown in fig. 2.
According to the image compression method provided by the embodiment of the application, DCT transformation is performed on an image to be compressed, filtering is performed on coefficients subjected to DCT transformation, unimportant coefficients are lost to achieve a larger compression ratio, the filtering and quantization processes are effectively combined, the algorithm complexity is reduced, a new quantization parameter table (used for quantizing a non-ROI) is generated, different quantization parameters are adopted for quantizing a whole image according to the coding requirements of an ROI region, and the effects are shown in figures 3 and 4, wherein figure 3 is an image effect diagram before compression, and figure 4 is an image effect diagram after the image compression method is used for compression. The method can accurately position the ROI area, the compression rate is obviously improved, for the image size of 640x480, the image size can be reduced from the original 144521 bytes to 85161 bytes by adopting the image compression method disclosed by the application, and finally the balance between the compression efficiency and the image quality is achieved.
Based on the same inventive concept, the embodiment of the present application further provides an image compression apparatus 100, as shown in fig. 5. The image compression apparatus 100 includes: an acquisition module 110 and a processing module 120.
The obtaining module 110 is configured to obtain an image to be compressed, where the image to be compressed is an image after discrete cosine transform.
A processing module 120, configured to determine the ROI region and the non-ROI region in the image to be compressed, quantize data in the ROI region based on a preset first quantization parameter, and quantize data in the non-ROI region based on a preset second quantization parameter, where the first quantization parameter and the second quantization parameter are different, and the second quantization parameter is related to a feature of the data after discrete cosine transform; and the image compression unit is also used for entropy coding the quantized data to obtain compressed image data.
The processing module 120 is configured to determine, for each image block in the image to be compressed, a region type of the image block according to a preset configuration file, where the region type is an ROI region or a non-ROI region; wherein the configuration file contains the area type of each image block in the image to be compressed.
The obtaining module 110 is further configured to obtain a target filter coefficient selected by a user from a plurality of preset sets of filter coefficients, where second quantization parameters corresponding to different filter parameters are different, and correspondingly, the processing module 120 is configured to quantize data in the non-ROI area based on the preset second quantization parameter corresponding to the target filter coefficient.
The image compression apparatus 100 provided in the embodiment of the present application has the same implementation principle and technical effect as the foregoing method embodiments, and for the sake of brief description, reference may be made to the corresponding contents in the foregoing method embodiments for the portions of the apparatus embodiments that are not mentioned.
As shown in fig. 6, fig. 6 is a block diagram illustrating a structure of an electronic device 200 according to an embodiment of the present disclosure. The electronic device 200 includes: a transceiver 210, a memory 220, a communication bus 230, and a processor 240.
The elements of the transceiver 210, the memory 220, and the processor 240 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, the components may be electrically coupled to each other via one or more communication buses 230 or signal lines. The transceiver 210 is used for transceiving data. The memory 220 is used to store a computer program such as the software functional module shown in fig. 5, that is, the image compression apparatus 100. The image compression apparatus 100 includes at least one software functional module, which may be stored in the memory 220 in the form of software or Firmware (Firmware) or solidified in an Operating System (OS) of the electronic device 200. The processor 240 is configured to execute an executable module stored in the memory 220, such as a software functional module or a computer program included in the image compression apparatus 100. For example, the processor 240 is configured to obtain an image to be compressed, where the image to be compressed is an image after discrete cosine transform; determining the ROI area and the non-ROI area in the image to be compressed; quantizing the data in the ROI area based on a preset first quantization parameter, and quantizing the data in the non-ROI area based on a preset second quantization parameter, wherein the first quantization parameter is different from the second quantization parameter, and the second quantization parameter is related to the characteristics of the data after discrete cosine transform; and entropy coding the quantized data to obtain compressed image data.
The Memory 220 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Read-Only Memory (EPROM), an electrically Erasable Read-Only Memory (EEPROM), and the like.
The processor 240 may be an integrated circuit chip having signal processing capabilities. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor 240 may be any conventional processor or the like.
The electronic device 200 includes, but is not limited to, a computer, a smart phone, a tablet, and the like.
The embodiment of the present application further provides a non-volatile computer-readable storage medium (hereinafter, referred to as a storage medium), where the storage medium stores a computer program, and the computer program is executed by a computer such as the electronic device 200 described above to perform the above-described image compression method.
It should be noted that, in the present specification, the embodiments are all described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments may be referred to each other.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product stored in a computer-readable storage medium, which includes several instructions for causing a computer device (which may be a personal computer, a notebook computer, a server, or an electronic device) to execute all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned computer-readable storage media comprise: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. An image compression method, comprising:
acquiring an image to be compressed, wherein the image to be compressed is an image subjected to discrete cosine transform;
determining the ROI area and the non-ROI area in the image to be compressed;
quantizing the data in the ROI area based on a preset first quantization parameter, and quantizing the data in the non-ROI area based on a preset second quantization parameter, wherein the first quantization parameter is different from the second quantization parameter, and the second quantization parameter is related to the characteristics of the data after discrete cosine transform;
and entropy coding the quantized data to obtain compressed image data.
2. The method of claim 1, wherein determining the ROI and non-ROI areas in the image to be compressed comprises:
determining the region type of each image block in the image to be compressed according to a preset configuration file, wherein the region type is an ROI region or a non-ROI region;
wherein the configuration file contains the area type of each image block in the image to be compressed.
3. The method of claim 1, wherein determining the second quantization parameter comprises:
and determining the second quantization parameter according to a preset filter coefficient table, a preset first quantization parameter table and a preset calculation formula, wherein elements in the first quantization parameter table correspond to elements in the filter coefficient table one by one, each element in the first quantization parameter table is used for determining one second quantization parameter, and filter coefficients in the filter coefficient table are related to the characteristics of the data after discrete cosine transform.
4. The method of claim 3, wherein determining the second quantization parameter according to a preset filter coefficient table, a preset first quantization parameter table and a preset calculation formula comprises:
the serial number of i is 1 to N in sequence, the element value with the serial number of i in the first quantization parameter table is amplified by M times, and the quotient of the amplified value of the element with the serial number of i and the element with the serial number of i in the filter coefficient table is determined; and comparing the quotient with a preset threshold value to obtain the minimum value in the quotient and the preset threshold value, wherein the minimum value is the second quantization parameter corresponding to the element with the number i, M is a non-0 integer, and N is the maximum number of the element in the first quantization parameter table.
5. The method of claim 4, wherein prior to determining a quotient of the amplified value of the element numbered i and the element numbered i in the filter coefficient table, the method further comprises:
determining that the value of an element numbered i in the filter coefficient table is not 0;
and if the value of the element numbered i in the filter coefficient table is 0, the second quantization parameter corresponding to the element numbered i is the preset threshold value.
6. The method of claim 3, wherein the table of filter coefficients comprises 2 8-by-8 matrices, each element in each matrix having a value of [0, 255], and wherein the element at the top left corner of the matrix has the largest value and the element at the bottom right corner of the matrix has the smallest value.
7. The method of claim 1, further comprising:
acquiring a target filter coefficient selected by a user from a plurality of preset groups of filter coefficients, wherein second quantization parameters corresponding to different filter parameters are different; accordingly, the
Quantizing the data in the non-ROI region based on a preset second quantization parameter, including:
and quantizing the data in the non-ROI area based on a preset second quantization parameter corresponding to the target filter coefficient.
8. An image compression apparatus, comprising:
the device comprises an acquisition module, a compression module and a compression module, wherein the acquisition module is used for acquiring an image to be compressed, and the image to be compressed is an image subjected to discrete cosine transform;
a processing module, configured to determine the ROI region and the non-ROI region in the image to be compressed, quantize data in the ROI region based on a preset first quantization parameter, and quantize data in the non-ROI region based on a preset second quantization parameter, where the first quantization parameter and the second quantization parameter are different, and the second quantization parameter is related to a feature of the data after discrete cosine transform; and the image compression unit is also used for entropy coding the quantized data to obtain compressed image data.
9. An electronic device, comprising:
a memory and a processor, the processor coupled to the memory;
the memory is used for storing programs;
the processor to invoke a program stored in the memory to perform the method of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202111118136.9A 2021-09-23 2021-09-23 Image compression method and device, electronic equipment and computer readable storage medium Pending CN115086683A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111118136.9A CN115086683A (en) 2021-09-23 2021-09-23 Image compression method and device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111118136.9A CN115086683A (en) 2021-09-23 2021-09-23 Image compression method and device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN115086683A true CN115086683A (en) 2022-09-20

Family

ID=83246423

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111118136.9A Pending CN115086683A (en) 2021-09-23 2021-09-23 Image compression method and device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN115086683A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024098843A1 (en) * 2022-11-10 2024-05-16 苏州元脑智能科技有限公司 Method and system for improving compression quality of jpeg, chip and electronic device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024098843A1 (en) * 2022-11-10 2024-05-16 苏州元脑智能科技有限公司 Method and system for improving compression quality of jpeg, chip and electronic device

Similar Documents

Publication Publication Date Title
KR102071764B1 (en) Picture coding and decoding methods and devices
CN102165773B (en) Image decoding method and image coding method
CN111699695A (en) Method and apparatus for decoding a received encoded data set
RU2567988C2 (en) Encoder, method of encoding data, decoder, method of decoding data, system for transmitting data, method of transmitting data and programme product
CN114339215A (en) Point cloud coding and decoding method, encoder, decoder and computer storage medium
CN108881913B (en) Method and apparatus for image encoding
Lin et al. A spatial rnn codec for end-to-end image compression
CN105027560A (en) Method of determining binary codewords for transform coefficients
CN110996101B (en) Video coding method and device
AU2021200431B2 (en) Techniques for high efficiency entropy coding of video data
CN114040205A (en) Method for selecting intra chroma prediction mode, image processing apparatus, and storage apparatus
CN115086683A (en) Image compression method and device, electronic equipment and computer readable storage medium
WO2002100102A1 (en) Interframe encoding method and apparatus
US9060171B2 (en) Image processing system and method
WO2022067526A1 (en) Image compression method and apparatus
CN114025166A (en) Video compression method, electronic device and computer-readable storage medium
US9723312B2 (en) Method and system for random accessible image compression with adaptive quantization
Naaz et al. Implementation of hybrid algorithm for image compression and decompression
JPH02264585A (en) Encoding system for picture signal
Stamm PGF: A new progressive file format for lossy and lossless image compression
WO2022217472A1 (en) Point cloud encoding and decoding methods, encoder, decoder, and computer readable storage medium
EP4117289A1 (en) Image processing method and image processing device
Ameer Investigating polynomial fitting schemes for image compression
CN110113619B (en) Encoding method, encoding device, electronic equipment and storage medium
CN110858900B (en) Data compression method and device for multiplexing simplified inverse quantization multiplication factor and displacement table

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination