Image compression method, device, equipment, medium and program product

By dynamically determining the quantization parameters and encoding processing, the problems of insufficient image compression rate and poor quality under fixed quantization parameters are solved, and efficient image compression and decompression within the preset range are achieved.

CN119011856APending Publication Date: 2024-11-22XIAN UNISOC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410938854.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-12
Publication Date
2024-11-22

AI Technical Summary

Technical Problem

When image compression is compressed using fixed quantization parameters in the prior art, it is difficult to compress the image within a preset compression rate, and the image quality after decompression is poor.

Method used

By acquiring multiple channel images and image blocks of the image to be processed, the quantization parameters are dynamically determined, the quantization parameters are adjusted based on the preset parameters or the compression rate of the compressed image block, and the pixel residual value is quantized and encoding process is carried out to ensure that the compression rate is Improve image quality within a certain range.

Benefits of technology

It realizes improving image compression quality within a given compression rate range, reducing the loss of image after understanding compression, and improving image compression efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119011856A_ABST
    Figure CN119011856A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an image compression method and device, equipment, a medium and a program product. The method comprises the following steps: acquiring a to-be-processed image, determining a plurality of channel images corresponding to the to-be-processed image, and determining a plurality of image blocks included in each channel image; for any image block in any channel image, determining a quantization parameter corresponding to the image block; the quantization parameter is a preset quantization parameter or is determined based on the compression ratio of the compressed image block; acquiring a pixel residual value of each original pixel in the image block; according to a quantization parameter corresponding to the image block, performing quantization processing on the pixel residual value to obtain a quantization result of the original pixel; and encoding the quantization results of the plurality of original pixels in the image blocks to obtain compressed image blocks corresponding to the image blocks, and determining that the compressed image comprises the compressed image blocks corresponding to each image block. According to the method provided by the embodiment of the invention, the compression quality can be improved while the compression rate of the compressed image is limited within a certain range.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of image processing technology, and in particular, to an image compression method, apparatus, device, medium, and program product. Background Art

[0002] By compressing images, you can reduce the pressure on memory and bandwidth.

[0003] In the related art, it is usually necessary to calculate the residual value of each original pixel in the image to be processed, and quantize the residual value according to a fixed quantization parameter, and encode the quantization result. In the above manner, a compressed image is obtained.

[0004] However, in the related art, the method of using a fixed quantization parameter may result in the problem that the image cannot be compressed within a preset compression rate and the image quality after decompression is poor. Summary of the invention

[0005] The embodiments of the present application provide an image compression method, apparatus, device, medium, and program product, which can improve the compression quality while limiting the compression rate of the compressed image within a certain range.

[0006] In a first aspect, an embodiment of the present application provides an image compression method, comprising:

[0007] Acquire an image to be processed, determine a plurality of channel images corresponding to the image to be processed, and determine a plurality of image blocks included in each channel image;

[0008] For any image block in any channel image, determine a quantization parameter corresponding to the image block; the quantization parameter is a preset quantization parameter, or is determined based on a compression ratio of a compressed image block;

[0009] Obtain the pixel residual value of each original pixel in the image block;

[0010] According to the quantization parameter corresponding to the image block, the pixel residual value is quantized to obtain the quantization result of the original pixel;

[0011] The quantization results of the multiple original pixels in the image block are encoded to obtain a compressed image block corresponding to the image block, and it is determined that the compressed image includes the compressed image block corresponding to each image block.

[0012] In one implementation, determining a quantization parameter corresponding to an image block includes:

[0013] In the case where the image block is the first image block in the channel image, the preset quantization parameter is determined as the quantization parameter corresponding to the image block;

[0014] When the image block is not the first image block in the channel image, a quantization parameter corresponding to the image block is determined according to a compression rate of the compressed image block.

[0015] In one implementation, determining a quantization parameter corresponding to an image block according to a compression ratio of a compressed image block includes:

[0016] Obtaining compression rates of a plurality of compressed image blocks in a channel image; the plurality of compressed image blocks including a previous image block of the image block;

[0017] Determining an average compression rate according to the compression rates of the plurality of compressed image blocks;

[0018] Determine a first difference between a compression rate of a previous image block of the image block and a target compression rate, and determine a first quantization parameter according to the first difference;

[0019] A second difference between the average compression rate and the target compression rate is determined, and a quantization parameter corresponding to the image block is determined according to the second difference and the first quantization parameter.

[0020] In one implementation, the method further includes:

[0021] Get the preset compression rate;

[0022] The difference between the preset compression ratio and the preset margin is determined as the target compression ratio.

[0023] In one implementation, determining a plurality of image blocks included in each channel image includes:

[0024] For any channel image, the channel image is padded to obtain a padded channel image; wherein the padded channel image includes a plurality of original pixels and a plurality of padded pixels;

[0025] The channel image after edge padding is divided into blocks to determine a plurality of image blocks included in the channel image; the image block includes a plurality of original pixels, or at least one original pixel and at least one edge padding pixel.

[0026] In one implementation, obtaining a pixel residual value of each original pixel in an image block includes:

[0027] For any original pixel, obtain the pixel value of the original pixel;

[0028] Obtaining a pixel value of at least one adjacent pixel corresponding to the original pixel; the adjacent pixel is a padded pixel or an original pixel;

[0029] Determining a predicted pixel value of an original pixel based on a pixel value of at least one neighboring pixel;

[0030] A residual value of the original pixel is determined based on the pixel value of the original pixel and the predicted pixel value of the original pixel.

[0031] In one implementation, obtaining a pixel value of at least one adjacent pixel corresponding to an original pixel includes:

[0032] For any adjacent pixel, when it is determined that there is a quantization result of the adjacent pixel, determine a reconstructed pixel value of the adjacent pixel according to the quantization result of the adjacent pixel;

[0033] The reconstructed pixel value of the adjacent pixel is determined as the pixel value of the adjacent pixel.

[0034] In one implementation, determining the reconstructed pixel value of the adjacent pixel according to the quantization result of the adjacent pixel includes:

[0035] Determine first pixel residual values ​​of adjacent pixels according to a quantization parameter corresponding to the image block and quantization results of adjacent pixels;

[0036] The reconstructed pixel values ​​of the adjacent pixels are determined according to the first pixel residual values ​​of the adjacent pixels and the predicted pixel values ​​of the adjacent pixels.

[0037] In one implementation, determining a residual value of an original pixel according to a pixel value of the original pixel and a predicted pixel value of the original pixel includes:

[0038] Determining an initial residual value of the original pixel according to the pixel value of the original pixel and the predicted pixel value of the original pixel;

[0039] Determining a gradient difference parameter according to a predicted pixel value of an original pixel and a pixel value of at least one adjacent pixel;

[0040] Determine the deviation parameter according to the gradient difference parameter;

[0041] According to the deviation parameter, the initial residual value is adjusted to obtain the residual value of the original pixel.

