A data compression method based on LZW encoding

By preprocessing sensor data and dynamic update of compressed dictionary, the problem of low compression efficiency caused by excessive compression dictionary in LZW encoding is solved, and more efficient data compression is achieved.

CN118842474BActive Publication Date: 2025-03-28SHANGHAI JUPO TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411320190.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-23
Publication Date
2025-03-28
Estimated Expiration
2044-09-23

AI Technical Summary

Technical Problem

LZW encoding is used in sensor data compression because most strings do not appear again in the compressed dictionary, resulting in the dictionary taking up too much space, which makes the reappeared strings use a larger sequence number, resulting in a longer length of compressed data and limited compression efficiency.

Method used

By preprocessing the sensor data, an initial compressed dictionary is constructed, and the compressed dictionary is updated according to the predicted repetition rate of each string during the compression process, ensuring that the dictionary length is within the upper limit of the length, and avoiding the strings that do not appear again occupying too much space.

Benefits of technology

By constantly updating the compressed dictionary, we ensure that the encoding results of the encoded objects are as small as possible and the number of bits of the compressed data is as small as possible, which improves the compression efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118842474B_ABST
    Figure CN118842474B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data encoding and compression, and in particular to a data compression method based on LZW encoding, comprising: preprocessing sensor data, obtaining a sequence to be encoded to construct an initial compression dictionary, obtaining a length upper limit according to the length of the initial compression dictionary, and in the process of compressing the sequence to be encoded, after each encoding of an encoding object is realized, judging the length of the compression dictionary, if the length of the compression dictionary reaches the upper limit, obtaining a predicted repetition rate of each character string according to the overall frequency and the encoded frequency of characters in all character strings in the compression dictionary, updating the compression dictionary according to the predicted repetition rate, and ensuring that the length of the compression dictionary is within the length upper limit by continuously updating the compression dictionary, so that the encoding result of the encoding object is as small as possible, thereby making the number of bits of compressed data as small as possible, and achieving the effect of improving compression efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data coding and compression, and in particular to a data compression method based on LZW coding. Background Art

[0002] With the development of Internet of Things technology, sensors are increasingly used. The data collected by sensors needs to be transmitted to the data processing platform through the Internet of Things for analysis. The amount of data collected by sensors is huge. In order to ensure transmission efficiency, sensor data needs to be compressed.

[0003] LZW encoding continuously adds all the shortest strings that appear for the first time in the sensor data to the compression dictionary. When the string appears again, it is compressed using the sequence number of the corresponding string in the compression dictionary. However, most of the strings in the compression dictionary of LZW encoding may not appear again in the future. These strings occupy most of the space in the compression dictionary, so that the strings that appear again may correspond to larger sequence numbers in the compression dictionary. The length of the binary data corresponding to the larger sequence number is longer, which in turn makes the compressed data length of the sensor data longer. Therefore, the compression efficiency of LZW encoding is limited. Summary of the invention

[0004] In order to solve the above problems, the present invention provides a data compression method based on LZW coding.

[0005] A data compression method based on LZW encoding of the present invention adopts the following technical solution:

[0006] An embodiment of the present invention provides a data compression method based on LZW encoding, the method comprising the following steps:

[0007] Collect sensor data, pre-process the sensor data, and obtain a sequence to be encoded; construct an initial compression dictionary according to each character in the sequence to be encoded; and obtain an upper limit of the length according to the length of the initial compression dictionary;

[0008] The frequency of occurrence of each character in the sequence to be encoded is taken as the overall frequency of each character; an empty sequence is constructed as the encoded sequence;

[0009] Compress the coded sequence, including:

[0010] S1: Match the sequence to be encoded according to the compression dictionary, obtain the encoding object and the encoding result of the encoding object; update the encoded sequence according to the encoding object;

[0011] S2: when the length of the compression dictionary is greater than or equal to the upper limit of the length, obtaining the uncoded frequency of each character according to the coded sequence and the overall frequency of each character; calculating the predicted repetition rate of each character string in the compression dictionary according to the uncoded frequency of each character contained in each character string in the compression dictionary; updating the compression dictionary according to the predicted repetition rate of each character string in the compression dictionary;

[0012] S3: The encoding object and the next character of the encoding object in the sequence to be encoded are combined into a string as a first string, and the first string is added to the end of the compression dictionary;

[0013] S4: repeat S1 to S3 until each character in the sequence to be encoded has been matched and then stop the iteration; obtain compressed data according to the encoding result of each encoding object;

