Image compression method, computer device and computer readable storage medium

By analyzing the image data characteristics and selecting suitable compression algorithms and encoding methods, the problems of low image compression efficiency and high processor performance of TFT screens are solved, and the image compression effect with high efficiency and low power consumption is achieved.

CN118573861BActive Publication Date: 2024-12-31ZHUHAI XINMAT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411052671.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-02
Publication Date
2024-12-31
Estimated Expiration
2044-08-02

AI Technical Summary

Technical Problem

When the existing image compression method processes image data of TFT screens, the compression efficiency is not high and the processor performance requirements are high, which can easily lead to overheating or power consumption problems, and there is no optimization compression based on the data characteristics.

Method used

By obtaining the pixel value difference data of the image, querying the zero difference data and the frequency value group with the highest frequency, selecting the algorithm that occupies the smallest storage space among different compression algorithms for compression, combining zero encoding, address encoding and original encoding data for synthesis. Dynamically adjust the compression algorithm to achieve the optimal compression rate.

Benefits of technology

Efficient image compression in low processor performance is achieved, reducing processor cost and power consumption requirements, and ensuring higher compression rates and lower decompression processing requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118573861B_ABST
    Figure CN118573861B_ABST
Patent Text Reader

Abstract

The present invention provides an image compression method, a computer device and a computer-readable storage medium, the method comprising: obtaining at least one original image, and obtaining the pixel value of each pixel point of the original image, calculating the difference between the pixel value of the target pixel point and the reference pixel point of the original image, and obtaining a plurality of difference data; querying the frequency value group with the highest frequency in the remaining difference data; obtaining the compressed storage space occupied by a plurality of different compression algorithms when running, and applying the target compression algorithm with the minimum value in the compressed storage space to compress the original image; when calculating the compressed storage space corresponding to each compression algorithm, traversing the values ​​of a preset range, calculating a plurality of original image compressed storage spaces according to the values ​​of the preset range, and taking the preset range corresponding to the minimum original image compressed storage space as the target preset range value. The present invention ensures a higher compression rate when the processor can correctly compress the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image compression, and in particular to an image compression method, a computer device and a computer-readable storage medium. Background Art

[0002] In the application of TFT screen displaying images, the processor is responsible for image processing and image display, and the memory is used to store computer programs and images. The data format of TFT screen pixels is generally binary data Red5Green6Blue5, so the image storage of TFT screen is generally stored in binary data. Therefore, when processing the data of TFT screen, the larger the image data to be processed, the larger the storage capacity of the memory needs to be.

[0003] When using lossy compression algorithms such as JPEG algorithm to compress images on a small-resolution TFT screen, the decompressed image is prone to blurring due to the small number of pixels on the small-resolution TFT screen. When using lossless compression algorithms such as PNG algorithm to compress, since the PNG algorithm compresses images with a pixel data format of Red8Green8Blue8 into 3 8-bit data, its compression rate is not high when applied to TFT screens, and the algorithm is complex, the processor requires higher processing performance, increasing the cost of the processor.

[0004] An existing image stream compression method includes confirming the pixels of an image in an image stream: obtaining the horizontal high-frequency component W and the vertical high-frequency component H of the image through the resolution of the image; generating an image sequence: sorting each frame of the image in the image stream by dividing the frame sequence of motion picture data according to the image plane, and generating a corresponding image sequence for each frame of the image; confirming the compression reference image: selecting one of the frames of the image in the image stream as the compression reference image; image comparison: comparing each frame of the image in the image stream with the compression reference image along the image sequence, obtaining the repetition of the image and the compression reference image and extracting the difference between the image and the compression reference image; image stream compression: compressing each frame of the image in the image stream along the image sequence relative to the compression reference image in units of a single frame of the image, and generating image compression coding. However, the image compression method performs difference calculation on all pixel points of the image and performs coding compression based on the difference calculation. In the decompression process, the processor needs to have high processing performance, which increases the cost of the processor. When the processing performance of the processor is poor, a large amount of calculation makes the processor in a high-load state, and the processor may cause errors in image compression due to overheating or power consumption problems. Furthermore, the image compression method does not perform compression according to data characteristics, resulting in low compression efficiency. Summary of the invention

[0005] A first object of the present invention is to provide an image compression method that performs compression according to data characteristics.

[0006] The second object of the present invention is to provide a computer device for implementing the above-mentioned image compression method.

[0007] A third object of the present invention is to provide a computer-readable storage medium for an image compression method applying the above-mentioned image compression method.

[0008] To achieve the first objective of the present invention, the present invention provides an image compression method, comprising:

