Image compression method, device, computer equipment and storage medium

By converting and analyzing the data of the image block in the primary color space and the target color space, and selecting an appropriate compression and encoding method for image compression, the problem of poor image compression quality in the prior art is solved, and higher quality image compression is achieved.

CN114363621BActive Publication Date: 2025-03-14SHENZHEN AIXIESHENG TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210035324.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-13
Publication Date
2025-03-14
Estimated Expiration
2042-01-13

AI Technical Summary

Technical Problem

The existing image compression technology results in poor image quality after compression when the pixel chromaticity changes in areas with a large range of pixels, especially because the two brightness components share a set of chromaticity components.

Method used

By obtaining its data under the primary color color space for each image block in the target image to be compressed, it is obtained and converted into the target color space. According to the maximum and minimum value difference of the image block in brightness, first chrominance and second chrominance components, an appropriate compression encoding method is selected for the same proportional compression.

Benefits of technology

This method can adaptively select a suitable compression encoding method based on the brightness and chromaticity difference value of the image block, avoid compression errors caused by excessive chromaticity component difference value, and thereby improve the quality of image compression.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114363621B_ABST
    Figure CN114363621B_ABST
Patent Text Reader

Abstract

The present application relates to an image compression method, device, computer equipment and storage medium. The method comprises: for each image block in the target image, obtaining the first image block data of the image block in the primary color space; converting the first image block data into the second image block data in the target color space; for each component in the brightness component, the first chroma component and the second chroma component, determining the difference between the maximum component value and the minimum component value of the image block under the component based on the second image block data to obtain the maximum brightness difference value, the maximum first chroma difference value and the maximum second chroma difference value; according to the maximum brightness difference value, the maximum first chroma difference value and the maximum second chroma difference value, selecting the target compression encoding method that matches the second image block data; compressing each image block in the same proportion according to the corresponding target compression encoding method, and obtaining the compressed data of each image block that meets the preset compression ratio. The present application scheme can improve the image compression quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image compression method, apparatus, computer equipment and storage medium. Background Art

[0002] With the development of image processing technology, image compression technology has emerged. Due to human visual characteristics, humans are insensitive to color difference components, so image compression can be achieved by coarse chrominance sampling. Existing compression technology compresses image data in YUV (brightness and color difference) format, such as YUV422.

[0003] Although every two brightness components of YUV422 share a set of chrominance components, a compression ratio of 2 / 3 can be achieved in the end, however, in areas where the pixel chrominance variation range is relatively large, the adjacent chrominance components differ greatly, and two brightness components sharing a set of chrominance components will produce a large error, resulting in poor quality of the compressed image. Therefore, it is necessary to propose an image compression method that can ensure the quality of image compression. Summary of the invention

[0004] Based on this, it is necessary to provide an image compression method, apparatus, computer device, computer-readable storage medium and computer program product that ensure image compression quality in response to the above technical problems.

[0005] In a first aspect, the present application provides an image compression method. The method comprises:

[0006] For each image block in the target image to be compressed, obtaining first image block data of the image block in a primary color space;

[0007] Converting the first image block data into second image block data in a target color space; the target color space includes a brightness component, a first chroma component, and a second chroma component; the second image block data includes component values ​​of each pixel in the image block under the brightness component, the first chroma component, and the second chroma component, respectively;

[0008] For each of the luminance component, the first chrominance component, and the second chrominance component, determine, based on the second image block data, a difference between a maximum component value and a minimum component value of the image block under the component, so as to obtain a maximum luminance difference value, a maximum first chrominance difference value, and a maximum second chrominance difference value;

[0009] Selecting a target compression encoding method matching the second image block data from preset compression encoding methods according to the maximum brightness difference value, the maximum first chromaticity difference value, and the maximum second chromaticity difference value;

[0010] Each image block is compressed at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio; the compressed data of each image block includes the corresponding identifier of the target compression coding method; the identifier is used to indicate that the compressed data of the corresponding image block is to be decompressed.

[0011] In one embodiment, the first chromaticity component is an orange component; the second chromaticity component is a green component; the maximum first chromaticity difference is a maximum orange difference; the maximum second chromaticity difference is a maximum green difference; and selecting a target compression encoding method matching the second image block data from preset compression encoding methods according to the maximum brightness difference, the maximum first chromaticity difference, and the maximum second chromaticity difference comprises:

[0012] If the maximum orange difference and the maximum green difference meet the first lossless compression condition, determining that the target compression encoding mode matched by the second image block data is the first lossless compression encoding mode;

[0013] The step of compressing each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio includes:

[0014] Obtaining orange component differences between the orange component values ​​of each pixel in the second image block data and the minimum orange component value, and obtaining green component differences between the green component values ​​of each pixel in the second image block data and the minimum green component value;

[0015] According to the first lossless compression encoding method, the first identification storage bit number is used to store the identification of the first lossless compression encoding method, the first orange difference storage bit number and the first green difference storage bit number are used to store the orange component difference values ​​and the green component difference values ​​respectively, and the first component value storage bit number is used to store the minimum green component value, the minimum orange component value and the component values ​​of each pixel under the brightness component respectively, to obtain lossless compression data of an image block whose size meets the preset compression ratio;

[0016] The number of first orange difference storage bits and the number of first green difference storage bits match the maximum orange difference and the maximum green difference respectively; the total number of each storage bit matches the total number of storage bits required for the preset compression ratio.

[0017] In one embodiment, the method further comprises:

[0018] If the maximum brightness difference, the maximum orange difference and the maximum green difference meet a second lossless compression condition, determining that the target compression encoding mode matched by the second image block data is a second lossless compression encoding mode; and the second lossless compression condition is greater than the maximum green difference and the maximum orange difference required by the first lossless compression condition;

[0019] Obtaining brightness component differences between brightness component values ​​of each pixel in the second image block data and the minimum brightness component value;

[0020] According to the second lossless compression encoding method, the bit positions of the second identification storage bit position are used to store the identifier of the second lossless compression encoding method, the bit positions of the second orange difference value storage bit position, the second green difference value storage bit position and the first brightness difference value storage bit position are used to respectively store the orange component difference values, the green component difference values ​​and the brightness component difference values, and the bit positions of the second component value storage bit position are used to respectively store the minimum green component value, the minimum orange component value and the minimum brightness component value, so as to obtain lossless compressed data of an image block whose size meets the preset compression ratio;

[0021] Among them, the number of bits for storing the second orange difference and the number of bits for storing the second green difference respectively match the maximum orange difference and the maximum green difference; the number of bits for storing the first brightness difference matches the maximum brightness difference; the total number of each storage bit is consistent with the total number of storage bits required for the preset compression ratio.

[0022] In one embodiment, the first chromaticity component is an orange component; the second chromaticity component is a green component; the maximum first chromaticity difference is a maximum orange difference; the maximum second chromaticity difference is a maximum green difference; and selecting a target compression encoding method matching the second image block data from preset compression encoding methods according to the maximum brightness difference, the maximum first chromaticity difference, and the maximum second chromaticity difference comprises:

[0023] If the maximum brightness difference value, the maximum orange difference value and the maximum green difference value meet the first lossy compression condition, determining that the target compression encoding mode matched by the second image block data is the first lossy compression encoding mode;

[0024] The step of compressing each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio includes:

[0025] Obtaining brightness component differences between brightness component values ​​of each pixel in the second image block data and the minimum brightness component value;

[0026] According to the first lossy compression encoding mode, the bit positions of the third identification storage bit position are used to store the identification of the first lossy compression encoding mode, the bit positions of the first lossy difference storage bit position are used to respectively store the data of the first preset bit positions in the binary data of each of the orange component difference values ​​and each of the green component difference values, the bit positions of the second brightness difference storage bit position are used to respectively store each of the brightness component difference values, and the first orange component value storage bit position, the first green component value storage bit position and the first brightness component value storage bit position are used to respectively store the minimum orange component value, the minimum green component value and the minimum brightness component value, to obtain lossy compressed data of an image block whose size meets the preset compression ratio;

[0027] Among them, the first preset number of bits matches the first lossy difference storage number of bits; the second brightness difference storage number of bits matches the maximum brightness difference; the total number of each storage bit number matches the total number of storage bits required for the preset compression ratio.

[0028] In one embodiment, the method further comprises:

[0029] If the maximum brightness difference value, the maximum orange difference value, and the maximum green difference value meet a second lossy compression condition, determining that the target compression encoding method matched by the second image block data is a second lossy compression encoding method; the compression loss of the second lossy compression encoding method is higher than the compression loss of the first lossy compression encoding method;

[0030] According to the second lossy compression encoding mode, the bit positions of the fourth identification storage bit number are used to store the identification of the second lossy compression encoding mode, the orange lossy difference storage bit positions are used to store the data of the first second preset bit positions in the binary data of each orange component difference value, the bit positions of the green lossy difference storage bit positions are used to store the data of the first third preset bit positions in the binary data of each green component difference value, the bit positions of the third brightness difference storage bit positions are used to store each brightness component difference value, and the second orange component value storage bit positions, the second green component value storage bit positions and the second brightness component value storage bit positions are used to store the minimum orange component value, the minimum green component value and the minimum brightness component value respectively, to obtain lossy compressed data of an image block whose size meets the preset compression ratio;

