Image processing method and related device thereof
By determining the channel prediction value and channel value of the image in the SOC chip, calculating the residual value and encoding, and generating the target compressed image, the bandwidth pressure problem of image data transmission in the SOC chip is solved, and efficient compression and decompression of the image is achieved.
Patent Information
- Application Number
- PCT/CN2024/105054
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-26
- Filing Date
- 2024-07-11
- Publication Date
- 2025-07-03
AI Technical Summary
In SOC chips, due to the need to transport data of multiple frames of images simultaneously, DDR-SDRAM and NOC bandwidth allocation create huge bandwidth pressure, which is difficult to effectively solve in the prior art.
By determining the channel prediction value and channel value of the image to be compressed in the preset channel prediction area, the channel residual value is calculated, and the residual value is encoded using a static Hoffman encoding table, the target Hoffman encoding and original encoding are integrated to generate the target compressed image.
The bandwidth pressure of image data transmission is reduced, effective compression and decompression of images are achieved, taking into account image fidelity and processing efficiency.
Smart Images

Figure CN2024105054_03072025_PF_FP_ABST
Abstract
Description
Image processing method and related device
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on December 26, 2023, with application number 202311818732.7 and application name “A method for image processing and related equipment”, the entire contents of which are incorporated by reference into this application.
Technical field
[0002] The present application relates to the field of image processing, and in particular to an image processing method and related equipment. [Background Technology]
[0003] With the development of SOC (system on chip) technology, more and more functions are integrated into a single chip. For SOC chips that need to process large amounts of image data, batch data transmission is essential. For example, the Video In subsystem and Display subsystem in the SOC chip both need to transmit image data.
[0004] For complex SOC systems, the need to simultaneously carry multiple frames of image data creates enormous bandwidth pressure on DDR-SDRAM (double data rate SDRAM) bandwidth and NOC (network on chip) bandwidth allocation.
[0005] Therefore, how to reduce bandwidth pressure has become an urgent problem to be solved.
[0006] [Summary of the invention]
[0007] The present application provides an image processing method and related devices for compressing images to reduce bandwidth pressure.
[0008] The first aspect of the present application provides an image processing method, comprising:
[0009] Determining a first channel prediction value, a first channel value, and a second channel value of the image to be compressed in a preset channel prediction area;
[0010] Calculating the difference between the first channel value and the corresponding first channel prediction value to obtain a first channel residual value corresponding to the first channel value;
[0011] Encoding the first channel residual value according to a static Huffman coding table to obtain a target Huffman code of the first channel value, wherein the target Huffman code includes a first Huffman code, an extended bit width code, and a sign code;
[0012] The target Huffman code and the original code are integrated to obtain a target compressed image after the image to be compressed is compressed, wherein the original code corresponds to the second channel value of the image to be compressed that is not in the preset channel prediction area, and the original code is used to decompress the target compressed image.
[0013] In some embodiments, determining the first channel prediction value, the first channel value, and the second channel value of the image to be compressed in the preset channel prediction area includes:
[0014] According to the first starting and ending position information of the preset channel prediction area, the preset channel prediction area, the first channel value, the first channel prediction value, and the second channel value are obtained from the image to be compressed, wherein the first starting and ending position information includes a first starting position parameter i, a first ending position parameter v, and a first division parameter for dividing the image to be compressed into rows or columns.
[0015] In some embodiments, the image to be compressed has m rows and n columns, and obtaining the preset channel prediction area, the first channel value, and the first channel prediction value in the image to be compressed based on the first start and end position information of the preset channel prediction area includes:
[0016] According to the first starting position parameter i and the first ending position parameter v, intercepting the i-th group to the v-th group of the divided image to be compressed to determine them as the preset channel prediction area, and then obtaining the first channel value of the preset channel prediction area;
[0017] acquiring, according to the first starting position parameter i and the first ending position parameter v, third channel values of the divided i-1th group to the v-1th group of the to-be-compressed image to determine as the first channel prediction value of the preset channel prediction area;
[0018] According to the first starting position parameter i, the second channel value of the i-1th group of the divided image to be compressed is obtained, wherein the third channel values of the i-1th group to the v-1th group correspond to the first channel values of the i-th group to the v-th group respectively, i=2, v is m or n.
[0019] In some embodiments, the method further comprises:
[0020] Creating a preset extended bit width and the sign code, wherein the sign code is used to indicate the positive or negative value of the first channel residual value;
[0021] Creating multiple channel value intervals, multiple first association relationships, and multiple second association relationships based on the preset extended bit width number, and creating two third association relationships, wherein the first association relationship is an association relationship between the corresponding channel value interval and the first Huffman code, the second association relationship is an association relationship between the corresponding channel value interval, a fourth channel value within the channel value interval, and an extended bit width code determined by the preset extended bit width number, the third association relationship is an association relationship between the positive and negative values and the sign code, and the fourth channel value is used to represent the absolute value of the first channel residual value;
[0022] The multiple channel value intervals, the multiple first association relationships, the multiple second association relationships, and the two third association relationships are determined to be the static Huffman coding table.
[0023] In some embodiments, the creating of multiple channel value intervals, multiple first association relationships, and multiple second association relationships based on the preset extended bit width number, and the creating of two third association relationships, wherein the first association relationship is an association relationship between the corresponding channel value interval and the first Huffman code, the second association relationship is an association relationship between the corresponding channel value interval, the fourth channel value within the channel value interval, and the extended bit width code determined by the preset extended bit width number, and the third association relationship is an association relationship between the positive and negative properties and the sign code, including:
[0024] Dividing the channel value range into the plurality of channel value intervals according to the preset extended bit width number, wherein the channel value interval contains a plurality of the fourth channel values, and the channel value range is determined by the channel depth number;
[0025] Creating a first Huffman code associated with the channel value interval to obtain a plurality of first Huffman codes corresponding to the plurality of channel value intervals, and further creating a first association relationship between the channel value interval and the associated first Huffman code to obtain the plurality of first association relationships;
[0026] An extended bit width code for the fourth channel value is created to obtain multiple extended bit width codes corresponding to the multiple channel value intervals, and then a second association relationship is created between the corresponding channel value interval, the fourth channel value within the channel value interval, and the extended bit width code to obtain the multiple second association relationships, wherein the extended bit width code is created according to the preset extended bit width number.
[0027] Positive and negative sign codes are created respectively, thereby creating the two third association relationships.
[0028] In some embodiments, encoding the first channel residual value according to a static Huffman coding table to obtain a target Huffman code of the first channel value includes:
[0029] Searching the static Huffman coding table for a target first Huffman code, a target extended bit width code, and a target symbol code corresponding to the first channel residual value;
[0030] The target first Huffman code, the target extended bit width code, and the target sign code are integrated to obtain a target Huffman code of the first channel value.
[0031] In some implementations, searching for a target first Huffman code, a target extended bit width code, and a target symbol code corresponding to the first channel residual value includes:
[0032] searching, according to the plurality of channel value intervals and the plurality of first association relationships in the static Huffman coding table, for the target first Huffman coding of the absolute value of the first channel residual value;
[0033] Searching for a first target second association relationship associated with the absolute value from the plurality of second association relationships, and then acquiring the target extended bit width code associated with the absolute value based on the first target second association relationship;
[0034] From the two third association relationships, a target symbol code corresponding to the positive or negative sign of the first channel residual value is searched.
[0035] In some embodiments, searching for the target first Huffman code of the absolute value of the first channel residual value according to the multiple channel value intervals and the multiple first association relationships in the static Huffman code table includes:
[0036] Searching for a first target channel value interval of the absolute value from the plurality of channel value intervals in the static Huffman coding table;
[0037] From the multiple first association relationships, a first target first association relationship associated with the first target channel value interval is searched, and then, based on the first target first association relationship, the target first Huffman code associated with the absolute value is obtained.
[0038] In some implementations, searching, from the plurality of second association relationships, a first target second association relationship associated with the absolute value, and then, based on the first target second association relationship, acquiring the target extended bit width code associated with the absolute value, includes:
[0039] According to the first target channel value interval, searching, from the plurality of second association relationships, a plurality of second target second association relationships associated with the first target channel value interval;
[0040] From the plurality of second-target second association relationships, the first-target second association relationship including the fourth channel value associated with the absolute value is searched according to the absolute value.
[0041] In some embodiments, the method further comprises:
[0042] Obtaining the original code of the target compressed image and the target Huffman code in the preset channel prediction area, wherein the target compressed image is a coded image with m rows and n columns;
[0043] Determining the first channel residual value associated with the target Huffman code according to the target Huffman code and the static Huffman code table;
[0044] Calculating a sum of the first channel residual value and the second channel value obtained by decompressing the original code to obtain the first channel value corresponding to the first channel residual value;
[0045] The first channel value and the second channel value are integrated to obtain a decompressed image after the target compressed image is decompressed.
[0046] In some embodiments, determining the first channel residual value associated with the target Huffman code according to the target Huffman code and the static Huffman code table includes:
[0047] Splitting the target Huffman code into the first Huffman code, the extended bit width code and the symbol code;
[0048] The first channel residual value of the target Huffman code is determined according to the first Huffman code, the extended bit width code, the sign code, and the static Huffman code table.
[0049] In some embodiments, determining the first channel residual value of the target Huffman code according to the first Huffman code, the extended bit width code, the sign code, and the static Huffman code table includes:
[0050] Determining a second target channel value interval of the first Huffman code from the multiple first association relationships in the static Huffman code table;
[0051] According to the second target channel value interval and the extended bit width code, searching, from the plurality of second association relationships in the static Huffman coding table, for an absolute value of the first channel residual value associated with the second target channel value interval and the extended bit width code;
[0052] Determining the positive or negative nature of the sign code from the two third association relationships in the static Huffman coding table;
[0053] The absolute value and the positive / negative value are integrated to obtain the first channel residual value.
[0054] In some embodiments, searching, from the plurality of second association relationships in the static Huffman coding table according to the second target channel value interval and the extended bit width code, for an absolute value of the first channel residual value associated with the second target channel value interval and the extended bit width code includes:
[0055] searching, from the plurality of second association relationships, a third target second association relationship associated with the second target channel value interval and the extended bit width code according to the second target channel value interval and the extended bit width code;
[0056] A fourth channel value is obtained from the third target second association relationship to be determined as an absolute value of the first channel residual value.
[0057] In some implementations, searching, from the plurality of second association relationships, a third target second association relationship associated with the second target channel value interval and the extended bit width code according to the second target channel value interval and the extended bit width code includes:
[0058] searching, according to the second target channel value interval, from the plurality of second association relationships, a plurality of fourth target second association relationships associated with the second target channel value interval;
[0059] According to the extended bit width code, the third target second association relationship corresponding to the extended bit width code is searched from the plurality of fourth target second association relationships.
[0060] In some implementations, searching, from the plurality of second association relationships, a third target second association relationship associated with the second target channel value interval and the extended bit width code according to the second target channel value interval and the extended bit width code includes:
[0061] searching, according to the extended bit width code, from the plurality of second association relationships, a plurality of fifth target second association relationships associated with the extended bit width code;
[0062] According to the second target channel value interval, the third target second association relationship corresponding to the second target channel value interval is searched from the plurality of fifth target second association relationships.
[0063] In some embodiments, determining the second target channel value interval of the first Huffman code from the multiple first association relationships in the static Huffman coding table includes:
[0064] According to the first Huffman code, a second target first association relationship associated with the first Huffman code is searched from the multiple first association relationships in the static Huffman code table, and then, a second target channel value interval associated with the first Huffman code is obtained from the second target first association relationship.
[0065] In some embodiments, obtaining the original code of the target compressed image and the target Huffman code in the preset channel prediction area includes:
[0066] According to the second start and end position information of the preset channel prediction area, the preset channel prediction area, the target Huffman code and the original code are obtained from the target compressed image, wherein the second start and end position information includes a second start position parameter j and a second end position parameter k, and a second division parameter for dividing the image to be compressed into rows or columns.
[0067] In some embodiments, obtaining the preset channel prediction region, the target Huffman code, and the original code from the target compressed image based on the second start and end position information of the preset channel prediction region includes:
[0068] According to the second starting position parameter j and the second ending position parameter k, intercepting the jth group to the kth group of the divided target compressed image to determine them as the preset channel prediction area, and then obtaining the target Huffman code of the preset channel prediction area;
[0069] According to the second starting position parameter j, the first to j-1th groups of the divided target compressed images are intercepted to obtain the original codes, wherein j=2 and k is m or n.
[0070] In some embodiments, calculating the sum of the first channel residual value and the second channel value obtained by decompressing the original code to obtain the first channel value corresponding to the first channel residual value includes:
[0071] Decompressing the original code to obtain the second channel value;
[0072] Taking the second channel value as the starting value, the first channel residual value of each group from the jth to the kth group of the target compressed image is sequentially used as the added value, and accumulated to the second channel value to obtain the first channel value of each group from the jth to the kth group of the target compressed image.
[0073] In some embodiments, the preset extended bit width is preset to p bits, and the number of the multiple channel value intervals is 2 q-p , q is the channel depth number, p is an integer and less than the channel depth number.
[0074] In some implementations, the preset extended bit width is preset to 2 bits, and the number of the plurality of channel value intervals is 64.
[0075] In some implementations, dividing the channel value range into the plurality of channel value intervals according to the preset extended bit width number includes:
[0076] Determining the number of representations of the preset extended bit width number;
[0077] The channel value range is divided into the multiple channel value intervals according to the number of representations.
[0078] A second aspect of the present application provides an image processing device, comprising:
[0079] a determination module, configured to determine a first channel prediction value and a first channel value, as well as a second channel value, of the image to be compressed in a preset channel prediction area;
[0080] a calculation module, configured to perform difference calculation between the first channel value and the corresponding first channel prediction value to obtain a first channel residual value corresponding to the first channel value;
[0081] an acquisition module, configured to encode the first channel residual value according to a static Huffman coding table to obtain a target Huffman code of the first channel value, wherein the target Huffman code includes a first Huffman code, an extended bit width code, and a sign code;
[0082] An integration module is used to integrate the target Huffman code and the original code to obtain a target compressed image after the image to be compressed is compressed, wherein the original code corresponds to the second channel value of the image to be compressed that is not in the preset channel prediction area, and the original code is used to decompress the target compressed image.
[0083] A third aspect of the present application provides a computer-readable storage medium comprising instructions, which, when executed on a computer, enables the computer to execute the method as described in the first aspect of the present application.
[0084] A fourth aspect of the present application provides an electronic device, comprising a memory and a processor, wherein the processor is configured to execute program instructions stored in the memory to implement the method of the first aspect of the present application.
[0085] Compared with the prior art, the technical solution of the present application obtains the first channel residual value of the image to be compressed in the preset channel prediction area by determining the first channel prediction value and the first channel value of the image to be compressed in the preset channel prediction area, and then encodes the first channel residual value using a static Huffman coding table to obtain the target Huffman code of the first channel value, and then integrates the original code and the target Huffman code of the image to be compressed that is not in the preset channel prediction area to obtain the target compressed image after compression of the image to be compressed, thereby reducing the size of the image to be compressed and thus reducing the bandwidth pressure.
Brief Description of the Drawings
[0086] FIG1 is a flow chart of an image processing method according to an embodiment of the present application;
[0087] FIG2 is a flow chart of another image processing method according to an embodiment of the present application;
[0088] FIG3 is a flow chart of creating a static Huffman coding table according to an embodiment of the present application;
[0089] FIG4 is a flowchart of another static Huffman coding table creation embodiment of the present application;
[0090] FIG5 is a flow chart of obtaining a target Huffman code according to an embodiment of the present application;
[0091] FIG6 is a flowchart of another target Huffman coding acquisition process according to an embodiment of the present application;
[0092] FIG7 is a flow chart of decompression of a target compressed image according to an embodiment of the present application;
[0093] FIG8 is another flowchart of local decompression of a target compressed image according to an embodiment of the present application;
[0094] FIG9 is another flowchart of local decompression of a target compressed image according to an embodiment of the present application;
[0095] FIG10 is another flowchart of local decompression of a target compressed image according to an embodiment of the present application;
[0096] FIG11 is a schematic diagram of an RGB channel image according to an embodiment of the present application;
[0097] FIG12 is a structural diagram of an image processing device according to an embodiment of the present application;
[0098] FIG13 is a structural diagram of an electronic device according to an embodiment of the present application. [Specific implementation method]
[0099] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0100] The present application provides an image processing method and related devices for compressing images to reduce bandwidth pressure. The method of the present application includes image compression and decompression, which is used in SOC systems and also in other devices, such as cloud servers, mobile phones, tablets or laptops, which are not specifically limited here. Furthermore, compression and decompression can be used simultaneously in the same device, and image compression and image decompression can also be used in the above-mentioned different devices, which are not specifically limited here. The compression and decompression methods of the present application are now illustrated using a laptop as an example.
[0101] It should be noted that in image compression, the channel values of the image are compressed into corresponding codes, and in the image decompression process, the compressed codes are restored to the corresponding channel values.
[0102] Please refer to FIG1 , which provides an image processing method for compressing the size of an image to be compressed, thereby reducing bandwidth pressure.
[0103] 101. Determine a first channel prediction value, a first channel value, and a second channel value of an image to be compressed in a preset channel prediction area;
[0104] After obtaining the image to be compressed, its first channel prediction value and first channel value, as well as the second channel value in the preset channel prediction area are determined, wherein the first channel value is the original channel value of the image to be compressed in the preset channel prediction area, the first channel prediction value is the first channel value of the image to be compressed in the preset channel prediction area obtained through a preset operation, and the second channel value is the original channel value of the image to be compressed that is not in the preset channel prediction area.
[0105] It can be understood that the first channel value, the first channel prediction value and the preset channel prediction area are associated with each other.
[0106] 102. Calculate the difference between the first channel value and the corresponding first channel prediction value to obtain a first channel residual value corresponding to the first channel value;
[0107] After determining the first channel value and the first channel prediction value of the preset channel prediction area, a difference calculation is performed based on the first channel value and the first channel prediction value to obtain a first channel residual value.
[0108] The first channel residual value corresponds to a preset channel prediction region and is used to reduce the amplitude range of the first channel value in the preset channel prediction region and remove redundant channel values in the preset channel prediction region.
[0109] 103. Encode the first channel residual value according to a static Huffman coding table to obtain a target Huffman code of the first channel value, wherein the target Huffman code includes a first Huffman code, an extended bit width code, and a sign code;
[0110] After determining the first channel residual value of the preset channel prediction area, an encoding operation is performed on the first channel residual value according to the static Huffman coding table to obtain a target Huffman code of the first channel value, wherein the target Huffman code includes a first Huffman code, an extended bit width code and a sign code.
[0111] It can be understood that the target Huffman code corresponds to the first channel value, the first channel prediction value and the first channel residual value of the image to be compressed in the preset channel prediction area.
[0112] Compared with the original encoding of the first channel value, the first channel value is encoded by using a static Huffman coding table to obtain a target Huffman coding, thereby reducing the image size.
[0113] 104. Integrate the target Huffman code and the original code to obtain a target compressed image after the image to be compressed is compressed, wherein the original code corresponds to the second channel value of the image to be compressed that is not in the preset channel prediction area, and the original code is used to decompress the target compressed image.
[0114] After determining the target Huffman code of the preset channel prediction area, the target Huffman code and the original code are integrated to obtain a target compressed image after the image to be compressed is compressed, and the original code corresponds to the second channel value of the image to be compressed that is not in the preset channel prediction area.
[0115] Among them, the area not in the preset channel prediction area is the area after removing the preset channel prediction area from the entire area of the image to be compressed, that is, the non-preset channel prediction area, and the second channel value is used to decompress the target compressed image to obtain the channel value of the target compressed image.
[0116] The present application divides the image to be compressed into a preset channel prediction area and a non-preset channel prediction area, and transforms the first channel value of the preset channel prediction area into a first channel residual value through the first channel prediction value, so as to reduce the redundant channel values of the image to be compressed and reduce the amplitude range of the first channel value in the preset channel prediction area. Furthermore, the first channel residual value of the preset channel prediction area is encoded to obtain a target Huffman code of the first channel residual value of the preset channel prediction area, and the original code corresponding to the first channel value of the preset channel prediction area is replaced by the target Huffman code, thereby achieving fewer bits than the original code corresponding to the first channel value of the preset channel prediction area, thereby realizing compression of the image to be compressed. Finally, the target Huffman code corresponding to the preset channel prediction area and the original code of the non-preset channel prediction area are integrated to obtain a target compressed image.
[0117] Please refer to FIG. 2 , which further describes how to obtain the preset channel prediction area, the first channel value, the first channel prediction value, and the second channel value of the image to be compressed in step 101 .
[0118] 201. Obtain the preset channel prediction region, the first channel value, the first channel prediction value, and the second channel value from the image to be compressed based on first starting and ending position information of the preset channel prediction region, wherein the first starting and ending position information includes a first starting position parameter i, a first ending position parameter v, and a first partition parameter for partitioning the image to be compressed into rows or columns.
[0119] In some embodiments, the image to be compressed is divided into rows using the first division parameter for row division based on the first start and end position information, and then the preset channel prediction area, the first channel value, the first channel prediction value, and the second channel value are obtained from the image to be compressed based on the first start position parameter i and the first end position parameter v.
[0120] In some embodiments, the image to be compressed is divided into columns using the first division parameter for column division based on the first start and end position information, and then the preset channel prediction area, the first channel value, the first channel prediction value, and the second channel value are obtained from the image to be compressed based on the first start position parameter i and the first end position parameter v.
[0121] In some embodiments, the image to be compressed is divided into rows and columns using the first division parameters for column division and row division based on the first start and end position information, and then the preset channel prediction area, the first channel value, the first channel prediction value, and the second channel value are obtained from the image to be compressed based on the first start position parameter i and the first end position parameter v.
[0122] It should be noted that, for row division or column division, there is a corresponding first starting position parameter i and first ending position parameter v of the row division or column division.
[0123] For example, for row partitioning, there is a first starting position parameter i for the starting row and a first ending position parameter v for the ending row; for column partitioning, there is a first starting position parameter i for the starting column and a first ending position parameter v for the ending column.
[0124] Regarding how to obtain the preset channel prediction area, the first channel value, the first channel prediction value, and the second channel value from the image to be compressed with m rows and n columns through the first start and end position information, see steps 201a and 201b, wherein 201a describes the preset channel prediction area, the first channel value, the first channel prediction value, and the second channel value divided by the corresponding rows, and 201b describes the preset channel prediction area, the first channel value, the first channel prediction value, and the second channel value divided by the corresponding columns, please see 201a.
[0125] 201a1. After dividing the image to be compressed according to the first division parameter for row division, intercept the i-th to v-th groups of the divided image to be compressed according to the first starting position parameter i and the first ending position parameter v to determine them as the preset channel prediction areas, and then obtain the first channel value of the preset channel prediction areas;
[0126] After the image to be compressed is divided according to the first division parameter of row division, a total of vi rows from the i-th row to the v-th row of the image to be compressed are obtained according to the first starting position parameter i and the first ending position parameter v of the row division, and the vi rows are determined as the preset channel prediction area, and then the first channel value of the ni rows is obtained.
[0127] 201a2. Obtain third channel values of the divided i-1th to v-1th groups of the image to be compressed according to the first starting position parameter i and the first ending position parameter v, to determine the first channel prediction values of the preset channel prediction area.
[0128] According to the first starting position parameter i and the first ending position parameter v, the third channel values of the i-1th group to the v-1th group of the divided image to be compressed are obtained to determine that the third channel value is the first channel prediction value of the preset channel prediction area.
[0129] 201a3. According to the first starting position parameter i, obtain the second channel value of the i-1th group of the divided image to be compressed, wherein the third channel values of the i-1th group to the v-1th group correspond to the first channel values of the i-th group to the v-th group respectively, i=2, v is m.
[0130] According to the first starting position parameter i, the second channel value of the i-1th group of the divided image to be compressed is obtained, wherein the third channel values of the i-1th group to the v-1th group correspond to the first channel values of the i-th group to the v-th group respectively, where i is an integer, i∈[2,v), and v is m.
[0131] Please refer to 201b. Since this step is equivalent to step 201a, the details will not be repeated here.
[0132] 201b1. After dividing the image to be compressed according to the first division parameter of columns, intercept the i-th group to the v-th group of the divided image to be compressed according to the first starting position parameter i and the first ending position parameter v to determine them as the preset channel prediction area, and then obtain the first channel value of the preset channel prediction area;
[0133] 201b2. Obtain third channel values of the divided i-1th to v-1th groups of the image to be compressed according to the first starting position parameter i and the first ending position parameter v, to determine the first channel prediction values of the preset channel prediction area;
[0134] 201b3. According to the first starting position parameter i, obtain the second channel value of the i-1th group of the divided image to be compressed, wherein the third channel values of the i-1th group to the v-1th group correspond to the first channel values of the i-th group to the v-th group respectively, i is an integer, i∈[2,v), and v is n.
[0135] It can be understood that the first channel prediction value includes the second channel value used to decompress the target compressed image.
[0136] It is understandable that the above step 201a or 201b does not require complex prediction of the first channel prediction value of the first channel, and retains the channel information of the image to be compressed as much as possible, thereby achieving both image fidelity and light and fast processing.
[0137] In some embodiments, i in step 201a or 201b is set to 2 to achieve both image fidelity and fast processing.
[0138] Based on step 201a or 201b, the first channel residual value in step 103 is obtained by performing a difference calculation between the first channel value and the corresponding first channel prediction value.
[0139] Specifically, taking row division as an example, the first channel value of each column in the i-th to v-th columns of the image to be compressed is subtracted from the third channel value of each column in the i-1-th to v-1-th columns of the corresponding image to be compressed (i.e., the first channel prediction value) to obtain the first channel residual value of each column in the i-th to v-th columns of the image to be compressed.
[0140] In some embodiments, the first channel residual value has a positive or negative sign and is a signed number, and its positive or negative sign is encoded. In some embodiments, one bit is used for encoding to distinguish the positive or negative sign.
[0141] In some embodiments, v is the number of rows m of the image to be compressed with m rows and n columns, and i is 2.
[0142] In some embodiments, the operation is performed by column division, and correspondingly v is the number n of columns of the image to be compressed with m rows and n columns, and i takes the value of 2.
[0143] Further, please refer to FIG3 , which illustrates the creation of a static Huffman coding table of the present application, including:
[0144] 301. Create a preset extended bit width and a sign code, where the sign code is used to indicate the positive or negative value of the first channel residual value.
[0145] Create a preset extended bit width number and a sign code, and end the Huffman coding. The end of the Huffman coding is used to mark the end of the coding process.
[0146] 302. Create multiple channel value intervals, multiple first association relationships, and multiple second association relationships based on the preset extended bit width number, and create two third association relationships, wherein the first association relationship is an association relationship between a corresponding channel value interval and a first Huffman code, the second association relationship is an association relationship between the corresponding channel value interval, a fourth channel value within the channel value interval, and an extended bit width code determined by the preset extended bit width number, and the third association relationship is an association relationship between the positive and negative values and a sign code, and the fourth channel value is used to represent the absolute value of the first channel residual value.
[0147] A plurality of channel value intervals, a plurality of first association relationships, and a plurality of second association relationships are created according to the preset extended bit width number, and two third association relationships are created.
[0148] Among them, the first association relationship is a one-to-one association relationship between the corresponding channel value interval and the first Huffman code, and the second association relationship is a one-to-one association relationship between the corresponding channel value interval, the fourth channel value under the channel value interval and the extended bit width code determined by the preset extended bit width number.
[0149] The first Huffman code, the sign code and the extended bit width code together constitute the target Huffman code, the sign code is used to indicate the positive or negative value of the first channel residual value, and the fourth channel value is used to indicate the absolute value of the first channel residual value.
[0150] Regarding the positive or negative nature of the first channel residual value, in some embodiments, a bit is used to represent the positive or negative nature of the first channel residual value, for example, the character 0 represents positive, 1 represents negative, or 0 represents negative, 1 represents positive, and the specific details are not limited here.
[0151] It should be emphasized that each channel value interval corresponds to a corresponding first Huffman code, each channel value interval corresponds to corresponding multiple fourth channel values, and each fourth channel value corresponds to a corresponding extended bit width code. Therefore, each channel value interval corresponds to multiple extended bit width codes. Since the extended bit width code is determined by a preset extended bit width number, different channel value intervals correspond to the same extended bit width code.
[0152] Secondly, each second association relationship of the plurality of second association relationships has a different fourth channel value, and may have the same channel value interval and the same extended bit width code.
[0153] In some embodiments, the preset extended bit width is preset to p bits, and the number of multiple channel value intervals is 2 q-p , q is the channel depth number, p is an integer and less than the channel depth number, the channel depth number is the number of bits, see the following for details.
[0154] In some embodiments, p is 2, q is 8, the number of multiple channel value intervals is 64, each channel value interval corresponds to 4 fourth channel values and 4 extended bit width codes, and the 4 extended bit width codes are determined by the permutation and combination of two bits of 0 and 1.
[0155] 303. Determine the multiple channel value intervals, the multiple first association relationships, the multiple second association relationships, and the two third association relationships as the static Huffman coding table.
[0156] A plurality of channel value intervals, a plurality of first association relationships, a plurality of second association relationships, and two third association relationships are determined as a static Huffman coding table.
[0157] In some embodiments, the static Huffman encoding table also includes an end Huffman encoding.
[0158] In some embodiments, after the static Huffman coding table is determined, it is stored locally or in the cloud for executing the image processing method of the present application in the cloud or locally.
[0159] Please refer to FIG. 4 , which further describes step 302 , which is how to create multiple channel value intervals, multiple first association relationships, and multiple second association relationships by presetting the extended bit width and the channel value range.
[0160] In some embodiments, the channel value range is determined by the channel depth, for example, [0, 255] composed of a channel depth of 8 bits, [0, 1023] composed of a channel depth of 10 bits, [0, 4095] composed of a channel depth of 12 bits, [0, 65535] composed of a channel depth of 16 bits, etc.
[0161] Regarding the specific implementation of creating multiple channel value intervals, multiple first association relationships, and multiple second association relationships in a channel range according to a preset extended bit width number, an example is now described using a channel value range of [0, 255] consisting of an 8-bit channel depth and a preset extended bit width number p of 2. It should be emphasized that the present application is not limited to this, and includes:
[0162] 401. Divide a channel value range into the plurality of channel value intervals according to the preset extended bit width, wherein the channel value interval contains a plurality of the fourth channel values, and the channel value range is determined by the channel depth;
[0163] For the channel value range of 0 to 255, the preset extended bit width number p is 2, then the number of representations is 4, and the number of multiple channel value intervals is 64, and each channel value interval has 4 fourth channel values. For example, one channel value interval corresponds to 4 fourth channel values of 8-11.
[0164] 402. Create a first Huffman code associated with the channel value interval to obtain a plurality of first Huffman codes corresponding to the plurality of channel value intervals, and further create a first association relationship between the channel value interval and the associated first Huffman code to obtain the plurality of first association relationships;
[0165] An associated first Huffman code is created for each of the multiple channel value intervals to obtain multiple first Huffman codes. Furthermore, a first association relationship is created between each channel value interval and the associated first Huffman code to obtain multiple first association relationships, that is, 64 channel value intervals correspond one to one to one to one of the 64 first Huffman codes, and the first association relationships therebetween.
[0166] 403. Create an extended bit width code for the fourth channel value to obtain a plurality of extended bit width codes corresponding to the plurality of channel value intervals, and then create a second association relationship between the corresponding channel value interval, the fourth channel value within the channel value interval, and the extended bit width code to obtain the plurality of second association relationships, wherein the extended bit width code is created according to the preset extended bit width number.
[0167] Creating an extended bit width code corresponding to each fourth channel value in each channel value interval to obtain multiple extended bit width codes, that is, each channel value interval in the 64 channel value intervals has four fourth channel values, thereby creating four extended bit width codes corresponding to each channel value interval, and further creating a second association relationship between each channel value interval, each fourth channel value in each channel value interval, and the associated extended bit width code to obtain multiple second association relationships.
[0168] It can be understood that each channel value interval has the same extended bit width code. When the first channel residual value is obtained, the channel value interval and the extended bit width code associated with the first channel residual value are determined through the first channel value residual value and multiple second association relationships. The first channel residual value cannot be determined using the channel value interval or the extended bit width code alone, but the channel value interval and the extended bit width code can be shared to determine the second association relationship corresponding to the first channel residual value associated with the two in multiple second association relationships, and then the specific value of the first channel residual value associated with the two is obtained based on the second association relationship.
[0169] It can be understood that for the channel value range of 0 to 255 constituted by an 8-bit channel depth and the preset extended bit width number p is 2, there are 64 channel value intervals, 64 first association relationships, 64 first Huffman codes, 256 second association relationships, 256 different fourth channel values, and 256 preset extended bit width codes.
[0170] It is understandable that for 8, 10, 12, 16-bit channel depths and the preset extended bit width p, the number of channel value intervals is determined to be 2 q-p , q is the channel depth number mentioned above, and p is an integer less than the channel depth number mentioned above.
[0171] 404. Create positive and negative symbol codes for the positive and negative properties respectively, and then create the two third association relationships.
[0172] In some embodiments, a symbol code is created that associates positivity with positivity, and a symbol code is created that associates negativity with negativity, thereby creating two third association relationships. It can be seen that positivity and negativity are represented by one bit.
[0173] Based on the above embodiment, further referring to FIG. 5 , FIG. 5 describes how to perform a Huffman encoding operation on the first channel residual value, including:
[0174] 501. Search the static Huffman coding table for a target first Huffman code, a target extended bit width code, and a target symbol code corresponding to the first channel residual value.
[0175] A target first Huffman code and a target extended bit width code, as well as a target symbol code corresponding to the first channel residual value are obtained from multiple first association relationships, multiple second association relationships, and two third association relationships in the static Huffman coding table.
[0176] 502. Integrate the target first Huffman code, the target extended bit width code, and the target symbol code to obtain a target Huffman code of the first channel value;
[0177] The target first Huffman code, the target extended bit width code, and the target symbol code are integrated to obtain a target Huffman code of the first channel value.
[0178] Please refer to Figure 6, which further describes how to determine the target first Huffman code and the target extended bit width code in the target Huffman code corresponding to the first channel residual value based on the first association relationship and the second association relationship between the obtained first channel residual value and the static Huffman coding table.
[0179] 601. Searching for a first target channel value interval of the absolute value from the multiple channel value intervals in the static Huffman coding table;
[0180] After obtaining the first channel residual value of the preset channel prediction area, a first target channel value interval of the absolute value of the first channel residual value is searched among multiple channel value intervals in the static Huffman coding table.
[0181] 602. Search, from the multiple first association relationships, a first target first association relationship associated with the first target channel value interval, and then, based on the first target first association relationship, obtain the target first Huffman code associated with the absolute value;
[0182] From multiple first association relationships, find the first target first association relationship associated with the obtained first target channel value interval, and then obtain the target first Huffman code based on the first target first association relationship, which corresponds to the absolute value of the first channel residual value.
[0183] 603. Search for a first target second association relationship associated with the absolute value from the multiple second association relationships, and then, based on the first target second association relationship, obtain the target extended bit width code associated with the absolute value.
[0184] Since the created second association relationship includes a channel value interval, an extended bit width code, and a fourth channel value used to represent the absolute value of the first channel residual value, the target extended bit width code associated with the absolute value of the first channel residual value can be directly found from multiple second association relationships, that is, step 603a, or the target extended bit width code associated with the absolute value of the first channel residual value can be indirectly found from multiple second association relationships through the channel value interval and the extended bit width code, that is, step 603b.
[0185] In some embodiments, the target extended bit width code associated with the absolute value of the first channel residual value is directly found from the plurality of second association relationships, and the following steps are included after step 602:
[0186] 603a. Search, from the multiple second association relationships, a first target second association relationship associated with the absolute value of the first channel residual value, and then obtain the target extended bit width code associated with the absolute value of the first channel residual value based on the first target second association relationship.
[0187] In some embodiments, the target extended bit width code associated with the first channel residual value is indirectly found from the plurality of second association relationships, and the following steps are included after step 602:
[0188] 603b1. Search, according to the first target channel value interval, from the plurality of second association relationships, for a plurality of second target second association relationships associated with the first target channel value interval;
[0189] 603b2. Search, from the plurality of second-target second association relationships, according to the absolute value of the first channel residual value, for the first-target second association relationship including the fourth channel value associated with the absolute value of the first channel residual value.
[0190] It is understandable that step 603 after step 602 selects either 603a or 603b (603b1 and 603b2).
[0191] 604. Search for a target symbol code corresponding to the positive or negative sign of the first channel residual value from the two third association relationships.
[0192] From the two third association relationships, a target symbol code with positive or negative value is searched, wherein the positive or negative value is the positive or negative value of the first channel residual value.
[0193] In some embodiments, step 604 and step 603 are performed simultaneously, or step 604 precedes step 603, which is not specifically limited here.
[0194] In some embodiments, after obtaining the target compressed image of the image to be compressed, it is determined whether the size of the target compressed image is smaller than the size of the image to be compressed. If it is smaller, the target compressed image is determined to be the final target compressed image. If it is greater than or equal to, the image to be compressed is determined to be the final target compressed image.
[0195] In some embodiments, the final target compressed image is encapsulated, and the encapsulated final target compressed image includes a data packet header and a data portion. The data packet header is used to indicate whether the final target compressed image is a compressed image or an original image, and the data portion is used to indicate the corresponding encoding stream.
[0196] Based on the above embodiment, please refer to FIG. 7 , which describes how to decompress the acquired target compressed image to obtain a decompressed image.
[0197] 701. Obtain the original code of the target compressed image and the target Huffman code in the preset channel prediction area, wherein the target compressed image is a coded image with m rows and n columns;
[0198] After obtaining the target compressed image as an encoded image of m rows and n columns, the original encoding of the target compressed image and the target Huffman encoding of the preset channel prediction area are obtained, wherein the original encoding is the normal encoding of the second channel value of the target compressed image in the non-preset channel prediction area.
[0199] 702. Determine the first channel residual value associated with the target Huffman code according to the target Huffman code and the static Huffman code table;
[0200] 703. Calculate a sum of the first channel residual value and the second channel value obtained by decompressing the original code to obtain the first channel value corresponding to the first channel residual value.
[0201] 704 . Integrate the first channel value and the second channel value to obtain a decompressed image after decompressing the target compressed image.
[0202] Please refer to FIG8 , which further describes how to determine the first channel residual value associated with the target Huffman coding, including:
[0203] 801. Divide the target Huffman code into the first Huffman code, the extended bit width code, and the symbol code;
[0204] Since the target Huffman code includes the first Huffman code, the extended bit width code, and the sign code, it is divided to obtain the first Huffman code, the extended bit width code, and the sign code which are independent of each other.
[0205] 802. Determine the first channel residual value of the target Huffman code according to the first Huffman code, the extended bit width code, the sign code, and the static Huffman code table.
[0206] Since the static Huffman coding table includes the first Huffman code, the extended bit width code and the sign code, and the fourth channel value for representing the absolute value of the first channel residual value, the first channel residual value is determined by the static Huffman coding table.
[0207] Please refer to Figure 9, which further describes how to obtain the first channel residual value, including:
[0208] 901. Search, according to the first Huffman code, the plurality of first association relationships in the static Huffman code table for a second target first association relationship associated with the first Huffman code, and further obtain, from the second target first association relationship, a second target channel value interval associated with the first Huffman code;
[0209] From the multiple first association relationships in the static Huffman coding table, a second target first association relationship including the first Huffman coding and the associated second target channel value interval is searched, and then the second target channel value interval is obtained from the second target first association relationship.
[0210] 902. Search, according to the second target channel value interval and the extended bit width code, from the plurality of second association relationships, for a third target second association relationship associated with the second target channel value interval and the extended bit width code.
[0211] From the multiple second association relationships, a second association relationship including both the second target channel value interval and the extended bit width code is searched to determine it as the third target second association relationship.
[0212] 903. Obtain a fourth channel value from the third target second association relationship to determine it as an absolute value of the first channel residual value.
[0213] Since the third target second association relationship is an association relationship between the second target channel value interval, the extended bit width code and the fourth channel value, the fourth channel value used to represent the absolute value of the first channel residual value is obtained according to the third target second association relationship.
[0214] In some embodiments, obtaining the third target second association relationship can be performed by searching for multiple fourth target second association relationships associated with the second target channel value interval from multiple second association relationships based on the second target channel value interval, and then searching for the third target second association relationship corresponding to the extended bit width code from multiple fourth target second association relationships based on the extended bit width code.
[0215] In some embodiments, obtaining the third target second association relationship can be performed by searching for multiple fifth target second association relationships associated with the extended bit width code from multiple second association relationships based on the extended bit width code, and then searching for the third target second association relationship corresponding to the second target channel value interval from multiple fifth target second association relationships based on the second target channel value interval.
[0216] The following describes how to obtain the original code and the target Huffman code in the preset channel prediction area from the target compressed image.
[0217] In some embodiments, based on the second starting and ending position information of the preset channel prediction area, the preset channel prediction area, the target Huffman code and the original code are obtained from the target compressed image, wherein the second starting and ending position information includes a second starting position parameter j and a second ending position parameter k, as well as a second division parameter for row division or column division of the image to be compressed.
[0218] Specifically, according to the second starting position parameter j and the second ending position parameter k, the jth group to the kth group of the target compressed image after division are intercepted to determine as the preset channel prediction area, and then the target Huffman code of the preset channel prediction area is obtained. Further, according to the second starting position parameter j, the 1st group to the j-1th group of the target compressed image after division are intercepted to obtain the original code, where j=2 and k is m or n.
[0219] Based on the above embodiment, please refer to FIG. 10 and FIG. 11 . FIG. 10 describes how to obtain the second channel value and the first channel value, including:
[0220] 1001. Decompress the original code to obtain the second channel value;
[0221] 1002. Taking the second channel value as a starting value, sequentially taking the first channel residual value of each of the j-th to k-th groups of the target compressed image as an added value, and accumulating them to the second channel value, to obtain the first channel value corresponding to each of the j-th to k-th groups of the target compressed image.
[0222] Please refer to Figure 11, which shows the three channel values of the RGB image. After obtaining the channel image of the corresponding R channel, G channel or B channel, the first column of channel values of the corresponding channel image, that is, the second channel value, and the first channel residual value corresponding to the remaining channel value of the corresponding channel image after removing the first column of channel values are obtained, and the first channel value is obtained by taking the first column of channel values as the starting value and accumulating the channel values of the corresponding column in sequence.
[0223] For example, taking R0 in FIG11 as the starting value, that is, the second channel value of the first column, it is necessary to obtain the first channel value of the third column, that is, the first channel value of R2. After obtaining the second channel value of R0 and the first channel residual values of R1 and R2 (the first channel residual value of R1 is R1-R0, and the first channel residual value of R2 is R2-R1), the respective first channel residual values of R1 and R2 can be accumulated to the second channel value of R0 to obtain the first channel value of R2.
[0224] It can be understood that the second channel value corresponding to the original code is used to decompress the target compressed image.
[0225] It should be pointed out that this application is used to operate channel images, and is also used to convert non-channel images into channel images for operation. Channel images include RGB images, grayscale images or single-channel images, which are not specifically limited here.
[0226] Referring to FIG. 12 , the present application further includes an image compression device, including:
[0227] A first determining module 1201 is configured to determine a first channel prediction value, a first channel value, and a second channel value of the image to be compressed in a preset channel prediction area;
[0228] A first calculation module 1202 is configured to perform difference calculation between the first channel value and the corresponding first channel prediction value to obtain a first channel residual value corresponding to the first channel value;
[0229] A first acquisition module 1203 is configured to encode the first channel residual value according to a static Huffman coding table to obtain a target Huffman code of the first channel value, wherein the target Huffman code includes a first Huffman code, an extended bit width code, and a sign code;
[0230] The first integration module 1204 is used to integrate the target Huffman code and the original code to obtain a target compressed image after the image to be compressed is compressed, wherein the original code corresponds to the second channel value of the image to be compressed that is not in the preset channel prediction area, and the original code is used to decompress the target compressed image.
[0231] In some embodiments, the first determining module 1201 includes:
[0232] A first acquisition submodule is used to obtain the preset channel prediction area, the first channel value, the first channel prediction value, and the second channel value from the image to be compressed based on the first starting and ending position information of the preset channel prediction area, wherein the first starting and ending position information includes a first starting position parameter i, a first ending position parameter v, and a first division parameter for dividing the image to be compressed into rows or columns.
[0233] In some embodiments, the image to be compressed has m rows and n columns, and the first acquisition submodule includes:
[0234] a first acquiring unit, configured to intercept, according to the first starting position parameter i and the first ending position parameter v, the i-th group to the v-th group of the divided image to be compressed, to determine them as the preset channel prediction area, and then acquire the first channel value of the preset channel prediction area;
[0235] a second acquiring unit, configured to acquire, based on the first starting position parameter i and the first ending position parameter v, the third channel values of the divided i-1th group to the v-1th group of the to-be-compressed image, to determine the first channel prediction value of the preset channel prediction area;
[0236] A third acquisition unit is used to obtain the second channel value of the i-1th group of the divided image to be compressed according to the first starting position parameter i, wherein the third channel values of the i-1th group to the v-1th group correspond to the first channel values of the i-th group to the v-th group respectively, i=2, v is m or n.
[0237] In some embodiments, the image compression apparatus further includes:
[0238] A first creation module is configured to create a preset extended bit width number and the sign code, wherein the sign code is used to indicate the positive or negative value of the first channel residual value;
[0239] a second creation module, configured to create, based on the preset extended bit width number, a plurality of channel value intervals, a plurality of first association relationships, and a plurality of second association relationships, and to create two third association relationships, wherein the first association relationship is an association relationship between a corresponding channel value interval and a first Huffman code, the second association relationship is an association relationship between the corresponding channel value interval, a fourth channel value within the channel value interval, and an extended bit width code determined by the preset extended bit width number, the third association relationship is an association relationship between the positive and negative values and the sign code, and the fourth channel value is used to represent the absolute value of the first channel residual value;
[0240] The second determining module is used to determine that the multiple channel value intervals, the multiple first association relationships, the multiple second association relationships, and the two third association relationships are the static Huffman coding table.
[0241] In some embodiments, the second creation module includes:
[0242] A first creating submodule is configured to divide a channel value range into the plurality of channel value intervals according to the preset extended bit width number, wherein the channel value interval contains a plurality of the fourth channel values, and the channel value range is determined by the channel depth number;
[0243] a second creation submodule, configured to create a first Huffman code associated with the channel value interval to obtain a plurality of first Huffman codes corresponding to the plurality of channel value intervals, and further create a first association relationship between the channel value interval and the associated first Huffman code to obtain the plurality of first association relationships;
[0244] a third creation submodule, configured to create an extended bit width code for the fourth channel value to obtain a plurality of extended bit width codes corresponding to the plurality of channel value intervals, and further create a second association relationship between the corresponding channel value interval, the fourth channel value within the channel value interval, and the extended bit width code to obtain the plurality of second association relationships, wherein the extended bit width code is created according to the preset extended bit width number;
[0245] The fourth creation submodule is used to create the positive and negative sign codes of the positivity and negativity respectively, and then create the two third association relationships.
[0246] In some embodiments, the first acquisition module 1203 includes:
[0247] A first search submodule is configured to search the static Huffman coding table for a target first Huffman code, a target extended bit width code, and a target symbol code corresponding to the first channel residual value;
[0248] A first integration submodule is configured to integrate the target first Huffman code, the target extended bit width code, and the target symbol code to obtain a target Huffman code for the first channel value.
[0249] In some embodiments, the first search submodule includes:
[0250] a first searching unit, configured to search for the target first Huffman code of the absolute value of the first channel residual value according to the multiple channel value intervals and the multiple first association relationships in the static Huffman code table;
[0251] a second searching unit, configured to search for a first target second association relationship associated with the absolute value from the plurality of second association relationships, and further, based on the first target second association relationship, obtain the target extended bit width code associated with the absolute value;
[0252] The third searching unit is configured to search for a target symbol code corresponding to the positive or negative sign of the first channel residual value from the two third association relationships.
[0253] In some embodiments, the first search unit includes:
[0254] a first search subunit, configured to search for a first target channel value interval of the absolute value from the plurality of channel value intervals in the static Huffman coding table;
[0255] The second search subunit is configured to search for a first target first association relationship associated with the first target channel value interval from the multiple first association relationships, and then obtain the target first Huffman code associated with the absolute value based on the first target first association relationship.
[0256] In some embodiments, the second search subunit includes:
[0257] a first search module, configured to search, according to the first target channel value interval, from the plurality of second association relationships for a plurality of second target second association relationships associated with the first target channel value interval;
[0258] The second search module is configured to search, from among the plurality of second-target second association relationships, for the first-target second association relationship including the fourth channel value associated with the absolute value according to the absolute value.
[0259] In some embodiments, the image compression apparatus further includes:
[0260] A second acquisition module is configured to acquire the original code of the target compressed image and the target Huffman code in the preset channel prediction area, wherein the target compressed image is a coded image with m rows and n columns;
[0261] A third determining module is configured to determine the first channel residual value associated with the target Huffman coding according to the target Huffman coding and the static Huffman coding table;
[0262] a second calculation module, configured to calculate a sum of the first channel residual value and the second channel value obtained by decompressing the original code, so as to obtain the first channel value corresponding to the first channel residual value;
[0263] The second integration module is configured to integrate the first channel value and the second channel value to obtain a decompressed image after the target compressed image is decompressed.
[0264] In some embodiments, the third determining module includes:
[0265] a segmentation submodule, configured to segment the target Huffman code into the first Huffman code, the extended bit width code, and the symbol code;
[0266] The first determining submodule is configured to determine the first channel residual value of the target Huffman code according to the first Huffman code, the extended bit width code, the sign code, and the static Huffman code table.
[0267] In some embodiments, the first determining submodule includes:
[0268] A first determining unit is configured to determine a second target channel value interval of the first Huffman code from the plurality of first association relationships in the static Huffman code table;
[0269] a fourth searching unit, configured to search, according to the second target channel value interval and the extended bit width code, from the plurality of second association relationships in the static Huffman coding table for an absolute value of the first channel residual value associated with the second target channel value interval and the extended bit width code;
[0270] a second determining unit, configured to determine the positive or negative nature of the sign code from the two third association relationships in the static Huffman coding table;
[0271] The first integration unit is configured to integrate the absolute value and the positive / negative value to obtain the first channel residual value.
[0272] In some embodiments, the fourth search unit includes:
[0273] a third search subunit, configured to search, according to the second target channel value interval and the extended bit width code, from the plurality of second association relationships for a third target second association relationship associated with the second target channel value interval and the extended bit width code;
[0274] The first acquisition subunit is configured to acquire a fourth channel value from the third target second association relationship to determine the fourth channel value as the absolute value of the first channel residual value.
[0275] In some embodiments, the third search subunit includes:
[0276] a third search module, configured to search, according to the second target channel value interval, from the plurality of second association relationships for a plurality of fourth target second association relationships associated with the second target channel value interval;
[0277] The fourth search module is configured to search, according to the extended bit width code, from the plurality of fourth target second association relationships for the third target second association relationship corresponding to the extended bit width code.
[0278] In some embodiments, the third search subunit includes:
[0279] a fifth search module, configured to search, according to the extended bit width code, from the plurality of second association relationships for a plurality of fifth target second association relationships associated with the extended bit width code;
[0280] The sixth search module is configured to search, based on the second target channel value interval, from the plurality of fifth target second association relationships for the third target second association relationship corresponding to the second target channel value interval.
[0281] In some embodiments, the first determining unit includes:
[0282] The fourth search subunit is used to search for the second target first association relationship associated with the first Huffman code from the multiple first association relationships in the static Huffman code table according to the first Huffman code, and then obtain the second target channel value interval associated with the first Huffman code from the second target first association relationship.
[0283] In some embodiments, the second acquisition module includes:
[0284] A second acquisition submodule is used to obtain the preset channel prediction area, the target Huffman code and the original code from the target compressed image according to the second start and end position information of the preset channel prediction area, wherein the second start and end position information includes a second start position parameter j and a second end position parameter k, and a second division parameter for dividing the image to be compressed into rows or columns.
[0285] In some embodiments, the second acquisition submodule includes:
[0286] a third determining unit, configured to intercept, according to the second starting position parameter j and the second ending position parameter k, the j-th group to the k-th group of the divided target compressed image to determine them as the preset channel prediction area, and further obtain the target Huffman code of the preset channel prediction area;
[0287] The fourth acquisition unit is used to intercept the first to j-1th groups of the divided target compressed images according to the second starting position parameter j to obtain the original code, wherein j=2 and k is m or n.
[0288] In some embodiments, the second computing module includes:
[0289] a decompression submodule, configured to decompress the original code to obtain the second channel value;
[0290] a calculation submodule, configured to use the second channel value as a starting value, and sequentially use the first channel residual value of each of the jth to kth groups of the target compressed image as an added value, and accumulate them to the second channel value to obtain the first channel value of each of the jth to kth groups of the target compressed image.
[0291] The present application also includes an electronic device, as shown in FIG13 , including: a memory 1301 , a processor 1302 , and a bus system 1303 ; wherein the memory is used to store programs; the processor is used to execute the programs in the memory, including executing the methods of the above embodiments;
[0292] The bus system is used to connect the memory and the processor so that the memory and the processor can communicate with each other.
[0293] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0294] In some embodiments, the memory 1301 may be an internal storage unit of the cloud device, for example, a hard disk or memory of the cloud device. In other embodiments, the memory 1301 may also be an external storage device of the cloud device, for example, a plug-in hard disk equipped on the cloud device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Furthermore, the memory may also include both an internal storage unit of the cloud device and an external storage device. The memory is used to store an operating system, an application, a boot loader (BootLoader), data, and other programs, such as the program code of a computer program. The memory may also be used to temporarily store data that has been output or is to be output.
[0295] The present application also includes a computer-readable storage medium comprising instructions, which, when executed on a computer, enable the computer to execute the method of the above embodiment.
[0296] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of each of the above-mentioned method embodiments.
[0297] The computer program includes computer program code, which may be in source code form, object code form, executable file, or some intermediate form. Computer-readable media may include at least: any entity or device capable of carrying the computer program code to a camera / terminal device, recording media, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunications signals, and software distribution media. Examples include USB flash drives, removable hard drives, magnetic disks, or optical disks. In some jurisdictions, due to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunications signals.
[0298] The above description is only an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the description and drawings of the present invention, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. An image processing method, wherein, Including: Determine a first channel prediction value, a first channel value, and a second channel value of the image to be compressed in a preset channel prediction region; Calculate the difference between the first channel value and the corresponding first channel prediction value to obtain a first channel residual value corresponding to the first channel value; Encode the first channel residual value according to a static Huffman coding table to obtain a target Huffman coding of the first channel value, where the target Huffman coding includes a first Huffman coding, an extended bit width code, and a symbol code; Integrate the target Huffman coding and the original coding to obtain a target compressed image after compression of the image to be compressed, where the original coding corresponds to the second channel value of the image to be compressed that is not in the preset channel prediction region, and the original coding is used to decompress the target compressed image.
2. The method according to claim 1, wherein, The determining the first channel prediction value, the first channel value, and the second channel value of the image to be compressed in the preset channel prediction region includes: According to first start and end position information of the preset channel prediction region, obtain the preset channel prediction region, the first channel value, the first channel prediction value, and the second channel value from the image to be compressed, where the first start and end position information includes a first start position parameter i, a first end position parameter v that are correlated with each other, and a first division parameter for row division or column division of the image to be compressed.
3. According to the method of claim 2, the image to be compressed is m rows by n columns, wherein, The obtaining the preset channel prediction region, the first channel value, the first channel prediction value, and the second channel value from the image to be compressed according to the first start and end position information of the preset channel prediction region includes: According to the first start position parameter i and the first end position parameter v, intercept the i-th group to the v-th group of the divided image to be compressed to determine as the preset channel prediction region, and further obtain the first channel value of the preset channel prediction region; According to the first start position parameter i and the first end position parameter v, obtain third channel values of the (i - 1)-th group to the (v - 1)-th group of the divided image to be compressed to determine as the first channel prediction value of the preset channel prediction region; According to the first start position parameter i, obtain the second channel value of the (i - 1)-th group of the divided image to be compressed, where the third channel values of the (i - 1)-th group to the (v - 1)-th group correspond to the first channel values of the i-th group to the v-th group in sequence, i = 2, and v is m or n.
4. The method according to any one of claims 1 to 3, wherein, The method further includes: Create a preset extended bit width number and the symbol code, where the symbol code is used to represent the positivity and negativity of the first channel residual value; Create multiple channel value intervals, multiple first association relationships, and multiple second association relationships according to the preset extended bit width number, and create two third association relationships. Among them, the first association relationship is the association relationship between the corresponding channel value interval and the first Huffman code, the second association relationship is the association relationship between the corresponding channel value interval, the fourth channel value under the channel value interval, and the extended bit width code determined by the preset extended bit width number, the third association relationship is the association relationship between the positive / negative property and the symbol code, and the fourth channel value is used to represent the absolute value of the first channel residual value; Determine the multiple channel value intervals, the multiple first association relationships, the multiple second association relationships, and the two third association relationships, which are the static Huffman coding table.
5. The method according to claim 4, wherein, The step of creating multiple channel value intervals, multiple first association relationships, and multiple second association relationships according to the preset extended bit width number, and creating two third association relationships. Among them, the first association relationship is the association relationship between the corresponding channel value interval and the first Huffman code, the second association relationship is the association relationship between the corresponding channel value interval, the fourth channel value under the channel value interval, and the extended bit width code determined by the preset extended bit width number, the third association relationship is the association relationship between the positive / negative property and the symbol code, includes: Divide the channel value range into the multiple channel value intervals according to the preset extended bit width number. Among them, there are multiple fourth channel values in the channel value interval, and the channel value range is determined by the number of channel depths; Create the first Huffman code associated with the channel value interval to obtain multiple first Huffman codes corresponding to the multiple channel value intervals. Furthermore, create the first association relationship between the channel value interval and the associated first Huffman code to obtain the multiple first association relationships; Create the extended bit width code of the fourth channel value to obtain multiple extended bit width codes corresponding to the multiple channel value intervals. Furthermore, create the second association relationship between the corresponding channel value interval, the fourth channel value under the channel value interval, and the extended bit width code to obtain the multiple second association relationships, where the extended bit width code is created according to the preset extended bit width number; Create the symbol codes for the positive and negative of the positive / negative property respectively, and then create the two third association relationships.
6. The method according to claim 4, wherein The step of encoding the first channel residual value according to the static Huffman coding table to obtain the target Huffman code of the first channel value, includes: Search in the static Huffman coding table for the target first Huffman code, target extended bit width code, and target symbol code corresponding to the first channel residual value; Integrate the target first Huffman code, the target extended bit width code, and the target symbol code to obtain the target Huffman code of the first channel value.
7. The method according to claim 6, wherein, The step of searching for the target first Huffman code, target extended bit width code, and target symbol code corresponding to the first channel residual value, includes: Look up the target first Huffman code of the absolute value of the first channel residual value according to the multiple channel value intervals and the multiple first association relationships in the static Huffman coding table; Look up a first target second association relationship associated with the absolute value from the multiple second association relationships, and further, based on the first target second association relationship, obtain the target extended bit width code associated with the absolute value; Look up the target symbol code of the positive or negative nature of the first channel residual value from the two third association relationships.
8. The method according to claim 7, wherein, The step of looking up the target first Huffman code of the absolute value of the first channel residual value according to the multiple channel value intervals and the multiple first association relationships in the static Huffman coding table includes: Look up a first target channel value interval of the absolute value from the multiple channel value intervals in the static Huffman coding table; Look up a first target first association relationship associated with the first target channel value interval from the multiple first association relationships, and further, based on the first target first association relationship, obtain the target first Huffman code associated with the absolute value.
9. The method according to claim 7 or 8, wherein The step of looking up a first target second association relationship associated with the absolute value from the multiple second association relationships includes: According to the first target channel value interval, look up multiple second target second association relationships associated with the first target channel value interval from the multiple second association relationships; From the multiple second target second association relationships, look up the first target second association relationship including a fourth channel value associated with the absolute value according to the absolute value.
10. The method according to claim 4, wherein, The method further includes: Obtain the original code of the target compressed image and the target Huffman code in the preset channel prediction region, where the target compressed image is a coded image with m rows and n columns; Determine the first channel residual value associated with the target Huffman code according to the target Huffman code and the static Huffman coding table; Perform a sum value calculation on the first channel residual value and the second channel value obtained by decompressing the original code to obtain the first channel value corresponding to the first channel residual value; Integrate the first channel value and the second channel value to obtain the decompressed image after decompressing the target compressed image.
11. According to the method of claim 10, wherein, The step of determining the first channel residual value associated with the target Huffman code according to the target Huffman code and the static Huffman coding table includes: Split the target Huffman code into the first Huffman code, the extended bit width code, and the symbol code; Determine the first channel residual value of the target Huffman code according to the first Huffman code, the extended bit width code, the symbol code, and the static Huffman coding table.
12. The method according to claim 11, wherein, The step of determining the first channel residual value of the target Huffman code according to the first Huffman code, the extended bit width code, the symbol code, and the static Huffman coding table includes: Determine a second target channel value interval of the first Huffman code from the multiple first association relationships in the static Huffman coding table; Based on the second target channel value range and the extended bit width code, find the absolute value of the first channel residual value associated with the second target channel value range and the extended bit width code from the multiple second association relationships in the static Huffman coding table; Determine the positivity or negativity of the symbol code from the two third association relationships in the static Huffman coding table; Integrate the absolute value and the positivity or negativity to obtain the first channel residual value.
13. According to the method of claim 12, wherein The step of based on the second target channel value range and the extended bit width code, finding the absolute value of the first channel residual value associated with the second target channel value range and the extended bit width code from the multiple second association relationships in the static Huffman coding table includes: Based on the second target channel value range and the extended bit width code, find a third target second association relationship associated with the second target channel value range and the extended bit width code from the multiple second association relationships; Obtain a fourth channel value from the third target second association relationship to determine it as the absolute value of the first channel residual value.
14. The method according to claim 13, wherein, The step of based on the second target channel value range and the extended bit width code, finding a third target second association relationship associated with the second target channel value range and the extended bit width code from the multiple second association relationships includes: Based on the second target channel value range, find multiple fourth target second association relationships associated with the second target channel value range from the multiple second association relationships; Based on the extended bit width code, find the third target second association relationship corresponding to the extended bit width code from the multiple fourth target second association relationships.
15. The method according to claim 13, wherein The step of based on the second target channel value range and the extended bit width code, finding a third target second association relationship associated with the second target channel value range and the extended bit width code from the multiple second association relationships includes: Based on the extended bit width code, find multiple fifth target second association relationships associated with the extended bit width code from the multiple second association relationships; Based on the second target channel value range, find the third target second association relationship corresponding to the second target channel value range from the multiple fifth target second association relationships. The step of determining the second target channel value range of the first Huffman coding from the multiple first association relationships in the static Huffman coding table includes:
16. The method according to any one of claims 12 to 15, wherein, Based on the first Huffman coding, find a second target first association relationship associated with the first Huffman coding from the multiple first association relationships in the static Huffman coding table, and then, obtain the second target channel value range associated with the first Huffman coding from the second target first association relationship. The step of obtaining the original coding of the target compressed image and the target Huffman coding in the preset channel prediction region includes:
17. The method according to any one of claims 10 to 15, wherein According to the second start and end position information of the preset channel prediction region, obtain the preset channel prediction region, the target Huffman coding, and the original coding from the target compressed image, where the second start and end position information includes a second start position parameter j and a second end position parameter k, and a second division parameter for row division or column division of the image to be compressed.
18. According to the method of claim 17, wherein, The obtaining of the preset channel prediction region, the target Huffman coding, and the original coding from the target compressed image according to the second start and end position information of the preset channel prediction region includes: According to the second start position parameter j and the second end position parameter k, intercept the j-th group to the k-th group of the divided target compressed image to determine the preset channel prediction region, and further obtain the target Huffman coding of the preset channel prediction region; According to the second start position parameter j, intercept the first group to the (j - 1)-th group of the divided target compressed image to obtain the original coding, where j = 2, and k is m or n.
19. The method according to claim 18, wherein, The calculating the sum of the first channel residual value and the second channel value obtained by decompressing the original coding to obtain the first channel value corresponding to the first channel residual value includes: Decompress the original coding to obtain the second channel value; Taking the second channel value as the starting value, sequentially using the first channel residual values of each group from the j-th group to the k-th group of the target compressed image as added values, and accumulating them to the second channel value to obtain the first channel values of each group from the j-th group to the k-th group of the target compressed image.
20. An image compression device, wherein, It includes: A first determination module, configured to determine a first channel prediction value, a first channel value, and a second channel value of the image to be compressed in the preset channel prediction region; A first calculation module, configured to perform a difference calculation between the first channel value and the corresponding first channel prediction value to obtain the first channel residual value corresponding to the first channel value; A first acquisition module, configured to code the first channel residual value according to a static Huffman coding table to obtain the target Huffman coding of the first channel value, where the target Huffman coding includes a first Huffman coding, an extended bit width code, and a symbol code; A first integration module, configured to integrate the target Huffman coding and the original coding to obtain the target compressed image after compression of the image to be compressed, where the original coding corresponds to the second channel value of the image to be compressed that is not in the preset channel prediction region, and the original coding is used to decompress the target compressed image.
21. A computer-readable storage medium, including instructions, where when it runs on a computer, it causes the computer to execute the method according to any one of claims 1 to 19.
22. An electronic device, wherein, It includes a memory and a processor, and the processor is configured to execute program instructions stored in the memory to implement the method according to any one of claims 1 to 19.
Citation Information
Patent Citations
Image processing device
CN110087072A
Image lossless compression method and system
CN111093081A
Image compression method and 3D noise reduction method based on improved Huffman coding
CN114640857A
Image lossless processing method and system based on industrial camera
CN116634168A
Image processing method and related equipment thereof
CN117939127A