[0042] In one implementation, encoding is performed on quantization results of a plurality of original pixels in an image block to obtain a compressed image block corresponding to the image block, including:

[0043] For any original pixel in the image block, the quantization result of the original pixel is processed into positive and negative numbers to obtain a processed quantization result;

[0044] When the ratio of the processed quantization result to 2 raised to the power of k is less than the preset length, the first encoding method is used to encode the processed quantization result to obtain compressed data of the original pixel; wherein k is an encoding coefficient;

[0045] When the ratio of the processed quantization result to 2 raised to the kth power is greater than or equal to the preset length, the second encoding method is used to encode the processed quantization result to obtain compressed data of the original pixel;

[0046] Determining a compressed image block includes compressed data for each original pixel in the image block.

[0047] In a second aspect, an embodiment of the present application provides an image compression device, comprising:

[0048] An acquisition module, used for acquiring an image to be processed, determining a plurality of channel images corresponding to the image to be processed, and determining a plurality of image blocks included in each channel image;

[0049] A processing module, for determining a quantization parameter corresponding to any image block in any channel image; the quantization parameter is a preset quantization parameter, or is determined based on a compression ratio of a compressed image block;

[0050] The processing module is further used to obtain a pixel residual value of each original pixel in the image block;

[0051] The processing module is further used to quantize the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel;

[0052] The processing module is further used to encode the quantization results of multiple original pixels in the image block to obtain a compressed image block corresponding to the image block, and determine that the compressed image includes the compressed image block corresponding to each image block.

[0053] In one implementation, the processing module is specifically configured to:

[0054] In the case where the image block is the first image block in the channel image, the preset quantization parameter is determined as the quantization parameter corresponding to the image block;

[0055] When the image block is not the first image block in the channel image, a quantization parameter corresponding to the image block is determined according to a compression rate of the compressed image block.

[0056] In one implementation, the processing module is specifically configured to:

[0057] Obtaining compression rates of a plurality of compressed image blocks in a channel image; the plurality of compressed image blocks including a previous image block of the image block;

[0058] Determining an average compression rate according to the compression rates of the plurality of compressed image blocks;

[0059] Determine a first difference between a compression rate of a previous image block of the image block and a target compression rate, and determine a first quantization parameter according to the first difference;

[0060] A second difference between the average compression rate and the target compression rate is determined, and a quantization parameter corresponding to the image block is determined according to the second difference and the first quantization parameter.

[0061] In one implementation, the processing module is further configured to:

[0062] Get the preset compression rate;

[0063] The difference between the preset compression ratio and the preset margin is determined as the target compression ratio.

[0064] In one implementation, the acquisition module is specifically used to:

[0065] For any channel image, the channel image is padded to obtain a padded channel image; wherein the padded channel image includes a plurality of original pixels and a plurality of padded pixels;

[0066] The channel image after edge padding is divided into blocks to determine a plurality of image blocks included in the channel image; the image block includes a plurality of original pixels, or at least one original pixel and at least one edge padding pixel.

[0067] In one implementation, the processing module is specifically configured to:

[0068] For any original pixel, obtain the pixel value of the original pixel;

[0069] Obtaining a pixel value of at least one adjacent pixel corresponding to the original pixel; the adjacent pixel is a padded pixel or an original pixel;

[0070] Determining a predicted pixel value of an original pixel based on a pixel value of at least one neighboring pixel;

[0071] A residual value of the original pixel is determined based on the pixel value of the original pixel and the predicted pixel value of the original pixel.

[0072] In one implementation, the processing module is specifically configured to:

[0073] For any adjacent pixel, when it is determined that there is a quantization result of the adjacent pixel, determine a reconstructed pixel value of the adjacent pixel according to the quantization result of the adjacent pixel;

[0074] The reconstructed pixel value of the adjacent pixel is determined as the pixel value of the adjacent pixel.

[0075] In one implementation, the processing module is specifically configured to:

[0076] Determine first pixel residual values ​​of adjacent pixels according to a quantization parameter corresponding to the image block and quantization results of adjacent pixels;

[0077] The reconstructed pixel values ​​of the adjacent pixels are determined according to the first pixel residual values ​​of the adjacent pixels and the predicted pixel values ​​of the adjacent pixels.

[0078] In one implementation, the processing module is specifically configured to:

[0079] Determining an initial residual value of the original pixel according to the pixel value of the original pixel and the predicted pixel value of the original pixel;

[0080] Determining a gradient difference parameter according to a predicted pixel value of an original pixel and a pixel value of at least one adjacent pixel;

[0081] Determine the deviation parameter according to the gradient difference parameter;

[0082] According to the deviation parameter, the initial residual value is adjusted to obtain the residual value of the original pixel.

[0083] In one implementation, the processing module is specifically configured to:

[0084] For any original pixel in the image block, the quantization result of the original pixel is processed into positive and negative numbers to obtain a processed quantization result;

[0085] When the ratio of the processed quantization result to 2 raised to the power of k is less than the preset length, the first encoding method is used to encode the processed quantization result to obtain compressed data of the original pixel; wherein k is an encoding coefficient;

[0086] When the ratio of the processed quantization result to 2 raised to the kth power is greater than or equal to the preset length, the second encoding method is used to encode the processed quantization result to obtain compressed data of the original pixel;

[0087] Determining a compressed image block includes compressed data for each original pixel in the image block.

[0088] In a third aspect, the present application provides a chip having a computer program stored thereon, and when the computer program is executed by the chip, the method as described in any one of the first aspects is implemented.

[0089] In a fourth aspect, the present application provides a chip module having a computer program stored thereon. When the computer program is executed by the chip module, the method of any one of the first aspects is implemented.

[0090] In a fifth aspect, an embodiment of the present application provides an image compression device, including: a memory and a processor;

[0091] Memory stores computer-executable instructions;

[0092] The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to the first aspect.

[0093] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-readable storage medium is stored computer execution instructions, which are used to implement the method of the first aspect when the computer execution instructions are executed by a processor.

[0094] In a seventh aspect, an embodiment of the present application provides a computer program product, comprising computer execution instructions, which, when executed by a processor, enable the method of the first aspect to be executed.

[0095] The embodiment of the present application provides an image compression method, apparatus, device, medium, and program product. In the method, the image compression device can obtain an image to be processed. The image compression device can determine multiple channel images corresponding to the image to be processed according to the image to be processed, and determine multiple image blocks included in each channel image. For any image block in any channel image, the image compression device can determine the quantization parameter corresponding to the image block, and obtain the pixel residual value of each original pixel in the image block. The image compression device can quantize the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel. The image compression device can encode the quantization results of multiple original pixels in the image block to obtain a compressed image block corresponding to the image block, and determine that the compressed image includes a compressed image block corresponding to each image block. In the embodiment of the present application, the quantization parameter corresponding to the image block is a preset quantization parameter, or is determined based on the compression rate of the compressed image block. In the above manner, the compression quality can be improved while limiting the compression rate of the compressed image within a certain range (so that the image loss of the decompressed image is smaller than that of the image to be processed). BRIEF DESCRIPTION OF THE DRAWINGS