[0031] Among them, the number of bits for storing orange lossy differences is less than the number of bits for storing green lossy differences; the number of bits for storing orange lossy differences is consistent with the second preset number of bits, and the number of bits for storing green lossy differences is consistent with the third preset number of bits; the number of bits for storing the third brightness difference matches the maximum brightness difference; and the total number of each storage bit number is consistent with the total number of storage bits required for the preset compression ratio.

[0032] In one embodiment, the first chromaticity component is an orange component; the second chromaticity component is a green component; the maximum first chromaticity difference is a maximum orange difference; the maximum second chromaticity difference is a maximum green difference; and selecting a target compression encoding method matching the second image block data from preset compression encoding methods according to the maximum brightness difference, the maximum first chromaticity difference, and the maximum second chromaticity difference comprises:

[0033] If the maximum brightness difference, the maximum orange difference and the maximum green difference meet the original space compression condition, determining that the target compression encoding mode matched by the second image block data is the primary color space compression encoding mode;

[0034] The step of compressing each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio includes:

[0035] According to the primary color space compression coding method, using the bit of the fifth identification storage bit number to store the identification of the primary color space compression coding method, using the primary color space storage bit number to respectively store the first four preset bit numbers of the binary data of each component value of each pixel in the first image block data in the primary color space, to obtain the primary color compressed data of the image block whose size meets the preset compression ratio;

[0036] The number of storage bits in the primary color space is consistent with a fourth preset number of bits; and the total number of each storage bit is consistent with the total number of storage bits required for the preset compression ratio.

[0037] In one embodiment, the method further includes an image decoding step; the image decoding step includes:

[0038] For the compressed data of each image block, a target decompression encoding mode for the compressed data is determined according to an identifier of the target compression encoding mode in the compressed data; the target decompression mode corresponds to the target compression encoding mode in a one-to-one manner;

[0039] The compressed data is decompressed according to the target decompression mode to obtain the target image.

[0040] In a second aspect, the present application also provides an image compression device. The device comprises:

[0041] An acquisition module is used to acquire, for each image block in a target image to be compressed, first image block data of the image block in a primary color space; convert the first image block data into second image block data in a target color space; the target color space includes a brightness component, a first chroma component, and a second chroma component; the second image block data includes component values ​​of each pixel in the image block under the brightness component, the first chroma component, and the second chroma component respectively;

[0042] a matching module, configured to determine, for each of the brightness component, the first chroma component, and the second chroma component, a difference between a maximum component value and a minimum component value of the image block under the component based on the second image block data, so as to obtain a maximum brightness difference value, a maximum first chroma difference value, and a maximum second chroma difference value; and select, according to the maximum brightness difference value, the maximum first chroma difference value, and the maximum second chroma difference value, a target compression encoding method that matches the second image block data from preset compression encoding methods;

[0043] A compression module is used to compress each image block at the same ratio according to a corresponding target compression coding method to obtain compressed data of each image block that meets a preset compression ratio; the compressed data of each image block includes an identifier of the corresponding target compression coding method; the identifier is used to indicate that the compressed data of the corresponding image block is to be decompressed.

[0044] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method described in each embodiment of the present application are implemented.

[0045] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.

[0046] In a fifth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.

[0047] The above-mentioned image compression method, apparatus, computer equipment, storage medium and computer program product obtain, for each image block in the target image to be compressed, first image block data of the image block in the primary color space; convert the first image block data into second image block data in the target color space; the target color space includes a brightness component, a first chroma component and a second chroma component; the second image block data includes component values ​​of each pixel in the image block under the brightness component, the first chroma component and the second chroma component respectively; for each component in the brightness component, the first chroma component and the second chroma component, determine the image based on the second image block data The difference between the maximum component value and the minimum component value of the block under the component is used to obtain the maximum brightness difference, the maximum first chromaticity difference and the maximum second chromaticity difference; according to the maximum brightness difference, the maximum first chromaticity difference and the maximum second chromaticity difference, a target compression coding method matching the second image block data is selected from the preset compression coding methods; each image block is compressed in the same proportion according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio; the compressed data of each image block includes the corresponding target compression coding method identification; the identification is used to indicate that the compressed data of the corresponding image block is decompressed. The target compression coding method can be adaptively selected according to the maximum brightness difference, the maximum first chromaticity difference and the maximum second chromaticity difference, and each image block in the target image is compressed in the same proportion, thereby avoiding the problem of large errors in the compressed data due to large differences in the color difference components of the pixels, and ensuring the quality of image compression. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 A diagram showing an application environment of an image compression method in an embodiment;

[0049] Figure 2 is a schematic flow chart of an image compression method in one embodiment;

[0050] Figure 3 A schematic diagram of a flow chart of an image decoding step in an embodiment;

[0051] Figure 4 is a structural block diagram of an image compression device in one embodiment;

[0052] Figure 5 is an internal structure diagram of a computer device in one embodiment;

[0053] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION

[0054] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0055] The image compression method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The terminal 102 can obtain the first image block data of the image block in the primary color space for each image block in the target image to be compressed. The terminal 102 can convert the first image block data into the second image block data in the target color space. The terminal 102 can determine the difference between the maximum component value and the minimum component value of the image block under the component based on the second image block data for each component in the brightness component, the first chromaticity component and the second chromaticity component, so as to obtain the maximum brightness difference, the maximum first chromaticity difference and the maximum second chromaticity difference. The terminal 102 can select the target compression coding method that matches the second image block data from the preset compression coding method according to the maximum brightness difference, the maximum first chromaticity difference and the maximum second chromaticity difference. The terminal 102 can compress each image block in the same proportion according to the corresponding target compression coding method to obtain the compressed data of each image block that meets the preset compression ratio. The terminal 102 may send the compressed data to the server 104, and the server 104 may store the compressed data. It is understood that the terminal 102 may directly store the compressed data.

[0056] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. The portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. The server 104 may be implemented as an independent server or a server cluster consisting of multiple servers.

[0057] In one embodiment, Figure 2 As shown, an image compression method is provided, which can be applied to a computer device, which can be Figure 1 The terminal or server in the embodiment specifically comprises the following steps:

[0058] Step 202: for each image block in the target image to be compressed, first image block data of the image block in the primary color space is obtained; and the first image block data is converted into second image block data in the target color space.

[0059] Among them, the primary color space is a red, green, and blue (RGB) color space with red (Red), green (Green), and blue (Blue) as basic colors. The primary color space includes a red component, a green component, and a red component. The target color space is a brightness and color difference (YUV) color space. "Y" represents brightness (Luminance or Luma), that is, a grayscale value, and "U" and "V" represent chrominance (Chrominance or Chroma), which is used to describe the color and saturation of the image and is used to specify the color of the pixel. The target color space includes a brightness component, a first chroma component, and a second chroma component. It can be understood that "U" and "V" are the first chroma component and the second chroma component, respectively. The first image block data includes the component values ​​of each pixel in the image block under the red component, the green component, and the red component, respectively. The second image block data includes the component values ​​of each pixel in the image block under the brightness component, the first chroma component, and the second chroma component, respectively.

[0060] Specifically, the computer device can obtain a target image to be compressed and split the target image into multiple image blocks. It is understandable that the sizes of the image blocks can be the same or different. The computer device can obtain the first image block data of the image block in the primary color space for each split image block. It is understandable that the data of the target image is the primary color image data in the primary color space, and the computer device can directly obtain the first image block data of the image block by splitting the primary color image data. The computer device can also split the target image and then determine the first image block data according to the split image blocks. The computer device can convert the first image block data into the second image block data in the target color space according to the first conversion formula. Among them, the first conversion formula is a formula for converting the data in the primary color space to the target color space.

[0061] In one embodiment, the first chromaticity component in the target color space may be an orange component (Co), and the second chromaticity component may be a green component (Cg). The target color space may be a luminance and orange-green (YCoCg) color space. The first conversion formula is:

[0062] Y=0.25R+0.5G+0.25B (1)

[0063] Co=0.5R-0.5B (2)

[0064] Cg=-0.25R+0.5G-0.25B (3)

[0065] It can be understood that if the image block includes 4 pixels, the first image block data includes R1, R2, R3, R4, G1, G2, G3, G4, B1, B2, B3 and B4. Among them, R1, G1 and B1 are the data of the first pixel in the primary color space, R2, G2 and B2 are the data of the second pixel, and so on. The computer device converts the image data in the primary color space to the target color space to obtain the second image block data including Y1, Y2, Y3, Y4, Co1, Co2, Co3, Co4, Cg1, Cg2, Cg3 and Cg4. Among them, Y1, Co1 and Cg1 are the data of the first pixel in the target color space, and so on.

[0066] In one embodiment, the computer device can split the target image into image blocks of equal size, each image block includes two rows and two columns of 4 pixels. It can be understood that there is no connection between the image blocks, and the computer device can use each image block as an independent processing unit, compress and encode the previous image block, and then compress and encode the next image block. For example, the first image block is composed of 4 pixels in the 1st to 2nd columns of the 1st row of the target image and the 1st to 2nd columns of the 2nd row, and the second image block is composed of 4 pixels in the 3rd to 4th columns of the 1st row of the target image and the 3rd to 4th columns of the 2nd row. After the computer device compresses and encodes the first image block, it can compress and encode the data in the second image block, and it will be circulated in sequence until the first two rows of data of the target image are all compressed and encoded, and then the data of the 3rd and 4th rows can be processed. The order of compression encoding is the same as the data of the first and second rows, and it will be circulated in sequence until all the image blocks of the target image are traversed.

