16-bit grayscale image lossless compression method and decompression method

By calculating the grayscale difference value of the 16-bit grayscale image and performing lossless conversion and encoding, the problem of low compression efficiency of 16-bit high-color depth images in the prior art is solved, efficient lossless compression and decompression are achieved, and compression ratio and transmission speed are improved.

CN119697381APending Publication Date: 2025-03-25王诗琪
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411912011.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

The existing lossless image compression method has limited support for 16-bit high color depth images, low compression ratio and a large CPU resource occupancy, making it difficult to meet storage and transmission needs.

Method used

A lossless compression method of 16-bit grayscale image is proposed. By calculating the grayscale difference between adjacent pixels, lossless conversion and encoding, the difference value sequence is encoded using preset encoding methods such as stroke encoding and zstd encoding.

Benefits of technology

The compression ratio of 16-bit grayscale images is improved from about 50% to about 60-90%, reducing data storage costs, improving data transmission speed, and achieving efficient compression and decompression efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119697381A_ABST
    Figure CN119697381A_ABST
Patent Text Reader

Abstract

The invention provides a 16-bit grayscale image lossless compression method and decompression method, and belongs to the technical field of digital image processing, and the compression method comprises the steps: obtaining 16-bit grayscale image data and image meta-information, the image meta-information comprising width, height, bit depth, scanning rules and a preset coding method; according to the sequence, the width, the height and the bit depth in the scanning rule, calculating a gray scale difference value between adjacent pixels in the 16-bit gray scale image data to obtain a difference value sequence of the 16-bit gray scale image data; carrying out lossless conversion on the difference value sequence; and coding the difference value sequence after lossless conversion by adopting a preset coding method to obtain a compression result of the 16-bit grayscale image data. Compared with a traditional method, the compression ratio of the method is improved from about 50% to about 60-90%, the data transmission speed is improved, and especially in the current cloud storage environment, the data transmission speed can be remarkably improved through the higher compression ratio.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of digital image processing, and in particular relates to a 16-bit grayscale image lossless compression method and a decompression method. Background Art

[0002] In professional fields such as medical imaging, 16-bit grayscale images are widely used due to their high dynamic range (0-65535) and rich detail information. Based on the accuracy requirements of medical diagnosis and relevant regulations, such images need to be stored losslessly. However, existing image lossless compression methods (such as PNG, TIFF, RLE, JPEG-LS, J2K-LS, etc.) usually have limited support for 16-bit high-color depth images, and can only achieve a compression ratio of about 50%. In addition, these compression algorithms usually require more CPU resources for compression and decompression, which is difficult to meet the growing storage and transmission needs.

[0003] In the prior art, lossy compression is usually used to store images. The images are 8-bit grayscale or 24-bit / 32-bit true color images. The application fields are usually in the Internet, media, game entertainment and other related industries. There is a lack of targeted design for lossless compression of 16-bit grayscale images in professional fields. Summary of the invention

[0004] In view of the deficiencies in the prior art, the present application proposes a 16-bit grayscale image lossless compression method and a decompression method.

[0005] In a first aspect, the present application proposes a 16-bit grayscale image lossless compression method, comprising:

[0006] Acquire 16-bit grayscale image data and image meta-information, wherein the image meta-information includes: width, height, bit depth, scanning rule, and preset encoding method;

[0007] Calculate the grayscale difference between adjacent pixels in the 16-bit grayscale image data according to the order, width, height and bit depth in the scanning rule to obtain a difference sequence of the 16-bit grayscale image data;

[0008] Performing lossless conversion on the difference sequence to obtain a lossless converted difference sequence;

[0009] The difference sequence after lossless conversion is encoded using a preset encoding method to obtain a compression result of the 16-bit grayscale image data.

[0010] The performing lossless conversion on the difference sequence to obtain the difference sequence after lossless conversion comprises:

[0011] If the grayscale difference is within the first preset interval, the lower 8 bits of the 16-bit grayscale difference are stored in the corresponding position of the difference sequence after lossless conversion;

[0012] If the grayscale difference is not within the first preset interval, the corresponding byte of the difference sequence after lossless conversion is marked with a mark bit, and the 16-bit grayscale difference is saved in the two bytes after the mark bit of the difference sequence after lossless conversion.

[0013] The scanning rules of the difference sequence include:

[0014] Scanning rule of the first difference sequence: taking the original gray value of the first pixel of the 16-bit gray image data as a reference point, and scanning the 16-bit gray image data pixel by pixel according to the rule that the rows and columns of the 16-bit gray image data are from small to large;