[0096] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0097] Figure 1 A schematic diagram of an application scenario provided in an embodiment of the present application;

[0098] Figure 2a A schematic diagram of a flow chart of a first embodiment of an image compression method provided in an embodiment of the present application;

[0099] Figure 2b A schematic diagram of the edge filling process provided in an embodiment of the present application;

[0100] Figure 2cA schematic diagram of dividing a channel image after edge padding provided in an embodiment of the present application;

[0101] Figure 2d A schematic diagram of an original pixel and adjacent pixels provided in an embodiment of the present application;

[0102] Figure 3 A schematic diagram of a flow chart of a second embodiment of an image compression method provided in an embodiment of the present application;

[0103] Figure 4a A schematic diagram of a flow chart of a third embodiment of an image compression method provided in an embodiment of the present application;

[0104] Figure 4b A schematic diagram of a process of compressing an image provided in an embodiment of the present application;

[0105] Figure 5 A flowchart of a fourth embodiment of an image compression method provided in an embodiment of the present application;

[0106] Figure 6 A schematic diagram of the structure of an image compression device provided by an exemplary embodiment of the present application;

[0107] Figure 7 A schematic diagram of the structure of an image compression device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0108] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0109] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0110] In this application, "at least one" means one or more, and "a plurality of" means two or more. In addition, in this application, "equal to" can be used in conjunction with "greater than" or "less than". When "equal to" is used in conjunction with "greater than", the technical solution of "greater than" is adopted; when "equal to" is used in conjunction with "less than", the technical solution of "less than" is adopted.

[0111] Figure 1 For a schematic diagram of an application scenario provided in an embodiment of the present application, see Figure 1 , the application scenario includes an image compression device 10. The image compression device 10 may be a terminal device or a server, which is not limited in the embodiment of the present application.

[0112] The image compression device 10 can obtain an image to be processed when compressing an image. The image to be processed includes original pixels 1, ..., original pixels N. Wherein N is a positive integer greater than 1.

[0113] The image compression device 10 can calculate the residual value of each original pixel in the image to be processed, and quantize the residual value according to a fixed quantization parameter, and encode the quantization result. In the above manner, a compressed image is obtained. The image compression device 10 can relieve the pressure of memory and bandwidth by compressing the image to be processed.

[0114] However, in the related art, the method of using fixed quantization parameters has the problem of low compression efficiency.

[0115] Based on the above technical problems, an embodiment of the present application provides an image compression method, and an image compression device can obtain an image to be processed. The image compression device can determine multiple channel images corresponding to the image to be processed according to the image to be processed, and determine multiple image blocks included in each channel image. For any image block in any channel image, the image compression device can determine the quantization parameter corresponding to the image block, and obtain the pixel residual value of each original pixel in the image block. The image compression device can quantize the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel. The image compression device can encode the quantization results of multiple original pixels in the image block to obtain a compressed image block corresponding to the image block, and determine that the compressed image includes a compressed image block corresponding to each image block. In the embodiment of the present application, the quantization parameter corresponding to the image block is a preset quantization parameter, or is determined based on the compression rate of the compressed image block. In the above manner, the compression quality can be improved while limiting the compression rate of the compressed image within a certain range.

[0116] The technical solutions shown in the present application are described in detail below through specific embodiments. It should be noted that the following embodiments can exist independently or in combination with each other, and the same or similar contents will not be described repeatedly in different embodiments.

[0117] Figure 2a This is a flow chart of an embodiment 1 of an image compression method provided in the present application. Figure 2a , the method may include:

[0118] S201: Acquire an image to be processed, determine a plurality of channel images corresponding to the image to be processed, and determine a plurality of image blocks included in each channel image.

[0119] In this embodiment, the image compression device can obtain an image to be processed, wherein the image to be processed can be an image file in any format, and each pixel of the image to be processed can have any bit width.

[0120] For example, the image to be processed may be an image file in RAW image format; for another example, the image to be processed may be an image file in RGB color mode; for another example, the image to be processed may be an image file in YUV format. It should be noted that Y represents luminance, U represents chrominance, specifically blue chrominance, and V represents chrominance, specifically red chrominance.

[0121] The image compression device can determine a plurality of channel images corresponding to the image to be processed according to the image to be processed.

[0122] Exemplarily, when the image to be processed is an image file in RAW format, the image compression device can determine the 4 channel images corresponding to the image to be processed based on the image to be processed. When the image to be processed is an image file in RGB format, the image compression device can determine the 3 channel images corresponding to the image to be processed based on the image to be processed. When the image to be processed is an image file in YUV format, the image compression device can determine the 3 channel images corresponding to the image to be processed based on the image to be processed.

[0123] After determining a plurality of channel images corresponding to the image to be processed, the image compression device may determine a plurality of image blocks included in each channel image.

[0124] Next, the determination of the multiple image blocks included in each channel image by the image compression device is described.

[0125] In one implementation:

[0126] For each channel image, the image compression device can perform edge padding processing on the channel image to obtain a padded channel image. The padded channel image includes a plurality of original pixels and a plurality of padded pixels. In one implementation, the image compression device can perform upper row padded and left column padded on the channel image to obtain a padded channel image.

[0127] For example, Figure 2b Schematic diagram of the edge filling process provided in the embodiment of the present application. Figure 2b As shown, the channel image includes original pixel 1 to original pixel 15. The image compression device can perform edge padding processing on the channel image to obtain the edge-padded channel image. The edge-padded channel image includes original pixel 1 to original pixel 15, and the edge-padded channel image also includes edge-padded pixel 1 to edge-padded pixel 9.

[0128] The image compression device can perform block processing on the channel image after edge padding to determine multiple image blocks included in the channel image. It should be noted that the image block includes multiple original pixels, or the image block includes at least one original pixel and at least one edge padding pixel.

[0129] For example, Figure 2c The following is a schematic diagram of dividing the channel image after edge filling provided in the embodiment of the present application. Figure 2c As shown, the channel image after edge padding includes original pixels 1 to original pixels 15, and edge padding pixels 1 to edge padding pixels 9. The image compression device can perform block processing on the channel image after edge padding to determine 6 image blocks (image block 1, image block 2, image block 3, image block 4, image block 5, and image block 6). Among them, image block 1 includes edge padding pixels 1, edge padding pixels 2, edge padding pixels 7, and original pixels 1; image block 2 includes edge padding pixels 3, edge padding pixels 4, original pixels 2, and original pixels 3; image block 3 includes edge padding pixels 5, edge padding pixels 6, original pixels 4, and original pixels 5; image block 4 includes edge padding pixels 8, edge padding pixels 9, original pixels 6, and original pixels 11; image block 5 includes original pixels 7, original pixels 8, original pixels 12, and original pixels 13; image block 6 includes original pixels 9, original pixels 10, original pixels 14, and original pixels 15.