[0014] Transmit, decompress and analyze compressed data.

[0015] Preferably, the preprocessing of the sensor data to obtain the sequence to be encoded includes the following specific steps:

[0016] The sensor data is converted into binary data, the binary data is encoded into characters, and a sequence consisting of all the characters obtained in order is used as a sequence to be encoded.

[0017] Preferably, the initial compression dictionary is constructed according to each character in the sequence to be encoded, and the specific steps include the following:

[0018] Count each character that appears in the sequence to be encoded, build an empty dictionary, add each character to the dictionary, and use the dictionary as the initial compression dictionary.

[0019] Preferably, the obtaining of the length upper limit according to the length of the initial compression dictionary comprises the following specific steps:

[0020] Set the expansion multiple and take the product of the expansion multiple and the length of the initial compression dictionary as the length upper limit.

[0021] Preferably, the step of matching the sequence to be encoded according to the compression dictionary to obtain the encoding object and the encoding result of the encoding object includes the following specific steps:

[0022] According to the compression dictionary, the longest match is performed on the sequence to be encoded starting from the first unmatched character in the sequence to be encoded, and the matching result is used as the encoding object; the serial number of the encoding object in the compression dictionary is used as the encoding result of the encoding object.

[0023] Preferably, the updating of the encoded sequence according to the encoding object comprises the following specific steps:

[0024] Append each character in the encoding object to the end of the encoded sequence in turn.

[0025] Preferably, the step of obtaining the uncoded frequency of each character according to the coded sequence and the overall frequency of each character comprises the following specific steps:

[0026] Get the number of times each character appears in the encoded sequence, divide the number by the length of the sequence to be encoded to get the encoded frequency of each character; subtract the encoded frequency from the overall frequency of each character to get the unencoded frequency of each character.

[0027] Preferably, the step of calculating the predicted repetition rate of each character string in the compression dictionary according to the uncoded frequency of each character contained in each character string in the compression dictionary comprises the following specific steps:

[0028]

[0029] In the formula, The first The predicted repetition rate of the string; The first The set of unencoded frequencies of each character contained in the string; is the minimum function; The first The sequence number of the string; The upper limit of the length of the compression dictionary; The compression dictionary is The number of strings that are substrings; is an exponential function with a natural constant as base; is a hyperparameter.

[0030] Preferably, the updating of the compression dictionary according to the predicted repetition rate of each character string in the compression dictionary comprises the following specific steps:

[0031] Preset culling quantity , the one with the smallest repetition rate will be predicted The character strings are removed from the compression dictionary, and the remaining characters and character strings in the compression dictionary are re-assigned serial numbers according to the serial numbers of the positions where they appear in the compression dictionary after being removed.

[0032] Preferably, the step of obtaining compressed data according to the encoding result of each encoding object comprises the following specific steps:

[0033] Get the maximum value of the encoding results of all encoding objects, recorded as ,Will As the first length, use Indicates that is the rounding symbol; convert the encoding result of each encoding object to a length of The binary number, the length of the encoding result of all the encoding objects is The binary numbers are concatenated together in order as the compressed data of the sequence to be encoded.

[0034] The beneficial effects of the technical solution of the present invention are as follows: LZW encoding continuously adds all the shortest character strings that appear for the first time in a sequence to be encoded to a compression dictionary, so that the length of the compression dictionary is very long; most of the character strings added to the compression dictionary may not appear again in the subsequent period, and these character strings occupy most of the space in the compression dictionary, so that the character strings that appear again may correspond to larger sequence numbers in the compression dictionary, and when encoding the character strings that appear again, a larger sequence number needs to be used for encoding, thereby making the length of the compressed data of the sequence to be encoded longer and the compression efficiency limited; the present invention preprocesses the sensor data, obtains the sequence to be encoded to construct an initial compression dictionary, obtains the length upper limit according to the length of the initial compression dictionary, and compresses the sequence to be encoded. In the compression process, after each encoding of an encoding object is realized, the length of the compression dictionary is judged. If the length of the compression dictionary reaches the upper limit, the predicted repetition rate of each character string is obtained according to the overall frequency of characters in all character strings in the compression dictionary and the encoded frequency, and the compression dictionary is updated according to the predicted repetition rate, ensuring that the character strings that may appear again in the future can be matched in the compression dictionary, so that the longer character strings in the encoding sequence can be encoded with a smaller sequence number, thereby ensuring the compression efficiency; the present invention continuously updates the compression dictionary to ensure that the length of the compression dictionary is within the upper limit of the length, so that the encoding result of the encoding object is as small as possible, thereby making the number of bits of the compressed data as small as possible, so that the compression efficiency is as high as possible. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0036] Figure 1 The present invention is a flowchart of a data compression method based on LZW encoding. DETAILED DESCRIPTION

