Binary Image Compression Encoding and Decoding Method Based on Base62 Encoding

By using a hybrid compression algorithm based on Base62 encoding, the problem of low transmission efficiency of binary images in the Internet of Things (IoT) is solved, achieving high compression ratio and simple decoding of image transmission effects, which is suitable for narrowband transmission and low-performance terminals in the IoT.

CN114286102BActive Publication Date: 2025-11-14SHANGHAI SEARI INTELLIGENT SYST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111344743.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-15
Publication Date
2025-11-14
Estimated Expiration
2041-11-15

AI Technical Summary

Technical Problem

Existing IoT transmission protocols and encoding methods are not suitable for transmitting large amounts of video, audio, and image information. In particular, the compression and decoding algorithms for binary images are inefficient on low-performance terminals and cannot meet the requirements of narrowband transmission.

Method used

A binary image compression encoding and decoding method based on Base62 encoding is adopted. By using a combination of algorithms such as row difference, column copy, skip white block and run-length encoding, and combining Base32 and Base62 encoding tables, multiple compression and decoding are performed to form a fixed and simple encoding table, which can meet the decompression needs of IoT narrowband transmission and low-performance terminals.

Benefits of technology

It achieves lossless compression with a high compression ratio, is suitable for network transmission, is easy to decode, meets the decompression needs of low-performance IoT terminals, and improves image transmission efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114286102B_ABST
    Figure CN114286102B_ABST
Patent Text Reader

Abstract

This invention relates to a binary image compression and decoding method based on Base62 encoding. The method involves converting the original binary image to Base32 to generate a Base32 two-dimensional array; setting the number of compressed bytes; compressing the Base32 array in blocks according to the number of compressed bytes to create an index matrix; performing a first compression on the Base32 two-dimensional array based on the index matrix; and performing a second compression on consecutive empty data segments appearing in the first compression result, based on the characteristics of numerous white blocks and similar adjacent rows in printed labels, using run-length encoding and character substitution algorithms. The resulting binary image compression is lossless, achieving a high compression ratio. Furthermore, being based on Base62 encoding, it is suitable for network transmission. The Base62 encoding table is fixed, simplifying decoding and meeting the needs of narrowband transmission in the Internet of Things (IoT) and decompression requirements of low-performance terminals.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to an information processing technology, and more particularly to a binary image compression encoding and decoding method based on Base62 encoding. Background Technology

[0002] The Internet of Things (IoT) is a medium that connects various objects into a network through information technology to help people obtain information about these objects. It has been widely applied in various fields such as smart logistics, intelligent transportation, and financial management. Common IoT communication protocols are mainly used for transmitting small amounts of text information and are not suitable for transmitting large amounts of video, audio, and image information. Printed labels, as binary (black and white) images, are widely used and have high compressibility. Therefore, an image compression and encoding / decoding algorithm that can adapt to the narrowband transmission and low-performance terminal decompression requirements of the IoT has considerable practical application value. For example... Figure 1 The image shows a printed sample label.

[0003] IoT transmission is based on the MQTT protocol, and billing is based on data traffic. Each platform has its own maximum message length, currently 32K for IoT platforms. Meanwhile, IoT edge gateways are mostly embedded systems, which generally have lower performance due to cost factors. Therefore, simple decoding algorithms and fixed code tables are preferable.

[0004] Binary code is not suitable for network transmission; Base64 is one of the most common encoding methods used on the network for transmitting 8-bit byte code (e.g., ...). Figure 2 The Base64 encoding table shown is an example. Base64 is a method of representing binary data using 64 printable characters. To unify and standardize Base64 output, Base62 is considered an improved version of unsigned base64 (the only difference between Base62 and Base64 is the absence of the two special symbols "+" and " / "). Additionally, standard Base64 requires padding with "=" at the end, but this is a convention and can be omitted by custom algorithms. In short, Base62 is an algorithm that corrects all the shortcomings of Base64; its only drawback is that it uses 1 / 32 of the space due to its smaller code space.

[0005] Commonly used lossless compression algorithms:

[0006] 1) Skip-white block encoding: Utilizing the characteristic of a large number of blank spaces in a binary image, each row is divided into several blocks, each block containing N pixels. For blocks containing only white pixels, a 1-bit codeword "0" is used, because the probability of white pixels appearing is high, so the shortest codeword is assigned. For blocks containing at least one black pixel, an N+1-bit codeword is used: the first bit is "1", called the prefix code; the remaining N bits are directly encoded, with white pixels being "0" and black pixels being "1".