[0130] S202: for any image block in any channel image, determine a quantization parameter corresponding to the image block; the quantization parameter is a preset quantization parameter, or is determined based on a compression ratio of a compressed image block.

[0131] In this embodiment, for any image block in any channel image, the image compression device can determine the quantization parameter corresponding to the image block.

[0132] The quantization parameter is a preset quantization parameter, or is determined based on the compression rate of a compressed image block.

[0133] In one implementation:

[0134] In the case where the image block is the first image block in a channel image (the channel image to which the image block belongs), the image compression device may determine the preset quantization parameter as the quantization parameter corresponding to the image block. In the case where the image block is not the first image block in a channel image (the channel image to which the image block belongs), the image compression device may determine the quantization parameter corresponding to the image block based on the compression rate of the compressed image block (the compressed image block among the multiple image blocks included in the channel image to which the image block belongs).

[0135] S203: Obtain a pixel residual value of each original pixel in the image block.

[0136] In this embodiment, the image compression device may obtain a pixel residual value of each original pixel in the image block.

[0137] In one implementation:

[0138] For any original pixel, the image compression device can obtain the pixel value of the original pixel. In one implementation, the image compression device can select the original pixel by sliding a sliding window.

[0139] The image compression device may determine at least one adjacent pixel corresponding to the original pixel, wherein the adjacent pixel is a fill-in pixel or an original pixel.

[0140] The image compression device may obtain a pixel value of at least one adjacent pixel.

[0141] The image compression device may determine a predicted pixel value of an original pixel based on a pixel value of at least one adjacent pixel.

[0142] The image compression device may determine a residual value of the original pixel based on the pixel value of the original pixel and the predicted pixel value of the original pixel.

[0143] Figure 2d A schematic diagram of an original pixel and adjacent pixels provided in an embodiment of the present application. Figure 2d As shown, for the original pixel x, the image compression device can determine the adjacent pixels of the original pixel x: adjacent pixel A, adjacent pixel B, adjacent pixel C, adjacent pixel D, adjacent pixel E, adjacent pixel F, adjacent pixel G, adjacent pixel H, adjacent pixel I, adjacent pixel J, and adjacent pixel K.

[0144] The image compression device may determine the predicted pixel value of the original pixel x based on the pixel value of each adjacent pixel. The image compression device may determine the residual value of the original pixel x according to the pixel value of the original pixel x and the predicted pixel value of the original pixel x.

[0145] S204: quantizing the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel.

[0146] In this embodiment, the image compression device may perform quantization processing on the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel.

[0147] In one implementation, the image compression device may determine the quotient of the pixel residual value and the quantization parameter as the quantization result of the original pixel.

[0148] By quantizing the pixel residual value in the above manner, the amount of data can be effectively reduced, thereby reducing the compression rate.

[0149] S205: Encoding the quantization results of the multiple original pixels in the image block to obtain a compressed image block corresponding to the image block, and determining that the compressed image includes the compressed image block corresponding to each image block.

[0150] In this embodiment, after obtaining the quantization results of multiple original pixels in the image, the image compression device can encode the quantization results of multiple original pixels in the image block to obtain a compressed image block corresponding to the image block, and determine that the compressed image includes the compressed image block corresponding to each image block.

[0151] In one implementation, the image compression device may perform positive and negative number processing on the quantization result of any original pixel in the image block to obtain a processed quantization result.

[0152] The image compression device may use a first encoding method to encode the processed quantization result when the ratio of the processed quantization result to 2 to the kth power is less than a preset length to obtain compressed data of the original pixel. The image compression device may use a second encoding method to encode the processed quantization result when the ratio of the processed quantization result to 2 to the kth power is greater than or equal to a preset length to obtain compressed data of the original pixel. The image compression device may determine that the compressed image block includes compressed data of each original pixel in the image block.

[0153] Beneficial effects of this embodiment: In this embodiment, the image compression device can obtain an image to be processed. The image compression device can determine multiple channel images corresponding to the image to be processed based on the image to be processed, and determine multiple image blocks included in each channel image. For any image block in any channel image, the image compression device can determine the quantization parameter corresponding to the image block, and obtain the pixel residual value of each original pixel in the image block. The image compression device can quantize the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel. The image compression device can encode the quantization results of multiple original pixels in the image block to obtain the compressed image block corresponding to the image block, and determine that the compressed image includes the compressed image block corresponding to each image block. In the above manner, the compression quality can be improved while limiting the compression rate of the compressed image within a certain range.

[0154] Figure 3 A flowchart of a second embodiment of an image compression method provided in an embodiment of the present application.

[0155] See also Figure 3 , the method may include:

[0156] S301: Acquire an image to be processed, determine a plurality of channel images corresponding to the image to be processed, and determine a plurality of image blocks included in each channel image.

[0157] In this embodiment, the image compression device may obtain an image to be processed, and obtain a plurality of channel images corresponding to the image to be processed, and a plurality of image blocks included in each channel image.

[0158] The specific implementation process is the same as S201 and will not be repeated here.

[0159] S302: For any image block in any channel image, when the image block is the first image block in the channel image, determine a preset quantization parameter as a quantization parameter corresponding to the image block.

[0160] In this embodiment, the image compression device may determine the preset quantization parameter as the quantization parameter corresponding to the image block when determining that the image block is the first image block in the channel image.

[0161] It should be noted that the first image block in the channel image means that among all the image blocks included in the channel image, except for the image block being processed, other image blocks are not compressed. At this time, the image block can be regarded as the first image block in the channel image.

[0162] It should be noted that the image compression device may execute S302 after executing S301. The image compression device may execute S304 after executing S302.

[0163] S303: For any image block in any channel image, when the image block is not the first image block in the channel image, determine a quantization parameter corresponding to the image block according to a compression rate of the compressed image block.

[0164] In this embodiment, when the image compression device determines that the image block is not the first image block in the channel image, the image compression device may determine the quantization parameter corresponding to the image block according to the compression rate of the compressed image block.

[0165] Next, a process in which the image compression device determines a quantization parameter corresponding to an image block according to a compression ratio of the compressed image block is described.

[0166] In one implementation, the image compression device may obtain compression rates of a plurality of compressed image blocks in the channel image, wherein the plurality of compressed image blocks include a previous image block of the image block.

[0167] The image compression device may determine an average compression rate according to the compression rates of a plurality of compressed image blocks.

[0168] The image compression device can determine a first difference between the compression rate of the previous image block of the image block and the target compression rate, and determine a first quantization parameter based on the first difference. In one implementation, the image compression device can determine the first quantization parameter based on the first difference by querying the expanded "code precedence data table".

