Lossless compression and decoding method for simple image

The lossless compression of simple images is solved by 0-order Columbus encoding, which solves the problems of high time and resource consumption in the prior art, and achieves efficient lossless compression effect.

CN119922326AActive Publication Date: 2025-05-02HEFEI JUNZHENG TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202311445997.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-31
Publication Date
2025-05-02
Estimated Expiration
2043-10-31

AI Technical Summary

Technical Problem

The existing lossless compression method consumes a long time and consumes a lot of resources when processing simple images, and the compression rate of simple images is not high.

Method used

The 0-order Columbus encoding is used to perform lossless compression of simple images. By recording the same character length continuously, space occupation is reduced, and the image is only traversed once, reducing time and space consumption.

Benefits of technology

It realizes time and resource savings, achieves considerable lossless compression rates, and is suitable for compression and decoding of simple images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119922326A_ABST
    Figure CN119922326A_ABST
Patent Text Reader

Abstract

The invention provides a lossless compression and decoding method for a simple image. The lossless compression and decoding method comprises the following steps: S1, lossless compression: S1.1, calculating a difference value between a current pixel point and a previous pixel point; determining whether a difference is 0- S1.2, if the pixel value is 0, updating the counter and the next pixel value; if the next pixel is empty, performing Golomb coding on the counter to S1.4; if not, returning to S1.1; s1.3, if the difference value is not 0, Columbus coding is carried out on the Count which is not 0, then a 5bit or 8bit fixed-length code is used for coding the pixel of which the difference value is not 0, and a 5bit difference value threshold value is set; the next pixel is updated, and if the next pixel is empty, S1.4 is executed; if not, returning to S1.1; s1.4, ending the coding; s2, lossless decoding: S2.1, recording a current bit; determining whether a current bit is 0- S2.2, if the number is 0, 0-order Golomb decoding is correspondingly carried out; and then the step S2.4 is carried out; s2.3, if the bit is not 0, correspondingly performing decoding of 2 + 5 or 2 + 8 bit right shift, taking the first two bits as identifiers, and then going to S2.4; s2.4, judging whether bit is null or not If so, ending; and if not, returning to the step S2.1.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of image processing, and in particular relates to a lossless compression and decoding method for a simple image. Background Art

[0002] In the prior art, with the development of computer graphics, commonly used lossless compression methods include Huffman coding, run-length coding, LZW coding, etc. The Huffman coding belongs to variable-length coding, which relies on the probability of character occurrence to construct a codeword with the shortest average length; the main idea of ​​the run-length coding is to replace a string of identical values ​​with a representative value; the LZW coding achieves compression by establishing a string table and using shorter codes to represent longer strings.

[0003] However, in the prior art, Huffman coding requires two rounds of image traversal, that is, the first round of traversal obtains the character frequency and obtains the codeword for each character, and the second round of traversal starts encoding. Two rounds of scanning take a long time, and the codeword corresponding to the character also requires space. Run-length coding has limited compression performance for continuous tone images. LZW builds a dictionary and sliding window, and the matching algorithm also consumes a lot of resources and has a low compression rate for simple images.

[0004] In addition, the commonly used terms in the prior art include:

[0005] Simple images: refers to images with simple content and high data redundancy. They are mostly artificially produced electronic images, such as invoices, business cards, work badges, web pages, etc.

[0006] Lossless compression: Compression uses the statistical redundancy of data to completely restore the original data without causing any distortion.

[0007] Decoding: The encoding end and the decoding end specify the protocol content, and the decoding end restores the received data. Fixed-length coding: refers to the fixed space occupied by the information bit during the encoding process.

[0008] Variable-length coding: refers to the inconsistency of the space occupied by information bits during the encoding process. Summary of the invention

[0009] In order to solve the above problems, the purpose of this application is to use a compression algorithm that takes less time and resources to achieve a considerable lossless compression rate, and the improvements are as follows:

[0010] 1) Use 0-order Golomb coding to compress consecutive characters of the same length into a value that takes up very little space;

[0011] 2). Only one pass through the image is needed, which takes less time;

[0012] 3). Only the value of the previous pixel and the counter value need to be cached, which consumes less space;

[0013] 4). Set the diff threshold to 5 bits to provide a small amount of fixed-length compression space for continuous-tone images.

[0014] Specifically, the present invention provides a method for lossless compression and decoding of a simple image, the method comprising the following steps:

[0015] S1, if lossless compression is used, includes:

[0016] S1.1, calculate the difference between the current pixel and the previous pixel; further determine whether the difference is 0? According to the result, proceed to step S1.2 and step S1.3 respectively;

[0017] S1.2, if it is 0, update the counter and the next pixel value. If the next pixel is empty, perform Golomb coding on the counter and proceed to step S1.4; if the next pixel is not empty, proceed to step S1.1;

[0018] Among them, the 0th order Columbus coding further includes:

[0019] ① Perform 0-order Golomb coding on a non-negative integer x;

[0020] ② Add 1 to itself, that is, x+1;

[0021] ③Write x+1 in binary form (x+1)2;

[0022] ④ Count the number of digits of (x+1)2 in binary form, recorded as M;

[0023] ⑤ Add M-1 zeros before the binary form (x+1)2;

[0024] S1.3, if it is not 0, first perform Golomb coding on the non-zero Count, and further encode the pixels whose difference is not 0 using 5-bit or 8-bit fixed-length coding, including setting a 5-bit difference diff threshold; update the next pixel, and if the next pixel is empty, proceed to step S1.4; if the next pixel is not empty, proceed to step S1.1;

[0025] S1.4, end of encoding;

[0026] S2: If lossless decoding is performed, the lossless decoding further includes:

[0027] S2.1, record the current bit; further determine whether the current bit is 0? According to the result, proceed to step S2.2 and step S2.3 respectively;

[0028] S2.2, if the current bit is 0, perform 0th-order Golomb decoding; then proceed to step S2.4;

[0029] The 0-order Columbus decoding further comprises:

[0030] ① Record the number of leading 0s in the Columbus code as M;

[0031] ②Convert the (M+1) bits following the leading 0 into decimal X;

[0032] ③X-1 is the decoded decimal;

[0033] S2.3, if the current bit is not 0, the corresponding bit is right-shifted by 2+5 or 2+8 bits for decoding, where the first two bits are the identifier, and then step S2.4 is performed;

[0034] S2.4, determine whether the bit is empty? If yes, then end; if no, then return to step S2.1.

[0035] The step S1.1 further comprises:

[0036] S1.1.1, input image;

[0037] S1.1.2, set the pixel value of the 0th pixel to 0, that is, predPel = 0; the first pixel value is recorded as curPel;

[0038] S1.1.3, calculate the difference, calculate the difference between the current pixel curPel and the previous pixel predPel and record it as diff, diff = curPel-predPel;

[0039] S1.1.4, determine whether diff=0 is established. If yes, proceed to step S1.2; if no, proceed to step S1.3.

[0040] If the value of step S1.2 is 0, the counter is incremented by 1, and the next pixel is taken to update predPel and curPel, and the process returns to step S1.1.3; the process further includes:

[0041] S1.2.1, then counter +1, Count++;

[0042] S1.2.2, take the next pixel, update predPel and curPel, that is, predPel = curPel, take the next pixel and record it as curPel;

[0043] S1.2.3, determine whether the pixel is empty? If not, return to step S1.1.3; if yes, proceed to step S1.2.4;

[0044] S1.2.4, perform Golomb encoding on Count; further proceed to step S1.4, and the encoding is completed.

[0045] If the value of step S1.3 is not 0 and the counter is not 0, the counter is encoded using the Golomb encoding, and the counter is set to 0 after completion; encoding 1 and comparing whether the diff is within the threshold, if it is within the threshold -16 to 15, encoding 1 and using 5 bits to encode diff; otherwise encoding 0 and using 8 bits to encode curPel, taking the next pixel to update predPel and curPel and returning to step S1.1.3; further comprising:

[0046] S1.3.1, determine whether Count == 0?

[0047] S1.3.2, if no, perform Golomb encoding on Count, Count=0; and further proceed to step S1.3.3; if yes, directly proceed to step S1.3.3;

[0048] S1.3.3, code 1;

[0049] S1.3.4, determine whether diff∈[-16,15] holds?

[0050] If yes, encode 1, 5-bit encoding diff;

[0051] If not, encode 0, 8-bit encode curPel;

[0052] S1.3.5, predPel = curPel, take the next pixel and record it as curPel;

[0053] S1.3.6, determine whether the pixel is empty?

[0054] If not, return to step S1.1.3; if yes, proceed to step S1.4 and the encoding ends.

[0055] The step S2.1 further comprises:

[0056] S2.1.1, input code stream;

[0057] S2.1.2, set the pixel value of the 0th pixel to 0, that is, predPel = 0;

[0058] S2.1.3, record the current bit as curBit.

[0059] The step S2.2, if the current bit is 0, the number of leading 0s is counted as M, and the number count is decoded according to the Golomb code, then the values ​​of the subsequent count pixels are all predPel, right-shifted 2M+1 bits; further comprising:

[0060] S2.2.1, starting from the current position, record the number of leading 0s as M;

[0061] S2.2.2, the M+1 binary digits after the leading 0 are converted to decimal x;

[0062] S2.2.3, decode to get X-1;

[0063] S2.2.4, then there are X-1 predPels following predPel;

[0064] S2.2.5, right shift the bit by 2M+1 bits; proceed to step S2.4.

[0065] The step S2.3, if the current bit is not 0, it means that there is diff, and it is shifted right by one bit; if the current bit is 1, it is shifted right by one bit, and the subsequent 5 bits are the binary of diff, and it is shifted right by 5 bits; if the current bit is not 1, it is shifted right by one bit, and the subsequent 8 bits are the binary of curPel, and it is shifted right by 8 bits; further comprising:

[0066] S2.3.1, if not, shift the bit right by 1;

[0067] S2.3.2, further determine whether curBit == 1? If yes, bit is shifted right by 1 bit; then proceed to step S2.3.3; if no, bit is shifted right by 1 bit, then proceed to step S2.3.6; S2.3.3, the last 5 bits of bit are converted to decimal diff;

[0068] S2.3.4, curPel=PredPel+diff; predPel=curPel;

[0069] S2.3.5, right shift bit by 5 bits; proceed to step S2.4;

[0070] S2.3.6, the last 8 bits of bit are converted to decimal curPel;

[0071] S2.3.7, predPel = curPel;

[0072] S2.3.8, shift right 8 bits; proceed to step S2.4.

[0073] The step S2.4 further includes: determining whether the bit is empty. If not, returning to step S2.1.3; if yes, ending.

[0074] Therefore, the advantages of this application are:

[0075] 1) A hardware-friendly algorithm with low compression ratio specifically for simple images can be implemented; 2) Simple images can be losslessly compressed using 0-order Golomb coding;

[0076] 3) There are also solutions to deal with chromaticity changes in simple images. BRIEF DESCRIPTION OF THE DRAWINGS

[0077] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.

[0078] Figure 1 It is a schematic diagram of the process of the present application method.

[0079] Figure 2 It is a schematic diagram of the process of lossless compression in the method of this application.

[0080] Figure 3 It is a flowchart of lossless decoding in the method of this application. DETAILED DESCRIPTION

[0081] In order to more clearly understand the technical content and advantages of the present invention, the present invention is now further described in detail in conjunction with the accompanying drawings.

[0082] like Figure 1 As shown, this application proposes a lossless compression and decoding method for a simple image. The core idea of ​​this technical solution is:

[0083] S1, if lossless compression is used, includes:

[0084] S1.1, calculate the difference between the current pixel and the previous pixel; further determine whether the difference is 0? According to the result, proceed to step S1.2 and step S1.3 respectively;

[0085] S1.2, if it is 0, update the counter and the next pixel value. If the next pixel is empty, perform Golomb coding on the counter and proceed to step S1.4; if the next pixel is not empty, proceed to step S1.1;

[0086] Among them, the 0th order Columbus coding further includes:

[0087] ① Perform 0-order Golomb coding on a non-negative integer x;

[0088] ② Add 1 to itself, that is, x+1;

[0089] ③Write x+1 in binary form (x+1)2;

[0090] ④ Count the number of digits of (x+1)2 in binary form, recorded as M;

[0091] ⑤ Add M-1 zeros before the binary form (x+1)2;

[0092] S1.3, if it is not 0, first perform Golomb coding on the non-zero Count, and further encode the pixels whose difference is not 0 using 5-bit or 8-bit fixed-length coding, including setting a 5-bit difference diff threshold; update the next pixel, and if the next pixel is empty, proceed to step S1.4; if the next pixel is not empty, proceed to step S1.1;

[0093] S1.4, end of encoding;

[0094] S2: If lossless decoding is performed, the lossless decoding further includes:

[0095] S2.1, record the current bit; further determine whether the current bit is 0? According to the result, proceed to step S2.2 and step S2.3 respectively;

[0096] S2.2, if the current bit is 0, perform 0th-order Golomb decoding; then proceed to step S2.4;

[0097] The 0-order Columbus decoding further comprises:

[0098] ① Record the number of leading 0s in the Columbus code as M;

[0099] ②Convert the (M+1) bits following the leading 0 into decimal X;

[0100] ③X-1 is the decoded decimal;

[0101] S2.3, if the current bit is not 0, the corresponding bit is right-shifted by 2+5 or 2+8 bits for decoding, where the first two bits are the identifier, and then step S2.4 is performed;

[0102] S2.4, determine whether the bit is empty? If yes, then end; if no, proceed to step S2.1.

[0103] An example of the 0th order Columbus encoding:

[0104]

[0105]

[0106] Correspondingly, an example of the 0-order Columbus decoding is:

[0107]

[0108] In summary, if Figure 2 As shown, the lossless compression process can also be described as:

[0109] (1) Set the pixel value of the 0th pixel to 0. The encoding traversal order of the entire lossless compressed image is from left to right and from top to bottom;

[0110] (2) Calculate the difference between the current pixel curPel and the previous pixel predPel and record it as diff;

[0111] (3) If diff is 0, then add 1 to the counter, take the next pixel to update predPel and curPel, and return to step (2);

[0112] (4) If diff is not 0 and the counter is not 0, the Golomb code counter is used and the counter is set to 0 after completion;

[0113] (5) Encode 1 and compare whether diff is within the threshold. If it is within the threshold -16 to 15, encode 1 and use 5 bits to encode diff; otherwise, encode 0 and use 8 bits to encode curPel, take the next pixel, update predPel and curPel and return to step (2);

[0114] Specifically, Figure 2 As shown, the process steps of lossless compression further include:

[0115] The step S1.1 further comprises:

[0116] S1.1.1, input image;

[0117] S1.1.2, set the pixel value of the 0th pixel to 0, that is, predPel = 0; the first pixel value is recorded as curPel;

[0118] S1.1.3, calculate the difference, calculate the difference between the current pixel curPel and the previous pixel predPel and record it as diff, diff = curPel-predPel;

[0119] S1.1.4, determine whether diff=0 is established. If yes, proceed to step S1.2; if no, proceed to step S1.3.

[0120] In step S1.2, if the value is 0, the counter is incremented by 1, and the next pixel is taken to update predPel and curPel, and the process returns to step S1.1.3; further comprising:

[0121] S1.2.1, then counter +1, Count++;

