Image compression method and device, image decompression method and device, storage medium and electronic equipment

By converting the image from RGB color space to YCoCg color space, and performing row merging processing and compression scheme traversal of each component, the problem of difficult to balance the compression ratio and image quality in high-resolution image compression is solved, and efficient data volume compression and low visual distortion are achieved.

CN119728990APending Publication Date: 2025-03-28SHENZHEN AIXIESHENG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411892050.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The prior art is difficult to maintain a high compression ratio and good image quality while simultaneously in the compression of high-resolution images, especially in images with complex scenes and more details.

Method used

By converting the original image from the RGB color space to the YCoCg color space, row merging processing and compression scheme traversal of the brightness component, the first chrominance component and the second chrominance component are respectively determined, and the target compression scheme is used for compression processing.

Benefits of technology

It achieves a high compression ratio while ensuring image quality, makes full use of the difference in sensitivity of the human eye to brightness and chromaticity, and reduces visual distortion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728990A_ABST
    Figure CN119728990A_ABST
Patent Text Reader

Abstract

The invention discloses an image compression method and device, an image decompression method and device, a storage medium and electronic equipment, and the image compression method comprises the steps: obtaining an original image; converting the original image from an RGB color space to a YCoCg color space to obtain a brightness component, a first chrominance component and a second chrominance component; performing row combination processing on the first chrominance component and the second chrominance component to obtain a first compression component and a second compression component; traversing all the compression schemes based on the brightness component, the first compression component and the second compression component, and determining a corresponding target compression scheme according to a traversing result; and performing compression processing on the brightness component, the first compression component and the second compression component by adopting a corresponding target compression scheme. According to the scheme, a relatively high compression ratio can be realized on the premise of ensuring the image quality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of image processing technology, and specifically to an image compression method, a decompression method, a device, a storage medium, and an electronic device. Background Art

[0002] With the rapid development of modern display technology, image resolution and display device performance are constantly improving, from traditional standard definition resolution to high definition (HD), ultra-high definition (4K / 8K) and other higher resolutions. This trend has greatly increased the amount of image data, resulting in increased burdens on image storage, transmission and display, especially in the case of limited bandwidth and storage resources. Therefore, how to achieve a high compression ratio while ensuring image quality has become an important topic in the field of image processing.

[0003] Although existing image compression methods have been successful to a certain extent, most methods still face difficulties in compressing high-resolution images, especially in complex scenes and images with more details. Traditional compression algorithms often find it difficult to maintain a high compression ratio and good image quality at the same time. Summary of the invention

[0004] The embodiments of the present application provide an image compression method, a decompression method, an apparatus, a storage medium, and an electronic device, which can achieve a higher compression ratio while ensuring image quality.

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

[0006] Get the original image;

[0007] Convert the original image from the RGB color space to the YCoCg color space to obtain a luminance component, a first chrominance component, and a second chrominance component;

[0008] Performing line merging processing on the first chroma component and the second chroma component respectively to obtain a first compressed component and a second compressed component;

[0009] Traversing all compression schemes based on the brightness component, the first compression component, and the second compression component respectively, and determining a corresponding target compression scheme according to the traversal results;

[0010] The brightness component, the first compressed component and the second compressed component are compressed respectively using the corresponding target compression scheme.

[0011] In the image compression method provided in the embodiment of the present application, traversing all compression schemes based on the brightness component, the first compression component, and the second compression component respectively, and determining the corresponding target compression scheme according to the traversal results, includes:

[0012] Dividing the brightness component, the first compression component and the second compression component into units respectively to obtain a plurality of first compression units, a plurality of second compression units and a plurality of third compression units;

[0013] For each of the first compression units, each of the second compression units or each of the third compression units, the decoding errors of all compression schemes are calculated respectively, and the compression scheme with the smallest decoding error is selected as the target compression scheme corresponding to the first compression unit, the second compression unit or the third compression unit.

[0014] In the image compression method provided in the embodiment of the present application, the step of calculating the decoding errors of all compression schemes includes:

[0015] sequentially compressing each of the first compression units, each of the second compression units, or each of the third compression units using each compression scheme to obtain a number of compressed data;

[0016] Decompressing the compressed data respectively by using corresponding decompression schemes to obtain decompressed data;

[0017] The sum of errors between each decompressed data and each corresponding first compression unit, each second compression unit or each third compression unit is calculated respectively to obtain a decoding error corresponding to the compression scheme.

[0018] In the image compression method provided in the embodiment of the present application, the performing row merging processing on the first chroma component and the second chroma component respectively to obtain the first compressed component and the second compressed component includes:

[0019] The pixel values ​​of two adjacent rows in the same column of the first chrominance component and the second chrominance component are respectively merged into one row of pixel values ​​to obtain a first compressed component and a second compressed component.

[0020] In the image compression method provided in the embodiment of the present application, the performing row merging processing on the first chroma component and the second chroma component respectively to obtain the first compressed component and the second compressed component includes:

[0021] Determine odd rows, even rows, odd columns, and even columns in the first chrominance component and the second chrominance component, respectively;

[0022] In the first chrominance component and the second chrominance component, the pixel values ​​of the even columns of each of the odd rows are removed, and the pixel values ​​of the odd columns of each of the even rows are removed to obtain the first compressed component and the second compressed component.

[0023] In a second aspect, an embodiment of the present application provides an image decompression method, comprising:

[0024] Get compressed data;

[0025] Decompressing the compressed data using a corresponding decompression scheme to obtain a brightness component, a first compressed component, and a second compressed component;

[0026] Performing interpolation processing on the first compressed component and the second compressed component respectively to obtain a first chrominance component and a second chrominance component;

[0027] The YCoCg color space composed of the luminance component, the first chrominance component and the second chrominance component is converted into an RGB color space to obtain an original image.

[0028] In a third aspect, an embodiment of the present application provides an image compression device, including:

[0029] An image acquisition unit, used for acquiring an original image;

[0030] A space conversion unit, used for converting the original image from the RGB color space to the YCoCg color space to obtain a brightness component, a first chrominance component, and a second chrominance component;

[0031] a component merging unit, configured to perform line merging processing on the first chroma component and the second chroma component respectively to obtain a first compressed component and a second compressed component;

[0032] A component traversal unit, configured to traverse all compression schemes based on the brightness component, the first compression component, and the second compression component, respectively, and determine a corresponding target compression scheme according to the traversal result;