[0007] 2) LZW encoding: Leveraging the characteristic of a large number of repetitive lines in a binary image, this is a compression technique that dynamically creates a compilation table based on the original data. It uses an initial dictionary (0-255) as a basis, stores each first occurrence of a string and represents it with a number, thereby greatly improving the compression efficiency of image files.

[0008] 3) Run-length encoding: Utilizing the characteristic of binary images with a large number of consecutive repetitive elements, it replaces consecutive symbols with the same value with a single symbol value or string length, making the symbol length shorter than the original data length. It only records the code and the number of repetitions of the same code when the code changes in each row or column, thus achieving data compression.

[0009] Run-length encoding, also known as "run-length encoding" or "travel encoding," is a statistical encoding method that belongs to lossless compression encoding. It is effective for binary graphs.

[0010] The basic principle of run-length encoding is to replace consecutive symbols with the same value (consecutive symbols form a continuous "run"; hence the name run-length encoding) with a single symbol value or string length, making the symbol length shorter than the length of the original data.

[0011] For example: 5555557777733322221111111

[0012] The run-length encoding is: (5, 6)(7, 5)(3, 3)(2, 4)(1, 7). It is evident that the run-length encoding has far fewer bits than the original string.

[0013] When encoding image data, pixels with the same gray value arranged in a certain direction can be regarded as continuous symbols. Replacing these continuous symbols with strings can significantly reduce the amount of data.

[0014] Travel coding is divided into two types: fixed-length travel coding and variable-length travel coding.

[0015] Run-length encoding is a continuous and precise encoding method. If even one bit of a symbol is incorrect during transmission, it can affect the entire encoded sequence, making it impossible to recover the original data from the run-length encoding.

[0016] 4) JBIG2 Encoding: JBIG2 divides a binary image into text regions, halftone regions, and normal regions, and uses different methods to compress different regions. For binary text regions, it uses a pattern matching-based compression method. Summary of the Invention

[0017] To address the issue that binary codes are unsuitable for network transmission and have limited transmission capacity in the Internet of Things (IoT), a binary image compression and decoding method based on Base62 encoding is proposed.

[0018] The technical solution of this invention is: a binary image compression encoding and decoding method based on Base62 encoding, including an encoding compression method and a decoding method:

[0019] The encoding and compression method specifically includes the following steps:

[0020] 1) Convert the original binary image to Base32 to generate a Base32 two-dimensional array;

[0021] 2) Set the number of bytes to be compressed, and compress the Base32 array into blocks according to the number of bytes to create an index matrix; the method for creating the index matrix is ​​as follows:

[0022] First, pre-scanning, which involves performing one of three compression algorithms (row selection difference, column copying, and color-blocking) or no compression on each compressed block to obtain the data segment length of the compressed result of each algorithm;

[0023] Then, considering the inflation factor, the lengths of the three compressed data segments are compared with the original length of the compressed block, and the shortest algorithm identifier is written into the index matrix.

[0024] 3) Compress the Base32 two-dimensional array from step 1) based on the index matrix;

[0025] 4) Secondary compression: The first compression result is run-length encoded using the Base32 encoding table, and the character is replaced by the most frequent line difference 1 + repetition flag. Finally, the Base32 values ​​of the three basic values ​​of the image pixel width L, number of lines H, and maximum line difference N are added to the beginning of the compressed result, and an end character is added to the end to complete the compression encoding.

[0026] The specific decoding steps are as follows:

[0027] A: Obtain the three basic values ​​of the image's pixel width L, number of rows H, and maximum line difference N from the very beginning of the compressed file, and create a Base32 cache array;

[0028] B: Read a compressed code segment according to the block flag. The compressed code segment can be divided into two categories: standard compressed blocks with block flag + data segment and compressed blocks with block flag + continuous flag + continuous number of no data segments. For standard compressed blocks, write the block flag and data segment to the index cache and the line data cache. For compressed blocks without data, first perform character substitution decoding, then perform run-length decoding, and write the block flag to the index cache. After the number of index cache segments reaches L / 5 of the number of compressed blocks in a single line, proceed to decoding step C.

[0029] C: Restore the Base32 encoded value of this row based on the index cache and row data cache, according to the Base32 cache array;

[0030] D: Repeat decoding step C until the number of index cached blocks is less than the number of compressed blocks per line L / 30, then return to decoding step B; repeat this process until the end character is read.

[0031] Furthermore, in step 2) of the encoding compression method, when the lengths of the compressed result data segments are the same, the compression method is selected according to the priority order of no compression > row difference > color block > column copy, based on the decompression computing power and the need for secondary compression.