[0015] Scanning rule for the second difference sequence: take the original gray value of the first pixel of the 16-bit grayscale image data as a reference point, and scan the 16-bit grayscale image data pixel by pixel in a serpentine pattern, with the rows of the 16-bit grayscale image data increasing from small to large and the columns of the 16-bit grayscale image data first increasing from small to large and then from large to small.

[0016] The preset encoding methods include: run length encoding, zstd encoding, LZ77 encoding, LZ4 encoding, and LZMA2 encoding.

[0017] The preset encoding method further includes an automatic encoding method, and the automatic encoding method is used to encode the difference sequence after lossless conversion to obtain the compression result of the 16-bit grayscale image data, including:

[0018] Performing feature statistics on the difference sequence after the lossless conversion to obtain continuity, entropy value and repeatability of the difference sequence after the lossless conversion;

[0019] If the continuity reaches a preset continuity threshold, the difference sequence after lossless conversion is encoded by using run length compression coding to obtain a compression result of the 16-bit grayscale image data, and the compression coding is recorded as run length coding;

[0020] If the continuity does not reach a preset continuity threshold, determining whether the entropy value of the difference sequence after lossless conversion reaches a preset entropy threshold;

[0021] If the entropy value of the difference sequence after lossless conversion does not reach a preset entropy threshold, Huffman coding is used to encode the difference sequence after lossless conversion to obtain a compression result of the 16-bit grayscale image data, and the compression code is recorded as the Huffman code;

[0022] If the entropy value of the difference sequence after lossless conversion reaches a preset entropy threshold, then determine whether the repeatability of the difference sequence after lossless conversion reaches a preset repeatability threshold;

[0023] If the repeatability of the difference sequence after lossless conversion does not reach a preset repeat threshold, the difference sequence after lossless conversion is encoded using zstd encoding to obtain a compression result of the 16-bit grayscale image data, and the compressed encoding is recorded as zstd encoding;

[0024] If the repeatability of the difference sequence after lossless conversion reaches a preset repeat threshold, the difference sequence after lossless conversion is encoded using LZ77 encoding to obtain a compression result of the 16-bit grayscale image data, and the compression encoding is recorded as LZ77 encoding.

[0025] The first preset interval is [-127, 127].

[0026] In a second aspect, the present application proposes a 16-bit grayscale image lossless decompression method, comprising:

[0027] Obtaining image data to be decompressed and image meta information, wherein the image meta information includes: width, height, bit depth, scanning rule and preset encoding method;

[0028] Decompress the image data to be decompressed by using a preset encoding method of the image meta-information to obtain a difference sequence after lossless conversion;

[0029] According to the marking bit of the difference sequence after lossless conversion, the difference sequence after lossless conversion is inversely transformed to obtain a difference sequence of 16-bit grayscale image data;

[0030] According to the scanning rule in the image meta-information, the difference sequence of the 16-bit grayscale image data is inversely transformed to obtain the decompressed 16-bit grayscale image data.

[0031] In a third aspect, the present application proposes an electronic device comprising: one or more processors, and a memory, wherein the memory is used to store instructions, and when the instructions are executed by the one or more processors, the one or more processors execute the 16-bit grayscale image lossless compression method.

[0032] In a fourth aspect, the present application proposes a computer-readable storage medium storing executable instructions, which, when executed, enable a processor to execute the 16-bit grayscale image lossless compression method.

[0033] In a fifth aspect, the present application proposes a computer program product, including a computer program or instructions, which implement the 16-bit grayscale image lossless compression method when executed by a processor.

[0034] Beneficial effects:

[0035] This application proposes a 16-bit grayscale image lossless compression method and decompression method. Compared with traditional methods, the compression ratio is increased from about 50% to about 60-90%; it is optimized for specific scenarios, and for images with dense homogeneous areas such as medical images, such as CT head images, the compression ratio can reach 80-90%; the compression method of this application is completely lossless, ensuring the integrity of the image data; the compression and decompression efficiency of this application is high, and when using run-length compression encoding, real-time compression and decompression efficiency can be obtained; this application is simple to implement and easy to implement in engineering. This application reduces data storage costs, and can reduce data storage costs by ~25% compared to existing compression schemes. This application improves data transmission speed, especially in the current cloud storage environment, a higher compression ratio can significantly increase data transmission speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A flow chart of a 16-bit grayscale image lossless compression method and a decompression method according to an embodiment of the present invention;