[0033] A component compression unit is used to respectively compress the brightness component, the first compressed component and the second compressed component using the corresponding target compression scheme.

[0034] In a fourth aspect, an embodiment of the present application provides an image decompression device, comprising:

[0035] A data acquisition unit, used for acquiring compressed data;

[0036] A data decompression unit, configured to decompress the compressed data using a corresponding decompression scheme to obtain a brightness component, a first compressed component, and a second compressed component;

[0037] a component interpolation unit, configured to perform interpolation processing on the first compressed component and the second compressed component respectively to obtain a first chrominance component and a second chrominance component;

[0038] The space restoration unit is used to restore the YCoCg color space composed of the brightness component, the first chrominance component and the second chrominance component to the RGB color space to obtain the original image.

[0039] In a fifth aspect, the present application provides a storage medium storing a plurality of instructions, wherein the instructions are suitable for loading by a processor to execute any of the methods described above.

[0040] In a sixth aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the methods described above when executing the computer program.

[0041] In summary, the image compression method provided by the embodiment of the present application includes obtaining an original image; converting the original image from the RGB color space to the YCoCg color space to obtain a brightness component, a first chromaticity component, and a second chromaticity component; performing row merging processing on the first chromaticity component and the second chromaticity component respectively to obtain a first compressed component and a second compressed component; traversing all compression schemes based on the brightness component, the first compressed component, and the second compressed component respectively, and determining the corresponding target compression scheme according to the traversal results; and compressing the brightness component, the first compressed component, and the second compressed component respectively using the corresponding target compression scheme. This scheme fully utilizes the difference in sensitivity of the human eye to brightness and chromaticity by compressing the brightness component, the first chromaticity component, and the second chromaticity component respectively using different compression schemes, thereby achieving efficient data compression and low visual distortion. That is, this scheme can achieve a higher compression ratio while ensuring image quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0043] Figure 1 It is a flowchart of the image compression method provided in an embodiment of the present application.

[0044] Figure 2 It is the first conversion formula provided in the embodiment of the present application.

[0045] Figure 3 It is a flowchart of the image decompression method provided in an embodiment of the present application.

[0046] Figure 4 It is the second conversion formula provided in the embodiment of the present application.

[0047] Figure 5 It is a structural schematic diagram of the image compression device provided in an embodiment of the present application.

[0048] Figure 6 This is a schematic diagram of the structure of the image decompression device provided in the embodiment of the present application.

[0049] Figure 7 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0051] It should be noted that, in this article, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element. In addition, components, features, and elements with the same name in different embodiments of the present application may have the same meaning or different meanings, and their specific meanings need to be determined by their explanation in the specific embodiment or further combined with the context of the specific embodiment.

[0052] 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.

[0053] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present application, and have no specific meanings. Therefore, "module", "component" or "unit" can be used in a mixed manner.

[0054] In the description of the present application, it should be noted that the terms "upper", "lower", "left", "right", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present application. In addition, terms such as "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.

[0055] Current image compression methods still face difficulties in compressing high-resolution images, especially in complex scenes and images with more details. Traditional compression algorithms often find it difficult to maintain a high compression ratio and good image quality at the same time.

[0056] Based on this, the embodiments of the present application provide an image compression method, a decompression method, a device, a storage medium and an electronic device. Specifically, the image compression device and the decompression device can be integrated in an electronic device, and the electronic device can be a server or a terminal. Among them, the terminal can include a mobile phone, a wearable smart device, a tablet computer, a laptop computer, and a personal computer (PC), etc.; the server can be a single server or a server cluster composed of multiple servers, and can be a physical server or a virtual server.

[0057] For example, after acquiring the original image, the electronic device can convert the original image from the RGB color space to the YCoCg color space to obtain a brightness component, a first chromaticity component, and a second chromaticity component; then, perform row merging processing on the first chromaticity component and the second chromaticity component respectively to obtain a first compressed component and a second compressed component; then, traverse all compression schemes based on the brightness component, the first compressed component, and the second compressed component respectively, and determine the corresponding target compression scheme according to the traversal results; finally, use the corresponding target compression scheme to compress the brightness component, the first compressed component, and the second compressed component respectively.

[0058] For another example, after acquiring the compressed data, the electronic device can use a corresponding decompression scheme to decompress the compressed data to obtain a brightness component, a first compressed component, and a second compressed component; interpolate the first compressed component and the second compressed component respectively to obtain a first chroma component and a second chroma component; convert the YCoCg color space composed of the brightness component, the first chroma component and the second chroma component into an RGB color space to obtain the original image.

[0059] The technical solutions shown in the present application will be described in detail below through specific embodiments. It should be noted that the description order of the following embodiments is not intended to limit the priority order of the embodiments.

[0060] See also Figure 1 , Figure 1 : is a flow chart of the image compression method provided in the embodiment of the present application. The specific flow of the image compression method can be as follows:

[0061] 101. Obtain the original image.

[0062] The original image may be an image obtained by a digital camera, a scanner, a network download or any other image acquisition device. The type of the original image may be a static image, such as a picture in JPEG, PNG, or BMP format, or a dynamic image, such as a video sequence.

[0063] 102. Convert the original image from the RGB color space to the YCoCg color space to obtain a brightness component, a first chrominance component, and a second chrominance component.

[0064] In a specific implementation process, after the original image is obtained, the original image can be converted from the RGB color space to the YCoCg color space to obtain the brightness component Y, the first chromaticity component Co, and the second chromaticity component Cg corresponding to the original image.

[0065] Specifically, a linear transformation can be used to convert the original image from the RGB color space to the YCoCg color space. The conversion formula can be as follows: Figure 2 shown.

[0066] 103. Perform line merging processing on the first chrominance component and the second chrominance component respectively to obtain a first compressed component and a second compressed component.

[0067] In some embodiments, pixel values ​​of two adjacent rows in the same column of the first chrominance component and the second chrominance component may be merged into one row of pixel values ​​to obtain the first compressed component and the second compressed component.

[0068] Specifically, all rows of the first chromaticity component Co and the second chromaticity component Cg can be divided into groups of two rows (the first row and the second row are grouped together, the third row and the fourth row are grouped together, and so on, until the last two rows). For each group of two rows of data, the average of the pixel values ​​in the same column is calculated, and the average is used as the value of the merged data, thereby achieving the effect of reducing the amount of data by half, that is, a 2-fold compression ratio.