[0032] Furthermore, the row difference and column copy compression algorithm in step 2) of the encoding compression method is a derivative algorithm based on LZW. In the row difference compression algorithm, the row difference symbol represents the relative row position of the reference data block, and the data segment content is the difference value encoding between the target data block and the reference data block. In the column copy compression algorithm, the column difference symbol represents the relative column position of the reference data block and only retains the hit results with no difference.

[0033] Furthermore, the color-block compression algorithm in step 2) of the encoding compression method is a derivative algorithm based on white-block compression: based on the characteristic that binary line segments are either 0 or 1, the binary line segments are represented by recording the position of data jump points.

[0034] Furthermore, in step 4) of the encoding compression method, the secondary compression is based on the characteristics of a large number of white blocks on the printed label and the similarity of adjacent rows. The continuous empty data segments that appear in the first compression result are compressed using run-length encoding and character substitution algorithms.

[0035] Furthermore, the Base32 encoding table is based on Base62 encoding. 0 to 31 correspond to the first 32 bits of the original Base62 encoding, and some content in 32 to 62 is defined as flag bits. A fixed code table is established, and run-length encoding is performed. That is, based on the feature of fixed row width of the label image, the Base32 encoding table is used to re-encode the binary image in the row direction.

[0036] The beneficial effects of this invention are as follows: the binary image compression encoding and decoding method based on Base62 encoding is lossless, has a high compression ratio, and is suitable for QR code tags; based on Base62 encoding, it is suitable for network transmission; the Base62 encoding table is fixed, decoding is simple, and it meets the needs of narrowband transmission and low-performance terminal decompression in the Internet of Things. Attached Figure Description

[0037] Figure 1 This is a schematic diagram of a printed sample label;

[0038] Figure 2 A table showing the Base64 encoding;

[0039] Figure 3 A table showing the correspondence between the three coding systems;

[0040] Figure 4 This is a diagram illustrating a cached data dictionary.

[0041] Figure 5 This is a compressed pre-scan distribution diagram of the example label of the present invention;

[0042] Figure 6 A timing comparison graph of encoding and decoding for four example tags using the method of the present invention. Detailed Implementation

[0043] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. These embodiments are based on the technical solution of the present invention and provide detailed implementation methods and specific operating procedures. However, the scope of protection of the present invention is not limited to the following embodiments.

[0044] Based on the compression requirements of binary images, various commonly used compression algorithms are improved in a targeted manner. Through hybrid coding and multiple compression methods, a fixed and reasonable encoding table and compression parameters are determined, forming a dedicated image compression encoding and decoding algorithm with high compression ratio and simple decompression algorithm, such as... Figure 3 The table shows the three coding correspondences.

[0045] Based on Base62 encoding, a fixed code table is established. Since the code table must contain both numerical values ​​and identifiers, a maximum of 5-bit numerical encoding, i.e., Base32 (0-31), can be used. Due to the fixed row width of the label image, Base32 is used to re-encode the binary image in the row direction. The inflation factor for this step is 8 / 5 (inflation factor: the data length after encoding becomes 8 / 5 of the original length; that is, a 5KB file becomes 8KB after Base32 encoding). In Base62, 0-31 are defined as Base32 numerical values, and some content in 32-62 is defined as flag bits, while some is unused. The fixed row width of the label image explains why re-encoding is performed in the row direction, because the length of the label pattern printed by a binary label printer, such as an invoice, is variable, making column-direction Base32 encoding unsuitable.

[0046] The compression is based on two compression algorithms: LZW and skip-white-block compression. The length of the compressed block is fixed and must be compatible with both algorithms. Using a 5-bit numerical encoding with a maximum value of 31, the maximum length of the compressed block is 30 bits, or 6 bytes.

[0047] By using a pre-scanning method, compression can select the algorithm with the highest compression ratio from multiple compression algorithms for mixed encoding. Both LZW and skipped white blocks are sensitive to noise, and the QR code area has a high probability of expansion. As a countermeasure, no compression should also be included as an algorithm incorporating pre-scanning.

[0048] LZW-based derivative algorithms