[0037] Figure 2 A schematic flow chart of a 16-bit grayscale image lossless compression method and a decompression method according to an embodiment of the present invention;

[0038] Figure 3 Schematic diagram of a 16-bit to 8-bit encoding method according to an embodiment of the present invention;

[0039] Figure 4 A schematic diagram of a scanning rule of a first difference sequence according to an embodiment of the present invention;

[0040] Figure 5 A schematic diagram of a scanning rule for a second difference sequence according to an embodiment of the present invention. DETAILED DESCRIPTION

[0041] The specific implementation of the present application is further described in detail below in conjunction with the drawings and examples.

[0042] Since the existing lossless compression algorithms are not specifically designed for 16-bit grayscale images, this application proposes a 16-bit grayscale image lossless compression method and a decompression method. Compared with traditional methods, the compression ratio of 16-bit grayscale images is improved; the compression process is lossless and the image quality is guaranteed; the storage space occupancy is reduced; and the data transmission efficiency is improved.

[0043] Embodiment 1:

[0044] This embodiment proposes a 16-bit grayscale image lossless compression method and a decompression method. This application combines 16-bit grayscale images, especially the characteristics of medical images where adjacent pixel values ​​are usually not very different, to provide a lossless compression method combining pixel difference coding + run-length compression or entropy coding, such as Figure 1 , Figure 2 As shown, including:

[0045] Step S1: Obtain 16-bit grayscale image data and image meta-information, the image meta-information includes: width, height, bit depth, scanning rules and preset encoding method:

[0046] In this embodiment, the original 16-bit grayscale image data is read and image meta-information is obtained, wherein the image meta-information includes: width, height, bit depth (16 bits in this embodiment), scanning rules and a preset encoding method.

[0047] Step S2: Calculating the grayscale differences between adjacent pixels in the 16-bit grayscale image data according to the order in the scanning rule of the difference sequence to obtain the difference sequence of the 16-bit grayscale image data, including:

[0048] Step S2.1: Scan each pixel of the original 16-bit grayscale image data pixel by pixel;

[0049] Step S2.2: Calculate the grayscale difference between adjacent pixels;

[0050] Step S2.3: Generate a difference sequence based on the grayscale differences between adjacent pixels.

[0051] The scanning rules of the difference sequence include:

[0052] Scanning rule of the first difference sequence: take the original gray value of the first pixel of the 16-bit gray image data as the reference point, and scan the 16-bit gray image data pixel by pixel according to the rule that the rows and columns of the 16-bit gray image data are from small to large, such as Figure 4 As shown;

[0053] The scanning rule of the second difference sequence is: take the original gray value of the first pixel of the 16-bit gray image data as the reference point, and scan the 16-bit gray image data pixel by pixel in a serpentine pattern, with the rows of the 16-bit gray image data increasing from small to large and the columns of the 16-bit gray image data first increasing from small to large and then from large to small, such as Figure 5 shown.

[0054] It is understood that scanning the original 16-bit grayscale image data can also use snake scanning (such as Figure 5 ) to further improve the correlation between pixels, but it is necessary to record the scanning method used so that the data can be correctly decompressed and restored.

[0055] Step S3: performing lossless conversion on the difference sequence to obtain a difference sequence after lossless conversion, including:

[0056] Step S3.1: If the grayscale difference is within a first preset interval, the lower 8 bits of the 16-bit grayscale difference are stored in the corresponding position of the difference sequence after lossless conversion;

[0057] Step S3.2: If the grayscale difference is not within the first preset interval, the corresponding byte of the difference sequence after lossless conversion is marked with a mark bit, and the 16-bit grayscale difference is saved in the two bytes after the mark bit of the difference sequence after lossless conversion.

[0058] In the present embodiment, this part is the key to achieve efficient lossless compression. 16-bit grayscale image data has a relatively large dynamic range, but the difference between adjacent pixels is often very small. There is no need to use 16 bits to save the difference between adjacent pixels. It can be represented by an 8-bit data width, and directly using 8-bit data to save the difference between adjacent pixels makes the original image without any loss due to conversion. Therefore, the present application performs a lossless conversion of 16-bit grayscale image data. Since most of the data in the difference sequence can be represented by 8 bits, directly storing the difference sequence in 8 bits directly compresses nearly 50% of the storage space, and further compressing and encoding the result can achieve efficient lossless compression. The specific 16-bit to 8-bit encoding method is as follows: Figure 3 As shown:

[0059] 1. Read the data in the difference sequence one by one