[0069] In another embodiment, the data amount in the row and column directions can be halved by selectively retaining specific pixel values ​​in the first chrominance component Co and the second chrominance component Cg, thereby achieving a 2-fold compression ratio.

[0070] Specifically, the pixel values ​​of each row in the first chroma component and the second chroma component are divided into odd columns and even columns according to the number of columns. The pixel values ​​of the odd columns are retained in the odd rows, and the pixel values ​​of the even columns are discarded. The pixel values ​​of the even columns are retained in the even rows, and the pixel values ​​of the odd columns are discarded. After processing, most of the data of the first chroma component and the second chroma component are discarded, and only the pixel values ​​that meet the conditions are retained, thereby halving the data amount to obtain the first compressed component and the second compressed component.

[0071] The following description is made by taking the first chrominance component Co as an example.

[0072] For example, the first chrominance component Co is as follows:

[0073] Co11 Co12 Co13 Co14 Co15 Co16 Co21 Co22 Co23 Co24 Co25 Co26

[0074] Then, the corresponding pixel values ​​saved are as follows:

[0075] Co11 Co13 Co15 Co22 Co24 Co26

[0076] The first compression component is as follows:

[0077] Co11 Co22 Co13 Co24 Co15 Co26

[0078] That is, step 103 may specifically be: determining odd rows, even rows, odd columns, and even columns in the first chrominance component and the second chrominance component, respectively. In the first chrominance component and the second chrominance component, removing the pixel values ​​of the even columns of each odd row, and removing the pixel values ​​of the odd columns of each even row, to obtain the first compressed component and the second compressed component.

[0079] 104. Traverse all compression schemes based on the brightness component, the first compression component, and the second compression component respectively, and determine a corresponding target compression scheme according to the traversal results.

[0080] It should be noted that in the embodiment of the present application, when compressing the brightness component, the first compression component or the second compression component, two rows and three columns are used as a compression unit for compression, and each unit contains 6 pixel values. Each pixel value is usually represented by 8 bits, so the total data volume of each compression unit is 48 bits.

[0081] Therefore, before compression, the brightness component, the first compressed component and the second compressed component may be divided into units to obtain a plurality of first compressed units, a plurality of second compressed units and a plurality of third compressed units.

[0082] Afterwards, for each first compression unit, each second compression unit or each third compression unit, the decoding errors of all compression schemes are calculated respectively, and the compression scheme with the smallest decoding error is selected as the target compression scheme corresponding to the first compression unit, the second compression unit or the third compression unit.

[0083] Specifically, for each first compression unit, the decoding errors of all compression schemes can be calculated respectively, and the compression scheme with the smallest decoding error is selected as the target compression scheme corresponding to the first compression unit. For each second compression unit, the decoding errors of all compression schemes can be calculated respectively, and the compression scheme with the smallest decoding error is selected as the target compression scheme corresponding to the second compression unit. For each third compression unit, the decoding errors of all compression schemes can be calculated respectively, and the compression scheme with the smallest decoding error is selected as the target compression scheme corresponding to the third compression unit.

[0084] The decoding errors of all compression schemes can be calculated by: sequentially compressing each first compression unit, each second compression unit, or each third compression unit using each compression scheme to obtain a number of compressed data; decompressing the compressed data using a corresponding decompression scheme to obtain a number of decompressed data; respectively calculating the sum of errors between each decompressed data and each first compression unit, each second compression unit, or each third compression unit to obtain the decoding errors of the corresponding compression scheme. Thus, the decoding errors of all compression schemes for each first compression unit, each second compression unit, or each third compression unit are obtained.

[0085] In the embodiment of the present application, all compression schemes can be specifically divided into five compression modes (a first compression mode, a second compression mode, a third compression mode, a fourth compression mode and a fifth compression mode), and each compression mode includes but is not limited to a compression scheme.

[0086] It can be understood that, when compressing the brightness component, the first compression component or the second compression component, the unit division is first performed, and then all compression schemes are traversed based on each compression unit to select the most suitable target compression scheme. Therefore, the specific process of determining the target compression scheme is exactly the same. For the convenience of description, the brightness component Y is taken as an example to describe the specific compression process.

[0087] For example, a compression unit of the luminance component Y can be as follows:

[0088] Y1 Y2 Y3 Y4 Y5 Y6

[0089] The first compression mode is specifically as follows: first determine the maximum value Ymax and the minimum value Ymin among the 6 pixel values. When the difference between the maximum value Ymax and the minimum value Ymin is less than the preset value 4, the subsequent traversal process can be stopped, and the compression mode is directly used as the target compression scheme of the corresponding compression unit to achieve lossless compression (i.e., the decoding error is 0).

[0090] When the compression unit is compressed using the first compression mode, 4 bits can be used to save the first mode mark 1111, then 8 bits can be used to save the minimum value Ymin, and finally 2 bits can be used to save the difference between each pixel value and the minimum value. A total of 12 bits are required for 6 pixel values, so a total of 24 bits are required to save the compressed data. By fixing the 4-bit mode mark to save the compression mode, 8 bits to save the minimum value Ymin, and 12 bits to save the difference between each pixel value and the minimum value, the first compression mode can compress the original 48-bit data into 24 bits, which not only reduces the amount of data by half (achieving a 2-fold compression ratio), but also ensures lossless image quality. It can be understood that after the compression unit is compressed using the first compression mode, the compressed data format obtained is, from front to back, the first mode mark, the minimum value, and the difference between each pixel value and the minimum value.

[0091] The second compression mode is specifically: dividing the 6 pixel values ​​into two groups, and then using the mean value within the group to represent each pixel value within the group. It can be understood that there are 16 grouping schemes for dividing the 6 pixel values ​​into two groups, that is, the second compression mode includes 16 compression schemes.

[0092] When a compression scheme in the second compression mode is used to compress the compression unit, 4 bits can be used to save the second mode mark 1110. Then 4 bits are used to save the group number corresponding to the compression scheme. For example, when Y1, Y2, and Y3 are one group and Y4, Y5, and Y6 are another group, the 4-bit mark 0000 can be used as the group number. When Y1, Y2, and Y4 are one group and Y3, Y5, and Y6 are another group, the 4-bit mark 0001 can be used as the group number. Finally, 16 bits are used to save two group means (the first mean G_mean1 and the second mean G_mean2), and each mean uses 8 bits to save the corresponding data. Therefore, a total of 24 bits are required to save the compressed data, which means that the amount of data is halved (achieves a 2-fold compression ratio) and the image quality is guaranteed to be lossless. It can be understood that after the compression unit is compressed using the second compression mode, the compressed data format obtained is the second mode mark, the group number, the first mean, and the second mean from front to back.