[0067] Step 204, for each of the brightness component, the first chroma component and the second chroma component, determine the difference between the maximum component value and the minimum component value of the image block under the component based on the second image block data to obtain the maximum brightness difference value, the maximum first chroma difference value and the maximum second chroma difference value; according to the maximum brightness difference value, the maximum first chroma difference value and the maximum second chroma difference value, select a target compression encoding method that matches the second image block data from preset compression encoding methods.

[0068] The maximum brightness difference is the difference between the maximum component value and the minimum component value under the brightness component. The maximum first chromaticity difference is the difference between the maximum component value and the minimum component value under the first chromaticity component. The maximum second chromaticity difference is the difference between the maximum component value and the minimum component value under the second chromaticity component.

[0069] Specifically, the computer device may determine the maximum component value and the minimum component value of each component from the second image block data, and calculate the difference between the maximum component value and the minimum component value of each component to obtain the maximum brightness difference value, the maximum first chromaticity difference value, and the maximum second chromaticity difference value. The computer device may select a target compression encoding method that matches the second image block data from the preset compression encoding methods according to the maximum brightness difference value, the maximum first chromaticity difference value, and the maximum second chromaticity difference value and the compression condition corresponding to the preset compression encoding method.

[0070] Step 206 , compress each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio.

[0071] The compressed data of each image block includes an identifier of a corresponding target compression encoding method, and the identifier is used to indicate that the compressed data of the corresponding image block is to be decompressed.

[0072] Specifically, the computer device may compress each image block at the same ratio according to a preset compression ratio and a corresponding target compression coding method, so as to obtain compressed data of each image block that meets the preset compression ratio.

[0073] In one embodiment, the size of a component value in the first image block data and the second image block data is 1 byte, that is, the number of bits of a component value is 8 bits. It can be understood that if the image block includes 4 pixels, the number of bits of the first image block data and the second image block data is 96 bits. The computer device can compress each image block in the same proportion according to the corresponding target compression coding method at a preset compression ratio of 2 / 3, and obtain compressed data of 8 bytes for each image block that meets the preset compression ratio of 2 / 3. It can be understood that the number of bits of compressed data is 64 bits.

[0074] In one embodiment, the image compression method can be applied to a mipi display system. A computer device can use the image compression method to compress and encode image data of a mipi display system. Wherein, mipi is a mobile industry processor interface (abbreviated as mipi).

[0075] The image compression method comprises the following steps: for each image block in the target image to be compressed, obtaining first image block data of the image block in the primary color space; converting the first image block data into second image block data in the target color space; the target color space comprises a brightness component, a first chroma component and a second chroma component; the second image block data comprises component values ​​of each pixel in the image block in the brightness component, the first chroma component and the second chroma component respectively; for each component in the brightness component, the first chroma component and the second chroma component, determining the difference between the maximum component value and the minimum component value of the image block in the component based on the second image block data to obtain a maximum brightness difference value, a maximum first chroma difference value and a maximum second chroma difference value; selecting a target compression coding method matching the second image block data from preset compression coding methods according to the maximum brightness difference value, the maximum first chroma difference value and the maximum second chroma difference value; compressing each image block in the same proportion according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression proportion; the compressed data of each image block comprises an identifier of the corresponding target compression coding method; the identifier is used to indicate that the compressed data of the corresponding image block is to be decompressed. It is capable of adaptively selecting the target compression encoding method according to the maximum brightness difference value, the maximum first chromaticity difference value and the maximum second chromaticity difference value, and compressing each image block in the target image at the same ratio, thereby avoiding the problem of large errors in the compressed data due to large differences in the color difference components of the pixels, and ensuring the quality of image compression.

[0076] In one embodiment, the first chromaticity component is an orange component; the second chromaticity component is a green component; the maximum first chromaticity difference is a maximum orange difference; the maximum second chromaticity difference is a maximum green difference; according to the maximum brightness difference, the maximum first chromaticity difference and the maximum second chromaticity difference, selecting a target compression encoding method that matches the second image block data from a preset compression encoding method includes: if the maximum orange difference and the maximum green difference meet the first lossless compression condition, determining that the target compression encoding method that matches the second image block data is the first lossless compression encoding method; compressing each image block at the same ratio according to the corresponding target compression encoding method to obtain compressed data of each image block that meets the preset compression ratio includes: obtaining the second image The orange component difference between the orange component value of each pixel in the block data and the minimum orange component value, and the green component difference between the green component value of each pixel in the second image block data and the minimum green component value are obtained; according to the first lossless compression coding method, the bit positions of the first identification storage bit number are used to store the identifier of the first lossless compression coding method, the bits of the first orange difference storage bit number and the first green difference storage bit number are used to respectively store the orange component difference values ​​and the green component difference values, and the bits of the first component value storage bit number are used to respectively store the minimum green component value, the minimum orange component value and the component values ​​of each pixel under the brightness component, so as to obtain lossless compressed data of an image block whose size meets the preset compression ratio.

[0077] The first orange difference storage bit number and the first green difference storage bit number match the maximum orange difference value and the maximum green difference value respectively. The total number of each storage bit number matches the total storage bit number required for the preset compression ratio.

[0078] Specifically, the computer device can determine whether the maximum orange difference and the maximum green difference meet the first lossless compression condition, and if so, determine that the target compression encoding method matched by the second image block data is the first lossless compression encoding method. The computer device can obtain the orange component difference between the orange component value of each pixel in the second image block data and the minimum orange component value, and obtain the green component difference between the green component value of each pixel in the second image block data and the minimum green component value, and according to the first lossless compression encoding method, use the bits of the first identification storage bit number to store the identifier of the first lossless compression encoding method, use the bits of the first orange difference storage bit number and the first green difference storage bit number to store the orange component difference and the green component difference respectively, and use the bits of the first component value storage bit number to store the minimum green component value, the minimum orange component value, and the component values ​​of each pixel under the brightness component respectively, to obtain lossless compression data of an image block whose size meets the preset compression ratio.

[0079] In one embodiment, the image block includes 4 pixels, the first image block data size is 96 bits, and the preset compression ratio is 2 / 3. The first lossless compression condition may be that the maximum orange difference is less than 2 and the maximum green difference is less than 4. The number of bits of the first identification storage bit is 4, the number of bits of the first orange difference storage bit is 1, the number of bits of the first green difference storage bit is 2, and the number of bits of the first component value storage bit is 8. The computer device may use 4 bits to store the identification of the first lossless compression encoding method, use 1 bit to store 4 orange component differences respectively, use 2 bits to store 4 green component differences respectively, and use 8 bits to store the minimum green component value, the minimum orange component value, and each component value of the 4 pixels under the brightness component respectively. It can be understood that the total number of the above storage bits is 64 bits, and the computer device can obtain 64 bits of lossless compressed data. Since the maximum orange difference is less than 2, the computer device can use 1 bit to store each orange component difference. Similarly, since the maximum greenness difference is less than 4, the computer device can store the difference of each greenness component using 2 bits. The identifier of the first lossless compression encoding method may be 1110.

[0080] In this embodiment, the computer device can store the identifier of the first lossless compression encoding method, the difference values ​​of each orange component, the difference values ​​of each green component, the minimum green component value, the minimum orange component value, and the component values ​​of each pixel under the brightness component according to the first lossless compression encoding method, and obtain lossless compression data of an image block whose size meets the preset compression ratio. It can be understood that the lossless compression data obtained according to the first lossless compression encoding method includes the complete component values ​​of each pixel under the brightness component, as well as the difference values ​​of each orange component and the difference values ​​of each green component. Compared with the traditional compression method, the chromaticity component value is completely retained in the form of difference, which can improve the quality of image compression.

[0081] In one embodiment, the method further includes: if the maximum brightness difference, the maximum orange difference and the maximum green difference meet the second lossless compression condition, determining that the target compression encoding method matching the second image block data is the second lossless compression encoding method; the second lossless compression condition is greater than the maximum green difference and the maximum orange difference required by the first lossless compression condition; obtaining the brightness component difference between the brightness component value of each pixel in the second image block data and the minimum brightness component value; according to the second lossless compression encoding method, using the bits of the second identification storage bit number to store the identifier of the second lossless compression encoding method, using the bits of the second orange difference storage bit number, the second green difference storage bit number and the first brightness difference storage bit number to respectively store the orange component difference values, the green component difference values ​​and the brightness component difference values, and using the bits of the second component value storage bit number to respectively store the minimum green component value, the minimum orange component value and the minimum brightness component value, so as to obtain lossless compressed data of an image block whose size meets the preset compression ratio.

[0082] Among them, the second orange difference storage bit number and the second green difference storage bit number match the maximum orange difference and the maximum green difference respectively; the first brightness difference storage bit number matches the maximum brightness difference; the total number of each storage bit number matches the total storage bit number required for the preset compression ratio.