[0009] The image compression method comprises: obtaining at least one original image, and obtaining the pixel value of each pixel point of the original image, calculating the difference between the pixel value of the target pixel point of the original image and the pixel value of the reference pixel point, and obtaining a plurality of difference data; querying the data with a difference of zero in the plurality of difference data, and recording them as zero difference data; querying the remaining difference data except the data with a difference of zero in the difference data, and the frequency value group with the highest frequency, wherein the number of values ​​in the frequency value group is a value within a preset range; obtaining the compressed storage space occupied by a preset number of different compression algorithms when running, and applying a target compression algorithm that occupies the minimum value of the compressed storage space among the plurality of compression algorithms to compress the original image; wherein obtaining the compressed storage space occupied by the preset number of different compression algorithms when running comprises: when calculating the compressed storage space corresponding to each compression algorithm, traversing the values ​​within the preset range, calculating the compressed storage space corresponding to a plurality of original images according to the values ​​within the preset range, querying the minimum compressed storage space of the original image, and taking the preset range corresponding to the minimum compressed storage space of the original image as the target preset range value.

[0010] As can be seen from the above scheme, different compression algorithms have different processing methods for each data. The present invention is provided with three compression algorithms. The first compression algorithm reduces the encoding amount of the original encoded data, the second compression algorithm reduces the encoding amount of the zero-encoded data, and the third compression algorithm reduces the encoding amount of the address data. By calculating the storage space of the original image using different compression algorithms, the compression method with the smallest storage space is selected for compression, so that the compression method can be flexibly processed, so that the compression rate can be optimal. And the preset range is the compression range when the image is compressed in the processor. By calculating the original image compression storage space within the preset range, the target preset range value with the highest compression rate within the preset range is calculated. Compression by the target preset range value can ensure a higher compression rate when the processor can correctly and losslessly compress the image. And because the pixel values ​​of the pixels in each original image are inconsistent, the compression method of each original image can be confirmed by calculating multiple original image compression storage spaces to confirm the target preset range value, and each original image can ensure the optimal compression rate. And the processor performance requirements are low during decompression, and the generated data can be directly pushed to the screen, reducing the cost and power consumption requirements of the processor.

[0011] In a further scheme, the step of compressing the compression algorithm corresponding to the minimum value in multiple compressed storage spaces includes: encoding zero difference data to obtain zero-coded data; encoding the target frequency value group of the target preset range value, and using the encoding result of the target frequency value group as address data; retaining the remaining data of the original image, encoding the remaining data to form original coded data; and synthesizing image compression data based on pixel position of the zero-coded data, address data and original coded data.

[0012] It can be seen that the image compression data can ensure the optimal compression rate within the processing range of the processor.

[0013] In a further scheme, the compression algorithms include a first compression algorithm, a second compression algorithm and a third compression algorithm; the amount of zero-coded data of the second compression algorithm is smaller than the amount of zero-coded data of the first compression algorithm, and the amount of zero-coded data of the second compression algorithm is smaller than the amount of zero-coded data of the third compression algorithm.

[0014] It can be seen that the second compression algorithm records zero-coded data as a one-bit value, and the first compression algorithm and the third compression algorithm record zero-coded data as a two-bit value. When there are many pixels whose difference between the original image and the reference image is zero, selecting the second compression algorithm can increase the compression rate.

[0015] In a further scheme, the original encoded data of the first compression algorithm includes a first guide code, the original encoded data of the second compression algorithm is provided with a second guide code, and the original encoded data of the third compression algorithm is provided with a third guide code; the data amount of the first guide code is smaller than the data amount of the second guide code, and the data amount of the first guide code is smaller than the data amount of the third guide code.

[0016] It can be seen that the first compression algorithm records the first guide code as a one-bit value, the second compression algorithm and the third compression algorithm respectively record the second guide code and the third guide code as two-bit values. When the original image retains more original coding data of the original pixels, selecting the first compression algorithm can improve the compression rate.

[0017] In a further scheme, the address data of the first compression algorithm includes a fourth guide code, the address data of the second compression algorithm includes a fifth guide code, and the address data of the third compression algorithm includes a sixth guide code; the data amount of the sixth guide code is smaller than the data amount of the fourth guide code, and the data amount of the sixth guide code is smaller than the data amount of the fifth guide code.

[0018] It can be seen that the third compression algorithm records the sixth guide code as a one-bit value, the first compression algorithm and the second compression algorithm respectively record the fourth guide code and the fifth guide code as two-bit values. When the original image has more address codes, selecting the third compression algorithm can improve the compression rate.