[0049] Using the preceding data as a dictionary, the algorithm searches for reference blocks with the smallest differences in both row and column directions. The difference values ​​are then written into the data segment in a position-plus-content format. The row-differential compression algorithm uses row-differential operators to represent the relative row position of the reference data block, and the data segment content is the encoded difference value between the target and reference data blocks. The column-replicative compression algorithm uses column-differential operators to represent the relative column position of the reference data block and only retains the hit results where there is no difference. Since the compressed block is a one-dimensional array of length 30 (30:1 aspect ratio), the hit rate of column-referenced data is much lower than that of row-referenced data. However, due to the row-based encoding and decoding characteristics, column-referenced data does not occupy the decoding buffer, while row-referenced data requires n rows of decoding buffer. Based on actual testing, a maximum row-referenced value of 9 and a maximum column-referenced value of 3 can meet the actual compression requirements.

[0050] like Figure 4 The diagram shows a cached data dictionary. The current position is the data block to be encoded (Kfffff in the diagram). It can be seen that the third line of the row reference (ffffff) has the smallest difference from the target data block. Based on the row reference differential algorithm, in the row differential example, the third line is hit, and there is a difference in the 0th byte. The difference value is K, so the encoding result is: rAK ("r" is the row difference symbol 3 in the Base62 table, representing that the position of the reference block is row -3, i.e., "ffffff", and "A" is the value 0 in the Base62 table, representing that the target block and the reference block are different in the character at the 0th position, and the content is "K").

[0051] Due to the low hit rate of column references, to simplify the algorithm, only the hit results that are indistinguishable can be retained, forming a column reference-based replication algorithm—column replication.

[0052] Derivative algorithms based on skipping white tiles:

[0053] Based on the characteristic that binary line segments are either 0 or 1, binary line segments can be represented by recording the position of data jump points. This method does not require recording data content and has the highest compression ratio for continuous line segments. Since this method skips both white and black blocks, this derivative algorithm can be marked with color-skipping blocks.

[0054] Due to the characteristic of printed labels having a large number of white blocks, the default is 0 as the starting state of the line segment. The compression codes for all-white and all-black line segments are y and yA, respectively, which have the highest compression ratio.

[0055]

[0056] The transition points of the binary line segment in the example above are 5 and 18, corresponding to... Figure 2 The Base64 encoding table shown is compressed using the code yFS (y represents all white; in the Base64 encoding table, 5 corresponds to F and 18 corresponds to S).

[0057] Secondary compression

[0058] Due to the numerous white blocks and similarity between adjacent lines in the printed label, a large number of consecutive empty data segments (only block markers, data segments are empty) will inevitably appear in the first compression result. This part is suitable for secondary compression using run-length encoding and character substitution algorithms to form the final output result. Example of a first compression result: ppppppppppppypppppppppp, after run-length encoding it becomes plMyplK (based on the example of run-length encoding in the background technology, this can be understood as P being 12 bits long, M for 12 and K for 10 in the Base64 encoding table), after character substitution it becomes 5My5K (the character "pl" is replaced with the character "5" - the substitution symbol A in the base62 table).

[0059] This invention presents a binary image compression encoding and decoding method based on Base62 encoding. The specific encoding steps are as follows:

[0060] Encoding Step 1: Convert the original binary image to Base32 to generate a Base32 two-dimensional array. Example label: 600 pixels wide and 400 pixels high. The Base32 array is an 8-bit character two-dimensional array with a width of 120 and a height of 400 (the Base32 array is a matrix with a width of 120 and a height of 400, and the element format is U8).

[0061] Encoding Step 2: Compress the Base32 array into 6-byte blocks and create an index matrix. The index matrix is ​​a two-dimensional array with a width of 20 and a height of 400. Pre-scanning involves compressing each compressed block (each block is ultimately compressed using one of three algorithms or uncompressed; each block is independent, therefore each line and the entire file are compressed using a hybrid method) using row difference, column copy, and color-block compression algorithms to obtain the data segment length of each algorithm's compression result. Considering inflation, these three lengths are compared with the original length of the compressed block (6 bytes), and the shortest algorithm identifier is written into the index matrix. When data segment lengths are the same, they are prioritized according to decompression computing power and secondary compression requirements: uncompressed > row difference > color-block > column copy.

[0062] Encoding step 3: Compress the Base32 two-dimensional array once according to the index matrix.

[0063] Encoding Step 4: Perform run-length encoding on the compressed result using a Base32 encoding table, and replace the most frequent line difference symbol 1 + repetition flag with a character (replacement symbol A). Finally, add the Base32 values ​​of the image's pixel width L (600), number of lines H (400), and maximum line difference N (9) to the beginning of the compressed result, and add an end symbol (61) to the end to complete the compression encoding. The smaller the maximum line difference N, the smaller the buffer requirement at the decoding end.