[0169] It should be noted that, in one implementation, after obtaining the preset compression rate, the image compression device can determine the difference between the preset compression rate and the preset margin as the target compression rate. In the above manner, a certain margin can be left between the target compression rate and the preset compression rate, so as to leave the margin for some image blocks that are difficult to compress (such as image blocks with large pixel residual values), thereby avoiding the problem of obvious blockiness of the compressed image after decompression, and improving the image quality of the compressed image after decompression.

[0170] The image compression device may determine a second difference between the average compression rate and the target compression rate. The image compression device may determine the quantization parameter corresponding to the image block based on the second difference and the first quantization parameter. In one implementation, the image compression device may determine the quantization parameter corresponding to the image block based on the second difference and the first quantization parameter by querying the expanded "code prior data table".

[0171] Through the above-mentioned two-step adjustment method, when the compression rate of the compressed image block is less than the target compression rate, the quantization parameter of the image block can be reduced, and when the compression rate of the compressed image block is greater than the target compression rate, the quantization parameter of the image block can be increased, so that the compression rate of the image block continues to approach the target compression rate, so that the compression rate of the image to be processed can be within the preset compression rate.

[0172] It should be noted that the image compression device may execute S303 after executing S301. The image compression device may execute S304 after executing S303.

[0173] S304: Obtain a pixel residual value of each original pixel in the image block.

[0174] In this embodiment, the image compression device may obtain a pixel residual value of each original pixel in the image block.

[0175] The specific implementation process is the same as S203 and will not be repeated here.

[0176] S305: quantizing the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel.

[0177] In this embodiment, the image compression device may perform quantization processing on the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel.

[0178] The specific implementation process is the same as S204 and will not be repeated here.

[0179] S306: Encoding the quantization results of the multiple original pixels in the image block to obtain a compressed image block corresponding to the image block, and determining that the compressed image includes the compressed image block corresponding to each image block.

[0180] In this embodiment, the image compression device may perform encoding processing on quantization results of multiple original pixels in the image block to obtain compressed image blocks corresponding to the image block, and determine that the compressed image includes the compressed image blocks corresponding to each image block.

[0181] The specific implementation process is the same as S205 and will not be repeated here.

[0182] Beneficial effects of this embodiment: In this embodiment, when the image block is the first image block in the channel image, the image compression device can directly determine the preset quantization parameter as the quantization parameter corresponding to the image block. When the image block is not the first image block in the channel image, the image compression device can determine the quantization parameter corresponding to the image block based on the compression rate of the compressed image block. In the above manner, the compression rate determined based on the size of the compressed image and the size of the image to be processed can be controlled within a certain range (within the preset compression rate), thereby improving the compression quality.

[0183] Next, S203 in the first embodiment is described in detail through the third method embodiment.

[0184] Figure 4a This is a flow chart of a third embodiment of an image compression method provided in the present application. Figure 4a , the method may include:

[0185] S401: For any original pixel, obtain the pixel value of the original pixel.

[0186] In this embodiment, for any original pixel, the image compression device can obtain the pixel value of the original pixel.

[0187] S402: Obtain a pixel value of at least one adjacent pixel corresponding to the original pixel.

[0188] In this embodiment, the image compression device may obtain a pixel value of at least one adjacent pixel corresponding to the original image, wherein the adjacent pixel is a padded pixel or an original pixel.

[0189] In one implementation, for any adjacent pixel, the image compression device may determine whether there is a quantization result of the adjacent pixel.

[0190] The image compression device can directly obtain the pixel value of the adjacent pixel when determining that there is no quantization result of the adjacent pixel. It should be noted that when the adjacent pixel is a padded pixel, there is no quantization result of the adjacent pixel. When the adjacent pixel is an original pixel and the image compression device does not calculate the quantization result of the adjacent pixel, there is no quantization result of the adjacent pixel.

[0191] The image compression device may determine the reconstructed pixel value of the adjacent pixel according to the quantization result of the adjacent pixel when it is determined that there is a quantization result of the adjacent pixel. In one implementation, the image compression device may determine the first pixel residual value of the adjacent pixel according to the quantization parameter corresponding to the image block (the image block to which the adjacent pixel belongs) and the quantization result of the adjacent pixel. The image compression device may determine the reconstructed pixel value of the adjacent pixel according to the first pixel residual value of the adjacent pixel and the predicted pixel value of the adjacent pixel.

[0192] The image compression device may determine the reconstructed pixel value of the adjacent pixel as the pixel value of the adjacent pixel.

[0193] It should be noted that the reason why the image compression device needs to determine the reconstructed pixel value of the adjacent pixel is that when there is a quantization result of the adjacent pixel, there is no pixel value of the adjacent pixel. The image compression device needs to obtain the reconstructed value of the adjacent pixel by reconstruction.

[0194] S403: Determine a predicted pixel value of the original pixel according to the pixel value of at least one adjacent pixel.

[0195] In this embodiment, the image compression device may determine a predicted pixel value of an original pixel according to a pixel value of at least one adjacent pixel.

[0196] In one implementation, the image compression device determines an average pixel value based on the pixel value of at least one adjacent pixel, and determines the average pixel value as the predicted pixel value of the original pixel.

[0197] In one implementation, the image compression device may determine the relative position of the adjacent pixel and the original pixel, and determine the weight value of the adjacent pixel based on the relative position. The image compression device may determine the predicted pixel value of the original pixel based on the pixel value of at least one adjacent pixel and the weight value of each adjacent pixel.

[0198] S404: Determine a residual value of the original pixel according to the pixel value of the original pixel and the predicted pixel value of the original pixel.

[0199] In this embodiment, the image compression device may determine the residual value of the original pixel according to the pixel value of the original pixel and the predicted pixel value of the original pixel.

[0200] In one implementation:

[0201] The image compression device may determine an initial residual value of the original pixel based on the pixel value of the original pixel and the predicted pixel value of the original pixel.

[0202] The image compression device may determine the gradient difference parameter based on the predicted pixel value of the original pixel and the pixel value of at least one adjacent pixel. In one implementation, the image compression device may determine the predicted pixel value of the original pixel and the pixel value of each adjacent pixel to determine the pixel difference. The image compression device may determine the gradient difference parameter based on at least one pixel difference.

[0203] The image compression device may determine the deviation parameter based on the gradient difference parameter. In one implementation, the image compression device may determine the deviation parameter based on the gradient difference parameter and the historical deviation parameter. In addition, the image compression device may add 1 to the accumulated number. The image compression device may clear the historical deviation parameter when the accumulated number reaches a preset number; the image compression device may use the obtained deviation parameter as a new historical deviation parameter for determining the deviation parameter next time when it is determined that the accumulated number does not reach the preset number.

[0204] After obtaining the deviation parameter, the image compression device can adjust the initial residual value according to the deviation parameter to obtain the residual value of the original pixel.

[0205] Figure 4b The following is a schematic diagram of a process of compressing an image provided by an embodiment of the present application. Figure 4b As shown,

[0206] The image compression device can process the image to be processed by channels to obtain multiple channel images. For any channel image, the image compression device can perform edge filling processing and block processing on the channel image.