[0083] Specifically, the computer device can determine whether the maximum brightness difference, the maximum orange difference, and the maximum green difference meet the second lossless compression condition. If so, the target compression encoding method for matching the second image block data is determined to be the second lossless compression encoding method. The second lossless compression condition is greater than the maximum green difference and the maximum orange difference required by the first lossless compression condition. It can be understood that if at least one of the maximum green difference and the maximum orange difference is greater than the data size required by the first lossless compression condition, the computer device cannot perform lossless compression according to the first lossless compression encoding method. The computer device can obtain the brightness component difference between the brightness component value of each pixel in the second image block data and the minimum brightness component value, and according to the second lossless compression coding method, use the bit positions of the second identification storage bit number to store the identifier of the second lossless compression coding method, use the bit positions of the second orange difference storage bit number, the second green difference storage bit number and the first brightness difference storage bit number to respectively store each orange component difference value, each green component difference value and each brightness component difference value, and use the bit positions of the second component value storage bit number to respectively store the minimum green component value, the minimum orange component value and the minimum brightness component value, so as to obtain lossless compressed data of an image block whose size meets the preset compression ratio.

[0084] In one embodiment, the image block includes 4 pixels, the first image block data size is 96 bits, and the preset compression ratio is 2 / 3. The second lossless compression condition can be that the maximum brightness difference is less than 8, the maximum orange difference is less than 8, and the maximum green difference is less than 8. It can be understood that each brightness component difference, each orange component difference, and each green component difference under the second lossless compression condition can be stored with 3 bits. The number of bits of the second identification storage bit is 3, the number of bits of the second orange difference storage bit, the second green difference storage bit, and the first brightness difference storage bit are all 3, and the number of bits of the second component value storage bit is 8. The computer device can use 3 bits to store the identification of the second lossless compression encoding method, use 3 bits to store each orange component difference, each green component difference, and each brightness component difference, and use 8 bits to store the minimum green component value, the minimum orange component value, and the minimum brightness component value. It can be understood that the total number of the above storage bits is 63 bits, and the computer device can encode the 64th bit with 1 0 or 1. Among them, the identifier of the second lossless compression encoding method can be 110.

[0085] In one embodiment, the computer device may compress the image block according to the order of the identifier of the target compression coding method -> each component value of each pixel under the brightness component -> each component value of each pixel under the orange component -> each component value of each pixel under the green component -> each brightness component difference of each pixel -> each orange component difference of each pixel -> each green component difference of each pixel to obtain the compressed data of the image block. It can be understood that if the compressed data corresponding to the target compression coding method does not completely contain the above data, the computer device may skip the ordering of the corresponding data for compression coding. For example, in the lossless compression data corresponding to the second lossless compression encoding method, bits 1 to 3 are the identifier of the second lossless compression encoding method, bits 4 to 11 are the minimum brightness component value, bits 12 to 19 are the minimum orange component value, bits 20 to 27 are the minimum green component value, bits 28 to 39 are the brightness component difference values ​​of each pixel, bits 40 to 51 are the orange component difference values ​​of each pixel, and bits 52 to 63 are the green component difference values ​​of each pixel.

[0086] In this embodiment, even when the maximum brightness difference, the maximum orange difference and the maximum green difference do not meet the first lossless compression condition, that is, the computer device cannot directly perform lossless compression according to the first lossless compression encoding method, the computer device can store the identifier of the second lossless compression encoding method, each orange component difference, each green component difference and each brightness component difference, the minimum green component value, the minimum orange component value and the minimum brightness component value according to the second lossless compression encoding method, to achieve lossless compression of the second image block data, thereby improving the quality of image compression.

[0087] In one embodiment, the first chromaticity component is an orange component; the second chromaticity component is a green component; the maximum first chromaticity difference is a maximum orange difference; the maximum second chromaticity difference is a maximum green difference; according to the maximum brightness difference, the maximum first chromaticity difference and the maximum second chromaticity difference, selecting a target compression coding method that matches the second image block data from a preset compression coding method includes: if the maximum brightness difference, the maximum orange difference and the maximum green difference meet the first lossy compression condition, determining that the target compression coding method that matches the second image block data is the first lossy compression coding method; compressing each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio includes: obtaining the second image the brightness component difference between the brightness component value of each pixel in the block data and the minimum brightness component value; according to the first lossy compression coding method, using the bit of the third identification storage bit number to store the identification of the first lossy compression coding method, using the bit of the first lossy difference storage bit number to respectively store the data of the first preset number of bits in the binary data of each orange component difference value and each green component difference value, using the bit of the second brightness difference storage bit number to respectively store each brightness component difference value, and using the first orange component value storage bit number, the first green component value storage bit number and the first brightness component value storage bit number to respectively store the minimum orange component value, the minimum green component value and the minimum brightness component value, to obtain lossy compressed data of an image block whose size meets the preset compression ratio.

[0088] Among them, the first preset number of bits matches the first lossy difference storage number of bits; the second brightness difference storage number of bits matches the maximum brightness difference; and the total number of each storage number of bits matches the total number of storage bits required for the preset compression ratio.

[0089] Specifically, the computer device can determine whether the maximum brightness difference, the maximum orange difference, and the maximum green difference meet the first lossy compression condition, and if so, determine that the target compression encoding method matched by the second image block data is the first lossy compression encoding method. The computer device can obtain the brightness component difference between the brightness component value of each pixel in the second image block data and the minimum brightness component value, and according to the first lossy compression encoding method, use the bits of the third identification storage bit number to store the identifier of the first lossy compression encoding method, use the bits of the first lossy difference storage bit number to store the first preset bit number of binary data of each orange component difference and each green component difference, use the bits of the second brightness difference storage bit number to store each brightness component difference, and use the first orange component value storage bit number, the first green component value storage bit number, and the first brightness component value storage bit number to store the minimum orange component value, the minimum green component value, and the minimum brightness component value, respectively, to obtain lossy compressed data of an image block whose size meets the preset compression ratio.

[0090] In one embodiment, if the orange component difference is greater than the maximum value represented by the first preset number of bits, the computing computer device may intercept the data of the first second preset number of bits of the binary data of the orange component difference. If the green component difference is greater than the maximum value represented by the first preset number of bits, the computing computer device may intercept the data of the first second preset number of bits of the binary data of the green component difference.

[0091] In one embodiment, the image block includes 4 pixels, the first image block data size is 96 bits, and the preset compression ratio is 2 / 3. The first lossy compression condition may be that the maximum brightness difference is less than 16, the maximum orange difference is less than 16, and the maximum green difference is less than 16. The number of bits of the third identification storage digit is 1, the number of bits of the first lossy difference storage digit is 3, the number of bits of the second brightness difference storage digit is 4, the number of bits of the first orange component value storage digit is 7, the number of bits of the first green component value storage digit is 8, and the number of bits of the first brightness component value storage digit is 8. The computer device may use 1 bit to store the identification of the first lossy compression encoding method, use 3 bits to store the first 3 bits of binary data of each orange component difference and each green component difference respectively, use 4 bits to store 4 brightness component differences respectively, and use 7 bits to store the minimum orange component value, 8 bits to store the minimum green component value, and 8 bits to store the minimum brightness component value. It can be understood that the total number of the above storage bits is 64 bits. Among them, the identifier of the first lossy compression encoding method can be 0.

[0092] In this embodiment, the computer device can perform lossy compression on image blocks with large brightness or chromaticity changes, and store the difference and minimum value of each component, so as to ensure that the lossy compressed data includes the component value of each component. Compared with the traditional compression method in which two brightness component values ​​directly share a set of chromaticity component values, the quality of image compression can be improved.

[0093] In one embodiment, the method further includes: if the maximum brightness difference, the maximum orange difference and the maximum green difference meet the second lossy compression condition, determining that the target compression encoding method matching the second image block data is the second lossy compression encoding method; the compression loss of the second lossy compression encoding method is higher than the compression loss of the first lossy compression encoding method; according to the second lossy compression encoding method, using the bit positions of the fourth identification storage bit number to store the identifier of the second lossy compression encoding method, using the orange lossy difference storage bit number to store the data of the first second preset bit positions in the binary data of each orange component difference, using the bit positions of the green lossy difference storage bit number to store the data of the first third preset bit positions in the binary data of each green component difference, using the bit positions of the third brightness difference storage bit number to store each brightness component difference, and using the second orange component value storage bit number, the second green component value storage bit number and the second brightness component value storage bit number to respectively store the minimum orange component value, the minimum green component value and the minimum brightness component value, so as to obtain lossy compressed data of an image block whose size meets the preset compression ratio.

[0094] Among them, the number of orange lossy difference storage bits is less than the green lossy difference storage bit number; the number of orange lossy difference storage bits is consistent with the second preset number of bits, and the number of green lossy difference storage bits is consistent with the third preset number of bits; the third brightness difference storage bit number matches the maximum brightness difference; the total number of each storage bit number is consistent with the total storage bit number required for the preset compression ratio.