[0060] 2. If the data is between [-127, 127], store the data in the lower 8 bits directly.

[0061] 3. If the data is <-127 or >127, store the marker 0x80[-128] first, and then directly store the 16-bit difference data.

[0062] 4. Until all the data in the difference sequence is processed.

[0063] The preset encoding methods include: run length encoding, zstd encoding (Zstandard, referred to as zstd), LZ77 encoding (Lempel-Ziv-77, referred to as LZ77)), LZ4 encoding, and LZMA2 encoding (Lempel-Ziv-Markov chain Algorithm, referred to as LZMA).

[0064] The preset encoding method also includes an automatic encoding method, and the automatic encoding method is used to encode the difference sequence after lossless conversion to obtain the compression result of the 16-bit grayscale image data.

[0065] Step S4: using a preset encoding method to encode the difference sequence after lossless conversion to obtain a compression result of the 16-bit grayscale image data, including:

[0066] Step S4.1: performing feature statistics on the difference sequence after the lossless conversion to obtain the continuity, entropy value and repeatability of the difference sequence after the lossless conversion;

[0067] Step S4.2: if the continuity reaches a preset continuity threshold, the difference sequence after lossless conversion is encoded using run length compression coding to obtain a compression result of the 16-bit grayscale image data, and the compression coding is recorded as run length coding;

[0068] Step S4.3: If the continuity does not reach the preset continuity threshold, determine whether the entropy value of the difference sequence after lossless conversion reaches the preset entropy threshold;

[0069] Step S4.4: if the entropy value of the difference sequence after lossless conversion does not reach the preset entropy threshold, the difference sequence after lossless conversion is encoded using Huffman coding to obtain the compression result of the 16-bit grayscale image data, and the compression coding is recorded as Huffman coding;

[0070] Step S4.5: If the entropy value of the difference sequence after lossless conversion reaches a preset entropy threshold, determine whether the repeatability of the difference sequence after lossless conversion reaches a preset repeatability threshold;

[0071] Step S4.6: if the repeatability of the difference sequence after lossless conversion does not reach a preset repeatability threshold, the difference sequence after lossless conversion is encoded using zstd encoding to obtain a compression result of the 16-bit grayscale image data, and the compressed encoding is recorded as zstd encoding;

[0072] Step S4.7: If the repeatability of the difference sequence after lossless conversion reaches a preset repeat threshold, the difference sequence after lossless conversion is encoded using LZ77 encoding to obtain the compression result of the 16-bit grayscale image data, and the compressed encoding is recorded as LZ77 encoding.

[0073] The continuity threshold, entropy threshold, and repeatability threshold can be determined according to the needs of the project, whether to pursue faster compression speed or higher compression ratio. For example, if the continuity threshold is lowered, the compression will use more stroke compression, which will obtain real-time compression and decompression efficiency. If the ultimate compression ratio is pursued, the encoding can be preset to LZMA2 or multiple encodings + discriminators can be performed at the same time to select the most efficient encoding. The setting of the threshold needs to be combined with the needs of the project, and this embodiment will not be repeated.

[0074] In this embodiment, the difference sequence after lossless conversion is further compressed and encoded. The difference sequence encoding process in the previous step basically achieves a compression ratio of nearly 50%. Next, the 8-bit difference sequence after encoding is further losslessly encoded to achieve a higher compression ratio.

[0075] 1. If a compression method is specified, such as run length encoding, Huffman encoding, LZ77 encoding, LZ4 encoding, zstd encoding, LZMA2 encoding and other compression algorithms, the specified encoding method is used to compress the 8-bit difference code sequence;

[0076] 2. If you select automatic encoding, then:

[0077] a) Analyze the statistical characteristics of the difference sequence, including: the continuity, entropy value and repeatability of the difference sequence after lossless conversion.

[0078] In this embodiment, the continuity calculation is to count the proportion of the running length of the same value of adjacent data in the total length.

[0079] In this embodiment, the entropy value is the information entropy of the calculated data distribution value, and the probability of each data value is counted and calculated according to the Shannon entropy formula.

[0080] In this embodiment, the repeatability analysis is used to detect data repetitive patterns and determine the redundancy of data to determine whether a higher compression ratio can be achieved using dictionary encoding such as LZ77. Repeatability calculations can use sliding window matching of repetitive patterns, hash table optimization versions, or block statistics.

[0081] The calculation methods of continuity, entropy value and repeatability are all mature methods and will not be elaborated in detail in this embodiment.

[0082] b) If there are many consecutive identical data, select run length compression encoding. For example, 100 consecutive 5s are recorded as 1005.