[0019] In a further scheme, after compressing the compression algorithm corresponding to the minimum value of multiple compression storage spaces, the following is also performed: calculating the current image compression rate and the average compression rate of compressed images, judging whether the current image compression rate is greater than the average compression rate, if not, defining the original image currently being compressed as a reference image; if the current image compression rate is greater than the average compression rate, updating the average compression rate.

[0020] In a further solution, updating the average compression rate includes: calculating the sum of the compression rates of multiple latest compressed images by the average compression rate of multiple compressed images and the compression rate of the current image, and then dividing the sum by the number of latest compressed images to obtain the latest average compression rate.

[0021] It can be seen that by comparing the current image compression rate and the average compression rate, if the average compression rate is less than the current image compression rate, it proves that the compression rate has deteriorated, that is, the reference image needs to be changed so that the compression effect will not deteriorate further during subsequent compression.

[0022] In a further scheme, calculating the difference between the pixel values ​​of the target pixel point of the original image and the reference pixel point includes: calculating the difference between the pixel value of the target pixel point of the original image and the pixel value of the corresponding pixel point of the reference image; or calculating the difference between the pixel value of the target pixel point of the original image and the pixel value of the previous pixel point of the original image.

[0023] It can be seen that when the original image is defined as a dynamic image, the reference pixel is the pixel corresponding to the target pixel on the reference image; when the original image is defined as a reference image, the reference pixel is the previous pixel of the original image.

[0024] In order to achieve the second purpose of the present invention, the computer device provided by the present invention includes a processor and a memory, wherein the memory stores a computer program, and is characterized in that the computer program implements the above-mentioned image compression method when executed by the processor.

[0025] In order to achieve the third objective of the present invention, the present invention provides a computer-readable storage medium, on which a computer program is stored, characterized in that the above-mentioned image compression method is implemented when the computer program is executed. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 It is a flow chart of an embodiment of the image compression method of the present invention.

[0027] The present invention is further described below in conjunction with the accompanying drawings and embodiments. DETAILED DESCRIPTION

[0028] The image compression method of the present invention calculates the storage space of different compression algorithms to determine the compression algorithm with the smallest storage space, and uses the compression algorithm for compression, so that the image compression method of the present invention selects different compression algorithms for compression according to different data characteristics, thereby improving compression efficiency.

[0029] Image compression method embodiment:

[0030] See also Figure 1In this embodiment, multiple original images are provided, and the processor first executes step S1 to obtain at least one original image. After the processor sorts the original images, it reads the data of multiple original images. Among them, the pixel points of the original image are set to Width×Length=n, Width is the number of pixels in the row direction of the original image, and Length is the number of pixels in the column direction of the original image. Among them, the number of original images is p. Convert multiple original images into RGB565 format, wherein each pixel point of the original image includes 3 8-bit RGB data to 5 bits R (red), 6 bits G (green), and 5 bits B (blue), and splice the three RGB data into a 16-bit data. Furthermore, if in order to improve the compression efficiency, RGB565 can be further approximated and truncated to generate data with a bit width less than 16. For the sake of clear description, the following embodiments use data with a bit width of 16 for illustration.

[0031] Through the original row and column distribution of the original image, there are two ways of row and column splicing: row end splicing and column end splicing. For the reference image, the optimization method is to compare the compression efficiency of these two splicing methods. The following takes the row end splicing as an example to illustrate a specific implementation method. You can get multiple original image data pic_src1, pic_src2, pic_src3...pic_srcp. Among them, the data of the kth original image pic_srck is pic_srck[1:n].

[0032] In this embodiment, before starting to compress multiple original images, the first original image pic_src1 is defined as a reference image, that is, pic_src_ref[1:n]=pic_src1[1:n]. pic_src_ref[1:n] is the original data of the reference image, and pic_src1[1:n] is the original image data of the first image. The remaining images are defined as dynamic images.

[0033] After obtaining the original image, execute step S2 to obtain the pixel value of each pixel of the original image, calculate the difference between the pixel value of the target pixel of the original image and the pixel value of the reference pixel, and obtain multiple difference data. The original image currently being compressed is defined as the current image, i.e., pic_srck[1:n]. Read the data of the current image, perform difference calculation on the current image and the reference image, and obtain multiple difference data pic_delta[1:n]. If the current image is a reference image, i.e., pic_src_ref[1:n]=pic_srck[1:n], calculate the difference between the pixel value of the target pixel of the original image and the pixel value of the previous pixel corresponding to the original image, and the calculation method of the difference data is:

