Method and apparatus for image recompression
By obtaining the probability distribution parameters of the quantized DCT coefficients of the image and encoding them using an entropy encoder, the problem of further compression of image data in the cloud is solved, achieving a higher compression ratio and saving storage space.
Patent Information
- Application Number
- CN202380098418.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-18
- Publication Date
- 2025-12-12
AI Technical Summary
In existing technologies, there is still room for improvement in the image compression rate of cloud data, especially for already compressed image data, where how to further save disk space is a challenge.
By acquiring the quantized discrete cosine transform (DCT) coefficients of the image, and using the contextual information of each quantized DCT coefficient to determine its probability distribution parameters, an entropy encoder is used to encode the image, including a multi-symbol arithmetic encoder (MSAC) and a run-length Rice-Columbus encoder (RLRG) to adjust the coding length and achieve a higher compression ratio.
The image compression ratio has been improved, further saving storage space.
Smart Images

Figure CN121128172A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this application relate to the field of image compression, and more specifically, to a method and related apparatus for image recompression. Background Technology
[0002] In recent years, with the emergence of various data storage and cloud services, data compression has once again become crucial. One of the key and most expensive factors in organizing cloud services is disk space.
[0003] Most of the data currently in the cloud is media data. This data is usually compressed in a more or less efficient way, but there is still a strong desire to further improve its compression ratio to save cloud disk space. Therefore, the issue of recompressing this data has emerged.
[0004] Therefore, how to recompress an already compressed image is a challenge. Summary of the Invention
[0005] Embodiments of this application provide a method and related apparatus for image recompression. This technical solution can save disk space.
[0006] According to a first aspect, embodiments of this application provide an image recompression method, the method comprising: The quantized discrete cosine transform (DCT) coefficients are obtained from the first image; Based on the context information of each quantized DCT coefficient, obtain the probability distribution parameters corresponding to each quantized DCT coefficient; The probability of each quantized DCT coefficient is determined based on the probability distribution parameters corresponding to each quantized DCT coefficient. The first image is encoded according to the probability of each quantized DCT coefficient.
[0007] Using the above method, the probability distribution parameter can accurately predict the probability of each quantized DCT coefficient, thereby adjusting the encoding length of each quantized DCT coefficient according to the probability of each quantized DCT coefficient, thus obtaining a higher compression ratio and further saving storage space.
[0008] In one possible design, the first image is a JPEG image.
[0009] In one possible design, obtaining the quantized discrete cosine transform (DCT) coefficients based on the first image includes: obtaining each quantized DCT coefficient by decoding the JPEG image.
[0010] In one possible design, the probability distribution is a Laplace distribution.
[0011] In one possible design, the probability distribution parameters include the standard deviation of the probability distribution.
[0012] In one possible design, the Laplace distribution parameters include the standard deviation of the Laplace distribution.
[0013] In one possible design, obtaining the probability distribution parameters corresponding to each quantized DCT coefficient based on the context information of each quantized DCT coefficient includes: Based on the context information in the three directions of each quantized DCT coefficient, obtain the three standard deviations of the probability distribution corresponding to each quantized DCT coefficient; Based on the three standard deviations of the probability distribution, obtain the target standard deviation of the probability distribution corresponding to each quantized DCT coefficient.
[0014] In one possible design, determining the probability of each quantized DCT coefficient based on the probability distribution parameter corresponding to each quantized DCT coefficient includes: determining the probability of each quantized DCT coefficient based on the probability distribution parameter corresponding to each quantized DCT coefficient and the value of each quantized DCT coefficient.
[0015] In one possible design, encoding the first image according to the probability of each quantized DCT coefficient includes: encoding the quantized DCT coefficients using an entropy encoder according to the probability of each quantized DCT coefficient.
[0016] In one possible design, the entropy encoder is a multi-symbolarithmetic coder (MSAC) or a run-length Rice-Golomb coder (RLRG).
[0017] In one possible design, when using an RLRG encoder, the DCT coefficients can be distributed into buckets, and the DCT coefficients in the buckets can be sorted according to the Laplace distribution parameters calculated for the previous bucket.
[0018] In one possible design, all positions in the 8x8 blocks of the image are unified in a data structure called buckets, such that the 8x8 blocks have 64 buckets.
[0019] In one possible design, encoding the first image according to the probability of each quantized DCT coefficient includes: encoding the quantized DCT coefficients in the bucket by the MSAC if the number of zeros in the bucket that assigns the quantized DCT coefficients is less than a threshold.
[0020] In one possible design, encoding the first image based on the probability of each quantized DCT coefficient includes: encoding the quantized DCT coefficients in the bucket by the RLRG if the number of zeros in the bucket assigning the quantized DCT coefficients is greater than a threshold.
[0021] According to a second aspect, embodiments of this application provide an electronic device having the function of implementing the method of the first aspect. The function can be implemented in hardware or by hardware executing corresponding software. The hardware or the software includes one or more modules corresponding to the function.
[0022] According to a third aspect, embodiments of this application provide a computer-readable storage medium including instructions. When the instructions are executed on a computer, the computer causes the computer to perform the methods described in the first aspect or any possible design of the first aspect.
[0023] According to a fourth aspect, an electronic device is provided, including a processor, a memory, and a communication interface. The processor is connected to the memory and the communication interface. The memory is used to store instructions, the processor is used to execute the instructions, and the communication interface is used to communicate with other network elements under the control of the processor. When the processor executes the instructions stored in the memory, the processor performs the method described in the first aspect or any possible design of the first aspect.
[0024] According to a fifth aspect, a chip system is provided, the chip system including a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to call the computer program from the memory and run the computer program, such that a server on which the chip resides performs the method of the first aspect or any possible design of the first aspect.
[0025] According to a sixth aspect, a computer program product is provided that, when the computer program product is run on a server, causes the server to perform the method of the first aspect or any possible design of the first aspect. Attached Figure Description
[0026] One or more embodiments are described by way of example with the accompanying drawings, which are not intended to limit the embodiments. Elements with the same reference numerals in the drawings are illustrated as similar elements, and the scale of the drawings is not limited.
[0027] Figure 1 This is a schematic diagram of a method for image recompression.
[0028] Figure 2 The contextual information collection of quantized DCT coefficients located in a specific bucket is shown.
[0029] Figure 3 A schematic diagram is shown illustrating the encoding of different buckets based on different encoders.
[0030] Figure 4 The results of applying the proposed method for recompressing a set of test JPEG images are shown.
[0031] Figure 5 This is a schematic block diagram of an electronic device according to an embodiment of this application.
[0032] Figure 6 This is a schematic block diagram of an electronic device according to an embodiment of this application. Detailed Implementation
[0033] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0034] In the specification, claims, and drawings of this invention, the term "comprising" and any other variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that comprises a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other inherent steps or units of the process, method, product, or apparatus.
[0035] This application presents various aspects, embodiments, or features within the context of systems comprising multiple devices, components, modules, etc. It should be understood that various systems may include additional devices, components, modules, etc., and / or may exclude all devices, components, modules, etc., discussed in conjunction with the accompanying drawings. Furthermore, combinations of these approaches may also be used.
[0036] Furthermore, in the embodiments of this application, terms such as "exemplary" and "for example" are used to indicate examples or illustrations. Any embodiment or design described as "exemplary" in this application should not be construed as a preferred or advantageous embodiment compared to other embodiments or designs. Rather, the purpose of using the term "example" is to present a concept in a concrete manner.
[0037] In this application, the terms “related” and “corresponding” are sometimes used interchangeably. It should be noted that when the difference is not emphasized, the two terms have the same meaning.
[0038] The business scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Although architectures are constantly evolving and new business scenarios are emerging, the technical solutions provided by the embodiments of this application are also applicable to solving similar technical problems.
[0039] In recent years, with the emergence of various data storage and cloud services, data compression has once again become crucial. One of the key and most expensive factors in organizing cloud services is disk space.
[0040] Most of the data currently in the cloud is media data. This data is usually compressed in a more or less efficient way, but there is still a strong desire to further improve its compression ratio to save cloud disk space. Therefore, the issue of recompressing this data has emerged.
[0041] To address the aforementioned issues, embodiments of this application provide a method and apparatus for image recompression, which helps to further save disk space.
[0042] Figure 1 This is a schematic diagram of a method for image recompression. The method can be performed by a device for image recompression, or by a module or unit within that device. Specifically, the method includes the following steps.
[0043] Step 110: Extract the quantized discrete cosine transform (DCT) coefficients of the first image.
[0044] The embodiments of this application do not specifically limit the first image, as long as the quantized DCT coefficients can be obtained from the first image. The following are examples of possible implementations of the first image.
[0045] In one possible implementation, the first image is the original image without any compression. In embodiments of this application, the quantized DCT coefficients can be obtained from the original image.
[0046] In one possible implementation, the first image is a Joint Photographic Experts Group (JPEG) image. In embodiments of this application, the JPEG image can be decompressed to obtain the quantized DCT coefficients corresponding to the JPEG image.
[0047] It should be understood that a JPEG image is a compressed image obtained by compressing the image data using JPEG technology. For ease of description, a detailed explanation of JPEG images is provided below.
[0048] For example, in JPEG compression, the image is divided into multiple blocks, each 8x8 pixels in size. Each block is processed independently throughout the compression process. Each 8x8 block is represented as an 8x8 matrix in the data. A two-dimensional DCT transform is performed on the 8x8 matrix to obtain a matrix containing 8x8 DCT coefficients. Then, the DCT coefficient matrix is quantized to obtain a matrix containing 8x8 quantized DCT coefficients. Finally, the quantized DCT coefficient matrix is converted into a one-dimensional array, and this one-dimensional array is encoded to obtain the JPEG image described above.
[0049] In the embodiments of this application, the JPEG image can be decompressed to obtain the quantization DCT coefficient matrix corresponding to each block, wherein each quantization DCT coefficient matrix includes 8x8 quantization DCT coefficients.
[0050] In embodiments of this application, a bucket represents a set of quantized DCT coefficients at fixed positions within each block. That is, an image divided into 8x8 pixel blocks can include 64 buckets, each bucket containing a set of quantized DCT coefficients at the same position within each 8x8 block. Figure 2 The image shown is a portion of an image consisting of 20 blocks of size 8x8 pixels, each block containing 8x8 quantized DCT coefficients. Therefore, this portion of the image comprises 64 buckets, each containing a set of 20 quantized DCT coefficients at the same location in the 20 blocks.
[0051] Optionally, in some embodiments, the correlation between buckets can also be evaluated using some correlation metrics. If some buckets are strongly correlated, these buckets can be merged. After merging, context information can also be shared between two or more merged buckets.
[0052] In one possible implementation, we can use the Pearson correlation coefficient to assess the correlation between buckets.
[0053] Step 120: Determine the probability distribution parameters corresponding to each quantized DCT coefficient based on the context information of each quantized DCT coefficient.
[0054] Based on the context information of each quantized DCT coefficient, the probability distribution parameter corresponding to each quantized DCT coefficient can be determined, and thus the probability of each quantized DCT coefficient can be estimated based on the probability distribution parameter corresponding to each quantized DCT coefficient.
[0055] The above probability distribution can be implemented in various ways, and the embodiments of this application do not provide specific details. In one possible implementation, the probability distribution is a generalized Gaussian distribution. In another possible implementation, the probability distribution is a Laplace distribution.
[0056] For ease of description, Figure 2 Taking the quantized DCT coefficients in the Qth bucket of the current block (i) as an example, we introduce the context information of the quantized DCT coefficients. For example, the dashed line represents the quantized DCT coefficient corresponding to position 1. Here, Q is an integer greater than 0.
[0057] like Figure 2 As shown, the quantized DCT coefficients in the current block (e.g., the quantized DCT coefficients corresponding to the positions marked as 1, indicated by the dashed lines) can include contextual information in three directions: vertical (V), horizontal (H), and diagonal (D).
[0058] For example, contextual information in the vertical direction can include a set of quantized DCT coefficients corresponding to buckets in multiple blocks along the vertical direction, the length of which is limited by the image size. For example, as... Figure 2 As shown, this set of quantized DCT coefficients includes the quantized DCT coefficients corresponding to position 2 (represented by dashed lines), position 3 (represented by dashed lines), and position 4 (represented by dashed lines).
[0059] For example, horizontal context information can include a set of quantized DCT coefficients for corresponding buckets in multiple blocks along the horizontal direction. The length of this set of quantized DCT coefficients is limited by the image size. For example, ... Figure 2 As shown, this set of quantized DCT coefficients includes the quantized DCT coefficients marked at position 5 (dashed line), the quantized DCT coefficients marked at position 6 (dashed line), and the quantized DCT coefficients marked at position 7 (dashed line).
[0060] For example, contextual information along the diagonal direction can include a set of quantized DCT coefficients for corresponding buckets in multiple blocks along the diagonal direction. The length of this set of quantized DCT coefficients is limited by the image size. For example, such as Figure 2As shown, this set of quantized DCT coefficients includes the quantized DCT coefficients marked at position 8 (dashed line), the quantized DCT coefficients marked at position 9 (dashed line), and the quantized DCT coefficients marked at position 10 (dashed line).
[0061] The following example, using the probability distribution as a Laplace distribution, explains in detail how to determine the Laplace distribution parameters corresponding to each quantized DCT coefficient based on the context information of each quantized DCT coefficient.
[0062] For example, the Laplace distribution has two parameters that need to be predicted: the mean μ and the standard deviation σ. In one possible implementation, embodiments of this application may set μ=0, and determine the σ of the Laplace distribution corresponding to each quantized DCT coefficient based on the context information of each quantized DCT coefficient.
[0063] In the embodiments of this application, the standard deviation of the Laplace distribution of the specific quantified DCT coefficients can be calculated using the following formula σ.
[0064] (Formula 1) In Formula 1, k is the index of the bucket, i.e., ; It's a bucket The standard deviation, It is a block index. It's a bucket The absolute value of the DCT coefficients, the block is ; These are empirical parameters.
[0065] We can predict in one of the following directions—horizontal (H), vertical (V), and diagonal (D)—using Formula 1. Alternatively, we can predict using Equation 1 by using a linear combination of two or three of the following directions: horizontal (H), vertical (V), and diagonal (D). In the embodiments of this application, it is not limited to using any of the directions H, V, and D for prediction. .
[0066] Below, to account for 2D dependencies, we predict using three directions—horizontal, vertical, and diagonal—using Equation 1. This resulted in three predictions. : , ,in, This represents the standard deviation of the horizontal prediction calculated according to Formula 1. This represents the standard deviation of the vertical prediction calculated according to Formula 1. This represents the standard deviation of the diagonal direction prediction calculated according to Formula 1. The standard deviation is calculated as follows: (Formula 2) Coefficients A, B, and C can be selected in various ways.
[0067] Step 130: Determine the probability of each quantized DCT coefficient based on the Laplace distribution parameter corresponding to each quantized DCT coefficient.
[0068] In the embodiments of this application, after estimating the Laplace distribution parameters corresponding to each quantized DCT coefficient, the probability of each quantized DCT coefficient can be determined based on the Laplace distribution corresponding to each quantized DCT coefficient.
[0069] For example, if the parameter of the Laplace distribution is the standard deviation σ of the Laplace distribution, then after estimating the standard deviation σ of the Laplace distribution corresponding to the quantized DCT coefficients, the probability of the quantized DCT coefficients can be estimated by an explicit formula or a pre-calculated table.
[0070] For example, the following explicit formula is used for probability estimation.
[0071] (Formula 3) If X is a discrete set (e.g., -3, -2, -1, 0, 1, 2, 3, etc.), then the probability of each quantized DCT coefficient will be approximated using Equation 4: (Formula 4) In actual calculation In this context, the value of the i-th quantized DCT coefficient is denoted as . Calculated using Formula 1.
[0072] Step 140: Encode each quantized DCT coefficient according to the probability of each quantized DCT coefficient.
[0073] After determining the probability of each quantized DCT coefficient, embodiments of this application can encode the quantized DCT coefficient using an entropy encoder. Specifically, the entropy encoder can explicitly use the probability of each quantized DCT coefficient or not explicitly use the probability to encode each quantized DCT coefficient.
[0074] It should be understood that the embodiments of this application do not specifically define the above-mentioned entropy encoder, as long as it is an entropy encoder that requires probability estimation.
[0075] In one example, the entropy encoder that utilizes explicit probability computation is the multi-symbol arithmetic coder (MSAC). In another example, the entropy encoder that does not use explicit probability estimation is the run-length Rice-Golomb coder (RLRG).
[0076] It should be understood that different buckets may use the same entropy encoder or different entropy encoders, and the embodiments of this application do not specifically limit this.
[0077] Optionally, in some embodiments, a combination of MSAC and RLRG can be used for encoding. Specifically, all buckets can be divided into two groups. One group can use MSAC to encode the quantized DCT coefficients, and the other group can use RLRG to encode the quantized DCT coefficients.
[0078] The embodiments of this application do not specify a classification criterion for dividing all barrels into two groups. For example, as Figure 3 As shown, the classification criterion is the number of zeros in each bucket. If the number of zeros in a bucket is less than a threshold, the quantized DCT coefficients in the bucket can be encoded using MSAC. If the number of zeros in a bucket is greater than the threshold, the quantized DCT coefficients in the bucket can be encoded using RLRG.
[0079] The value of the above threshold can be determined empirically.
[0080] For example, the application results of the proposed method for recompressing a set of test images are as follows: Figure 4 As shown.
[0081] from Figure 4 The data shows that recompressing images using the method provided in the embodiments of this application can save storage space.
[0082] Figure 5 This is a schematic block diagram of an electronic device 500 according to an embodiment of this application. Figure 5 As shown, the electronic device 500 includes a processing unit 501 and an encoding unit 502.
[0083] Processing unit 501 is used to obtain quantized discrete cosine transform (DCT) coefficients based on the first image.
[0084] The processing unit 501 is also used to obtain the probability distribution parameters corresponding to each quantized DCT coefficient based on the context information of each quantized DCT coefficient.
[0085] The processing unit 501 is also used to determine the probability of each quantized DCT coefficient based on the probability distribution parameter corresponding to each quantized DCT coefficient.
[0086] The encoding unit 502 is used to encode the first image according to the probability of each quantized DCT coefficient.
[0087] In some embodiments, the first image is a JPEG image.
[0088] In some embodiments, the processing unit 501 is specifically configured to obtain each quantized DCT coefficient by decoding the JPEG image.
[0089] In some embodiments, the probability distribution is a Laplace distribution.
[0090] In some embodiments, the probability distribution parameter includes the standard deviation of the probability distribution.
[0091] In some embodiments, the Laplace distribution parameter includes the standard deviation of the Laplace distribution.
[0092] In some embodiments, the processing unit 501 is specifically configured to: obtain the three standard deviations of the probability distribution corresponding to each quantized DCT coefficient based on the context information of the three directions of each quantized DCT coefficient; and obtain the target standard deviation of the probability distribution corresponding to each quantized DCT coefficient based on the three standard deviations of the probability distribution.
[0093] In some embodiments, the processing unit 501 is specifically used to determine the probability of each quantized DCT coefficient based on the probability distribution parameter corresponding to each quantized DCT coefficient and the value of each quantized DCT coefficient.
[0094] In some embodiments, the encoding unit 502 is specifically configured to encode the quantized DCT coefficients using an entropy encoder based on the probability of each quantized DCT coefficient.
[0095] In some embodiments, the entropy encoder is a multi-symbol arithmetic encoder (MSAC) or a run-length Rice-Golomb encoder (RLRG).
[0096] In some embodiments, all positions in an 8x8 block of an image are unified in a data structure called buckets, such that the 8x8 block has 64 buckets.
[0097] In some embodiments, if the number of zeros in the bucket where the quantized DCT coefficients are assigned is less than a threshold, the encoding unit 502 is specifically used to encode all the quantized DCT coefficients in the bucket using MSAC.
[0098] In some embodiments, if the number of zeros in the bucket containing the first quantized DCT coefficient is greater than a threshold, the encoding unit 502 is specifically used to encode all quantized DCT coefficients in the bucket using RLRG.
[0099] It should be understood that the electronic device 500 in the embodiments of this application can correspond to the electronic device in the above embodiments, and the above and other management operations and / or functions of each unit in the electronic device are used to implement the corresponding steps of the above method. For the sake of brevity, they will not be described in detail here.
[0100] like Figure 6 As shown, the electronic device 600 may include a transceiver 601, a processor 602, and a memory 603. The memory 603 may be used to store code, instructions, etc., executed by the processor 602.
[0101] It should be understood that processor 602 can be an integrated circuit chip with signal processing capabilities. In implementation, the various steps of the above method embodiments can be completed by hardware integrated logic circuits in the processor or by software instructions. The processor can be a general-purpose processor, a central processing unit (CPU), a graphics processing unit (GPU), a neural processing unit (NPU), a system-on-chip (SoC), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor, or it can be any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly embodied in the execution of a hardware decoding processor, or executed using a combination of hardware and software modules in the decoding processor. The software modules can reside in mature storage media in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with the hardware in the processor, completes the steps of the above methods.
[0102] It should be understood that the memory 603 in the embodiments of the present invention may be volatile memory or non-volatile memory, or may include both volatile memory and non-volatile memory. Non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
[0103] It should be noted that the memory of the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0104] Embodiments of this application also provide a system-on-a-chip (SoC) including an input / output interface, at least one processor, at least one memory, and a bus. The at least one memory is used to store instructions, and the at least one processor is used to invoke the instructions from the at least one memory to perform the operations in the methods of the above embodiments.
[0105] Embodiments of this application also provide a computer storage medium that can store program instructions for performing any of the methods described above.
[0106] Optionally, the storage medium may be a memory 603.
[0107] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed by hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but should not consider such implementation to be beyond the scope of this application.
[0108] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the above method embodiments, and will not be repeated here.
[0109] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and other division methods may be used in actual implementation. For example, multiple units or components may be merged or integrated into another system, or some features may be ignored or not performed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be implemented through some interfaces. Direct coupling or communication connection between devices or units can be implemented electronically, mechanically, or in other ways.
[0110] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0111] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0112] If implemented as software functional units and sold or used as independent products, these functions can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to instruct a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0113] The above descriptions are merely some specific implementations of this application and are not intended to limit the scope of protection of this application. Any variations or substitutions easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for image recompression, characterized in that, The method includes: The quantized discrete cosine transform (DCT) coefficients are obtained from the first image; Based on the context information of each quantized DCT coefficient, obtain the probability distribution parameters corresponding to each quantized DCT coefficient; The probability of each quantized DCT coefficient is determined based on the probability distribution parameters corresponding to each quantized DCT coefficient. The first image is encoded according to the probability of each quantized DCT coefficient.
2. The method according to claim 1, characterized in that, The probability distribution parameters include the Laplace distribution parameters.
3. The method according to claim 1 or 2, characterized in that, The first image is a JPEG image.
4. The method according to claim 3, characterized in that, The step of obtaining the quantized discrete cosine transform (DCT) coefficients based on the first image includes: Each quantized DCT coefficient is obtained by decoding the JPEG image.
5. The method according to any one of claims 1 to 4, characterized in that, The probability distribution parameters include the standard deviation of the probability distribution.
6. The method according to claim 5, characterized in that, The step of obtaining the probability distribution parameters corresponding to each quantized DCT coefficient based on the context information of each quantized DCT coefficient includes: Based on the context information of each quantized DCT coefficient in three directions, obtain the three standard deviations of the probability distribution corresponding to each quantized DCT coefficient; Based on the three standard deviations of the probability distribution, obtain the target standard deviation of the probability distribution corresponding to each quantized DCT coefficient.
7. The method according to any one of claims 1 to 6, characterized in that, Determining the probability of each quantized DCT coefficient based on the probability distribution parameters corresponding to each quantized DCT coefficient includes: The probability of each quantized DCT coefficient is determined based on the probability distribution parameter corresponding to each quantized DCT coefficient and the value of each quantized DCT coefficient.
8. The method according to any one of claims 1 to 7, characterized in that, Encoding the first image based on the probability of each quantized DCT coefficient includes: The quantized DCT coefficients are encoded using an entropy encoder based on the probability of each quantized DCT coefficient.
9. The method according to claim 8, characterized in that, The entropy encoder is a multi-symbol arithmetic coder (MSAC) or a run-length Rice-Golomb coder (RLRG).
10. The method according to claim 9, characterized in that, Encoding the first image based on the probability of each quantized DCT coefficient includes: If the number of zeros in the bucket containing the first quantized DCT coefficient is less than a threshold, then the quantized DCT coefficient in the bucket is encoded by the MSAC.
11. The method according to claim 9, characterized in that, Encoding the first image based on the probability of each quantized DCT coefficient includes: If the number of zeros in the bucket containing the first quantized DCT coefficient is greater than a threshold, then the quantized DCT coefficient in the bucket is encoded by the RLRG.
12. An electronic device, characterized in that, The electronic device includes: The processing unit is used to obtain the quantized discrete cosine transform (DCT) coefficients based on the first image; The processing unit is further configured to obtain the probability distribution parameters corresponding to each quantized DCT coefficient based on the context information of each quantized DCT coefficient. The processing unit is further configured to determine the probability of each quantized DCT coefficient based on the probability distribution parameter corresponding to each quantized DCT coefficient. An encoding unit is configured to encode the first image according to the probability of each quantized DCT coefficient.
13. The electronic device according to claim 12, characterized in that, The probability distribution parameters include the Laplace distribution parameters.
14. The electronic device according to claim 12 or 13, characterized in that, The first image is a JPEG image.
15. The electronic device according to claim 14, characterized in that, The processing unit is also used to obtain each quantized DCT coefficient by decoding the JPEG image.
16. The electronic device according to any one of claims 12 to 15, characterized in that, The probability distribution parameters include the standard deviation of the probability distribution.
17. The electronic device according to claim 16, characterized in that, The processing unit is further configured to: obtain three standard deviations of the probability distribution corresponding to each quantized DCT coefficient based on the context information of the three directions of each quantized DCT coefficient; and obtain the target standard deviation of the probability distribution corresponding to each quantized DCT coefficient based on the three standard deviations of the probability distribution.
18. The electronic device according to any one of claims 12 to 17, characterized in that, The processing unit is further configured to determine the probability of each quantized DCT coefficient based on the probability distribution parameter corresponding to each quantized DCT coefficient and the value of each quantized DCT coefficient.
19. The electronic device according to any one of claims 12 to 18, characterized in that, The encoding unit is further configured to encode the quantized DCT coefficients using an entropy encoder based on the probability of each quantized DCT coefficient.
20. The electronic device according to claim 19, characterized in that, The entropy encoder is a multi-symbol arithmetic coder (MSAC) or a run-length Rice-Golomb coder (RLRG).
21. The electronic device according to claim 20, characterized in that, If the number of zeros in the bucket containing the first quantized DCT coefficient is less than a threshold, the encoding unit is further configured to encode the quantized DCT coefficient in the bucket using the MSAC.
22. The electronic device according to claim 20, characterized in that, If the number of zeros in the bucket containing the first quantized DCT coefficient is greater than a threshold, the encoding unit is further configured to encode the quantized DCT coefficients in the bucket using the RLRG.
23. A computer-readable storage medium, characterized in that, Used to store instructions that, when run on a server, cause the server to perform the method according to any one of claims 1 to 11.
24. A device, characterized in that, The device includes a memory and a processor, the memory being used to store a computer program, and the processor being used to retrieve and run the computer program from the memory, causing a server on which the chip resides to perform the method according to any one of claims 1 to 11.
25. A computer program product, characterized in that, When the computer program product is run on the server, the server causes the server to perform the method according to any one of claims 1 to 11.