[0083] c) If the data entropy value does not reach the entropy value threshold, select Huffman coding;

[0084] d) If the data is highly repetitive, select lz77 dictionary encoding.

[0085] e) If none of the above conditions are met, select zstd encoding

[0086] 3. Encode and compress the encoded difference sequence according to the selected encoding method.

[0087] Finally, the compression result of the 16-bit grayscale image data is packaged, including:

[0088] 1. Encapsulate image metadata (image width, height, bit depth (16 bits), encoding method, scanning rules, etc.);

[0089] 2. Encapsulate the encoded difference sequence;

[0090] 3. Generate a compressed file.

[0091] Embodiment 2:

[0092] This embodiment provides a 16-bit grayscale image lossless decompression method, including:

[0093] Step S100: Obtaining image data to be decompressed and image meta information, wherein the image meta information includes: width, height, bit depth, scanning rule and preset encoding method;

[0094] Step S101: decompressing the image data to be decompressed according to a preset encoding method of the image meta-information to obtain a difference sequence after lossless conversion;

[0095] Step S102: performing an inverse transformation on the difference sequence after lossless conversion according to the marking bit of the difference sequence after lossless conversion to obtain a difference sequence of 16-bit grayscale image data;

[0096] Step S103: According to the saved scanning rule of the difference sequence, the difference sequence of the 16-bit grayscale image data is inversely transformed to obtain the decompressed 16-bit grayscale image data.

[0097] In this embodiment, data decompression is the inverse operation of compression. According to the compression encoding method mentioned above, data decompression can be relatively easy to achieve.

[0098] Embodiment 3:

[0099] This embodiment proposes an electronic device, including: one or more processors, and a memory, wherein the memory is used to store instructions, and when the instructions are executed by the one or more processors, the one or more processors execute the 16-bit grayscale image lossless compression method.

[0100] The electronic device may be a mobile phone, a computer or a tablet computer, etc., including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the 16-bit grayscale image lossless compression method described in the embodiment is implemented. It is understood that the electronic device may also include an input / output (I / O) interface and a communication component.

[0101] The processor is used to execute all or part of the steps in the 16-bit grayscale image lossless compression method as described in the above embodiment. The memory is used to store various types of data, which may include instructions of any application or method in the electronic device, as well as data related to the application.

[0102] The processor can be an application specific integrated circuit (ASIC), a digital signal processor (DSP), a programmable logic device (PLD), a field programmable gate array (FPGA), a controller, a microcontroller, a microprocessor or other electronic components, and is used to execute the 16-bit grayscale image lossless compression method described in the above embodiment.

[0103] Embodiment 4:

[0104] This embodiment provides a computer-readable storage medium storing executable instructions. When the instructions are executed and implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium.

[0105] The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the 16-bit grayscale image lossless compression method described in each embodiment of the present application.