[0034] pic_delta[1]=pic_src_ref[1];

[0035] pic_delta[2]=pic_src_ref[2]-pic_src_ref[1]; ......

[0037] pic_delta[n]=pic_src_ref[n]-pic_src_ref[n-1].

[0038] The previous pixel defined here can be the previous column of pixels in the same row, or the previous row of pixels in the same column. One of them is selected as the compression option for this image according to the final compression rate and the information is retained.

[0039] If the current image is a dynamic image, the pixel value of the target pixel point of the original image and the pixel value of the corresponding pixel point of the reference image are calculated, and the difference is calculated as follows:

[0040] pic_delta[1]=pic_srck[1]-pic_src_ref[1];

[0041] pic_delta[2]=pic_srck[2]-pic_src_ref[2]; ......

[0043] pic_delta[n]=pic_srck[n]-pic_src_ref[n].

[0044] The difference obtained by the above calculation is converted into a 16-bit complement code for storage.

[0045] After obtaining the difference data, step S3 is executed to search for data with a difference of zero in the plurality of difference data and record it as zero difference data. In the plurality of difference data pic_delta[1:n], search for data with a difference of zero and record the number of occurrences of the zero difference data as pic_hf0.

[0046] After recording the zero difference data, step S4 is executed to query the frequency value group with the highest frequency in the difference data except the data with zero difference, wherein the number of values ​​in the frequency value group is the value in the preset range. The preset range is the compression processing range when the processor compresses the original image. In this embodiment, the preset range is defined as , where the value range of m is set to [3,7] in this embodiment. The value range of m is determined according to the performance of the processor and is not limited to the value range of [3,7]. Where m is a natural number. However, the preset range can also be directly defined as m, and the value range of m is [8,128]. In order to reduce the amount of calculation, the preset range in this embodiment is defined as 2 m . The frequency value group with the highest frequency in the difference data is queried according to the value range of the preset range, that is, the number of frequency values ​​in the query frequency value group is determined according to the value range of the preset range, and then the frequency value group with the highest frequency is queried according to the number of values, that is, the 2 with the highest frequency is found. m Since the value range of m is [3,7], the number of frequency value groups is five, and the number of values ​​of each frequency value group is determined according to the preset range. In this embodiment, the frequency value group pic_table[1:2 m ] and the number of times each frequency value in the frequency value group appears in the difference data pic_hf[1:2 m ].

[0047] After querying the frequency value group with the highest frequency in the difference data, execute step S5 to obtain the compressed storage space occupied by a preset number of different compression algorithms when running, and apply the compression algorithm corresponding to the minimum value of the compressed storage space occupied by multiple compression algorithms for compression.

[0048] Among them, calculating the compressed storage space corresponding to different compression algorithms includes traversing the values ​​in the preset range, calculating multiple original image compressed storage spaces according to the values ​​in the preset range, querying the smallest original image compressed storage space, and determining the target preset range value.

[0049] In this embodiment, three compression algorithms are provided, which are respectively a first compression algorithm, a second compression algorithm and a third compression algorithm, wherein different compression algorithms have different calculation formulas for calculating the compressed storage space of the original image.

[0050] The calculation formula of the original image compression storage space of the first compression algorithm is: TM1=2×pic_hf0+(2+m)×sum(pic_hf[1:2 m ])+17×(n-sum(pic_hf[1:2 m ])-pic_hf0)+17×2 m; Wherein, the value range of m is [3,7], and multiple original image compression storage spaces are calculated according to the values ​​in the preset range, that is, multiple TM1 values ​​are calculated by the value range of m. The minimum original image compression storage space in the first compression algorithm is queried, that is, TM1_min is queried among the multiple TM1 values, and the minimum value m_min1 of m corresponding to TM1_min, m_min1 is the target preset range value.

[0051] The calculation formula of the original image compression storage space of the second compression algorithm is TM2=1×pic_hf0+(2+m)×sum(pic_hf[1:2 m ])+18×(n-sum(pic_hf[1:2 m ])-pic_hf0)+17×2 m , where the value range of m is [3,7]. Multiple original image compression storage spaces are calculated according to the values ​​in the preset range, that is, multiple TM2 values ​​are calculated by the value range of m. The minimum original image compression storage space in the second compression algorithm is queried, that is, TM2_min is queried among the multiple TM2 values, and the minimum value m_min2 of m corresponding to TM2_min, where m_min2 is the target preset range value.