[0093] The third compression mode is specifically: divide the 6 pixel values ​​into three groups, and then use the mean value within the group to represent each pixel value within the group. It can be understood that there are 8 grouping schemes for dividing the 6 pixel values ​​into three groups, that is, the second compression mode includes 8 compression schemes.

[0094] When a compression scheme in the third compression mode is used to compress the compression unit, 3 bits may be used to store the third mode flag 110. Then 3 bits may be used to store the group number corresponding to the compression scheme. For example, when Y1, Y2, and Y3 are a group, Y4, Y5 are a group, and Y6 are a group, the 3-bit flag 000 may be used as the corresponding group number; when Y1 and Y4 are a group, Y2 and Y5 are a group, and Y3 and Y6 are a group, the 3-bit flag 001 may be used as the corresponding group number.

[0095] Finally, 18 bits are used to save the three intra-group means (the first mean G_mean1, the second mean G_mean2 and the third mean G_mean3). It should be noted that each mean is saved using 6 bits, and only the upper 6 bits of its corresponding data are retained. Therefore, a total of 24 bits are required to save the compressed data. Saving the upper 6 bits and discarding the lower 2 bits can effectively retain the main information of the image while reducing visual distortion. That is, when a compression scheme in the third compression mode is used to compress the compression unit, the quality of the image can be guaranteed while halving the amount of data (achieving a 2-fold compression ratio). It can be understood that after the compression unit is compressed using the third compression mode, the compressed data format obtained is, from front to back, the third mode mark bit, the group number, the first mean, the second mean and the third mean.

[0096] For example, when the brightness component Y = {57, 59, 63, 55, 58, 52}, the grouping scheme is

[0097] {Y1, Y2}, {Y3, Y4}, {Y5, Y6}. The first mean value G_mean1 is: (57+59) / 2=58. The second mean value G_mean2 is: (63+55) / 2=59. The third mean value G_mean3 is: (58+52) / 2=55.

[0098] The first mean G_mean1, the second mean G_mean2 and the third mean G_mean3 are converted to 6-bit data as follows:

[0099] 58(8bit:00111010)→6bit:001110;

[0100] 59(8bit:00111011)→6bit:001110;

[0101] 55(8bit:00110111)→6bit:001101;

[0102] The amount of data stored in each mean is 6 bits, a total of 6×3=18 bits. Adding the third mode flag bit (3 bits) and the group number (3 bits), the total amount of data is: 3+3+18=24 bits.

[0103] The fourth compression mode is specifically: six pixel values ​​are saved respectively by different bit numbers. Specifically, 2 bits can be used to save the fourth mode mark bit 10 first, and then 16 bits can be used to save Y2, Y3, Y4 and Y5 (each pixel value is saved using 4 bits, and the high 4 bits of the corresponding data are saved). Finally, 6 bits are used to save Y1 and Y6 (each pixel value is saved using 3 bits, and the high 3 bits of the corresponding data are saved). Therefore, a total of 24 bits are required to save the compressed data, which means that the amount of data is halved (achieving a 2-fold compression ratio). It can be understood that after the compression unit is compressed using the fourth compression mode, the compressed data format obtained can be the fourth mode mark bit, the second pixel value, the third pixel value, the fourth pixel value, the fifth pixel value, the first pixel value and the sixth pixel value from front to back.

[0104] For example, when the brightness component Y = {Y1, Y2, Y3, Y4, Y5, Y6} = {58, 63, 60, 55, 57, 52}, 63, 60, 55 and 57 can be converted to binary data: 63 = 00111111, 60 = 00111100, 55 = 00110111, 57 = 00111001, and then take the high 4 bits: Y2 = 0011, Y3 = 0011, Y4 = 0011, Y5 = 0011. Then convert 58 and 52 into binary: 58 = 00111010, 52 = 00110100, and take the high 3 bits: Y1 = 001, Y6 = 001.

[0105] It is understandable that high-bit data retains the main information of the image, and discarding low-bit data has little effect on the visual effect. Therefore, the fourth compression mode saves six pixel values ​​by different bit numbers, and can compress the original 48-bit data into 24 bits, which not only achieves efficient compression but also retains the main information of the image.

[0106] The fifth compression mode is specifically: dividing the 6 pixel values ​​into four groups, and then using the mean value within the group to represent each pixel value within the group. It can be understood that there are 8 grouping schemes for dividing the 6 pixel values ​​into four groups, that is, the fifth compression mode includes 8 compression schemes.

[0107] When a compression scheme in the fifth compression mode is used to compress the compression unit, 1 bit can be used to save the fifth mode mark bit 0 first. Then 3 bits are used to save the group number corresponding to the compression scheme. For example, when Y1 and Y2 are a group, Y4 and Y5 are a group, Y6 is a group, and Y3 is a group, the 3-bit mark 000 can be used as the corresponding group number; when Y1 and Y4 are a group, Y3 and Y5 are a group, Y6 is a group, and Y2 is a group, the 3-bit mark 001 can be used as the corresponding group number. Finally, 20 bits are used to save the four mean values ​​in the group (the first mean G_mean1, the second mean G_mean2, the third mean G_mean3, and the fourth mean G_mean4). It should be noted that each mean value is saved using 5 bits, and only the high 5 bits of its corresponding data are retained. It can be understood that after the compression unit is compressed using the fifth compression mode, the compressed data format obtained is the fifth mode mark bit, the group number, the first mean value, the second mean value, the third mean value, and the fourth mean value from front to back.

[0108] For example, when G_mean1=58, G_mean2=56, G_mean3=52, G_mean4=63, you can first convert it into binary data, and then extract the high 5 bits for storage:

[0109] Gmean1=58(8bit:00111010)→5bit:00111;

[0110] Gmean2=56(8bit:00111000)→5bit:00111;

[0111] Gmean3=52(8bit:00110100)→5bit:00110;

[0112] Gmean4=63(8bit:00111111)→5bit:00111;

[0113] The amount of data stored in each mean is 5 bits, a total of 5×4=20 bits. Adding the fifth mode flag bit (1 bit) and the group number (3 bits), the total amount of data is: 20+1+3=24 bits.

[0114] By using the high 5 bits to save the group mean, the main features of the image can be retained and visual distortion can be reduced. That is, the fifth compression mode compresses the original data from 48 bits to 24 bits by dividing the 6 brightness components into 4 groups and saving the high 5 bits of the mean value within the group, achieving a good balance between compression ratio and image quality.