[0037] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of a data compression method based on LZW coding proposed by the present invention, its specific implementation, structure, features and effects, in conjunction with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.

[0038] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.

[0039] A specific scheme of a data compression method based on LZW encoding provided by the present invention is described in detail below with reference to the accompanying drawings.

[0040] See also Figure 1 , which shows a flow chart of a data compression method based on LZW encoding provided by an embodiment of the present invention, the method comprising the following steps:

[0041] S001. Collect sensor data, pre-process the sensor data, and obtain the sequence to be encoded.

[0042] Use deployed sensors to collect sensor data, such as collecting industrial environment temperature data through temperature sensors and collecting patient heartbeat signal data through heart rate sensors.

[0043] It should be noted that since the accuracy of sensors is usually large, the collected sensor data has more decimal places, and thus the repetition rate of the sensor data is small. Existing compression algorithms such as Huffman coding, arithmetic coding, and LZW coding encode based on the repetition rate of the data, and the compression effect on sensor data with a small repetition rate is poor. Therefore, the collected sensor data needs to be preprocessed to increase the repetition rate of the sensor data.

[0044] In the embodiment of the present invention, the collected sensor data is converted into binary data, the obtained binary data is converted into characters using base64 encoding, and all the obtained characters are sequentially formed into a sequence as a sequence to be encoded.

[0045] It should be noted that since the base64 code contains only 64 different characters and the number of characters is limited, the binary data corresponding to the sensor data is converted into characters using base64. In the obtained sequence to be encoded, the repetition rate of the characters is relatively large, which can improve the compression efficiency.

[0046] At this point, the sequence to be encoded is obtained.

[0047] S002. Construct an initial compression dictionary, compress the coded sequence, and obtain compressed data.

[0048] It should be noted that LZW encoding is a lossless compression algorithm. By continuously adding all the shortest strings that appear for the first time in the sequence to be encoded to the compression dictionary, when the string appears again, the corresponding string sequence number in the compression dictionary is used for encoding, which can achieve a good compression effect. However, continuously adding all the shortest strings that appear for the first time in the sequence to be encoded to the compression dictionary makes the length of the compression dictionary very long. Most of the strings added to the compression dictionary may not appear again in the future. These strings occupy most of the space in the compression dictionary, so that the strings that appear again may correspond to larger sequence numbers in the compression dictionary. When encoding the strings that appear again, a larger sequence number needs to be used for encoding. In order to ensure smooth decoding, it is necessary to convert the encoding of each string that appears again in the sequence to be encoded into a binary number of uniform length and store it as the compressed data of the sequence to be encoded. The length of the binary number depends on the maximum value of all the encodings of the strings that appear again. The maximum value of all the encodings of the strings that appear again is larger, which makes the length of the binary number longer, and then makes the length of the compressed data of the sequence to be encoded longer, and the compression efficiency is limited.

[0049] It should be further explained that in order to make the length of the compressed data finally obtained shorter, the length of each binary number needs to be shorter. When the compression dictionary is small, the serial numbers of all the character strings contained in the compression dictionary are small, so that the codes of the character strings in the sequence to be encoded can be smaller. Therefore, it is necessary to limit the size of the compression dictionary. The embodiment of the present invention limits the size of the compression dictionary. During the compression process of the sequence to be encoded, when the size of the compression dictionary reaches a certain level, the probability of all the character strings contained in the compression dictionary appearing again is predicted, and some character strings are eliminated according to the predicted probability, so that the compression dictionary becomes smaller. Through continuous iteration, it can be ensured that the compression dictionary is small throughout the compression process of the sequence to be encoded, so that the codes of the characters in the sequence to be encoded are smaller, the corresponding compressed data length of the sequence to be encoded is shorter, and the compression efficiency is higher.

[0050] In the embodiment of the present invention, each character appearing in the sequence to be encoded is counted, and the number of character types is recorded as . Construct an empty dictionary, add each character to the dictionary, and use the dictionary as the initial compression dictionary. The serial number of each character is the serial number of the position where each character appears in the initial compression dictionary. At this time, the length of the initial compression dictionary is .