[0052] The calculation formula of the original image compression storage space of the third compression algorithm is TM3=2×pic_hf0+(1+m)×sum(pic_hf[1:2 m ])+18×(n-sum(pic_hf[1:2 m ])-pic_hf0)+17×2 m . The value range of m is [3,7]. Multiple original image compression storage spaces are calculated according to the values ​​in the preset range, that is, multiple TM3 values ​​are calculated by the value range of m. The minimum original image compression storage space in the second compression algorithm is queried, that is, TM3_min is queried among the multiple TM3 values, and the minimum value m_min3 of m corresponding to TM3_min, m_min3 is the target preset range value.

[0053] In step S5, the target compression algorithm that occupies the minimum value in the compressed storage space among the multiple compression algorithms is used to compress the original image, that is, TM1_min, TM2_min and TM3_min are compared; if TM1_min is the minimum value, the first compression algorithm is used for compression; if TM2_min is the minimum value, the second compression algorithm is used for compression; if TM3_min is the minimum value, the third compression algorithm is used for compression.

[0054] Among them, the three compression algorithms all encode the zero difference data to obtain zero-coded data; encode the target frequency value group of the target preset range value, and use the encoding result of the target frequency value group as the address data; retain the remaining data of the original image, and encode the remaining data to form the original coded data; and synthesize the zero-coded data, address data and original coded data into image compression data according to the pixel position.

[0055] In the first compression algorithm, the zero code data is 2 bits of data (00). The address data is 2 bits of data (01) + m_min1 bits of data (pic_table_addr). In the address data, the 2 bits of data (01) are the fourth guide code. Since the value of m in the first compression algorithm is m_min1, the target frequency value group is pic_table[1:2 m_min1 ], pic_table_addr is the address code, through which the target frequency value group pic_table[1: 2 m _min1 ] If the current image is a reference image, the original coded data is 1 bit data (1) + 16 bits data (pic_src_ref[1:n]); if the current image is a dynamic image, the original coded data is 1 bit data (1) + 16 bits data (pic_srck[1:n]). Among them, 1 bit data (1) is the first guide code. The original coded data retains the original data.

[0056] In the second compression algorithm, the zero code data is 1 bit data (1). The address data is 2 bits data (01) + m_min2 bits data (pic_table_addr). Among them, the 2 bits data (01) is the fifth guide code. Since the value of m in the second compression algorithm is m_min2, the target frequency value group is pic_table[1:2 m_min2 ], pic_table_addr is the address code, through which the target frequency value group pic_table[1:2 m_min2 ] If the current image is a reference image, the original coded data is 2-bit data (00) + 16-bit data (pic_src_ref[1:n]); if the current image is a dynamic image, the original coded data is 2-bit data (00) + 16-bit data (pic_srck[1:n]). Among them, the 2-bit data (00) is the second guide code. The original coded data retains the original data.

[0057] In the third compression algorithm, the zero code data is 2 bits of data (00). The address data is 2 bits of data (01) + m_min3 bits of data (pic_table_addr). Among them, the 2 bits of data (01) are the sixth guide code. Since the value of m in the third compression algorithm is m_min3, the target frequency value group is pic_table[1:2 m_min3 ], pic_table_addr is the address code, through which the target frequency value group pic_table[1:2 m_min3 ] If the current image is a reference image, the original coded data is 2-bit data (00) + 16-bit data (pic_src_ref[1:n]); if the current image is a dynamic image, the original coded data is 2-bit data (00) + 16-bit data (pic_srck[1:n]). Among them, the 2-bit data (00) is the third guide code. The original coded data retains the original data.

[0058] Among them, the data amount of the zero-coded data of the second compression algorithm is less than the data amount of the zero-coded data of the first compression algorithm, and the data amount of the zero-coded data of the second compression algorithm is less than the data amount of the zero-coded data of the third compression algorithm. The data amount of the first guide code is less than the data amount of the second guide code, and the data amount of the first guide code is less than the data amount of the third guide code. The data amount of the sixth guide code is less than the data amount of the fourth guide code, and the data amount of the sixth guide code is less than the data amount of the fifth guide code.

[0059] That is, the first compression algorithm in this embodiment reduces the amount of code of the original code data, the second compression algorithm reduces the amount of code of the zero code data, and the third compression algorithm reduces the amount of code of the address data. By calculating the storage space of different compression algorithms and then determining which compression algorithm to use, the compression rate can be increased.

[0060] After synthesizing the image compression data, the current image compression rate and the average compression rate of the compressed images are calculated to determine whether the current image compression rate is greater than the average compression rate. If not, the currently compressed original image is defined as the latest reference image; if the current image compression rate is greater than the average compression rate, the average compression rate is updated. After being defined as the latest reference image, the reference image needs to re-execute the compression steps of step S1 to step S5 as a reference for subsequent dynamic images. The greater the compression rate, the better the compression effect.