[0207] The image compression device may determine a quantization parameter corresponding to the image block.

[0208] The image compression device may obtain an initial residual value of each original pixel in the image block. The image compression device may determine a gradient difference parameter based on a predicted pixel value of the original pixel and a pixel value of at least one adjacent pixel. The image compression device may determine a deviation parameter based on the gradient difference parameter. The image compression device may adjust the initial residual value based on the deviation parameter to obtain a residual value of the original pixel.

[0209] The image compression device can quantize the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel. The image compression device can encode the quantization results of multiple original pixels in the image block to obtain a compressed image block corresponding to the image block.

[0210] The image compression device may determine the quantization parameter of the next image block according to the compression rate of the compressed image block.

[0211] The image compression device can obtain a compressed image after obtaining the compressed blocks of all image blocks.

[0212] The image compression device can perform transmission processing on the compressed image.

[0213] Beneficial effects of this embodiment: In this embodiment, for any original pixel, the image compression device can obtain the pixel value of the original pixel. The image compression device can obtain the pixel value of at least one adjacent pixel corresponding to the original pixel, and determine the predicted pixel value of the original pixel based on the pixel value of at least one adjacent pixel. The image compression device can determine the residual value of the original pixel based on the pixel value of the original pixel and the predicted pixel value of the original pixel. In the above manner, the residual value of the original pixel can be accurately determined, thereby improving the accuracy of determining the quantization result of the original pixel.

[0214] The following method embodiment 4 describes in detail the process of "encoding the quantization results of multiple original pixels in the image block to obtain a compressed image block corresponding to the image block" in S205 of embodiment 1.

[0215] Figure 5 A flowchart of a fourth embodiment of an image compression method provided in an embodiment of the present application.

[0216] See also Figure 5 , the method may include:

[0217] S501: For any original pixel in the image block, perform positive and negative number processing on the quantization result of the original pixel to obtain a processed quantization result.

[0218] In this embodiment, for any original pixel in the image block, the quantization result of the original pixel is processed into positive and negative numbers to obtain a processed quantization result.

[0219] In one implementation, when the quantization result is a negative number, the image compression device may perform positive and negative number processing on the quantization result based on the following formula to obtain a processed quantization result:

[0220] n=m*(-2)

[0221] In one implementation, when the quantization result is a positive number, the image compression device may perform positive and negative number processing on the quantization result based on the following formula to obtain a processed quantization result:

[0222] n=m*2+1

[0223] Among them, n represents the quantization result after processing, and m represents the quantization result.

[0224] S502: When the ratio of the processed quantization result to 2 raised to the kth power is less than a preset length, a first encoding method is used to encode the processed quantization result to obtain compressed data of the original pixel.

[0225] In this embodiment, the image compression device may use the first encoding method (ordinary encoding method) to encode the processed quantization result when determining that the processed quantization result satisfies the following formula to obtain compressed data of the original pixel.

[0226]

[0227] Wherein, n is the quantization result after processing, k is the coding coefficient, and B is the preset length. It should be noted that the difference between the first preset length (such as 11) and the preset length is 1, and the first preset length (such as 10) is the maximum number of bits for a pixel.

[0228] Next, the process of encoding the processed quantization result by the image compression device using the first encoding method (normal encoding method) is described.

[0229] The image compression device calculates the quotient and remainder based on the processed quantization result and the coding coefficient. For example, when the processed quantization result is 3 and the coding coefficient is 4, the image compression device can determine the difference between 3 and 2. 4 The quotient is 0 and the remainder is 3.

[0230] The image compression device encodes the quotient to obtain an encoded quotient. In one implementation, the image compression device may determine the number of 0s based on the size of the quotient, and the image compression device may determine the encoded quotient based on the number of 0s. For example, when the quotient is 0, the number of 0s is 0, and the encoded quotient is 0.

[0231] The image compression device encodes the remainder to obtain an encoded remainder. In one implementation, the image compression device may determine the binary number corresponding to the remainder as the encoded remainder. The number of bits of the binary number corresponding to the remainder is the same as the coding coefficient. For example, when the remainder is 3, the encoded remainder is 0011.

[0232] The image compression device determines the compressed data of the original pixel according to the encoded quotient and the encoded remainder. For example, based on the encoded quotient being 0 and the encoded remainder being 0011, the image compression device can determine that the compressed data of the original image is 00011.

[0233] S503: When the ratio of the processed quantization result to 2 raised to the kth power is greater than or equal to the preset length, a second encoding method is used to encode the processed quantization result to obtain compressed data of the original pixel.

[0234] In this embodiment, the image compression device may use the second encoding method (limited length encoding method) to encode the processed quantization result when determining that the processed quantization result satisfies the following formula to obtain compressed data of the original pixel.

[0235]

[0236] Among them, n is the quantization result after processing, k is the coding coefficient, and B is the preset length.

[0237] Next, the process of encoding the processed quantization result by the image compression device using the second encoding method to obtain compressed data of the original pixel is described.

[0238] The image compression device can determine whether the number of bits of the binary number corresponding to the processed quantization result is less than the preset length. If so, 0 is added before the binary number until the number of bits of the binary number corresponding to the processed quantization result reaches the first preset length (the first preset length is the preset length minus 1). The image compression device can add k+2 consecutive 0s before the binary number corresponding to the processed quantization result. In the above manner, the compressed data of the original pixel can be obtained.

[0239] The image compression device can determine that the compressed data is 00000011111111111 based on the quantization result of the original pixel after processing is 1023. It should be noted that the number of bits of the compressed data is 4+2+10. Among them, k is 4, and the first preset length is 10.

[0240] It should also be noted that, based on the above encoding logic, when decoding the compressed data, it can be determined whether the first code stream is 1. If so, the first decoding method (ordinary decoding method) is directly used to decode the compressed data; if not, the number of consecutive 0s is read. It should be noted that the first decoding method (ordinary decoding method) refers to determining the quotient and remainder based on the compressed data. Based on the quotient, remainder, and encoding coefficient, the processed quantization result is determined. Based on the processed quantization result, the quantization result is determined.

[0241] If the number of consecutive 0s is greater than k+1, it is determined that the second encoding method (limited length encoding method) is used for encoding, and the second decoding method can be used for decoding. Specifically, the first bit that is not 0 can be read continuously, 10 bits are taken, and converted to decimal to obtain the decoded data of the original pixel.

[0242] If the number of consecutive 0s is less than or equal to k+1, the first decoding method (normal decoding method) is used to decode the compressed data. For example, for 00011, based on the number of 0s being 3, which is less than 5 (5=4+1), the quantization result of the original pixel after processing is 3, and the quantization result of the original pixel is 2.

[0243] By means of the above method, the compressed data can be decoded without storing the header information. It should be noted that the header information is used to distinguish whether the compressed data is encoded by the first encoding method or the second encoding method.