[0095] Specifically, the computer device can determine whether the maximum brightness difference, the maximum orange difference, and the maximum green difference meet the second lossy compression condition. If so, the target compression encoding method for matching the second image block data is determined to be the second lossy compression encoding method. The compression loss of the second lossy compression encoding method is higher than the compression loss of the first lossy compression encoding method. It can be understood that if at least one of the maximum brightness difference, the maximum green difference, and the maximum orange difference is greater than the data size required by the first lossless compression condition, the computer device cannot perform lossy compression according to the first lossy compression encoding method. The computer device can use the bit positions of the fourth identification storage bit number to store the identifier of the second lossy compression encoding method according to the second lossy compression encoding method, use the orange lossy difference storage bit number to store the data of the first second preset number of bits in the binary data of each orange component difference, use the bit positions of the green lossy difference storage bit number to store the data of the first third preset number of bits in the binary data of each green component difference, use the bit positions of the third brightness difference storage bit number to store each brightness component difference, and use the second orange component value storage bit number, the second green component value storage bit number and the second brightness component value storage bit number to respectively store the minimum orange component value, the minimum green component value and the minimum brightness component value, so as to obtain lossy compressed data of an image block whose size meets the preset compression ratio.

[0096] In one embodiment, if the orange component difference is greater than the maximum value represented by the second preset number of bits, the computing computer device may intercept the data of the first second preset number of bits of the binary data of the orange component difference. If the green component difference is greater than the maximum value represented by the third preset number of bits, the computing computer device may intercept the data of the first second preset number of bits of the binary data of the green component difference.

[0097] In one embodiment, the image block includes 4 pixels, the first image block data size is 96 bits, and the preset compression ratio is 2 / 3. The second lossy compression condition can be that the maximum brightness difference is less than 32, the maximum orange difference is less than 16, and the maximum green difference is less than 16. The number of bits of the fourth identifier storage digit is 2, the number of bits of the orange lossy difference storage digit is 2, the number of bits of the green lossy difference storage digit is 3, the number of bits of the third brightness difference storage digit is 5, the number of bits of the second orange component value storage digit is 7, the number of bits of the second green component value storage digit is 7, and the number of bits of the second brightness component value storage digit is 8. The computer device may use 2 bits to store the identifier of the first lossy compression encoding method, use 2 bits to store the first 2 bits of the binary data of each orange component difference, use 3 bits to store the first 3 bits of the binary data of each green component difference, use 5 bits to store each brightness component difference, and use 7 bits to store the minimum orange component value, 7 bits to store the minimum green component value, and 8 bits to store the minimum brightness component value. It can be understood that the total number of the above storage bits is 64 bits. Among them, the identifier of the second lossy compression encoding method can be 10.

[0098] In this embodiment, if the computer device cannot perform lossy compression according to the first lossy compression encoding method, the computer device can perform lossy compression on the image blocks with greater brightness or chromaticity changes according to the second lossy compression encoding method, and store the difference and minimum value of each component, thereby ensuring that the lossy compressed data includes the component value of each component. Compared with the traditional compression method in which two brightness component values ​​directly share a set of chromaticity component values, the quality of image compression can be improved.

[0099] In one embodiment, the first chromaticity component is an orange component; the second chromaticity component is a green component; the maximum first chromaticity difference is a maximum orange difference; the maximum second chromaticity difference is a maximum green difference; according to the maximum brightness difference, the maximum first chromaticity difference and the maximum second chromaticity difference, selecting a target compression coding method matching the second image block data from preset compression coding methods includes: if the maximum brightness difference, the maximum orange difference and the maximum green difference meet the original space compression condition, then determining that the target compression coding method matching the second image block data is a primary color space compression coding method; compressing each image block in the same proportion according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio includes: according to the primary color space compression coding method, using the bit of the fifth identification storage bit number to store the identifier of the primary color space compression coding method, using the primary color space storage bit number to respectively store the first four preset bits of the binary data of each component value of each pixel in the first image block data in the primary color space, to obtain the primary color compressed data of the image block whose size meets the preset compression ratio.

[0100] The number of storage bits in the base color space is consistent with the fourth preset number of bits; and the total number of each storage bit is consistent with the total number of storage bits required for the preset compression ratio.

[0101] Specifically, the computer device can determine whether the maximum brightness difference, the maximum orange difference, and the maximum green difference meet the original space compression condition. If so, it is determined that the target compression encoding mode matched by the second image block data is the primary color space compression encoding mode. The computer device can use the bits of the fifth identification storage bit number to store the identifier of the primary color space compression encoding mode according to the primary color space compression encoding mode, and use the primary color space storage bit number to store the first four preset bits of binary data of each component value of each pixel in the first image block data in the primary color space, respectively, to obtain the primary color compressed data of the image block whose size meets the preset compression ratio.

[0102] In one embodiment, if the orange component difference is greater than the maximum value represented by the fourth preset number of bits, the computing computer device may intercept the data of the first fourth preset number of bits of the binary data of the orange component difference. If the green component difference is greater than the maximum value represented by the fourth preset number of bits, the computing computer device may intercept the data of the first fourth preset number of bits of the binary data of the green component difference. If the brightness component difference is greater than the maximum value represented by the fourth preset number of bits, the computing computer device may intercept the data of the first fourth preset number of bits of the binary data of the brightness component difference.

[0103] In one embodiment, the image block includes 4 pixels, the first image block data size is 96 bits, and the preset compression ratio is 2 / 3. The fifth identifier has 4 bits for storing the number of bits, and the primary color space has 5 bits for storing the number of bits. The computer device can use 4 bits to store the identifier of the primary color space compression encoding method, and use 5 bits to store the first 5 bits of the binary data of each component value of each pixel in the first image block data in the primary color space. It can be understood that the total number of each storage bit is 64 bits. Among them, the identifier of the primary color space compression encoding method can be 1111. The primary color space includes a red component, a green component, and a blue component.

[0104] In this embodiment, the computer device can use the bit of the fifth identification storage bit number to store the identifier of the primary color space compression encoding method according to the primary color space compression encoding method, and use the primary color space storage bit number to respectively store the first four preset bits of binary data of each component value of each pixel in the first image block data in the primary color space, to obtain the primary color compressed data of the image block whose size meets the preset compression ratio, and save the component values ​​of each component of the primary color space. Compared with the traditional compression method in which two brightness component values ​​directly share a set of chromaticity component values, the quality of image compression can be improved.

[0105] In one embodiment, Figure 3 As shown, the method also includes an image decoding step; the image decoding step includes:

[0106] Step 302: for the compressed data of each image block, determine the target decompression encoding method for the compressed data according to the identifier of the target compression encoding method in the compressed data.

[0107] Among them, the target decompression method corresponds one to one with the target compression encoding method.

[0108] Specifically, the computer device may determine the target decompression encoding method for the compressed data of each image block according to the identifier of the target compression encoding method in the compressed data.

[0109] In one embodiment, the preset compression coding method includes a first lossless compression coding method, a second lossless compression coding method, a first lossy compression coding method, a second lossy compression coding method, and a primary color space compression coding method. The identifiers of the first lossless compression coding method, the second lossless compression coding method, the first lossy compression coding method, the second lossy compression coding method, and the primary color space compression coding method are 1110, 110, 0, 10, and 1111, respectively.

[0110] Step 304, decompress the compressed data according to the target decompression method to obtain the target image.

[0111] Specifically, the computer device can decompress the compressed data according to the target decompression method to obtain the decompressed third image block data. If the target decompression method is the primary color space compression encoding method, the computer device can directly obtain the third image block data of the primary color space, that is, the third image block data in RGB format; if the target decompression method is not the primary color space compression encoding method, the computer device can convert the third image block data of the target color space, that is, the third image block data in YCoCg format, into the third image block data in RGB format. It can be understood that the computer device can obtain the third image block data in RGB format of each image block of the target image, thereby obtaining the data of the target image in RGB format, that is, the primary color image data under the primary color space.

[0112] In one embodiment, the computer device may convert the third image block data in the YCoCg format into the third image block data in the RGB format by using a second conversion formula. The second conversion formula is a formula for converting data in the target color space into the primary color space. The second conversion formula is:

[0113] R=Y+Co-Cg (4)

[0114] G=Y+Cg (5)

[0115] B=Y-Co-Cg (6)

[0116] In one embodiment, if the computer device recognizes that the target compression encoding method is identified as 1111, it determines that the target decompression encoding method for the compressed data is the primary color space decompression encoding method, and the computer device can decompress and encode the compressed data in the primary color space.

[0117] In one embodiment, the compressed data is binary data, and the computer device can convert the binary data into decimal data for decompression encoding. For example, the computer device can convert the binary data of the corresponding bits into decimal data by using a function that converts a binary number represented by a string into a decimal number, that is, a bin2dec function.

[0118] In one embodiment, the computer device may perform lossy compression encoding on the data. For the lossy compressed data after the lossy compression encoding, the computer device may use the weight value of the last bit of the lossy compressed data as a correction value to decompress the lossy compressed data.

[0119] In one embodiment, the target compression coding method is the primary color space compression coding method, and the target decompression coding method is the primary color space decompression coding method. The first to fourth bits of the primary color compression data are the identifier of the primary color space compression coding method, the fifth to twenty-fourth bits are the data of the first five bits in the binary data of the red component value of each pixel, the twenty-fifth to forty-fourth bits are the data of the first five bits in the binary data of the green component value of each pixel, and the forty-fifth to sixty-fourth bits are the data of the first five bits in the binary data of the green component value of each pixel. It can be understood that the computer device can decompress the component values ​​of each pixel in the primary color space in pixel order. For example, the fifth to ninth bits in the compressed data are the data of the first five bits in the binary data of the red component value (R1) of the first pixel. The computer device can convert the binary data of the fifth to ninth bits into decimal data, assign corresponding weights to the decimal data, and obtain the red component value of the first pixel after decompression coding after adding the correction value. Similarly, the computer device can obtain the remaining component values ​​of each pixel after decompression and encoding by decompressing and encoding the red component value of the first pixel.