[0064] Example of output result: YSQMJ……9, when the image is completely white (a sample of a completely white image), the compressed result is YSQMJylU5MZH9.

[0065] The specific decoding steps are as follows:

[0066] Decoding Step 1: Obtain the three basic values ​​from the beginning of the compressed file: pixel width L, number of rows H, and maximum line difference N. Create a Base32 cache array (L / 5, N). Create a two-dimensional array (L / 30, compressed block length 6) for the index cache and line data cache.

[0067] Decoding Step 2: Read a compressed code segment by block flag (any Base62 value > 39 is a block flag). The compressed code segment can be divided into two categories: standard compressed blocks with block flag + data segment, and compressed blocks without data with block flag (+ continuation flag + continuation quantity). For standard compressed blocks, write the block flag and data segment to the index cache and line data cache. For compressed blocks without data, first perform character substitution decoding, then perform run-length decoding, and write the block flag to the index cache. After the index cache reaches the number of compressed blocks in a single line (L / 5), proceed to Decoding Step 3.

[0068] Decoding Step 3: Based on the index cache and row data cache, reconstruct the Base32 encoded value of this row using the Base32 cache array. Index flag:

[0069] 1) Original encoding: Directly copy the data segment in the row data cache to the current position in the Base32 two-dimensional array.

[0070] 2) Row differential encoding: First, copy the contents of the first n rows and columns of the Base32 two-dimensional array to the current position of the Base32 two-dimensional array, and then modify the corresponding byte contents according to the position and content format of the data segment.

[0071] 3) Column copy encoding: First, copy the contents of the first n columns of the same row of the Base32 two-dimensional array to the current position of the Base32 two-dimensional array.

[0072] 4) Color block encoding: Create a binary array of length 30 with an initial value of 0. Based on the data segment content, for each position point, reverse the array value at the corresponding position and thereafter. Encode the result into 6 bytes of data using Base32 and write it into the current position of the Base32 two-dimensional array.

[0073] After decoding the Base32 encoded value of the current row, perform Base32 inverse encoding based on the pixel width L to restore the original value of the binary image for that row and output it. Clear the row data cache, clear the content of that row in the index cache, and update the Base32 cache array.

[0074] Decoding step 4: Repeat decoding step 3 until the number of index cached blocks is less than the number of compressed blocks per line L / 30, then return to decoding step 2. Repeat this process until the end-of-line character is read.

[0075] This section compares two commonly used image compression algorithms, JBIG2 (arithmetic compression) and GIF (LZW compression), with a dedicated image compression algorithm.

[0076] Table 1

[0077]

[0078] As shown in Table 1 above, the comparison between the original image, LZW compression, arithmetic compression, and dedicated image compression shows that the dedicated image compression algorithm is significantly better than the basic LZW compression algorithm. Compared with JBIG2 compression, which has the highest compression ratio for binary images, the file size of dedicated image compression is 94% to 101% of that of JBIG2 compression after removing the 8 / 5 dilation factor of Base32 encoding, which is very close.

[0079] like Figure 5 For the appendix Figure 1 Analysis of the compression pre-scan results of the label image shown shows that the line differential 1 plays an absolutely dominant role in the encoding. Since n-line differential decoding requires the decoder to cache n lines of decoding results as a dictionary, selecting a suitable line differential coefficient can reduce the cache performance requirements of the decoder at the cost of a certain reduction in compression ratio.

[0080] like Figure 6 The figure shows the results of encoding and decoding timing four example tags using the method of this invention. Tag 0 is a completely blank image used as a comparison benchmark, tag 1 is a tag image without a QR code, and tags 2 and 3 are common tag images containing QR codes. As can be seen from the figure, with the increase in image complexity, the timing increment for pre-scanning is more significant, while the timing increments for encoding and decoding are relatively gradual, with the timing increment for encoding being approximately twice that for decoding. Since pre-scanning and encoding are performed by the encoding end, the computational load is significantly biased towards the encoding end compared to the decoding end.

[0081] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this invention patent should be determined by the appended claims.

Claims

