Image compression method with controllable compression ratio
By using image encoding/decoding models and binary coding quantization compression technology, the problem of insufficient compression strength in image compression methods is solved, achieving custom compression ratios and fast response image compression effects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SEETATECH BEIJING TECH CO LTD
- Filing Date
- 2026-03-06
- Publication Date
- 2026-06-02
AI Technical Summary
Existing image compression methods cannot dynamically adjust the compression intensity according to the differences in local texture complexity of the image, resulting in severe distortion in areas with rich textures. Furthermore, they lack a compression feedback mechanism, making it impossible to quickly respond to the rapid response requirements of real-time interactive scenarios.
Image encoding and decoding models are used for downsampling, and binary encoding quantization compression is introduced. By controlling the bit width of the binary encoding, a custom compression ratio can be achieved or a specified compression quality can be maintained. End-to-end training is used to optimize the encoding and decoding models to adapt to different imaging requirements.
It achieves dynamic adjustment of compression intensity based on image content, reduces redundant information, improves compression efficiency, and meets the rapid response requirements of real-time interactive scenarios.
Smart Images

Figure CN122137976A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image compression, and more particularly to an image compression method with a controllable compression ratio. Background Technology
[0002] Image compression and storage is a crucial step in image processing, especially in scenarios where mobile terminals and edge devices have limited computing power. It is necessary to reduce the size of image data while ensuring visual imaging quality to save storage space and transmission bandwidth. Although existing standard compression methods such as JPEG and WebP have high compression efficiency, their compression ratios are preset by quantization tables or encoding parameters, making it difficult to dynamically adjust them according to real-time network conditions, device remaining capacity, or user preferences.
[0003] Existing technical solutions: Discrete cosine transform (DCT) is the core of current standards such as JPEG. It transforms an image from the spatial domain to the frequency domain and then performs lossy quantization on high-frequency components to achieve compression. However, the fixed quantization step size cannot respond to differences in the local texture complexity of the image, resulting in significant fluctuations in visual quality for different image content under the same parameters. Deep learning-based encoder schemes effectively improve compression performance by quantizing latent feature representations, but their model structure and compression parameters are fixed, lacking the ability to adjust for different imaging needs. This means that the compression performance of corresponding compression strategies cannot be specifically optimized for different image content.
[0004] Current image compression methods suffer from insufficient image content perception and an inability to dynamically adjust the compression intensity of regions based on local image information. This results in severe distortion in areas with rich textures, while flat areas are redundantly preserved. Furthermore, the lack of a compression feedback mechanism makes it impossible to directly evaluate the imaging quality of the decoded image based on the encoding parameters. Additionally, for time-sensitive applications, the compressed result cannot be quickly adjusted or recompressed, making the compression process unsuitable for rapid response in real-time interactive scenarios. Summary of the Invention
[0005] In view of the above problems, the present invention is proposed to provide an image compression method with a controllable compression ratio that overcomes or at least partially solves the above problems.
[0006] According to one aspect of the present invention, a method for image compression with a controllable compression ratio is provided, the image compression method comprising: Image encoding and decoding models are used to downsample image information to obtain intermediate features, and binary encoding is introduced to quantize and compress the intermediate features to obtain a compressed file. During decompression, the binary code is decoded into the original image using a decoding model, thus realizing the complete image compression and decompression process. During the compression process, a custom compression ratio or a specified compression quality can be achieved by controlling the bit width of the binary encoding.
[0007] Optionally, the step of using an image encoding / decoding model to downsample image information to obtain intermediate features specifically includes: Image encoding: The encoding process is obtained by concatenating multiple encoding modules, which map the features of the image; A single downsampling encoding module consists of the following: A single downsampling module consists of: an upper convolutional layer... Activation function Normalization and three modules; Through multiple sizes Convolutional stacking extracts image features within a certain range; activation functions suppress low-response features while preserving high-frequency feature information within the image; and normalization reduces the feature dimension. Multiple groups are used for independent normalization to achieve independent adjustment of features at different locations; Normalization: By independently grouping and statistically analyzing the data, the values within each group are counted independently, ensuring that effective image feature information is contained within each bit width when compressing different bit widths. Dimensional restructuring of features The total number of features is divided into G; Perform trigonometric hyperbolic tangent on channel c After the operation, the mapping parameters are introduced. and Each group is independently linearly scaled to adjust the feature distribution, and then the features are recombined to restore the original shape for subsequent processing. Through normalization operations, the quality of each group in the proposed image features is guaranteed. The information within is independently statistically analyzed, resulting in highly responsive activation features; Activation function: ReLU is used as the activation function, which only retains the part of the normalized value that is greater than zero; The activation function suppresses redundant information generated during image feature extraction; the relevant redundant information is ultimately represented by regions of 0 in binary encoding. Module concatenation: By concatenating multiple encoding modules, image information of different granularities is mapped to feature channels located in different groups. By introducing different masks to the feature channels during the model training phase, different group combinations are used to achieve image reconstruction with different precision.
[0008] Optionally, the step of introducing binary encoding to quantize and compress intermediate features to obtain a compressed file specifically includes: The feature encoding obtained through the compression process is of type float32. Storing a single encoded value requires 32 bits of storage space. Binary quantization is used to compress the results; Among them, Sigmoid is a type of activation function that maps values to floating-point numbers between 0 and 1, and Floor is a rounding down operation for values; by combining them, they form the Binary operation, which maps all values to 0 and 1. Intermediate encoding can convert the image compression information output by the encoder from floating-point to Boolean type.
[0009] Optionally, during decompression, the process of decoding the binary code into the original image using a decoding model specifically includes: Introducing explicit constraints in end-to-end training .
[0010] Optionally, the end-to-end training specifically includes: Use the encoder to process the original image. Convert to a binary quantization intermediate code of length n bits ; The Mask procedure is introduced to generate a random number K, where K ranges from 1 to n. After passing through a function... Keep the first K significant bits and set all other bits to zero; The decoding model is used to process the zeroed-out feature information and restore it to the target image. ; calculate and The L1 loss is used to generate a backward gradient to update all parameters in the encoding / decoding model; By using an end-to-end training method, the features of the image are mapped to binary codes in different regions, so that the low-range encoding preserves the image overview information, while the high-range encoding preserves the image details.
[0011] Optionally, the process of controlling the bit width of the binary encoding to achieve a custom compression ratio or maintain a specified compression quality specifically includes: After end-to-end training, different lengths Image reconstruction corresponding to different precision; Different regions of an image can be assigned different effective bits to maximize the image compression ratio; When performing image compression at a specified ratio or precision, first select appropriate initial parameters by referring to the curve; The number of bits (bpp) required to store one pixel corresponds to the binary bit width used, and the image structure similarity (ssim) corresponds to the accuracy of the target.
[0012] Optionally, the compression process, in which different regions of the image can be set with different effective bits to maximize the image compression ratio, includes: The user specifies the minimum desired compression ratio or the desired compression accuracy. The image is divided into multiple independent sub-images; each sub-image undergoes a separate encoding and decoding process. When the compression accuracy achieved within the subgraph is greater than the expected value; When the compression accuracy achieved within the subgraph is less than the expected value; Repeat the above operation until all subgraphs meet the condition that the encoding just meets the target precision; Output the corresponding compressed file; The method of dividing an image compression task into segments and performing iterative parameter search can meet the image compression requirements for a specified compression ratio or compression accuracy.
[0013] This invention provides an image compression method with controllable compression ratio. The method includes: downsampling image information using an image encoding / decoding model to obtain intermediate features; introducing binary encoding to quantize and compress the intermediate features to obtain a compressed file; during decompression, using a decoding model to decode the binary encoding back into the original image, thus achieving a complete image compression and decompression process; during compression, a custom compression ratio or maintaining a specified compression quality is achieved by controlling the bit width of the binary encoding. The method divides the image compression task into segments and performs iterative parameter search to meet the image compression requirements for a specified compression ratio or compression accuracy. Furthermore, the variable encoding bits can fully utilize the spatial redundancy in the sub-images, effectively improving the overall image compression ratio.
[0014] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0015] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 A flowchart of an image compression method with controllable compression ratio provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the Tanh hyperbolic tangent and normalized mapping curves provided in an embodiment of the present invention; Figure 3 A schematic diagram of the binarization mapping of numerical values provided in an embodiment of the present invention; Figure 4 A comparison diagram of encoding and compression effects provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of the curves showing the measured compression ratio (bpp) versus image precision (ssim) provided in an embodiment of the present invention. Detailed Implementation
[0017] Exemplary embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
[0018] The terms "comprising" and "having," and any variations thereof, in the specification, embodiments, claims, and drawings of this invention are intended to cover non-exclusive inclusion, such as including a series of steps or units.
[0019] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.
[0020] like Figure 1 As shown, an image compression method with controllable compression ratio includes: Image encoding and decoding models are used to downsample image information to obtain intermediate features, and binary encoding is introduced to quantize and compress the intermediate features to obtain a compressed file. During decompression, the binary code is decoded into the original image using a decoding model, thus realizing the complete image compression and decompression process. During the compression process, a custom compression ratio or a specified compression quality can be achieved by controlling the bit width of the binary encoding.
[0021] Image Compression Method Overview: To achieve a controllable compression ratio in image compression, this paper proposes an image encoding / decoding model to downsample image information to obtain intermediate features. Then, binary encoding is introduced to quantize and compress these intermediate features to obtain a compressed file. During decompression, a decoding model is used to decode the binary code back to the original image, thus realizing a complete image compression and decompression process. During compression, a custom compression ratio or maintaining a specified compression quality can be achieved by controlling the bit width of the binary code.
[0022] Compression process Image compression process: The image compression process uses a fully convolutional coding model. Multiple convolutional feature extraction modules downsample the image to reduce its feature resolution, resulting in an image with the shape... Image features.
[0023] Image encoding: The encoding process consists of multiple encoding modules connected in series. Each module continuously maps the image's features to reduce its spatial resolution and increase the dimensionality of those features. A single downsampling encoding module is structured as follows: A single downsampling module, as shown above, consists of convolution ( ), activation function ( ), normalization It consists of three modules. Multiple dimensions are available. Stacked convolutions can extract image features within a certain range. Activation functions retain high-frequency feature information within the image by suppressing low-response features, while normalization reduces the feature dimension. Independent normalization is performed in multiple groups to achieve independent adjustment of features at different locations.
[0024] Normalization: This function ensures a uniform distribution of high-response image features by independently grouping and statistically analyzing the values within each group. This guarantees that effective image feature information is contained within each bit width during compression.
[0025] Normalization involves the following processing steps: first, the features are reorganized in terms of dimensions. The features are totaled into G. Then, the c channel is processed... After the (trigonometric function hyperbolic tangent) operation, a mapping parameter is introduced. and Each group is independently linearly scaled to adjust its feature distribution, and finally, it is reconstructed to restore its original shape for subsequent processing. For example... Figure 2 As shown.
[0026] Through the above normalization operation, the normalization process can ensure that each group in the proposed image features is properly configured. Independent statistical analysis of the information within each region can generate highly responsive activation features. This avoids the situation where some feature channels are continuously suppressed during general normalization, resulting in a lack of usable information.
[0027] Activation function: ReLU is used as the activation function, which only retains the normalized values greater than zero. This effectively suppresses redundant information generated during image feature extraction. The relevant redundant information is ultimately represented as regions of zero in the binary encoding.
[0028] Module concatenation: By concatenating multiple encoding modules, image information of different granularities is mapped to feature channels located in different groups. By introducing different masks for the feature channels during the model training phase, different group combinations can be used to achieve image reconstruction with different precision.
[0029] Intermediate encoding, including: The feature encoding obtained through compression is of type float32. Storing a single encoded value requires 32 bits of storage space, and differences in decimal places do not cause significant changes in the feature distribution. Therefore, binary quantization is used to compress the result.
[0030] Sigmoid is an activation function that maps values to floating-point numbers between 0 and 1, while Floor rounds the value down. Combining these functions creates the Binary operation, mapping all values to 0 and 1. The binary mapping of values is as follows: Figure 3 As shown.
[0031] Intermediate encoding converts the image compression information output by the encoder from floating-point to Boolean. This effectively reduces the storage space occupied by a single data bit and also reduces redundancy in the compressed data, thereby significantly improving the compression ratio.
[0032] Comparing the feature activation patterns before and after quantization, the binary quantization operation in this method yields denser feature activations, effectively reducing data redundancy and improving the storage of redundant data. Figure 4 As shown.
[0033] Decoding process The decoding process, in contrast to the encoding process, involves restoring the original image from the compressed intermediate encoding. The model structure used in the decoding process is the same as that used in the encoding process, both consisting of stacked fully convolutional modules. Additionally, extra mapping layers are added to accommodate inputs with varying numbers of binary encoded compressed files, supporting inputs with different compression bit settings for different regions in high-resolution image compression.
[0034] Multiple compression ratio inputs: To implement an image decoding method that processes multiple compression ratios using a single decoding model, compressed information of different bit widths needs to be padded into a fixed shape to form the input of the decoding model.
[0035] In the padding process, Boolean values of 0 are used as padding to uniformly fill different states with a fixed length, adapting to the situation where a fixed-size model input is required in convolutional models. Furthermore, the redundant information corresponding to 0 during compression determines whether that bit is negligible in different precision compressions; therefore, all-zero padding can be seen as corresponding to image reconstruction at different precisions.
[0036] Binary Input Mapping: Fully convolutional models require floating-point input, necessitating floating-point mapping of binary information for processing. Therefore, a binary mapping dictionary is constructed in the decoder, ensuring that different binary codes can be indexed to a unique corresponding floating-point code.
[0037] Typical unique mapping length bits of need Using a floating-point number as a mapping dictionary would require significantly more storage than typical methods. Therefore, matrix multiplication is used to map the shape bits. of Equivalence is achieved through matrix multiplication, and all images share this mapping dictionary, thus enabling unique numerical mapping using two-dimensional matrix multiplication with minimal storage requirements.
[0038] End-to-end training The process of direct encoder feature mapping and encoder-decoder image reconstruction cannot explicitly constrain the resulting compressed file. It cannot specify the image information of what precision the c feature channels in different partitions correspond to. Therefore, such explicit constraints need to be introduced in end-to-end training.
[0039] The end-to-end training process used in this method is as follows: 1) First, use an Encoder to... (Original image) converted to a length of n bits (Binary quantization intermediate encoding). (Note: At this point, any position in length n may be a 1, which could contain the information needed for image reconstruction.) 2) Introduce the Mask procedure, which generates a random number K (K takes a value between 1 and n). After passing through this function... The first K valid bits can be retained, and all other bits can be set to zero.
[0040] 3) Use a decoding model to process the zeroed-out feature information and restore it to the target image. .
[0041] 4) Calculation and The L1 loss is used to generate inverse gradients that update all parameters in the encoding / decoding model. Different values of K correspond to different losses. Weights have fewer effective bits, resulting in lower weights and less impact on the model's weights; conversely, more effective bits result in higher weights.
[0042] This end-to-end training method maps image features to binary codes in different regions, allowing the lower regions to preserve overall image information while the higher regions retain detailed information. Different image compression techniques can be achieved through different encoding stages.
[0043] Controllable compression After end-to-end training, different lengths This allows for image reconstruction at different precision levels. Generally, images with less detail and texture require less information to achieve high-precision reconstruction, while those with more detail and texture require more information to support reconstruction. Therefore, different regions of an image can be assigned different effective bits to maximize the image compression ratio.
[0044] like Figure 5 As shown, when performing image compression at a specified ratio or precision, appropriate initial parameters can be selected by referring to the curves above. Here, bpp (bits required to store one pixel) corresponds to the binary bit width used, and ssim (image structural similarity) corresponds to the precision of the target.
[0045] Based on the above comparison, the compression process with controllable pressure ratio is as follows: The user specifies the desired minimum compression ratio or the desired compression precision. For example, if the desired SSIM is 0.9, the corresponding effective binary code bit length is 128 bits at a bpp of 2.
[0046] The image is divided into multiple independent sub-images. Each sub-image undergoes a separate encoding and decoding process.
[0047] If the compression accuracy achieved within the subgraph is greater than the expected value, then the binary code bit length is reduced.
[0048] If the compression accuracy achieved within the subgraph is less than the expected value, then the binary code bit length is increased.
[0049] Repeat the above operation until all subgraphs meet the condition that the encoding just meets the target precision.
[0050] Output the corresponding compressed file.
[0051] Beneficial effects: Dividing an image compression task into segments and performing iterative parameter search can meet the requirements of image compression for a specified compression ratio or compression accuracy. Furthermore, variable coding bits can fully utilize the spatial redundancy in the sub-images, thereby effectively improving the overall image compression ratio.
[0052] The above specific embodiments further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. An image compression method with controllable compression ratio, characterized in that, The image compression method includes: Image encoding and decoding models are used to downsample image information to obtain intermediate features, and binary encoding is introduced to quantize and compress the intermediate features to obtain a compressed file. During decompression, the binary code is decoded into the original image using a decoding model, thus realizing the complete image compression and decompression process. During the compression process, a custom compression ratio or a specified compression quality can be achieved by controlling the bit width of the binary encoding.
2. The image compression method with controllable compression ratio according to claim 1, characterized in that, The step of using an image encoding / decoding model to downsample image information to obtain intermediate features specifically includes: Image encoding: The encoding process is obtained by concatenating multiple encoding modules, which map the features of the image; A single downsampling encoding module consists of the following: A single downsampling module consists of: an upper convolutional layer... Activation function Normalization and three modules; Through multiple sizes Convolutional stacking extracts image features within a certain range; activation functions suppress low-response features while preserving high-frequency feature information within the image; and normalization reduces the feature dimension. Multiple groups are used for independent normalization to achieve independent adjustment of features at different locations; Normalization: By independently grouping and statistically analyzing the data, the values within each group are counted independently, ensuring that effective image feature information is contained within each bit width when compressing different bit widths. Dimensional restructuring of features The total number of features is divided into G; Perform trigonometric hyperbolic tangent on channel c After the operation, the mapping parameters are introduced. and Each group is independently linearly scaled to adjust the feature distribution, and then the features are recombined to restore the original shape for subsequent processing. Through normalization operations, the quality of each group in the proposed image features is guaranteed. The information within is independently statistically analyzed, resulting in highly responsive activation features; Activation function: ReLU is used as the activation function, which only retains the part of the normalized value that is greater than zero; The activation function suppresses redundant information generated during image feature extraction; the relevant redundant information is ultimately represented by regions of 0 in binary encoding. Module concatenation: By concatenating multiple encoding modules, image information of different granularities is mapped to feature channels located in different groups. By introducing different masks to the feature channels during the model training phase, different group combinations are used to achieve image reconstruction with different precision.
3. The image compression method with controllable compression ratio according to claim 1, characterized in that, The specific steps of introducing binary encoding to quantize and compress intermediate features to obtain a compressed file include: The feature encoding obtained through the compression process is of type float32. Storing a single encoded value requires 32 bits of storage space. Binary quantization is used to compress the results; Among them, Sigmoid is a type of activation function that maps values to floating-point numbers between 0 and 1, and Floor is a rounding down operation for values; by combining them, they form the Binary operation, which maps all values to 0 and 1. Intermediate encoding can convert the image compression information output by the encoder from floating-point to Boolean type.
4. The image compression method with controllable compression ratio according to claim 1, characterized in that, The decompression process, specifically involving decoding the binary code into the original image using a decoding model, includes: Introducing explicit constraints in end-to-end training 。 5. The image compression method with controllable compression ratio according to claim 4, characterized in that, The end-to-end training specifically includes: Use the encoder to process the original image. Convert to a binary quantization intermediate code of length n bits ; The Mask procedure is introduced to generate a random number K, where K ranges from 1 to n. After passing through a function... Keep the first K significant bits and set all other bits to zero; The decoding model is used to process the zeroed-out feature information and restore it to the target image. ; calculate and The L1 loss is used to generate a backward gradient to update all parameters in the encoding / decoding model; By using an end-to-end training method, the features of the image are mapped to binary codes in different regions, thereby enabling the low-range encoding to preserve the image overview information and the high-range encoding to preserve the image details.
6. The image compression method with controllable compression ratio according to claim 1, characterized in that, The compression process achieves a custom compression ratio or maintains a specified compression quality by controlling the bit width of the binary encoding, specifically including: After end-to-end training, different lengths Image reconstruction corresponding to different precision; Different regions of an image can be assigned different effective bits to maximize the image compression ratio; When performing image compression at a specified ratio or precision, first select appropriate initial parameters by referring to the curve; The number of bits (bpp) required to store one pixel corresponds to the binary bit width used, and the image structure similarity (ssim) corresponds to the accuracy of the target.
7. The image compression method with controllable compression ratio according to claim 6, characterized in that, The compression process, which allows different regions of the image to be assigned different significant bits to maximize the image compression ratio, includes: The user specifies the minimum desired compression ratio or the desired compression accuracy. The image is divided into multiple independent sub-images; each sub-image undergoes a separate encoding and decoding process. When the compression accuracy achieved within the subgraph is greater than the expected value; When the compression accuracy achieved within the subgraph is less than the expected value; Repeat the above operation until all subgraphs meet the condition that the encoding just meets the target precision; Output the corresponding compressed file; The method of dividing an image compression task into segments and performing iterative parameter search can meet the image compression requirements for a specified compression ratio or compression accuracy.