[0061] The step of updating the average compression rate includes calculating the sum of the compression rates of multiple latest compressed images by the average compression rate of multiple compressed images and the compression rate of the current image, and then dividing it by the number of latest compressed images to obtain the latest average compression rate. The calculation formula for updating the average compression rate is c_ref=(c_ref×p_ref+c_k) / (p_ref+1). c_ref is the average compression rate, c_k is the current image compression rate, and p_ref is the number of compressed images. The reference image can be updated by this method so that the compression effect will not deteriorate further when compression is performed subsequently.

[0062] When the image needs to be decompressed, the image compression data and header file information are read, and the header file information includes the compression algorithm type and the image type. The compression algorithm type is the first compression algorithm, the second compression algorithm, or the third compression algorithm, and the image type is a reference image or a dynamic image. The compression program is configured according to the header file information. The first compression algorithm and the reference image are used as examples below.

[0063] The number of pixels of the reference image read is recorded as p_count_tt1, three data buffers pic_table_buffer1, dat_buffer1, and dec_buffer1 are configured from the memory, the three data buffers are used for decompression, the target frequency value group pic_table is read from the memory and saved in the data buffer pic_table_buffer1, and the image compression data is saved in the data buffer dat_buffer1.

[0064] First, the data of the corresponding data unit word is obtained from the data buffer dat_buffer1 and assigned to the data group dat_w0. Furthermore, when decompressing for the first time, 32-bit data is read from the data buffer dat_buffer1 to the data group dat_w0, and the position counter c_cout1 is set to 32. Among them, the 32-bit data is two data units word. Since the 32-bit data assigned to the data group dat_w0 for the first time is the data of the original image, the first 16 bits of data in the assigned data group dat_w0 are assigned to the decompressed data dat_dec0, and the first data unit word in the decompressed data dat_dec0 ​​is saved to the high 16 bits of the data unit of the data buffer dec_buffer1, and the subsequent data of the data group dat_w0 is shifted to the left by 16 bits. At this time, the position counter c_cout1-16, the image decompression counter c_count_tt1=1.

[0065] Determine whether the image compression counter c_count_tt1 is equal to the image compression pixel p_count_tt1. If so, complete the decoding of the image. If not, continue to execute the next step.

[0066] Determine whether the number of bits of the position counter c_cout1 is less than or equal to 16. If so, obtain the data of the next data unit word, i.e., 16-bit data, from the data buffer dat_buffer1. Shift the 16-bit data of the data unit word to the left by 16-c_cout1 bits and perform an OR operation with the data group dat_w0 to obtain a new data group dat_w0.

[0067] Determine the highest bit dat_w0

[31] in the new data group dat_w0, that is, the highest bit of the guide code in the data. Since the first compression algorithm is used as an example at this time, if dat_w0

[31] =1, that is, the guide code is the guide code of the original coded data, then the decompressed data dat_dec0=dat_w0[30:16], that is, the code of the original coded data from the 31st to the 16th bit is used as the new decompressed data, and the new decompressed data is saved in the data unit of the data buffer dec_buffer1. At this time, the position counter c_cout1-17, 17 is the number of bits of the original coded data, and the image compression counter c_count_tt1+1.

[0068] If the highest bit dat_w0

[31] in the new data group dat_w0 is 0, it proves that there are two guide codes, and it is necessary to continue to judge the next bit dat_w0

[30] in the new data group dat_w0.

[0069] If dat_w0

[30] =0, it proves that the leading code is the leading code of the zero-coded data, and the last decompressed data dat_dec0 ​​needs to be written into the data buffer dec_buffer. At this time, the position counter c_cout1-2 and the image compression counter c_count_tt1+1.

[0070] If dat_w0

[30] =1, it proves that the guide code is the guide code of the address data, then the new decompressed data is dat_dec0=pic_table[dat_w0[29:30-m]]+dat_dec0, that is, the address code data is obtained from the data group, and then the difference information is queried from the target frequency value group, and then the difference is added to the previous decompressed data to obtain the new decompressed data, and the new decompressed data is saved in the data unit of the data buffer area dec_buffer1. At this time, the image compression counter c_count_tt1+1.

[0071] After the new decompressed data is saved in the data unit of the data buffer dec_buffer1, the process returns to the step of determining whether the image compression counter c_count_tt1 is equal to the image compression pixel p_count_tt1.