[0051] Preset an expansion multiple , the embodiment of the present invention is based on Take the example for explanation, and there is no specific limitation. The implementation personnel can set the expansion multiple according to the actual implementation situation. The product of the expansion multiple and the length of the initial compression dictionary is As the upper limit of the compression dictionary length, denoted as .

[0052] The frequency of occurrence of each character in the sequence to be encoded is counted as the overall frequency of each character.

[0053] Construct an empty sequence, recorded as the encoded sequence, to store the characters encoded in the process of encoding the sequence to be encoded. Compress the sequence to be encoded, specifically:

[0054] 1. Perform the longest match on the sequence to be encoded starting from the first unmatched character in the sequence to be encoded according to the compression dictionary, and use the matching result as the encoding object. Use the character or string number corresponding to the encoding object in the compression dictionary as the encoding result of the encoding object. Add each character in the encoding object to the end of the encoded sequence in turn.

[0055] 2. Determine the length of the compression dictionary. If the length of the compression dictionary is less than the upper limit, When the length of the compression dictionary reaches the upper limit, execute step 3; , obtain the number of times each character appears in the encoded sequence, divide the number by the length of the sequence to be encoded, and get the encoded frequency of each character. Subtract the encoded frequency from the overall frequency of each character to get the unencoded frequency of each character.

[0056] Compute the predicted repetition rate for each string in the compression dictionary based on the unencoded frequency of each character contained in each string in the compression dictionary:

[0057]

[0058] In the formula, The first The predicted repetition rate of the string; The first The set of unencoded frequencies of each character contained in the string; is the minimum function, To get the collection The minimum value in The probability of a string appearing again depends on the The uncoded frequency of each character contained in the string, when the When the uncoded frequency of a character contained in a string is low, it means that the probability of the next character appearing in the sequence to be encoded is low, then the string containing the character, that is, The probability of the string appearing next is also low. When the uncoded frequency of each character contained in the string is large, it means that the probability of each subsequent character appearing in the sequence to be encoded is high, then the string containing these characters, i.e. The probability of the string appearing next is also high. The predicted repetition rate of the string is high; The first The sequence number of the string; The upper limit of the length of the compression dictionary. The sequence number of the string Normalize; when The larger the sequence number of the string, the The string is the most recent string in the sequence to be encoded. Since the sequence to be encoded has local similarity, the next The higher the probability of a string repeating, the higher the probability of a string repeating. and , so that the obtained The predicted repetition rate of the string is more accurate.

[0059] In the formula, The compression dictionary is The number of strings that are substrings of the string, for example, When the first character string is AB, and the other characters in the compression dictionary are BC, ABD, ABC, DC, and ABDB, and AB is a substring of ABD, ABC, and ABDB, then the character string with the first character string in the compression dictionary is BC, ABD, ABC, DC, and ABDB. The number of strings that are substrings is 3; is an exponential function with a natural constant as base; is a hyperparameter, and the embodiment of the present invention is based on This is described as an example, without any specific limitation. The implementation personnel can set it according to the specific implementation situation. The value of is the number of characters in the sequence to be encoded. The hyperparameter is to prevent Larger, making The result is always close to 0; if the compression dictionary is If there are more strings whose substrings are strings, When the string appears again, the result of the longest match for the encoded sequence is more likely to be the one starting with The string that contains the substring will not be The strings are encoded separately, and the corresponding The necessity of the first character string in the compression dictionary is reduced. The number of strings that are substrings of the first string is small. When the string appears again, the result of the longest match to the encoded sequence is more likely to be A string is needed. In this case, the first The longest matching result is encoded by the serial number of the string, and the corresponding The string is more likely to exist in the compression dictionary, so As The penalty item is The more substrings there are, the more The more severe the punishment, the The predicted repetition rate of the string is reduced. On the contrary, when the compression dictionary is The smaller the number of strings that are substrings, the The lighter the punishment, the The predicted repetition rate of a string depends more on The value of .

[0060] At this point, the predicted repetition rate of each string in the compression dictionary is obtained.

[0061] In the embodiment of the present invention, a rejection quantity is preset. , the embodiment of the present invention is based on Take the example of , and do not set any specific limit. The implementer can set the number of eliminations according to the actual implementation situation. The character strings are removed from the compression dictionary, and the remaining characters and character strings in the compression dictionary are re-assigned serial numbers according to the serial numbers of the positions where they appear in the compression dictionary after being removed.