1. A binary image compression encoding and decoding method based on Base62 encoding, characterized in that, This includes encoding / compression methods and decoding methods: The encoding and compression method specifically includes the following steps: 1) Convert the original binary image to Base32 to generate a Base32 two-dimensional array; 2) Set the number of bytes to be compressed, and compress the Base32 two-dimensional array into blocks according to the number of bytes to create an index matrix; the method for creating the index matrix is ​​as follows: First, pre-scanning, which involves applying three compression algorithms to each compressed block: row differential, column copying, and color-blocking, to obtain the data segment length of the compressed result of each algorithm; Then, considering the inflation factor, the length of the compressed data segment is compared with the original length of the compressed block, and the shortest algorithm identifier is written into the index matrix. 3) Compress the Base32 two-dimensional array from step 1) based on the index matrix; 4) Secondary compression: The first compression result is run-length encoded using the Base32 encoding table, and the character is replaced by the most frequent line difference 1 + repetition flag. Finally, the Base32 values ​​of the three basic values ​​of the image pixel width L, number of lines H, and maximum line difference N are added to the beginning of the compressed result, and an end character is added to the end to complete the compression encoding. The Base32 encoding table is based on Base62 encoding. 0-31 correspond to the first 32 bits of the original Base62 encoding. Part of the content in 32-62 is defined as the flag bit. A fixed code table is established and run-length encoding is performed. That is, based on the feature of fixed row width of the label image, the Base32 encoding table is used to re-encode the binary image in the row direction. The specific decoding steps are as follows: A: Obtain the three basic values ​​of the image's pixel width L, number of rows H, and maximum row difference N from the very beginning of the compressed file, and create a Base32 cache array, as well as two-dimensional arrays for index cache and row data cache; B: Read a compressed code segment by block flag. The compressed code segment can be divided into two categories: standard compressed blocks with block flag + data segment and compressed blocks with block flag + continuous flag + continuous number of no data segments. For standard compressed blocks, write the block flag and data segment to the index cache and the row data cache. For compressed blocks without data, first perform character substitution decoding, then perform run-length decoding, and write the block flag into the index cache; Once the number of index cached blocks reaches L / 5 of the number of compressed blocks per line, proceed to decoding step C; C: Restore the Base32 encoded value of this row based on the index cache and row data cache, according to the Base32 cache array; Specifically, the index flags are as follows: Original encoding: directly copy the data segment in the row data cache to the current position of the Base32 two-dimensional array; Row differential encoding: first copy the contents of the first n rows and columns of the Base32 two-dimensional array to the current position of the Base32 two-dimensional array, and then modify the corresponding byte content according to the position and content format of the data segment; Column copy encoding: First, copy the contents of the first n columns of the same row of the Base32 two-dimensional array to the current position of the Base32 two-dimensional array; Color block encoding: Create a binary array of length 30 with an initial value of 0. For each position of the data segment, reverse the array value at the corresponding position and thereafter. Encode the result into 6 bytes of data using Base32 and write it into the current position of the Base32 two-dimensional array. After the Base32 encoded value of the current row is decoded, the original value of the binary image of the row is restored by Base32 inverse encoding according to the pixel width L and output; clear the row data cache, clear the content of the row in the index cache, and update the Base32 cache array; D: Repeat decoding step C until the number of index cached blocks is less than the number of compressed blocks per line L / 30, then return to decoding step B; repeat this process until the end character is read.

2. The binary image compression and decoding method based on Base62 encoding according to claim 1, characterized in that, In step 2) of the encoding compression method, when the lengths of the compressed result data segments are the same, the compression method is selected according to the priority order of no compression > row difference > color block > column copy, based on the decompression computing power and the need for secondary compression.

3. The binary image compression and decoding method based on Base62 encoding according to claim 1 or 2, characterized in that, The row difference and column copy compression algorithm described in step 2) of the encoding compression method is a derivative algorithm based on LZW. In the row difference compression algorithm, the row difference symbol represents the relative row position of the reference data block, and the data segment content is the difference value encoding between the target data block and the reference data block. In the column copy compression algorithm, the column difference symbol represents the relative column position of the reference data block and only retains the hit results with no difference.

4. The binary image compression and decoding method based on Base62 encoding according to claim 1 or 2, characterized in that, The color-block compression algorithm in step 2) of the encoding compression method is a derivative algorithm based on white-block compression: based on the characteristic that binary line segments are either 0 or 1, the binary line segments are represented by recording the position of data jump points.

5. The binary image compression encoding and decoding method based on Base62 encoding according to claim 1, characterized in that, In step 4) of the encoding compression method, the secondary compression is based on the characteristics of a large number of white blocks on the printed label and the similarity of adjacent rows. The continuous empty data segments that appear in the first compression result are compressed using run-length encoding and character substitution algorithms.

Citation Information

Patent Citations

  • System and method for secure data sharing

    CN106100852A

  • Method for encoding and compressing Hbase row keys in big medical data storage

    CN106777258A