[0115] In summary, the first compression mode includes 1 compression scheme, the second compression mode includes 16 compression schemes, the third compression mode includes 8 compression schemes, the fourth compression mode includes 1 compression scheme, and the fifth compression mode includes 8 compression schemes, for a total of 34 compression schemes.

[0116] It should be noted that, during the traversal process, when the difference between the maximum value and the minimum value in the compression component is less than the preset value 4, the traversal of other modes can be skipped, and the first compression mode can be directly used as the target compression scheme of the corresponding compression unit.

[0117] When the difference between the maximum and minimum values ​​in the compressed component is greater than or equal to the preset value 4, the remaining 33 compression schemes (all compression schemes in the second compression mode to the fifth compression mode) are traversed, and the compression scheme with the smallest decoding error among the remaining 33 compression schemes is taken as the target compression scheme for the corresponding compression unit.

[0118] 105. Use corresponding target compression schemes to compress the brightness component, the first compression component, and the second compression component respectively.

[0119] In some embodiments, each first compression unit, each second compression unit, or each third compression unit may be compressed using a corresponding target compression scheme. Specifically, each first compression unit in the brightness component may be compressed using a corresponding target compression scheme. Each second compression unit in the first compression component may be compressed using a corresponding target compression scheme. Each third compression unit in the second compression component may be compressed using a corresponding target compression scheme.

[0120] It can be understood that each first compression unit, each second compression unit, and each third compression unit may correspond to different target compression schemes.

[0121] In summary, the image compression method of the embodiment of the present application includes obtaining an original image; converting the original image from the RGB color space to the YCoCg color space to obtain a brightness component, a first chromaticity component, and a second chromaticity component; performing row merging processing on the first chromaticity component and the second chromaticity component respectively to obtain a first compressed component and a second compressed component; traversing all compression schemes based on the brightness component, the first compressed component, and the second compressed component respectively, and determining the corresponding target compression scheme according to the traversal results; and compressing the brightness component, the first compressed component, and the second compressed component respectively using the corresponding target compression scheme. This scheme makes full use of the difference in sensitivity of the human eye to brightness and chromaticity, and compresses the brightness component, the first chromaticity component, and the second chromaticity component respectively using different compression schemes, thereby achieving efficient data compression and low visual distortion. That is, this scheme can achieve a higher compression ratio while ensuring image quality, meeting the needs of efficient storage and transmission.

[0122] In order to better implement the image compression method provided in the embodiment of the present application, the embodiment of the present application also provides an image decompression method. Figure 3 As shown, the specific process of the image decompression method can be as follows:

[0123] 201. Obtain compressed data.

[0124] The compressed data refers to data obtained by compressing the original image using the image compression method of the embodiment of the present application.

[0125] 202. Decompress the compressed data using a corresponding decompression scheme to obtain a brightness component, a first compressed component, and a second compressed component.

[0126] Specifically, a decompression scheme corresponding to the compressed data may be determined according to the compressed data format of the compressed data, and then the compressed data may be decompressed using the corresponding decompression scheme to obtain a brightness component, a first compressed component, and a second compressed component.

[0127] The following takes the compressed data of the brightness component Y as an example to explain the decompression process in detail.

[0128] If the first bit of the compressed data is 0, it indicates that the compression mode used is the fifth compression mode. Therefore, the corresponding compression scheme can be determined according to the second to fourth bits of the compressed data, and then the corresponding mean value of each group is used to restore the pixel value.

[0129] For example, when the 2nd to 4th digits are 000, the corresponding groups are Y1 and Y2 as one group, Y4 and Y5 as one group, Y6 as one group, and Y3 as one group:

[0130] Take the 5 bits after the 4th bit to get G_mean1, then: Y1_decode = G_mean1*8+4, Y2_decode = Y1_decode;

[0131] Take the 5 bits after G_mean1 to get G_mean2, then: Y4_decode = G_mean2*8+4, Y5_decode = Y4_decode;

[0132] Take the 5 bits after G_mean2 to get G_mean3, then: Y6_decode = G_mean3*8+4;

[0133] Take the 5 bits after G_mean3 to get G_mean4, then: Y3_decode=G_mean4*8+4.

[0134] After the above process, the pixel value corresponding to each compression unit is obtained. After that, all compression units are arranged in order to obtain the brightness component Y.

[0135] If the first two bits of the compressed data are 10, it indicates that the compression mode used is the fourth compression mode. Therefore, the high-order data of each pixel can be read in sequence according to the compressed data, and each pixel can be restored based on the high-order data.

[0136] Specifically, when the first two bits of the compressed data are 10, the 4 bits after the second bit can be taken to get data1, then: Y2_decode = data1*16+8;

[0137] Take the 4 bits after data1 to get data2, then: Y3_decode = data2*16+8;

[0138] Take the 4 bits after data2 to get data3, then: Y4_decode = data3*16+8;

[0139] Take the 4 bits after data3 to get data4, then: Y5_decode = data4*16+8;

[0140] Take the last 3 bits of data4 to get data5, then: Y1_decode = data5*32+16;

[0141] Take the last 3 bits of data5 to get data6, then: Y6_decode = data6*32+16;

[0142] After the above process, the pixel value corresponding to each compression unit is obtained. After that, all compression units are arranged in order to obtain the brightness component Y.

[0143] When the first three bits of the compressed data are 110, it indicates that the compression mode used is the third compression mode. The corresponding compression scheme can be determined according to the 4th to 6th bits of the compressed data, and then the pixel value is restored using the corresponding mean value of each group.

[0144] For example, when the 4th to 6th digits are 000, the corresponding groups are Y1, Y2, and Y3 as one group, Y4 and Y5 as one group, and Y6 as one group:

[0145] Take the 6 bits after the 6th bit to get G_mean1, then: Y1_decode = G_mean1*4+2, Y2_decode = Y1_decode, Y3_decode = Y1_decode;

[0146] Take the 6 bits after G_mean1 to get G_mean2, then: Y4_decode = G_mean2*4+2, Y5_decode = Y4_decode;

[0147] Take the 6 bits after G_mean2 to get G_mean3, then: Y6_decode=G_mean3*4+2.

[0148] After the above process, the pixel value corresponding to each compression unit is obtained. After that, all compression units are arranged in order to obtain the brightness component Y.