[0062] 3. The encoding object and the next character of the encoding object in the sequence to be encoded are combined into a string, and the string is added to the end of the compression dictionary. The sequence number of the string is the sequence number of the position where the string appears in the compression dictionary.

[0063] 4. Repeat steps 1-3 according to the updated compression dictionary until all characters in the sequence to be encoded have been matched. Get the maximum value of the encoding results of all encoding objects, recorded as ,Will As the first length, use Indicates that To round up the symbol, convert the encoding result of each encoding object into a length of The binary number, the length of the encoding result of all the encoding objects is The binary numbers are concatenated together in order as the compressed data of the sequence to be encoded.

[0064] At this point, the compression of the sequence to be encoded is achieved, and the compressed data of the sequence to be encoded is obtained.

[0065] S003. Transmit, decompress and analyze compressed data.

[0066] The compressed data, the initial compression dictionary, the first length , the length of the sequence to be encoded, and the overall frequency of each character are uniformly transmitted to the data processing platform.

[0067] The data processing platform decompresses the compressed data, specifically:

[0068] Construct an empty sequence, called the decoded sequence, to store the decoded characters in the process of decompressing the compressed data. Divide the compressed data into multiple binary numbers of length L, convert each binary number into a decimal number, and use the sequence of all the decimal numbers in order as the encoding result sequence.

[0069] Decompress each encoding result in the encoding result sequence in turn, specifically:

[0070] For the current encoding result, obtain the character or string corresponding to the current encoding result in the compression dictionary as the encoding object of the current encoding result. Add each character in the encoding object to the end of the decoded sequence in turn.

[0071] Determine the length of the compression dictionary:

[0072] When the length of the compression dictionary is less than the upper limit When the next encoding result exists in the compression dictionary, the character corresponding to the next encoding result in the compression dictionary or the first character in the string is obtained as the last character. If the next encoding result does not exist in the compression dictionary, the first character in the encoding object of the current encoding result is used as the last character. The last character is concatenated after the encoding object of the current encoding result to obtain a string, and the string is added to the end of the compression dictionary.

[0073] When the length of the compression dictionary is greater than or equal to the upper limit , obtain the number of times each character appears in the decoded sequence, and divide the number by the length of the sequence to be encoded to obtain the decoded frequency of each character. Subtract the decoded frequency from the overall frequency of each character to obtain the unencoded frequency of each character. Calculate the predicted repetition rate of each string in the compression dictionary according to the unencoded frequency of each character contained in each string in the compression dictionary using the method in step S003, and update the compression dictionary according to the predicted repetition rate of each string. If the next encoding result exists in the updated compression dictionary, obtain the character corresponding to the next encoding result in the updated compression dictionary or the first character in the string as the end character. If the next encoding result does not exist in the updated compression dictionary, use the first character in the encoding object of the current encoding result as the end character. Concatenate the end character after the encoding object of the current encoding result to obtain a string, and add the string to the end of the updated compression dictionary.

[0074] The encoding objects of each encoding result are concatenated in order to obtain a character sequence. The character sequence is decoded using base64 encoding, and the decoding result is converted into sensor data.

[0075] The data processing platform analyzes the decoded sensor data.

[0076] Through the above steps, the encoding compression of sensor data is completed.

[0077] The embodiment of the present invention obtains an initial compression dictionary for a sequence to be encoded by preprocessing sensor data, obtains an upper limit of the length according to the length of the initial compression dictionary, and in the process of compressing the sequence to be encoded, after each encoding of an encoding object is implemented, the length of the compression dictionary is judged. If the length of the compression dictionary reaches the upper limit, the predicted repetition rate of each string is obtained according to the overall frequency of characters in all strings in the compression dictionary and the encoded frequency, and the compression dictionary is updated according to the predicted repetition rate, ensuring that the strings that may appear again in the future can be matched in the compression dictionary, so that the longer strings in the sequence to be encoded can be encoded with a smaller sequence number, thereby ensuring the compression efficiency; the embodiment of the present invention continuously updates the compression dictionary to ensure that the length of the compression dictionary is within the upper limit of the length, so that the encoding result of the encoding object is as small as possible, so that the number of bits of the compressed data is as small as possible, and the compression efficiency is as high as possible.