[0122] S1.2.2, take the next pixel, update predPel and curPel, that is, predPel = curPel, take the next pixel and record it as curPel;

[0123] S1.2.3, determine whether the pixel is empty? If not, return to step S1.1.3; if yes, proceed to step S1.2.4;

[0124] S1.2.4, perform Golomb encoding on Count; further proceed to step S1.4, and the encoding is completed.

[0125] In step S1.3, if it is not 0 and the counter is not 0, the counter is encoded using the Golomb encoding, and the counter is set to 0 after completion; encoding 1 and comparing whether diff is within the threshold, if it is within the threshold -16 to 15, encoding 1 and using 5 bits to encode diff; otherwise encoding 0 and using 8 bits to encode curPel, taking the next pixel to update predPel and curPel and returning to step S1.1.3; further comprising:

[0126] S1.3.1, determine whether Count == 0?

[0127] S1.3.2, if no, perform Golomb encoding on Count, Count=0; and further proceed to step S1.3.3; if yes, directly proceed to step S1.3.3;

[0128] S1.3.3, code 1;

[0129] S1.3.4, determine whether diff∈[-16,15] holds?

[0130] If yes, encode 1, 5-bit encoding diff;

[0131] If not, encode 0, 8-bit encode curPel;

[0132] S1.3.5, predPel = curPel, take the next pixel and record it as curPel;

[0133] S1.3.6, determine whether the pixel is empty?

[0134] If not, return to step S1.1.3; if yes, proceed to step S1.4 and the encoding ends.

[0135] like Figure 3 As shown, the lossless decoding process can also be described as:

[0136] (1) Set the pixel value of the 0th pixel to 0, that is, predPel = 0. The image decoding traversal order is from left to right and from top to bottom.

[0137] (2) If the current bit is 0, the number of leading 0s is m. The number count is decoded according to the Golomb code, and the values ​​of the subsequent count pixels are all predPel, shifted right by 2m+1 bits.

[0138] (3) If the current bit is 1, it means there is a diff. Shift right by one bit; if the current bit is 1, shift right by one bit, and the next 5 bits are the binary of diff, shift right by 5 bits; if the current bit is 0, shift right by one bit, and the next 8 bits are the binary of curPel, shift right by 8 bits; the current step is in the decoding identifier, for example, 11 indicates that the next 5 bits are waiting to be decoded, and 10 indicates that the next 8 bits are waiting to be decoded. The first bit must be 1, indicating that there is a diff; the second bit 1 or 0 indicates a different decoding method, so here the current bit is 1 and the current bit is 0 and the current bit is 0 and the current bit is 1 and the current bit is 0 and the current bit is 0 and the current bit is 1 and the current bit is 0 and the current bit is 0.

[0139] Specifically, Figure 3 As shown, the lossless decoding process further includes:

[0140] The step S2.1 further comprises:

[0141] S2.1.1, input code stream;

[0142] S2.1.2, set the pixel value of the 0th pixel to 0, that is, predPel = 0;

[0143] S2.1.3, record the current bit as curBit.

[0144] The step S2.2, if the current bit is 0, the number of leading 0s is counted as M, and the number count is decoded according to the Golomb code, then the values ​​of the subsequent count pixels are all predPel, right-shifted 2M+1 bits; further comprising:

[0145] S2.2.1, starting from the current position, record the number of leading 0s as M;

[0146] S2.2.2, the M+1 binary digits after the leading 0 are converted to decimal x;

[0147] S2.2.3, decode to get X-1;

[0148] S2.2.4, then there are X-1 predPels following predPel;

[0149] S2.2.5, right shift the bit by 2M+1 bits; proceed to step S2.4.

[0150] The step S2.3, if the current bit is not 0, it means that there is diff, and it is shifted right by one bit; if the current bit is 1, it is shifted right by one bit, and the subsequent 5 bits are the binary of diff, and it is shifted right by 5 bits; if the current bit is not 1, it is shifted right by one bit, and the subsequent 8 bits are the binary of curPel, and it is shifted right by 8 bits; further comprising:

[0151] S2.3.1, if not, shift the bit right by 1;

[0152] S2.3.2, further determine whether curBit == 1? If yes, bit is shifted right by 1 bit; then proceed to step S2.3.3; if no, bit is shifted right by 1 bit, then proceed to step S2.3.6; S2.3.3, the last 5 bits of bit are converted to decimal diff;

[0153] S2.3.4, curPel=PredPel+diff; predPel=curPel;

[0154] S2.3.5, right shift bit by 5 bits; proceed to step S2.4;

[0155] S2.3.6, the last 8 bits of bit are converted to decimal curPel;

[0156] S2.3.7, predPel = curPel;

[0157] S2.3.8, shift right 8 bits; proceed to step S2.4.

[0158] The step S2.4 further comprises,

[0159] Determine whether the bit is empty? If not, return to step S2.1.3; if yes, end.

[0160] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for lossless compression and decoding of a simple image, characterized in that: The method comprises the following steps: S1, if lossless compression is used, includes: S1.1, calculate the difference between the current pixel and the previous pixel; further determine whether the difference is 0? According to the result, proceed to step S1.2 and step S1.3 respectively; S1.2, if the difference is 0, update the counter and the next pixel value; if the next pixel is empty, perform Golomb encoding on the counter and proceed to step S1.4; if the next pixel is not empty, return to step S1.1; Among them, the 0th order Columbus coding further includes: ① Perform 0-order Golomb coding on a non-negative integer x; ② Add 1 to itself, that is, x+1; ③Write x+1 in binary form (x+1)2; ④ Count the number of digits of (x+1)2 in binary form, recorded as M; ⑤ Add M-1 zeros before the binary form (x+1)2; S1.3, if the difference is not 0, first perform Golomb coding on the non-zero Count, and further encode the pixels whose difference is not 0 using 5-bit or 8-bit fixed-length coding, including setting a 5-bit difference diff threshold; update the next pixel, if the next pixel is empty, further proceed to step S1.4; if the next pixel is not empty, return to step S1.1; S1.4, end of coding; S2: If lossless decoding is performed, the lossless decoding further includes: S2.1, record the current bit; further determine whether the current bit is 0? According to the result, proceed to step S2.2 and step S2.3 respectively; S2.2, if the current bit is 0, perform 0th-order Golomb decoding; then proceed to step S2.4; Wherein, the 0-order Columbus decoding further comprises: ① Record the number of leading 0s in the Columbus code as M; ②Convert the (M+1) bits following the leading 0 into decimal X; ③X-1 is the decoded decimal; S2.3, if the current bit is not 0, the corresponding bit is right-shifted by 2+5 or 2+8 bits for decoding, where the first two bits are the identifier, and then step S2.4 is performed; S2.4, determine whether the bit is empty? If yes, then end; if no, then return to step S2.

1.

2. A method for lossless compression and decoding of a simple image according to claim 1, characterized in that: The step S1.1 further comprises: S1.1.1, input image; S1.1.2, set the pixel value of the 0th pixel to 0, that is, predPel = 0; the first pixel value is recorded as curPel; S1.1.3, calculate the difference, calculate the difference between the current pixel curPel and the previous pixel predPel and record it as diff, diff = curPel-predPel; S1.1.4, determine whether diff=0 is established. If yes, proceed to step S1.2; if no, proceed to step S1.

3.

3. A method for lossless compression and decoding of a simple image according to claim 2, characterized in that: If the value of step S1.2 is 0, the counter is incremented by 1, and the next pixel is taken to update predPel and curPel, and the process returns to step S1.1.3; the process further includes: S1.2.1, then counter +1, Count++; S1.2.2, take the next pixel, update predPel and curPel, that is, predPel = curPel, take the next pixel and record it as curPel; S1.2.3, determine whether the pixel is empty? If not, return to step S1.1.3; if yes, proceed to step S1.2.4; S1.2.4, perform Golomb encoding on Count; further proceed to step S1.4, and the encoding is completed.