[0106] The aforementioned storage media include: flash memory, hard disk, multimedia card, card-type memory (for example, SD (Secure Digital Memory Card) or DX (Memory Data Register, MDR abbreviation, memory data register) memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, CD, server, APP (Application, abbreviation of application software) application store and other media that can store program verification codes, on which computer programs are stored. When the computer program is executed by the processor, the various steps of the above-mentioned 16-bit grayscale image lossless compression method can be implemented.

[0107] Embodiment 5:

[0108] This embodiment provides a computer program product, including a computer program or instructions, which implement the 16-bit grayscale image lossless compression method when executed by a processor.

[0109] Based on such understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a computer program product.

[0110] The various embodiments in the present application are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.

[0111] The protection scope of the present application is not limited to the above-mentioned embodiments. Obviously, those skilled in the art can make various changes and modifications to the present disclosure without departing from the scope and spirit of the present disclosure. If these changes and modifications fall within the scope of the claims of the present disclosure and their equivalents, the intention of the present disclosure also includes these changes and modifications.

Claims

1. A 16-bit grayscale image lossless compression method, characterized in that: include: Acquire 16-bit grayscale image data and image meta-information, wherein the image meta-information includes: width, height, bit depth, scanning rule, and preset encoding method; Calculate the grayscale difference between adjacent pixels in the 16-bit grayscale image data according to the order, width, height and bit depth in the scanning rule to obtain a difference sequence of the 16-bit grayscale image data; Performing lossless conversion on the difference sequence to obtain a lossless converted difference sequence; The difference sequence after lossless conversion is encoded using a preset encoding method to obtain a compression result of the 16-bit grayscale image data.

2. The 16-bit grayscale image lossless compression method according to claim 1, characterized in that: The performing lossless conversion on the difference sequence to obtain the difference sequence after lossless conversion includes: If the grayscale difference is within the first preset interval, the lower 8 bits of the 16-bit grayscale difference are stored in the corresponding position of the difference sequence after lossless conversion; If the grayscale difference is not within the first preset interval, the corresponding byte of the difference sequence after lossless conversion is marked with a mark bit, and the 16-bit grayscale difference is saved in the two bytes after the mark bit of the difference sequence after lossless conversion.

3. The 16-bit grayscale image lossless compression method according to claim 1, characterized in that: The scanning rules of the difference sequence include: Scanning rule of the first difference sequence: taking the original gray value of the first pixel of the 16-bit gray image data as a reference point, and scanning the 16-bit gray image data pixel by pixel according to the rule that the rows and columns of the 16-bit gray image data are from small to large; Scanning rule for the second difference sequence: take the original gray value of the first pixel of the 16-bit grayscale image data as a reference point, and scan the 16-bit grayscale image data pixel by pixel in a serpentine pattern, with the rows of the 16-bit grayscale image data increasing from small to large and the columns of the 16-bit grayscale image data first increasing from small to large and then from large to small.

4. The 16-bit grayscale image lossless compression method according to claim 1, characterized in that: The preset encoding methods include: run length encoding, zstd encoding, LZ77 encoding, LZ4 encoding, and LZMA2 encoding.

5. The 16-bit grayscale image lossless compression method according to claim 1, characterized in that: The preset encoding method further includes an automatic encoding method, and the automatic encoding method is used to encode the difference sequence after lossless conversion to obtain the compression result of the 16-bit grayscale image data, including: Performing feature statistics on the difference sequence after the lossless conversion to obtain continuity, entropy value and repeatability of the difference sequence after the lossless conversion; If the continuity reaches a preset continuity threshold, the difference sequence after lossless conversion is encoded by using run length compression coding to obtain a compression result of the 16-bit grayscale image data, and the compression coding is recorded as run length coding; If the continuity does not reach a preset continuity threshold, determining whether the entropy value of the difference sequence after lossless conversion reaches a preset entropy threshold; If the entropy value of the difference sequence after lossless conversion does not reach a preset entropy threshold, Huffman coding is used to encode the difference sequence after lossless conversion to obtain a compression result of the 16-bit grayscale image data, and the compression code is recorded as the Huffman code; If the entropy value of the difference sequence after lossless conversion reaches a preset entropy threshold, then determine whether the repeatability of the difference sequence after lossless conversion reaches a preset repeatability threshold; If the repeatability of the difference sequence after lossless conversion does not reach a preset repeat threshold, the difference sequence after lossless conversion is encoded using zstd encoding to obtain a compression result of the 16-bit grayscale image data, and the compressed encoding is recorded as zstd encoding; If the repeatability of the difference sequence after lossless conversion reaches a preset repeat threshold, the difference sequence after lossless conversion is encoded using LZ77 encoding to obtain a compression result of the 16-bit grayscale image data, and the compression encoding is recorded as LZ77 encoding.

6. The 16-bit grayscale image lossless compression method according to claim 2, characterized in that: The first preset interval is [-127, 127].

7. A 16-bit grayscale image lossless decompression method, characterized in that: include: Obtaining image data to be decompressed and image meta information, wherein the image meta information includes: width, height, bit depth, scanning rule and preset encoding method; Decompress the image data to be decompressed by using a preset encoding method of the image meta-information to obtain a difference sequence after lossless conversion; According to the marking bit of the difference sequence after lossless conversion, the difference sequence after lossless conversion is inversely transformed to obtain a difference sequence of 16-bit grayscale image data; According to the scanning rule in the image meta-information, the difference sequence of the 16-bit grayscale image data is inversely transformed to obtain the decompressed 16-bit grayscale image data.

8. An electronic device, characterized in that: include: One or more processors, and a memory, wherein the memory is used to store instructions, and when the instructions are executed by the one or more processors, the one or more processors execute the 16-bit grayscale image lossless compression method described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that: The device stores executable instructions, which, when executed, enable a processor to execute the 16-bit grayscale image lossless compression method as described in any one of claims 1 to 6.

10. A computer program product comprising a computer program or instructions, characterized in that When the computer program or instruction is executed by a processor, the 16-bit grayscale image lossless compression method described in any one of claims 1 to 6 is implemented.