[0078] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A data compression method based on LZW coding, characterized in that: The method comprises the following steps: Collect sensor data, pre-process the sensor data, and obtain a sequence to be encoded; construct an initial compression dictionary according to each character in the sequence to be encoded; and obtain an upper limit of the length according to the length of the initial compression dictionary; The frequency of occurrence of each character in the sequence to be encoded is taken as the overall frequency of each character; an empty sequence is constructed as the encoded sequence; Compress the coded sequence, including: S1: Match the sequence to be encoded according to the compression dictionary, obtain the encoding object and the encoding result of the encoding object; update the encoded sequence according to the encoding object; S2: when the length of the compression dictionary is greater than or equal to the upper limit of the length, obtaining the uncoded frequency of each character according to the coded sequence and the overall frequency of each character; calculating the predicted repetition rate of each character string in the compression dictionary according to the uncoded frequency of each character contained in each character string in the compression dictionary; updating the compression dictionary according to the predicted repetition rate of each character string in the compression dictionary; S3: The encoding object and the next character of the encoding object in the sequence to be encoded are combined into a string as a first string, and the first string is added to the end of the compression dictionary; S4: repeat S1 to S3 until each character in the sequence to be encoded has been matched and then stop the iteration; obtain compressed data according to the encoding result of each encoding object; Transmit, decompress and analyze compressed data; The specific steps of obtaining the uncoded frequency of each character according to the coded sequence and the overall frequency of each character are as follows: Obtain the number of times each character appears in the encoded sequence, divide the number by the length of the sequence to be encoded, and obtain the encoded frequency of each character; subtract the encoded frequency from the overall frequency of each character to obtain the unencoded frequency of each character; The step of calculating the predicted repetition rate of each character string in the compression dictionary according to the uncoded frequency of each character contained in each character string in the compression dictionary includes the following specific steps: In the formula, The first The predicted repetition rate of the string; The first The set of unencoded frequencies of each character contained in the string; is the minimum function; The first The sequence number of the string; The upper limit of the length of the compression dictionary; The compression dictionary is The number of strings that are substrings; is an exponential function with a natural constant as base; is a hyperparameter; The specific steps of updating the compression dictionary according to the predicted repetition rate of each character string in the compression dictionary are as follows: Preset culling quantity , the one with the smallest repetition rate will be predicted The character strings are removed from the compression dictionary, and the remaining characters and character strings in the compression dictionary are re-assigned serial numbers according to the serial numbers of the positions where they appear in the compression dictionary after being removed.

2. A data compression method based on LZW coding according to claim 1, characterized in that: The sensor data is preprocessed to obtain a sequence to be encoded, and the specific steps include the following: The sensor data is converted into binary data, the binary data is encoded into characters, and a sequence consisting of all the characters obtained in order is used as a sequence to be encoded.

3. The data compression method based on LZW coding according to claim 1, characterized in that: The specific steps of constructing an initial compression dictionary according to each character in the sequence to be encoded are as follows: Count each character that appears in the sequence to be encoded, build an empty dictionary, add each character to the dictionary, and use the dictionary as the initial compression dictionary.

4. The data compression method based on LZW coding according to claim 1, characterized in that: The specific steps of obtaining the length upper limit according to the length of the initial compression dictionary are as follows: Set the expansion multiple and take the product of the expansion multiple and the length of the initial compression dictionary as the length upper limit.

5. The data compression method based on LZW coding according to claim 1, characterized in that: The specific steps of matching the sequence to be encoded according to the compression dictionary to obtain the encoding object and the encoding result of the encoding object are as follows: According to the compression dictionary, the longest match is performed on the sequence to be encoded starting from the first unmatched character in the sequence to be encoded, and the matching result is used as the encoding object; the serial number of the encoding object in the compression dictionary is used as the encoding result of the encoding object.

6. The data compression method based on LZW coding according to claim 1, characterized in that: The updating of the encoded sequence according to the encoding object includes the following specific steps: Append each character in the encoding object to the end of the encoded sequence in turn.

7. The data compression method based on LZW coding according to claim 1, characterized in that: The specific steps of obtaining compressed data according to the encoding result of each encoding object are as follows: Get the maximum value of the encoding results of all encoding objects, recorded as ,Will As the first length, use Indicates that is the rounding symbol; convert the encoding result of each encoding object to a length of The binary number, the length of the encoding result of all the encoding objects is The binary numbers are concatenated together in order as the compressed data of the sequence to be encoded.

Citation Information

Patent Citations

  • Smart community face data storage method and system

    CN116521093A

  • Wireless sensor network data intelligent compression method

    CN117376429A