4. A method for lossless compression and decoding of a simple image according to claim 3, characterized in that: If the value of step S1.3 is not 0 and the counter is not 0, the counter is encoded using the Golomb encoding, and the counter is set to 0 after completion; encoding 1 and comparing whether the diff is within the threshold, if it is within the threshold -16 to 15, encoding 1 and using 5 bits to encode diff; otherwise encoding 0 and using 8 bits to encode curPel, taking the next pixel to update predPel and curPel and returning to step S1.1.3; further comprising: S1.3.1, determine whether Count == 0? S1.3.2, if no, perform Golomb encoding on Count, Count=0; and further proceed to step S1.3.3; if yes, directly proceed to step S1.3.3; S1.3.3, code 1; S1.3.4, determine whether diff∈[-16,15] holds? If yes, encode 1, 5-bit encoding diff; If not, encode 0, 8-bit encoding curPel; S1.3.5, predPel = curPel, take the next pixel and record it as curPel; S1.3.6, determine whether the pixel is empty? If not, return to step S1.1.3; if yes, proceed to step S1.4 and the encoding ends.

5. A method for lossless compression and decoding of a simple image according to claim 1, characterized in that: The step S2.1 further comprises: S2.1.1, input code stream; S2.1.2, set the pixel value of the 0th pixel to 0, that is, predPel = 0; S2.1.3, record the current bit as curBit.

6. A method for lossless compression and decoding of a simple image according to claim 5, characterized in that: The step S2.2, if the current bit is 0, the number of leading 0s is counted as M, and the number count is decoded according to the Golomb code, then the values ​​of the subsequent count pixels are all predPel, right-shifted 2M+1 bits; further comprising: S2.2.1, starting from the current position, record the number of leading 0s as M; S2.2.2, the M+1 binary digits after the leading 0 are converted to decimal x; S2.2.3, decode to get X-1; S2.2.4, then there are X-1 predPels following predPel; S2.2.5, right shift the bit by 2M+1 bits; proceed to step S2.

4.

7. A method for lossless compression and decoding of a simple image according to claim 6, characterized in that: The step S2.3, if the current bit is not 0, it means that there is diff, and it is shifted right by one bit; if the current bit is 1, it is shifted right by one bit, and the subsequent 5 bits are the binary of diff, and it is shifted right by 5 bits; if the current bit is not 1, it is shifted right by one bit, and the subsequent 8 bits are the binary of curPel, and it is shifted right by 8 bits; further comprising: S2.3.1, if not, shift the bit right by 1; S2.3.2, further determine whether curBit == 1? If yes, bit is shifted right by 1 bit; then proceed to step S2.3.3; if no, bit is shifted right by 1 bit, then proceed to step S2.3.6; S2.3.3, the last 5 bits of bit are converted to decimal diff; S2.3.4, curPel=PredPel+diff; predPel=curPel; S2.3.5, right shift bit by 5 bits; proceed to step S2.4; S2.3.6, the last 8 bits of bit are converted to decimal curPel; S2.3.7, predPel = curPel; S2.3.8, shift right 8 bits; proceed to step S2.

4.

8. A method for lossless compression and decoding of a simple image according to claim 7, characterized in that: The step S2.4 further comprises, Determine whether the bit is empty? If not, return to step S2.1.3; If yes, then end.

Citation Information

Patent Citations

  • Lossless encoding and decoding method of Bayer image

    CN107105208A

  • Mathematical lossless coding method and equipment

    CN113784140A

  • Video coding method and device, equipment and storage medium

    CN114760481A

  • Method and apparatus for encoding and decoding image based on code table selection adapted to residual value distribution

    US20100232722A1

  • Lossless image compression and restoration method and apparatus performing same

    WO2014189236A1