[0120] In one embodiment, the computer device may first convert binary data into a string by using a function that converts digital data into character data, i.e., the str function, and then convert the string into decimal data by using a function that converts a binary number represented by a string into a decimal number, i.e., the bin2dec function, and then assign a corresponding weight to the decimal data, and after adding the correction value, obtain the red component value of the first pixel after decompression encoding. The weight is 8 and the correction value is 4. It can be understood that the computer device uses the primary color space compression encoding method, and the primary color compressed data obtained includes the first 5 bits of the binary data of each component value of each pixel in the first image block data in the primary color space, and the binary data of each component value has 8 bits, so the weight is 2 to the power of (8-3), i.e., 8. Since the computer device only stores the first five bits of the component value lossily, the weight value of the last bit of the lossily stored component value, i.e., the weight of the 6th bit, is used as the correction value. Taking R1 as an example, the computer device can calculate R1 through bin2dec(str(5:9))*8+4, that is, the red component value of the first pixel after decompression and encoding.

[0121] In one embodiment, the target compression encoding mode is the first lossy compression encoding mode, and the target decompression encoding mode is the first lossy decompression encoding mode. The first bit of the lossy compression data is the identifier of the first lossy compression encoding mode, the second to ninth bits are the minimum brightness component value (Ymin), the tenth to the sixteenth bits are the first seven bits of the binary data of the minimum orange component value (Comin), the seventeenth to the twenty-fourth bits are the minimum green component value (Cgmin), the twenty-fifth to the fortyth bits are the differences of each brightness component, the forty-first to the fifty-second bits are the first three bits of the binary data of each orange component difference, and the fifty-third to the forty-fourth bits are the first three bits of the binary data of each green component difference. It can be understood that the computer device can decompress the component values ​​of each pixel in the target color space in pixel order. For example, the 10th to 16th bits of the lossy compressed data are the first 7 bits of the binary data of the minimum orange component value (Comin). The computer device can convert the 10th to 16th bits of the binary data into decimal data, assign a corresponding weight (the weight is 2) to the decimal data, and add a correction value (the correction value is 1) to obtain the minimum orange component value after decompression and encoding, that is, Comin = bin2dec (str (10:16)) * 2 + 1. The 25th to 28th bits of the lossy compressed data are the brightness component difference value (DiffY1) of the first pixel, and the brightness component value (Y1) of the first pixel is the sum of the brightness component difference value and the minimum brightness component value, that is, Y1 = Ymin + DiffY1. Similarly, the computer device can perform decompression encoding to obtain the brightness component values ​​of the remaining pixels. The 41st to 43rd bits in the lossy compressed data are the first 3 bits of the binary data of the orange component difference (DiffCo1) of the first pixel. The computer device can convert the 41st to 43rd bits of the binary data into decimal data, assign a corresponding weight (the weight is 2) to the decimal data, and add a correction value (the correction value is 1) to obtain the decompressed and encoded DiffCo1, that is, DiffCo1=bin2dec(str(41:43))*2+1. The computer device can perform decompression encoding to obtain the orange component value (Co1) of the first pixel as the sum of the orange component difference and the minimum orange component value, that is, Co1=Comin+DiffCo1. Similarly, the computer device can perform decompression encoding to obtain the orange component values ​​of the remaining pixels.The 53rd to 55th bits in the lossy compressed data are the first 3 bits of the binary data of the green component difference (DiffCg1) of the first pixel. The same as the decompression encoding of the orange component difference, the green component difference of the first pixel is DiffCg1=bin2dec(str(53:55))*2+1. The computer device can perform decompression encoding to obtain the green component value (Cg1) of the first pixel as the sum of the green component difference and the minimum green component value, that is, Cg1=Cgmin+DiffCg1. Similarly, the computer device can perform decompression encoding to obtain the green component values ​​of the remaining pixels.

[0122] In one embodiment, the target compression encoding mode is the second lossy compression encoding mode, and the target decompression encoding mode is the second lossy decompression encoding mode. The first and second bits of the lossy compression data are the identifier of the second lossy compression encoding mode, the third to tenth bits are the minimum brightness component value (Ymin), the eleventh to the seventeenth bits are the first seven bits of the binary data of the minimum orange component value (Comin), the eighteenth to the twenty-fourth bits are the first seven bits of the binary data of the minimum green component value (Cgmin), the twenty-fifth to the forty-fourth bits are the first two bits of the binary data of each brightness component difference, the forty-fifth to the fifty-second bits are the first two bits of the binary data of each orange component difference, and the fifty-third to the forty-fourth bits are the first three bits of the binary data of each green component difference. It can be understood that the computer device can decompress the component values ​​of each pixel in the target color space in pixel order. For example, the 11th to 17th bits of the lossy compressed data are the first 7 bits of the binary data of the minimum orange component value (Comin). The computer device can convert the 11th to 17th bits of the binary data into decimal data, assign a corresponding weight (the weight is 2) to the decimal data, and add a correction value (the correction value is 1) to obtain the minimum orange component value after decompression and encoding, that is, Comin = bin2dec (str (11:17)) * 2 + 1. The 25th to 29th bits of the lossy compressed data are the brightness component difference value (DiffY1) of the first pixel, and the brightness component value (Y1) of the first pixel is the sum of the brightness component difference value and the minimum brightness component value, that is, Y1 = Ymin + DiffY1. Similarly, the computer device can perform decompression encoding to obtain the brightness component values ​​of the remaining pixels. The 45th to 46th bits in the lossy compressed data are the first 2 bits of the binary data of the orange component difference (DiffCo1) of the first pixel. The computer device can convert the 45th to 46th bits of binary data into decimal data, assign a corresponding weight (the weight is 4) to the decimal data, and add a correction value (the correction value is 2) to obtain the decompressed and encoded DiffCo1, that is, DiffCo1=bin2dec(str(45:46))*4+2. The computer device can perform decompression encoding to obtain the orange component value (Co1) of the first pixel as the sum of the orange component difference and the minimum orange component value, that is, Co1=Comin+DiffCo1. Similarly, the computer device can perform decompression encoding to obtain the orange component values ​​of the remaining pixels.The 53rd to 55th bits in the lossy compressed data are the first 3 bits of the binary data of the green component difference (DiffCg1) of the first pixel. The same as the decompression encoding of the orange component difference, the green component difference of the first pixel is DiffCg1=bin2dec(str(53:55))*2+1. The computer device can perform decompression encoding to obtain the green component value (Cg1) of the first pixel as the sum of the green component difference and the minimum green component value, that is, Cg1=Cgmin+DiffCg1. Similarly, the computer device can perform decompression encoding to obtain the green component values ​​of the remaining pixels.

[0123] In one embodiment, the target compression encoding mode is the second lossless compression encoding mode, and the target decompression encoding mode is the second lossless decompression encoding mode. Bits 1 to 3 of the lossless compression data are the identifier of the second lossless compression encoding mode, bits 4 to 11 are the minimum brightness component value (Ymin), bits 12 to 19 are the minimum orange component value (Comin), bits 20 to 27 are the minimum green component value (Cgmin), bits 28 to 39 are the brightness component difference values, bits 40 to 51 are the orange component difference values, and bits 52 to 63 are the green component difference values. It can be understood that the computer device can decompress the component values ​​of each pixel in the target color space in pixel order. For example, the 4th to 11th bits in the lossless compressed data are the minimum brightness component value (Ymin), and the 28th to 30th bits in the lossy compressed data are the brightness component difference value (DiffY1) of the first pixel, then the brightness component value (Y1) of the first pixel is the sum of the brightness component difference value and the minimum brightness component value, that is, Y1 = Ymin + DiffY1. Similarly, the computer device can perform decompression encoding to obtain the component values ​​of each pixel.

[0124] In one embodiment, the target compression encoding method is the first lossless compression encoding method, and the target decompression encoding method is the first lossless decompression encoding method. The 1st to 4th bits of the lossless compression data are the identifier of the first lossless compression encoding method, the 5th to 36th bits are the brightness component values, the 37th to 44th bits are the minimum orange component value (Comin), the 45th to 52nd bits are the minimum green component value (Cgmin), the 53rd to 56th bits are the orange component difference values, and the 57th to 64th bits are the green component difference values. It can be understood that the computer device can decompress the component values ​​of each pixel in the target color space in pixel order. For example, the 5th to 12th bits in the lossless compression data are the brightness component values ​​(Y1) of the first pixel, and so on, the computer device can obtain the brightness component values ​​of the remaining pixels after decompression encoding. The 37th to 44th bits of the lossy compressed data are the minimum orange component value (Comin), and the 53rd bit is the orange component value (DiffCo1) of the first pixel. The orange component value (Co1) of the first pixel is the sum of the brightness component difference and the minimum brightness component value, that is, Co1 = Comin + DiffCo1. Similarly, the computer device can perform decompression encoding to obtain the orange component values ​​and green component values ​​of each pixel.

[0125] In this embodiment, for the compressed data of each image block, the target decompression encoding method for the compressed data is determined according to the identifier of the target compression encoding method in the compressed data; the compressed data is decompressed according to the target decompression method to obtain the target image, and the compressed image can be decompressed. Due to the improvement of image compression quality, the decompressed target image is clearer than the traditional decompressed image.