[0072] If the currently decompressed image is a dynamic image, first, the decompressed reference image is placed in ref_dec_buffer1. In addition, the pixel count of this dynamic image is set to p_count_tt2. At the same time, three data buffers pic_table_buffer2, dat_buffer2, and dec_buffer2 are configured from the memory. The three data buffers are used for decompression. The target frequency value group pic_table is read from the memory and saved in the data buffer pic_table_buffer2. The image compression data is saved in the data buffer dat_buffer2.

[0073] First, the data of the corresponding data unit word is obtained from the data buffer dat_buffer2 and assigned to the data group dat_w2. When decompressing for the first time, 32 bits of data are read from the data buffer dat_buffer2 to the data group dat_w2, and the position counter c_cout2 is set to 32. At this time, the image decompression counter c_count_tt2=0.

[0074] Determine whether the image decompression counter c_count_tt2 is equal to the number of pixels p_count_tt2 of the dynamic image. If the image decompression counter c_count_tt2 is equal to the number of pixels p_count_tt2 of the dynamic image, the decompression process of the dynamic image is completed. If the image decompression counter c_count_tt2 is not equal to the number of pixels p_count_tt2 of the dynamic image, determine whether the number of bits of the position counter c_cout2 is less than or equal to 16. If the number of bits of the position counter c_cout2 is less than or equal to 16, obtain 16-bit data from the data buffer dat_buffer2, and shift the 16-bit data left by 16-c_cout2, and OR it with the data group dat_w2 to obtain a new data group dat_w2.

[0075] Determine the highest bit dat_w2

[31] in the new data group dat_w2, that is, the highest bit of the guide code in the data. Since the first compression algorithm is used as an example at this time, if dat_w2

[31] =1, that is, the guide code is the guide code of the original coded data, then the decompressed data dat_dec2=dat_w2[30:16], that is, the code of the original coded data from the 31st to the 16th bit is used as the new decompressed data, and the new decompressed data is saved in the data unit of the data buffer dec_buffer2. At this time, the position counter c_cout2-17, 17 is the number of bits of the original coded data, and the image compression counter c_count_tt2+1.

[0076] If the highest bit dat_w2

[31] in the new data group dat_w2=0, it proves that there are two guide codes, and it is necessary to continue to judge the next bit dat_w2

[30] in the new data group dat_w2.

[0077] If dat_w2

[30] =0, it proves that the guide code is the guide code of zero-coded data, then it is necessary to obtain the decompressed data of the pixel point corresponding to the reference image, and write the decompressed data into the data buffer dec_buffer2. At this time, the position counter c_cout2-2, the image compression counter c_count_tt2+1.

[0078] If dat_w0

[30] =1, it proves that the guide code is the guide code of the address data. Then the new decompressed data is dat_dec2=pic_table[dat_w2[30:31-m]]+ref_dec_buffer1(c_count_tt2+1). That is, the address code data is obtained from the data group, and then the difference information is queried from the target frequency value group, and then the difference is added to the decompressed data of the pixel point corresponding to the pixel point in the reference image to obtain the new decompressed data, and the new decompressed data is saved to the data unit of the data buffer dec_buffer2. At this time, the image compression counter c_count_tt2+1.

[0079] After the new decompressed data is saved in the data unit of the data buffer dec_buffer2, the process returns to the step of determining whether the image compression counter c_count_tt2 is equal to the image compression pixel p_count_tt2.

[0080] In this embodiment, by calculating the storage space of different compression algorithms, the compression method with the smallest storage space is selected for compression, so that the compression method can be flexibly processed, so that the compression rate can be optimized. In addition, by calculating the original image compression storage space within a preset range, the target preset range value with the highest compression rate within the preset range is calculated. Compression by the target preset range value can ensure a higher compression rate when the processor can handle the image compression amount of the image.

[0081] Computer device embodiment:

[0082] The computer device of this embodiment includes a processor and a memory. The memory stores a computer program. When the processor executes the computer program, the above-mentioned image compression method embodiment is implemented.

[0083] The computer device may include but is not limited to a processor and a memory. Those skilled in the art will appreciate that the computer device may include more or fewer components, or a combination of certain components, or different components, for example, the computer device may also include input and output devices, network access devices, buses, etc.

[0084] Computer readable storage medium embodiment:

[0085] The image compression method in the computer device described in the above embodiment can be stored in a computer readable storage medium in the form of a computer program. When the computer program is executed by a processor, the steps of the above-mentioned image compression method embodiment in the computer device can be completed. The computer readable medium can be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0086] The above are only preferred embodiments of the present invention, but the design concept of the invention is not limited thereto. Without departing from the concept of the present invention, more other equivalent embodiments may be included. It is obvious to those skilled in the art that various changes, readjustments and substitutions can be made without departing from the protection scope of the present invention.