[0149] When the first 4 bits of the compressed data are 1110, it indicates that the compression mode used is the second compression mode. The corresponding compression scheme can be determined according to the 5th to 8th bits of the compressed data, and then the pixel value is restored using the corresponding mean value of each group.

[0150] For example, assuming that the 5th to 8th bits are 0000, the corresponding groups are Y1, Y2, and Y3 as one group, and Y4, Y5, and Y6 as one group:

[0151] The 8 bits after the 8th bit can be taken to get G_mean1, then: Y1_decode = G_mean1, Y2_decode = Y1_decode, Y3_decode = Y1_decode;

[0152] Then take the 8 bits after G_mean1 to get G_mean2, then: Y4_decode = G_mean2, Y5_decode = Y4_decode, Y6_decode = Y4_decode.

[0153] After the above process, the pixel value corresponding to each compression unit is obtained. After that, all compression units are arranged in order to obtain the brightness component Y.

[0154] When the first 4 bits of the compressed data are 1111, it indicates that the compression mode used is the first compression mode. At this time, the minimum value can be read, and then the difference between each pixel value and the minimum value can be read in sequence, and then the pixel value can be restored according to the minimum value and the difference between each pixel value and the minimum value.

[0155] For example, you can take the next 8 bits to get data_min, take the next 2 bits to get data1, take the next 2 bits to get data2, take the next 2 bits to get data3, take the next 2 bits to get data4, take the next 2 bits to get data5, and take the next 2 bits to get data6. Among them, data_min is the minimum value, and data1~data6 are the differences between each pixel value and the minimum value.

[0156] Specifically: Y1_decode=data_min+data1;

[0157] Y2_decode=data_min+data2;

[0158] Y3_decode=data_min+data3;

[0159] Y4_decode=data_min+data4;

[0160] Y5_decode=data_min+data5;

[0161] Y6_decode=data_min+data6;

[0162] After the above process, the pixel value corresponding to each compression unit is obtained. After that, all compression units are arranged in order to obtain the brightness component Y.

[0163] It should be noted that the decompression process of the first compressed component and the second compressed component is the same as the decompression process of the brightness component. For details, please refer to the decompression process of the brightness component, which will not be described in detail here.

[0164] 203. Perform interpolation processing on the first compressed component and the second compressed component respectively to obtain a first chrominance component and a second chrominance component.

[0165] With respect to step 103 in the image compression method provided in the embodiment of the present application, this embodiment provides two interpolation processing methods.

[0166] In one embodiment, a quasi-linear interpolation method may be used to perform interpolation processing on the first compressed component and the second compressed component respectively to obtain the first chrominance component and the second chrominance component.

[0167] It is understandable that since the number of rows of the first compressed component and the second compressed component is half of the first chrominance component and the second chrominance component, that is, every two adjacent rows are merged into one row, during decompression, the compressed row data needs to be mapped back to the original row data.

[0168] First, the compressed row number corresponding to the target row can be calculated. Assuming the target row number is r, its corresponding compressed row number is R=r / 2.

[0169] Then, the adjacent stored rows of the target row can be determined according to the value of the compressed row number R. Specifically, if R is an integer, it indicates that the target row directly corresponds to a certain stored row, and no interpolation is required. The pixel value of the stored row is directly used as the pixel value of the target row. If R is a decimal, it indicates that the target row is located between two adjacent stored rows, and the pixel value of the target row can be obtained by weighted calculation interpolation.

[0170] If the target row r is located in the adjacent saved row R low and R high If the pixel value of the target row is between r It can be calculated as follows:

[0171] Row r =(Row low *(R high -R)+Row high *(RR low )) / (R high -R low )

[0172] Among them, R high and R low It is the row number of the two adjacent rows above and below the target row. low Represents R low The pixel value of Row high Represents R high The pixel value of the target row. R represents the compressed row number corresponding to the target row. high -R indicates the target row r and the first saved row R low The distance used to calculate Row low The weight of RR low Indicates the target row r and the second saved row R high The distance used to calculate Row high The weight of .

[0173] That is, when the target row is located between two adjacent saved rows, the weight can be calculated according to the distance between the target row and the two adjacent saved rows, and then the pixel values ​​of the two adjacent saved rows are weighted averaged according to the weight to obtain the pixel value of the target row.

[0174] It can be understood that the target row refers to the row in the original image data (pixel value) that needs to be restored during the decompression process. These rows are not completely retained due to row merging during the compression process and need to be reconstructed from the compressed row data (saved row) through interpolation calculation. That is, the target row is the original row to be restored during decompression, and the saved row is the row that is retained during the compression process and used for interpolation.

[0175] In another embodiment, since the data storage methods of odd and even rows are different, odd rows store data of odd columns, and even rows store data of even columns. Except for edge pixels, each unsaved pixel has 4 saved pixels around it (located at the top, bottom, left, and right positions, respectively). To restore these unsaved pixels, a weighted interpolation method based on neighboring saved pixels can be used, while minimizing the buffer required for calculation to adapt to hardware implementation.

[0176] In some embodiments, in order to reduce computational complexity and the buffer required by the hardware, only three saved pixels (upper, left, and right positions) may be selected for interpolation calculation.

[0177] Taking the Co component as an example, the details are as follows:

[0178] Co11 Co13 Co15 Co17 Co22 Co23 Co24 Co26 Co31 Co33 Co35 Co37

[0179] Among them, Co23 is the pixel to be calculated. There are 4 saved pixels around Co23, namely: Co13, Co22, Co24, Co33. In order to calculate the pixel of Co23 and use as few buffers as possible for hardware implementation, you can choose to use Co13, Co22, and Co24 to calculate Co23, as follows: Co23 = Co13 / 4 + Co22*3 / 8 + Co24*3 / 8.

[0180] That is, in the embodiment of the present application, the pixel values ​​of the three neighboring saved pixels of the pixel to be restored can be weighted averaged to obtain the pixel value of the pixel to be restored. The three neighboring saved pixels refer to the pixels at the upper, left, and right positions of the pixel to be restored.

[0181] For edge pixels (such as pixels not saved at the image boundary), since there are less than 4 adjacent saved pixels, a specific processing method may be required.

[0182] In some embodiments, the pixel values ​​of all adjacent pixels may be weighted averaged to obtain the pixel value of the pixel to be restored. For example, if the upper or lower pixel is missing, only the pixel values ​​of the left and right pixels are weighted averaged to obtain the pixel value of the pixel to be restored.