[0126] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0127] Based on the same inventive concept, the embodiment of the present application also provides an image compression device for implementing the above-mentioned image compression method. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above-mentioned method, so the specific limitations in one or more image compression device embodiments provided below can refer to the limitations on the image compression method above, and will not be repeated here.

[0128] In one embodiment, Figure 4 As shown, an image compression device 400 is provided, comprising: an acquisition module 402, a matching module 404 and a compression module 406, wherein:

[0129] The acquisition module 402 is used to acquire, for each image block in the target image to be compressed, first image block data of the image block in the primary color space; convert the first image block data into second image block data in the target color space; the target color space includes a brightness component, a first chroma component and a second chroma component; the second image block data includes component values ​​of each pixel in the image block under the brightness component, the first chroma component and the second chroma component respectively.

[0130] A matching module 404 is used to determine, for each of the brightness component, the first chroma component and the second chroma component, the difference between the maximum component value and the minimum component value of the image block under the component based on the second image block data, so as to obtain a maximum brightness difference value, a maximum first chroma difference value and a maximum second chroma difference value; and select a target compression encoding method that matches the second image block data from preset compression encoding methods according to the maximum brightness difference value, the maximum first chroma difference value and the maximum second chroma difference value.

[0131] The compression module 406 is used to compress each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio; the compressed data of each image block includes the corresponding identifier of the target compression coding method; the identifier is used to indicate that the compressed data of the corresponding image block is to be decompressed.

[0132] In one embodiment, the first chromaticity component is an orange component; the second chromaticity component is a green component; the maximum first chromaticity difference is a maximum orange difference; the maximum second chromaticity difference is a maximum green difference; the matching module 404 is further configured to determine that the target compression encoding method matched by the second image block data is the first lossless compression encoding method if the maximum orange difference and the maximum green difference meet the first lossless compression condition; the compression module 406 is further configured to obtain the orange component difference between the orange component value of each pixel in the second image block data and the minimum orange component value, and obtain the second image block the green component values ​​of each pixel in the data and the green component differences between the minimum green component value; according to the first lossless compression encoding method, using the bits of the first identification storage bit number to store the identifier of the first lossless compression encoding method, using the bits of the first orange difference storage bit number and the first green difference storage bit number to respectively store the orange component differences and the green component differences, and using the bits of the first component value storage bit number to respectively store the minimum green component value, the minimum orange component value and the component values ​​of each pixel under the brightness component, to obtain lossless compressed data of an image block whose size meets the preset compression ratio.

[0133] In one embodiment, the matching module 404 is further used to determine that the target compression encoding mode matched by the second image block data is the second lossless compression encoding mode if the maximum brightness difference, the maximum orange difference and the maximum green difference meet the second lossless compression condition; the second lossless compression condition is greater than the maximum green difference and the maximum orange difference required by the first lossless compression condition; the compression module 406 is further used to obtain the brightness component difference between the brightness component value of each pixel in the second image block data and the minimum brightness component value; according to the second lossless compression encoding mode, the bit positions of the second identification storage bit number are used to store the identifier of the second lossless compression encoding mode, the bits of the second orange difference storage bit number, the second green difference storage bit number and the first brightness difference storage bit number are used to respectively store the orange component difference, the green component difference and the brightness component difference, and the bits of the second component value storage bit number are used to respectively store the minimum green component value, the minimum orange component value and the minimum brightness component value, so as to obtain lossless compressed data of an image block whose size meets the preset compression ratio.

[0134] In one embodiment, the first chromaticity component is an orange component; the second chromaticity component is a green component; the maximum first chromaticity difference is a maximum orange difference; the maximum second chromaticity difference is a maximum green difference; the matching module 404 is further used to determine that the target compression encoding method matched by the second image block data is a first lossy compression encoding method if the maximum brightness difference, the maximum orange difference and the maximum green difference meet the first lossy compression condition; the compression module 406 is further used to obtain the brightness component difference between the brightness component value of each pixel in the second image block data and the minimum brightness component value; according to the first lossy compression encoding method, The invention discloses a method for encoding a lossy compression image block, wherein the bit positions of the third identification storage bit number are used to store the identification of the first lossy compression encoding method, the bit positions of the first lossy difference storage bit number are used to respectively store the data of the first preset number of bits in the binary data of each of the orange component difference values ​​and each of the green component difference values, the bit positions of the second brightness difference storage bit number are used to respectively store each of the brightness component difference values, and the first orange component value storage bit position, the first green component value storage bit position and the first brightness component value storage bit position are used to respectively store the minimum orange component value, the minimum green component value and the minimum brightness component value, so as to obtain lossy compressed data of an image block whose size meets the preset compression ratio.

[0135] In one embodiment, the matching module 404 is further configured to determine that the target compression encoding mode for matching the second image block data is the second lossy compression encoding mode if the maximum brightness difference value, the maximum orange difference value, and the maximum green difference value meet the second lossy compression condition; the compression loss of the second lossy compression encoding mode is higher than the compression loss of the first lossy compression encoding mode; the compression module 406 is further configured to, according to the second lossy compression encoding mode, use the bit positions of the fourth identification storage bit position to store the identifier of the second lossy compression encoding mode, use the orange lossy difference storage bit position to store the data of the first second preset bit positions in the binary data of each orange component difference value, use the bit positions of the green lossy difference storage bit position to store the data of the first third preset bit positions in the binary data of each green component difference value, use the bit positions of the third brightness difference storage bit position to store each brightness component difference value, and use the second orange component value storage bit position, the second green component value storage bit position, and the second brightness component value storage bit position to respectively store the minimum orange component value, the minimum green component value, and the minimum brightness component value, so as to obtain lossy compressed data of an image block whose size meets the preset compression ratio.

[0136] In one embodiment, the first chromaticity component is an orange component; the second chromaticity component is a green component; the maximum first chromaticity difference is a maximum orange difference; the maximum second chromaticity difference is a maximum green difference; the matching module 404 is also used to determine that the target compression encoding method matched by the second image block data is a primary color space compression encoding method if the maximum brightness difference, the maximum orange difference and the maximum green difference meet the original space compression condition; the compression module 406 is also used to store the identifier of the primary color space compression encoding method using the bits of the fifth identifier storage bit number, and use the primary color space storage bit number to store the first four preset bits of binary data of each component value of each pixel in the first image block data in the primary color space according to the primary color space compression encoding method, so as to obtain primary color compressed data of an image block whose size meets the preset compression ratio.

[0137] In one embodiment, the device also includes a decompression module 406; the decompression module 406 is used to determine the target decompression encoding method for the compressed data of each image block according to the identifier of the target compression encoding method in the compressed data; the target decompression method corresponds to the target compression encoding method one by one; the compressed data is decompressed according to the target decompression method to obtain the target image.

[0138] Each module in the above-mentioned image compression device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.

[0139] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store image compression related data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an image compression method is implemented.

[0140] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface, the display unit and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, an image compression method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.

[0141] Those skilled in the art will understand that Figure 5 and Figure 6The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0142] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0143] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0144] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0145] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0146] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0147] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0148] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. An image compression method, characterized in that: The method comprises: For each image block in the target image to be compressed, obtaining first image block data of the image block in a primary color space; Converting the first image block data into second image block data in a target color space; the target color space includes a brightness component, a first chroma component, and a second chroma component; the second image block data includes component values ​​of each pixel in the image block under the brightness component, the first chroma component, and the second chroma component, respectively; For each of the brightness component, the first chroma component and the second chroma component, determine the difference between the maximum component value and the minimum component value of the image block under the component based on the second image block data to obtain a maximum brightness difference value, a maximum first chroma difference value and a maximum second chroma difference value; wherein the first chroma component is an orange component; the second chroma component is a green component; the maximum first chroma difference value is a maximum orange difference value; and the maximum second chroma difference value is a maximum green difference value; Selecting a target compression encoding method matching the second image block data from preset compression encoding methods according to the maximum brightness difference value, the maximum first chroma difference value, and the maximum second chroma difference value; Compressing each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio; the compressed data of each image block includes the corresponding identifier of the target compression coding method; the identifier is used to indicate that the compressed data of the corresponding image block is to be decompressed; The step of selecting a target compression encoding method matching the second image block data from preset compression encoding methods according to the maximum brightness difference value, the maximum first chromaticity difference value, and the maximum second chromaticity difference value includes: If the maximum orange difference and the maximum green difference meet the first lossless compression condition, determining that the target compression encoding mode matched by the second image block data is the first lossless compression encoding mode; The step of compressing each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio includes: Obtaining orange component differences between the orange component values ​​of each pixel in the second image block data and the minimum orange component value, and obtaining green component differences between the green component values ​​of each pixel in the second image block data and the minimum green component value; According to the first lossless compression encoding method, the first identification storage bit number is used to store the identification of the first lossless compression encoding method, the first orange difference storage bit number and the first green difference storage bit number are used to store the orange component difference values ​​and the green component difference values ​​respectively, and the first component value storage bit number is used to store the minimum green component value, the minimum orange component value and the component values ​​of each pixel under the brightness component respectively, to obtain lossless compression data of an image block whose size meets the preset compression ratio; The number of first orange difference storage bits and the number of first green difference storage bits match the maximum orange difference and the maximum green difference respectively; the total number of each storage bit matches the total number of storage bits required for the preset compression ratio.