Claims

1. An image compression method, comprising: Acquire at least one original image, and acquire pixel values ​​of each pixel point of the original image, calculate the difference between the pixel values ​​of the target pixel point and the reference pixel point of the original image, and obtain a plurality of difference data; Querying data with a difference of zero among the plurality of difference data, and recording the data as zero difference data; Features: Querying the frequency value group with the highest frequency in the remaining difference data except the data with the difference value of zero in the difference data, wherein the number of frequency values ​​of the query frequency value group is determined according to the value range of the preset range, and the frequency value group with the highest frequency is queried according to the number, the number of values ​​in the frequency value group is a value of the preset range, and the preset range is the compression processing range when the processor compresses the original image; Obtaining compressed storage spaces occupied by a preset number of different compression algorithms when they are running, and applying a target compression algorithm that occupies a minimum value of the compressed storage spaces among the multiple compression algorithms to compress the original image; Wherein, obtaining the compressed storage space occupied by a preset number of different compression algorithms when running includes: When calculating the compression storage space corresponding to each compression algorithm, the preset range of values ​​is traversed, multiple original image compression storage spaces are calculated according to the preset range of values, the smallest original image compression storage space is searched, and the preset range of values ​​corresponding to the smallest original image compression storage space is used as the target preset range of values; The step of applying a target compression algorithm that occupies a minimum value in the compression storage space among multiple compression algorithms to compress the original image comprises: The target frequency value group of the target preset range value is encoded, and the encoding result of the target frequency value group is used as address data.

2. The image compression method according to claim 1, characterized in that: The step of applying a target compression algorithm that occupies a minimum value in the compression storage space among multiple compression algorithms to compress the original image comprises: Encoding the zero difference data to obtain zero-coded data; retaining the remaining data of the original image, and encoding the remaining data to form original encoded data; The zero-coded data, the address data and the original coded data are synthesized into image compression data according to pixel positions.

3. The image compression method according to claim 2, characterized in that: The compression algorithms include a first compression algorithm, a second compression algorithm and a third compression algorithm; The amount of zero-coded data of the second compression algorithm is smaller than that of the first compression algorithm, and the amount of zero-coded data of the second compression algorithm is smaller than that of the third compression algorithm.

4. The image compression method according to claim 3, characterized in that: The original coded data of the first compression algorithm includes first guide coded data, the original coded data of the second compression algorithm is provided with second guide coded data, and the original coded data of the third compression algorithm is provided with third guide coded data; The data amount of the first guide code data is smaller than the data amount of the second guide code data, and the data amount of the first guide code data is smaller than the data amount of the third guide code data.

5. The image compression method according to claim 3 or 4, characterized in that: The address data of the first compression algorithm includes fourth boot code data, the address data of the second compression algorithm includes fifth boot code data, and the address data of the third compression algorithm includes sixth boot code data; The data amount of the sixth pilot code data is smaller than the data amount of the fourth pilot code data, and the data amount of the sixth pilot code data is smaller than the data amount of the fifth pilot code data.

6. The image compression method according to any one of claims 1 to 4, characterized in that: After applying the compression algorithm corresponding to the minimum value in the plurality of compression storage spaces for compression, further executing: respectively calculating the compression rate of the current image and the average compression rate of the plurality of compressed images, and determining whether the compression rate of the current image is greater than the average compression rate of the plurality of compressed images; if not, defining the original image currently being compressed as the latest reference image; If the current image compression rate is greater than the average compression rate of multiple compressed images, the average compression rate is updated.

7. The image compression method according to claim 6, characterized in that: Updating the average compression rate includes: calculating the sum of compression rates of multiple latest compressed images by the average compression rate of multiple compressed images and the compression rate of the current image, and then dividing the sum by the number of latest compressed images to obtain the latest average compression rate.

8. The image compression method according to claim 7, characterized in that: Calculating the difference between the pixel values ​​of the target pixel point and the reference pixel point of the original image includes: Calculating the difference between the pixel value of the target pixel point of the original image and the pixel value of the corresponding pixel point of the reference image; or The difference between the pixel value of the target pixel point of the original image and the pixel value of the previous pixel point of the original image is calculated.

9. A computer device comprising a processor and a memory, wherein the memory stores a computer program, wherein: When the computer program is executed by the processor, the image compression method according to any one of claims 1 to 8 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed, the image compression method according to any one of claims 1 to 8 is implemented.