[0244] S504: Determine that the compressed image block includes compressed data of each original pixel in the image block.

[0245] In this embodiment, the image compression device may determine that the compressed image block includes the compressed data of each original pixel in the image block after determining the compressed data of each original pixel in the image block.

[0246] Beneficial effects of this embodiment: for any original pixel in the image block, the image compression device can perform positive and negative number processing on the quantization result of the original pixel to obtain the processed quantization result. When the ratio of the processed quantization result to 2 to the kth power is less than the preset length, the image compression device adopts the first encoding method to encode the processed quantization result to obtain the compressed data of the original pixel. When the ratio of the processed quantization result to 2 to the kth power is greater than or equal to the preset length, the image compression device can adopt the second encoding method to encode the processed quantization result to obtain the compressed data of the original pixel. Compared with the related art, different identifiers are required to distinguish between compressed data with limited bit numbers and ordinary compressed data. In the embodiment of the present application, no identifier is required, and the compressed data of the original pixel can be decoded when the compressed data of the original pixel needs to be decoded (the compressed image is decompressed), thereby improving the decoding efficiency.

[0247] Figure 6 This is a schematic diagram of the structure of an image compression device provided by an exemplary embodiment of the present application. Figure 6 The image compression device 60 includes an acquisition module 61 and a processing module 62, wherein:

[0248] An acquisition module 61 is used to acquire an image to be processed, determine a plurality of channel images corresponding to the image to be processed, and determine a plurality of image blocks included in each channel image;

[0249] The processing module 62 is used to determine the quantization parameter corresponding to any image block in any channel image; the quantization parameter is a preset quantization parameter, or is determined based on the compression rate of the compressed image block;

[0250] The processing module 62 is further used to obtain a pixel residual value of each original pixel in the image block;

[0251] The processing module 62 is further used to perform quantization processing on the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel;

[0252] The processing module 62 is further used to perform encoding processing on the quantization results of multiple original pixels in the image block to obtain a compressed image block corresponding to the image block, and determine that the compressed image includes the compressed image block corresponding to each image block.

[0253] The image compression device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0254] In one implementation, the processing module 62 is specifically configured to:

[0255] In the case where the image block is the first image block in the channel image, the preset quantization parameter is determined as the quantization parameter corresponding to the image block;

[0256] When the image block is not the first image block in the channel image, a quantization parameter corresponding to the image block is determined according to a compression rate of the compressed image block.

[0257] The image compression device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0258] In one implementation, the processing module 62 is specifically configured to:

[0259] Obtaining compression rates of a plurality of compressed image blocks in a channel image; the plurality of compressed image blocks including a previous image block of the image block;

[0260] Determining an average compression rate according to the compression rates of the plurality of compressed image blocks;

[0261] Determine a first difference between a compression rate of a previous image block of the image block and a target compression rate, and determine a first quantization parameter according to the first difference;

[0262] A second difference between the average compression rate and the target compression rate is determined, and a quantization parameter corresponding to the image block is determined according to the second difference and the first quantization parameter.

[0263] The image compression device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0264] In one implementation, the processing module 62 is further configured to:

[0265] Get the preset compression rate;

[0266] The difference between the preset compression ratio and the preset margin is determined as the target compression ratio.

[0267] The image compression device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0268] In one implementation, the acquisition module 61 is specifically configured to:

[0269] For any channel image, the channel image is padded to obtain a padded channel image; wherein the padded channel image includes a plurality of original pixels and a plurality of padded pixels;

[0270] The channel image after edge padding is divided into blocks to determine a plurality of image blocks included in the channel image; the image block includes a plurality of original pixels, or at least one original pixel and at least one edge padding pixel.

[0271] The image compression device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0272] In one implementation, the processing module 62 is specifically configured to:

[0273] For any original pixel, obtain the pixel value of the original pixel;

[0274] Obtaining a pixel value of at least one adjacent pixel corresponding to the original pixel; the adjacent pixel is a padded pixel or an original pixel;

[0275] Determining a predicted pixel value of an original pixel based on a pixel value of at least one neighboring pixel;

[0276] A residual value of the original pixel is determined based on the pixel value of the original pixel and the predicted pixel value of the original pixel.

[0277] The image compression device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0278] In one implementation, the processing module 62 is specifically configured to:

[0279] For any adjacent pixel, when it is determined that there is a quantization result of the adjacent pixel, determine a reconstructed pixel value of the adjacent pixel according to the quantization result of the adjacent pixel;

[0280] The reconstructed pixel value of the adjacent pixel is determined as the pixel value of the adjacent pixel.

[0281] The image compression device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0282] In one implementation, the processing module 62 is specifically configured to:

[0283] Determine first pixel residual values ​​of adjacent pixels according to a quantization parameter corresponding to the image block and quantization results of adjacent pixels;

[0284] The reconstructed pixel values ​​of the adjacent pixels are determined according to the first pixel residual values ​​of the adjacent pixels and the predicted pixel values ​​of the adjacent pixels.

[0285] The image compression device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0286] In one implementation, the processing module 62 is specifically configured to:

[0287] Determining an initial residual value of the original pixel according to the pixel value of the original pixel and the predicted pixel value of the original pixel;

[0288] Determining a gradient difference parameter according to a predicted pixel value of an original pixel and a pixel value of at least one adjacent pixel;

[0289] Determine the deviation parameter according to the gradient difference parameter;

[0290] According to the deviation parameter, the initial residual value is adjusted to obtain the residual value of the original pixel.

[0291] The image compression device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0292] In one implementation, the processing module 62 is specifically configured to:

[0293] For any original pixel in the image block, the quantization result of the original pixel is processed into positive and negative numbers to obtain a processed quantization result;

[0294] When the ratio of the processed quantization result to 2 raised to the power of k is less than the preset length, the first encoding method is used to encode the processed quantization result to obtain compressed data of the original pixel; wherein k is an encoding coefficient;

[0295] When the ratio of the processed quantization result to 2 raised to the kth power is greater than or equal to the preset length, the second encoding method is used to encode the processed quantization result to obtain compressed data of the original pixel;

[0296] Determining a compressed image block includes compressed data for each original pixel in the image block.

[0297] The image compression device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0298] The embodiment of the present application also provides a chip. It can be understood that the chip can be a fifth generation mobile communication technology (5th Generation Mobile Communication Technology, referred to as 5G) chip.

[0299] A computer program is stored on the chip, and when the computer program is executed by the chip, the method of the above method embodiment is implemented.

[0300] The embodiment of the present application also provides a chip module. It can be understood that the chip module can be a 5G chip module.

[0301] A computer program is stored on the chip module, and when the computer program is executed by the chip module, the method of the above method embodiment is implemented.

[0302] Figure 7 A schematic diagram of the structure of an image compression device provided in an embodiment of the present application. It can be understood that the image compression device can be a 5G chip module.