2. The method according to claim 1, characterized in that The method further comprises: If the maximum brightness difference, the maximum orange difference and the maximum green difference meet a second lossless compression condition, determining that the target compression encoding mode matched by the second image block data is a second lossless compression encoding mode; and the second lossless compression condition is greater than the maximum green difference and the maximum orange difference required by the first lossless compression condition; Obtaining brightness component differences between brightness component values ​​of each pixel in the second image block data and the minimum brightness component value; According to the second lossless compression encoding method, the bit positions of the second identification storage bit position are used to store the identifier of the second lossless compression encoding method, the bit positions of the second orange difference value storage bit position, the second green difference value storage bit position and the first brightness difference value storage bit position are used to store the orange component difference values, the green component difference values ​​and the brightness component difference values ​​respectively, and the bit positions of the second component value storage bit position are used to store the minimum green component value, the minimum orange component value and the minimum brightness component value respectively, to obtain lossless compressed data of an image block whose size meets the preset compression ratio; Among them, the number of bits for storing the second orange difference and the number of bits for storing the second green difference respectively match the maximum orange difference and the maximum green difference; the number of bits for storing the first brightness difference matches the maximum brightness difference; the total number of each storage bit is consistent with the total number of storage bits required for the preset compression ratio.

3. The method according to claim 1, characterized in that The step of selecting a target compression encoding method matching the second image block data from preset compression encoding methods according to the maximum brightness difference value, the maximum first chromaticity difference value, and the maximum second chromaticity difference value includes: If the maximum brightness difference value, the maximum orange difference value and the maximum green difference value meet the first lossy compression condition, determining that the target compression encoding mode matched by the second image block data is the first lossy compression encoding mode; The step of compressing each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio includes: Obtaining brightness component differences between brightness component values ​​of each pixel in the second image block data and the minimum brightness component value; According to the first lossy compression encoding mode, the bit positions of the third identification storage bit position are used to store the identification of the first lossy compression encoding mode, the bit positions of the first lossy difference storage bit position are used to respectively store the data of the first preset bit positions in the binary data of each of the orange component difference values ​​and each of the green component difference values, the bit positions of the second brightness difference storage bit position are used to respectively store each of the brightness component difference values, and the first orange component value storage bit position, the first green component value storage bit position and the first brightness component value storage bit position are used to respectively store the minimum orange component value, the minimum green component value and the minimum brightness component value, to obtain lossy compressed data of an image block whose size meets the preset compression ratio; Among them, the first preset number of bits matches the first lossy difference storage number of bits; the second brightness difference storage number of bits matches the maximum brightness difference; the total number of each storage bit number matches the total number of storage bits required for the preset compression ratio.

4. The method according to claim 3, characterized in that The method further comprises: If the maximum brightness difference value, the maximum orange difference value, and the maximum green difference value meet a second lossy compression condition, determining that the target compression encoding method matched by the second image block data is a second lossy compression encoding method; the compression loss of the second lossy compression encoding method is higher than the compression loss of the first lossy compression encoding method; According to the second lossy compression encoding mode, the bit positions of the fourth identification storage bit number are used to store the identification of the second lossy compression encoding mode, the orange lossy difference storage bit positions are used to store the data of the first second preset bit positions in the binary data of each orange component difference value, the bit positions of the green lossy difference storage bit positions are used to store the data of the first third preset bit positions in the binary data of each green component difference value, the bit positions of the third brightness difference storage bit positions are used to store each brightness component difference value, and the second orange component value storage bit positions, the second green component value storage bit positions and the second brightness component value storage bit positions are used to store the minimum orange component value, the minimum green component value and the minimum brightness component value respectively, to obtain lossy compressed data of an image block whose size meets the preset compression ratio; Among them, the number of bits for storing orange lossy differences is less than the number of bits for storing green lossy differences; the number of bits for storing orange lossy differences is consistent with the second preset number of bits, and the number of bits for storing green lossy differences is consistent with the third preset number of bits; the number of bits for storing the third brightness difference matches the maximum brightness difference; and the total number of each storage bit number is consistent with the total number of storage bits required for the preset compression ratio.

5. The method according to claim 1, characterized in that The first chromaticity component is an orange component; the second chromaticity component is a green component; the maximum first chromaticity difference is a maximum orange difference; The maximum second chromaticity difference is the maximum green difference; and selecting a target compression encoding method matching the second image block data from preset compression encoding methods according to the maximum brightness difference, the maximum first chromaticity difference and the maximum second chromaticity difference includes: If the maximum brightness difference, the maximum orange difference and the maximum green difference meet the original space compression condition, determining that the target compression encoding mode matched by the second image block data is the primary color space compression encoding mode; The step of compressing each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio includes: According to the primary color space compression coding method, using the bit of the fifth identification storage bit number to store the identification of the primary color space compression coding method, using the primary color space storage bit number to respectively store the first four preset bit numbers of the binary data of each component value of each pixel in the first image block data in the primary color space, to obtain the primary color compressed data of the image block whose size meets the preset compression ratio; The number of storage bits in the primary color space is consistent with a fourth preset number of bits; and the total number of each storage bit is consistent with the total number of storage bits required for the preset compression ratio.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises an image decoding step; the image decoding step comprises: For the compressed data of each image block, a target decompression encoding mode for the compressed data is determined according to an identifier of the target compression encoding mode in the compressed data; the target decompression mode corresponds to the target compression encoding mode in a one-to-one manner; The compressed data is decompressed according to the target decompression mode to obtain the target image.

7. An image compression device, characterized in that: The device comprises: An acquisition module is used to acquire, for each image block in a target image to be compressed, first image block data of the image block in a primary color space; convert the first image block data into second image block data in a target color space; the target color space includes a brightness component, a first chroma component, and a second chroma component; the second image block data includes component values ​​of each pixel in the image block under the brightness component, the first chroma component, and the second chroma component, respectively; wherein the first chroma component is an orange component; and the second chroma component is a green component; a matching module, configured to determine, for each of the brightness component, the first chroma component, and the second chroma component, a difference between a maximum component value and a minimum component value of the image block under the component based on the second image block data, so as to obtain a maximum brightness difference value, a maximum first chroma difference value, and a maximum second chroma difference value; and select, according to the maximum brightness difference value, the maximum first chroma difference value, and the maximum second chroma difference value, a target compression encoding method matching the second image block data from preset compression encoding methods; wherein the maximum first chroma difference value is a maximum orange difference value; and the maximum second chroma difference value is a maximum green difference value; A compression module, used to compress each image block in the same proportion according to a corresponding target compression coding method to obtain compressed data of each image block that meets a preset compression ratio; the compressed data of each image block includes an identifier of the corresponding target compression coding method; the identifier is used to indicate that the compressed data of the corresponding image block is to be decompressed; The matching module is further configured to determine that the target compression encoding mode matched by the second image block data is the first lossless compression encoding mode if the maximum orange difference value and the maximum green difference value meet the first lossless compression condition; The step of compressing each image block at the same ratio according to the corresponding target compression coding method to obtain compressed data of each image block that meets the preset compression ratio includes: Obtaining orange component differences between the orange component values ​​of each pixel in the second image block data and the minimum orange component value, and obtaining green component differences between the green component values ​​of each pixel in the second image block data and the minimum green component value; According to the first lossless compression encoding method, the first identification storage bit number is used to store the identification of the first lossless compression encoding method, the first orange difference storage bit number and the first green difference storage bit number are used to store the orange component difference values ​​and the green component difference values ​​respectively, and the first component value storage bit number is used to store the minimum green component value, the minimum orange component value and the component values ​​of each pixel under the brightness component respectively, to obtain lossless compression data of an image block whose size meets the preset compression ratio; The number of first orange difference storage bits and the number of first green difference storage bits match the maximum orange difference and the maximum green difference respectively; the total number of each storage bit matches the total number of storage bits required for the preset compression ratio.

8. The device according to claim 7, characterized in that The matching module is further configured to determine that the target compression encoding mode for matching the second image block data is a second lossless compression encoding mode if the maximum brightness difference, the maximum orange difference, and the maximum green difference meet a second lossless compression condition; the second lossless compression condition is greater than the maximum green difference and the maximum orange difference required by the first lossless compression condition; Obtain the brightness component difference between the brightness component value of each pixel in the second image block data and the minimum brightness component value; according to the second lossless compression encoding method, use the bit of the second identification storage bit number to store the identifier of the second lossless compression encoding method, use the bit of the second orange difference storage bit number, the second green difference storage bit number and the first brightness difference storage bit number to respectively store the orange component difference values, the green component difference values ​​and the brightness component difference values, and use the bit of the second component value storage bit number to respectively store the minimum green component value, the minimum orange component value and the minimum brightness component value, so as to obtain lossless compressed data of an image block whose size meets the preset compression ratio; wherein the second orange difference storage bit number and the second green difference storage bit number match the maximum orange difference value and the maximum green difference value respectively; the first brightness difference storage bit number matches the maximum brightness difference value; and the total number of each storage bit number matches the total storage bit number required for the preset compression ratio.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Image data compression and decompression method and device

    CN103517022A

  • Image compression method and image processing apparatus

    CN104025561A