[0183] In some embodiments, the pixel value of the neighboring saved pixel may be directly used as the pixel value of the pixel to be restored.

[0184] 204. Convert the YCoCg color space composed of the brightness component, the first chrominance component, and the second chrominance component into an RGB color space to obtain an original image.

[0185] In a specific implementation process, after obtaining the brightness component Y, the first chromaticity component Co and the second chromaticity component Cg, the YCoCg color space can be obtained, and the original image can be obtained by converting the YCoCg color space into the RGB color space. Figure 4 The formula shown converts the YCoCg data back to RGB color space.

[0186] In summary, the image decompression method provided by the embodiment of the present application includes obtaining compressed data; decompressing the compressed data using a corresponding decompression scheme to obtain a brightness component, a first compressed component, and a second compressed component; interpolating the first compressed component and the second compressed component to obtain a first chroma component and a second chroma component; converting the YCoCg color space composed of the brightness component, the first chroma component, and the second chroma component into an RGB color space to obtain the original image. This scheme realizes efficient reconstruction from the compressed brightness component, the first compressed component, and the second compressed component to the original RGB image through reasonable analysis and interpolation of compressed data.

[0187] In order to better implement the image compression method provided in the embodiment of the present application, the embodiment of the present application also provides an image compression device, wherein the meanings of the terms are the same as those in the above-mentioned image compression method, and the specific implementation details can refer to the description in the method embodiment.

[0188] See also Figure 5 , Figure 5 30 is a schematic diagram of the structure of the device provided in the embodiment of the present application. The image compression device may include an image acquisition unit 301, a space conversion unit 302, a component merging unit 303, a component traversal unit 304 and a component compression unit 305.

[0189] An image acquisition unit 301 is used to acquire an original image;

[0190] The space conversion unit 302 is used to convert the original image from the RGB color space to the YCoCg color space to obtain a brightness component, a first chrominance component, and a second chrominance component;

[0191] A component merging unit 303, configured to perform line merging processing on the first chroma component and the second chroma component respectively to obtain a first compressed component and a second compressed component;

[0192] The component traversal unit 304 is used to traverse all compression schemes based on the brightness component, the first compression component and the second compression component respectively, and determine the corresponding target compression scheme according to the traversal results;

[0193] The component compression unit 305 is used to compress the brightness component, the first compression component and the second compression component respectively by using the corresponding target compression scheme.

[0194] The specific implementation methods of the above-mentioned units can be found in the above-mentioned embodiment of the method, which will not be described one by one here.

[0195] In summary, the image compression device provided by the embodiment of the present application can obtain the original image through the image acquisition unit 301; the space conversion unit 302 converts the original image from the RGB color space to the YCoCg color space to obtain the brightness component, the first chromaticity component and the second chromaticity component; the component merging unit 303 performs row merging processing on the first chromaticity component and the second chromaticity component respectively to obtain the first compressed component and the second compressed component; the component traversal unit 304 traverses all compression schemes based on the brightness component, the first compressed component and the second compressed component respectively, and determines the corresponding target compression scheme according to the traversal result; the component compression unit 305 uses the corresponding target compression scheme to compress the brightness component, the first compressed component and the second compressed component respectively. This scheme makes full use of the difference in sensitivity of the human eye to brightness and chromaticity, and compresses the brightness component, the first chromaticity component and the second chromaticity component respectively using different compression schemes, thereby achieving efficient data volume compression and low visual distortion. That is, this scheme can achieve a higher compression ratio while ensuring image quality, meeting the requirements of efficient storage and transmission.

[0196] In order to better implement the image decompression method provided in the embodiment of the present application, the embodiment of the present application also provides an image decompression device, wherein the meanings of the terms are the same as those in the above-mentioned image decompression method, and the specific implementation details can refer to the description in the method embodiment.

[0197] See also Figure 6 , Figure 64 is a schematic diagram of the structure of the image decompression device provided in the embodiment of the present application. The image decompression device may include a data acquisition unit 401, a data decompression unit 402, a component interpolation unit 403 and a space restoration unit 404.

[0198] A data acquisition unit 401 is used to acquire compressed data;

[0199] A data decompression unit 402, configured to decompress the compressed data using a corresponding decompression scheme to obtain a brightness component, a first compressed component, and a second compressed component;

[0200] A component interpolation unit 403, configured to perform interpolation processing on the first compressed component and the second compressed component respectively to obtain a first chroma component and a second chroma component;

[0201] The space restoration unit 404 is used to restore the YCoCg color space composed of the brightness component, the first chrominance component and the second chrominance component to the RGB color space to obtain the original image.

[0202] The specific implementation methods of the above-mentioned units can be found in the above-mentioned embodiment of the method, which will not be described one by one here.

[0203] In summary, the image decompression device provided by the embodiment of the present application can obtain compressed data through the data acquisition unit 401; the data decompression unit 402 uses the corresponding decompression scheme to decompress the compressed data to obtain the brightness component, the first compressed component and the second compressed component; the component interpolation unit 403 interpolates the first compressed component and the second compressed component respectively to obtain the first chroma component and the second chroma component; the space restoration unit 404 restores the YCoCg color space composed of the brightness component, the first chroma component and the second chroma component to the RGB color space to obtain the original image. This solution realizes efficient reconstruction from the compressed brightness component, the first compressed component and the second compressed component to the original RGB image through reasonable analysis and interpolation of compressed data.

[0204] The present application also provides an electronic device, in which the image compression device or image decompression device of the present application may be integrated, such as Figure 7 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:

[0205] The electronic device may include one or more processors 301 of processing cores and one or more computer-readable storage media memories 302 and other components. Those skilled in the art will appreciate that Figure 7 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0206] The processor 301 is the control center of the electronic device, which uses various interfaces and lines to connect various parts of the entire electronic device, and executes various functions of the electronic device and processes data by running or executing the software program and / or the present application stored in the memory 302, and calling the data stored in the memory 302, so as to monitor the electronic device as a whole. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operation storage medium, user interface and application program, etc., and the modem processor mainly processes wireless communication. It is understandable that the above-mentioned modem processor may not be integrated into the processor 301.

[0207] The memory 302 can be used to store software programs and the present application. The processor 301 executes various functional applications and data processing by running the software programs and the present application stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating storage medium, an application required for at least one function, etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.

[0208] Although not shown, the electronic device may further include a display unit, an input unit, a power supply, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 301 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 302 according to the following instructions, and the processor 301 will run the application programs stored in the memory 302, thereby realizing various functions, as follows:

[0209] Acquire an original image; convert the original image from an RGB color space to a YCoCg color space to obtain a brightness component, a first chromaticity component, and a second chromaticity component; perform row merging processing on the first chromaticity component and the second chromaticity component to obtain a first compressed component and a second compressed component; traverse all compression schemes based on the brightness component, the first compressed component, and the second compressed component, respectively, and determine a corresponding target compression scheme according to the traversal results; and compress the brightness component, the first compressed component, and the second compressed component respectively using the corresponding target compression scheme.

[0210] or as follows:

[0211] Acquire compressed data; decompress the compressed data using a corresponding decompression scheme to obtain a brightness component, a first compressed component, and a second compressed component; interpolate the first compressed component and the second compressed component to obtain a first chroma component and a second chroma component; convert a YCoCg color space composed of the brightness component, the first chroma component, and the second chroma component into an RGB color space to obtain an original image.

[0212] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0213] To this end, an embodiment of the present application provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the generation methods provided in the embodiment of the present application. For example, the instructions can execute the following steps:

[0214] Acquire an original image; convert the original image from an RGB color space to a YCoCg color space to obtain a brightness component, a first chromaticity component, and a second chromaticity component; perform row merging processing on the first chromaticity component and the second chromaticity component to obtain a first compressed component and a second compressed component; traverse all compression schemes based on the brightness component, the first compressed component, and the second compressed component, respectively, and determine a corresponding target compression scheme according to the traversal results; and compress the brightness component, the first compressed component, and the second compressed component respectively using the corresponding target compression scheme.

[0215] Or you can perform the following steps:

[0216] Acquire compressed data; decompress the compressed data using a corresponding decompression scheme to obtain a brightness component, a first compressed component, and a second compressed component; interpolate the first compressed component and the second compressed component to obtain a first chroma component and a second chroma component; convert a YCoCg color space composed of the brightness component, the first chroma component, and the second chroma component into an RGB color space to obtain an original image.

[0217] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0218] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0219] Since the instructions stored in the storage medium can execute the steps in any method provided in the embodiments of the present application, the beneficial effects that can be achieved by any method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0220] The image compression method, decompression method, device, storage medium and electronic device provided by the present application are respectively introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the core idea of ​​the present application; at the same time, for technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. An image compression method, characterized in that: include: Get the original image; Convert the original image from the RGB color space to the YCoCg color space to obtain a luminance component, a first chrominance component, and a second chrominance component; Performing line merging processing on the first chroma component and the second chroma component respectively to obtain a first compressed component and a second compressed component; Traversing all compression schemes based on the brightness component, the first compression component, and the second compression component respectively, and determining a corresponding target compression scheme according to the traversal results; The brightness component, the first compressed component and the second compressed component are compressed respectively using the corresponding target compression scheme.

2. The image compression method according to claim 1, characterized in that: The traversing all compression schemes based on the brightness component, the first compression component, and the second compression component respectively, and determining a corresponding target compression scheme according to the traversal result, includes: Dividing the brightness component, the first compression component and the second compression component into units respectively to obtain a plurality of first compression units, a plurality of second compression units and a plurality of third compression units; For each of the first compression units, each of the second compression units or each of the third compression units, the decoding errors of all compression schemes are calculated respectively, and the compression scheme with the smallest decoding error is selected as the target compression scheme corresponding to the first compression unit, the second compression unit or the third compression unit.

3. The image compression method according to claim 2, characterized in that: The calculation of decoding errors of all compression schemes includes: sequentially compressing each of the first compression units, each of the second compression units, or each of the third compression units using each compression scheme to obtain a number of compressed data; Decompressing the compressed data respectively by using corresponding decompression schemes to obtain decompressed data; The sum of errors between each decompressed data and each corresponding first compression unit, each second compression unit or each third compression unit is calculated respectively to obtain a decoding error corresponding to the compression scheme.

4. The image compression method according to claim 1, wherein: The performing row merging processing on the first chroma component and the second chroma component respectively to obtain a first compressed component and a second compressed component includes: The pixel values ​​of two adjacent rows in the same column of the first chrominance component and the second chrominance component are respectively merged into one row of pixel values ​​to obtain a first compressed component and a second compressed component.

5. The image compression method according to claim 1, wherein: The performing row merging processing on the first chroma component and the second chroma component respectively to obtain a first compressed component and a second compressed component includes: Determine odd rows, even rows, odd columns, and even columns in the first chrominance component and the second chrominance component, respectively; In the first chrominance component and the second chrominance component, the pixel values ​​of the even columns of each of the odd rows are removed, and the pixel values ​​of the odd columns of each of the even rows are removed to obtain the first compressed component and the second compressed component.

6. An image decompression method, characterized in that: include: Get compressed data; Decompressing the compressed data using a corresponding decompression scheme to obtain a brightness component, a first compressed component, and a second compressed component; Performing interpolation processing on the first compressed component and the second compressed component respectively to obtain a first chrominance component and a second chrominance component; The YCoCg color space composed of the luminance component, the first chrominance component and the second chrominance component is converted into an RGB color space to obtain an original image.

7. An image compression device, characterized in that: include: An image acquisition unit, used for acquiring an original image; A space conversion unit, used for converting the original image from the RGB color space to the YCoCg color space to obtain a brightness component, a first chrominance component, and a second chrominance component; a component merging unit, configured to perform line merging processing on the first chroma component and the second chroma component respectively to obtain a first compressed component and a second compressed component; A component traversal unit, configured to traverse all compression schemes based on the brightness component, the first compression component, and the second compression component, respectively, and determine a corresponding target compression scheme according to the traversal result; A component compression unit is used to respectively compress the brightness component, the first compressed component and the second compressed component using the corresponding target compression scheme.

8. An image decompression device, characterized in that: include: A data acquisition unit, used for acquiring compressed data; A data decompression unit, configured to decompress the compressed data using a corresponding decompression scheme to obtain a brightness component, a first compressed component, and a second compressed component; a component interpolation unit, configured to perform interpolation processing on the first compressed component and the second compressed component respectively to obtain a first chroma component and a second chroma component; The space restoration unit is used to restore the YCoCg color space composed of the brightness component, the first chrominance component and the second chrominance component to the RGB color space to obtain the original image.

9. A storage medium, characterized in that: The storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the method according to any one of claims 1 to 5 or 6.

10. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 5 or 6 is implemented.