[0303] See also Figure 7 The image compression device 70 may include a processor 71 and a memory 72. Exemplarily, the processor 71 and the memory 72 are interconnected via a bus 73.

[0304] Memory 72 stores computer executable instructions;

[0305] The processor 71 executes the computer-executable instructions stored in the memory 72, so that the processor 71 executes the method shown in the above method embodiment.

[0306] All or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a readable memory. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned memory (storage medium) includes: read-only memory (English: read-only memory, abbreviated: ROM), RAM, flash memory, hard disk, solid state drive, magnetic tape (English: magnetic tape), floppy disk (English: floppy disk), optical disc (English: optical disc) and any combination thereof.

[0307] Accordingly, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the method of the above method embodiment is used to implement the method.

[0308] Accordingly, an embodiment of the present application may also provide a computer program product, including computer execution instructions, which, when executed by a processor, enable the method shown in the above method embodiment to be executed.

[0309] These computer executable instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0310] These computer executable instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0311] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

[0312] In the present application, the term "include" and its variations may refer to non-restrictive inclusion; the term "or" and its variations may refer to "and / or". The terms "first", "second", etc. in the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In the present application, "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previously associated objects are in an "or" relationship.

Claims

1. An image compression method, characterized in that: include: Acquire an image to be processed, determine a plurality of channel images corresponding to the image to be processed, and determine a plurality of image blocks included in each channel image; For any image block in any channel image, determine a quantization parameter corresponding to the image block; The quantization parameter is a preset quantization parameter, or is determined based on the compression rate of the compressed image block; Obtaining a pixel residual value of each original pixel in the image block; quantizing the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel; The quantization results of the multiple original pixels in the image block are encoded to obtain a compressed image block corresponding to the image block, and it is determined that the compressed image includes the compressed image block corresponding to each image block.

2. The method according to claim 1, characterized in that The determining of the quantization parameter corresponding to the image block includes: In a case where the image block is the first image block in the channel image, determining a preset quantization parameter as a quantization parameter corresponding to the image block; In a case where the image block is not the first image block in the channel image, a quantization parameter corresponding to the image block is determined according to a compression rate of the compressed image block.

3. The method according to claim 2, characterized in that The step of determining a quantization parameter corresponding to the image block according to the compression rate of the compressed image block includes: Obtaining compression rates of a plurality of compressed image blocks in the channel image; the plurality of compressed image blocks including a previous image block of the image block; Determining an average compression rate according to the compression rates of the plurality of compressed image blocks; Determine a first difference between a compression rate of a previous image block of the image block and a target compression rate, and determine a first quantization parameter according to the first difference; A second difference between the average compression rate and the target compression rate is determined, and a quantization parameter corresponding to the image block is determined according to the second difference and the first quantization parameter.

4. The method according to claim 3, characterized in that Also includes: Get the preset compression rate; The difference between the preset compression ratio and the preset margin is determined as the target compression ratio.

5. The method according to any one of claims 1 to 4, characterized in that: The step of determining a plurality of image blocks included in each channel image comprises: For any channel image, perform edge padding processing on the channel image to obtain an edge-padded channel image; wherein the edge-padded channel image includes a plurality of original pixels and a plurality of edge-padded pixels; The channel image after edge padding is subjected to block processing to determine a plurality of image blocks included in the channel image; the image block includes a plurality of original pixels, or at least one original pixel and at least one edge padding pixel.

6. The method according to claim 5, characterized in that The obtaining of a pixel residual value of each original pixel in the image block comprises: For any original pixel, obtaining the pixel value of the original pixel; Obtaining a pixel value of at least one adjacent pixel corresponding to the original pixel; the adjacent pixel is a padded pixel or an original pixel; Determining a predicted pixel value of the original pixel according to a pixel value of the at least one adjacent pixel; A residual value of the original pixel is determined according to the pixel value of the original pixel and the predicted pixel value of the original pixel.

7. The method according to claim 6, characterized in that The obtaining of the pixel value of at least one adjacent pixel corresponding to the original pixel comprises: For any adjacent pixel, when it is determined that there is a quantization result of the adjacent pixel, determining a reconstructed pixel value of the adjacent pixel according to the quantization result of the adjacent pixel; The reconstructed pixel value of the adjacent pixel is determined as the pixel value of the adjacent pixel.

8. The method according to claim 7, characterized in that Determining the reconstructed pixel values ​​of the adjacent pixels according to the quantization results of the adjacent pixels includes: Determining first pixel residual values ​​of the adjacent pixels according to a quantization parameter corresponding to the image block and a quantization result of the adjacent pixels; Determine a reconstructed pixel value of the adjacent pixel according to the first pixel residual value of the adjacent pixel and the predicted pixel value of the adjacent pixel.

9. The method according to claim 6, characterized in that The determining the residual value of the original pixel according to the pixel value of the original pixel and the predicted pixel value of the original pixel comprises: Determining an initial residual value of the original pixel according to the pixel value of the original pixel and the predicted pixel value of the original pixel; Determining a gradient difference parameter according to the predicted pixel value of the original pixel and the pixel value of the at least one adjacent pixel; Determining a deviation parameter according to the gradient difference parameter; The initial residual value is adjusted according to the deviation parameter to obtain the residual value of the original pixel.

10. The method according to claim 1, characterized in that The encoding process is performed on the quantization results of the plurality of original pixels in the image block to obtain a compressed image block corresponding to the image block, including: For any original pixel in the image block, performing positive and negative number processing on the quantization result of the original pixel to obtain a processed quantization result; When the ratio of the processed quantization result to 2 raised to the power of k is less than a preset length, a first encoding method is used to encode the processed quantization result to obtain compressed data of the original pixel; wherein k is an encoding coefficient; When the ratio of the processed quantization result to 2 raised to the kth power is greater than or equal to the preset length, adopting a second encoding method to encode the processed quantization result to obtain compressed data of the original pixel; Determining the compressed image block includes compressed data for each original pixel in the image block.

11. An image compression device, characterized in that: include: An acquisition module, used for acquiring an image to be processed, determining a plurality of channel images corresponding to the image to be processed, and determining a plurality of image blocks included in each channel image; A processing module, used for determining a quantization parameter corresponding to any image block in any channel image; the quantization parameter is a preset quantization parameter, or is determined based on a compression ratio of a compressed image block; The processing module is further used to obtain a pixel residual value of each original pixel in the image block; The processing module is further used to perform quantization processing on the pixel residual value according to the quantization parameter corresponding to the image block to obtain the quantization result of the original pixel; The processing module is further used to perform encoding processing on the quantization results of multiple original pixels in the image block to obtain a compressed image block corresponding to the image block, and determine that the compressed image includes the compressed image block corresponding to each image block.

12. An image compression device, characterized in that: include: Memory and processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 10 when executed by a processor.

14. A computer program product, characterized in that The method comprises computer-executable instructions, which, when executed by a processor, enable the method according to any one of claims 1 to 10 to be performed.