CN113746485A - Data compression method, electronic equipment and storage medium - Google Patents

Data compression method, electronic equipment and storage medium Download PDF

Info

Publication number
CN113746485A
CN113746485A CN202110938795.0A CN202110938795A CN113746485A CN 113746485 A CN113746485 A CN 113746485A CN 202110938795 A CN202110938795 A CN 202110938795A CN 113746485 A CN113746485 A CN 113746485A
Authority
CN
China
Prior art keywords
data
data sequence
ith
sequence
encoding
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110938795.0A
Other languages
Chinese (zh)
Inventor
何雨龙
刘俊
梁力文
牛洋洋
龚梅军
杨梦丽
杜先于
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Shuliantianxia Intelligent Technology Co Ltd
Original Assignee
Shenzhen Shuliantianxia Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Shuliantianxia Intelligent Technology Co Ltd filed Critical Shenzhen Shuliantianxia Intelligent Technology Co Ltd
Priority to CN202110938795.0A priority Critical patent/CN113746485A/en
Publication of CN113746485A publication Critical patent/CN113746485A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H03ELECTRONIC CIRCUITRY
    • H03MCODING; DECODING; CODE CONVERSION IN GENERAL
    • H03M7/00Conversion of a code where information is represented by a given sequence or number of digits to a code where the same, similar or subset of information is represented by a different sequence or number of digits
    • H03M7/30Compression; Expansion; Suppression of unnecessary data, e.g. redundancy reduction

Abstract

The embodiment of the application relates to the technical field of data transmission, and discloses a data compression method, electronic equipment and a storage medium.

Description

Data compression method, electronic equipment and storage medium
Technical Field
The embodiment of the application relates to the technical field of data transmission, in particular to a data compression method, electronic equipment and a storage medium.
Background
Polysomnography (PSG) is the most commonly used sleep monitoring device to monitor sleep and health status by monitoring continuous breathing, arterial oxygen saturation, electroencephalogram, electrocardiogram, heart rate, etc. during sleep. Specifically, the PSG device generally includes a main control device and a plurality of data acquisition devices, where the plurality of data acquisition devices are used to acquire physiological signals of a human body in a sleep state, and the specific physiological signals include a plurality of real-time signals such as a heart rate, a temperature, a brain power, and an audio frequency. After the plurality of data acquisition devices acquire the physiological signals, the physiological signals are respectively transmitted to the main control device, so that the main control device acquires the physiological signals for subsequent analysis to determine the sleep state and the health state.
The data transmission between the data acquisition devices and the main control device has the characteristics of multiple channels, high sampling rate and large data volume, so that the data transmission volume is large and the transmission efficiency is low.
Disclosure of Invention
The technical problem mainly solved by the embodiments of the present application is to provide a data compression method, which can accurately control the data volume after compression to be effectively reduced relative to the data volume before compression, thereby reducing the data volume for transmission and improving the transmission efficiency.
In order to solve the foregoing technical problem, in a first aspect, an embodiment of the present application provides a data compression method, including:
acquiring an initial data sequence to be compressed, wherein the initial data sequence is time-varying data acquired within a preset time period;
coding the initial data sequence by adopting a preset first coding algorithm to obtain a first data sequence, wherein the length of the first data sequence is smaller than that of the initial data sequence;
coding the first data sequence by adopting a preset second coding algorithm to obtain a second data sequence;
and if the length of the second data sequence is smaller than that of the first data sequence, determining that a target data sequence comprises the second data sequence and a second identifier, wherein the target data sequence is used for obtaining the initial data sequence after being decoded, and the second identifier is used for representing the identity of the second coding algorithm.
In some embodiments, further comprising:
if the length of the second data sequence is greater than or equal to the length of the first data sequence, encoding the first data sequence by adopting a preset third encoding algorithm to obtain a third data sequence;
and if the length of the third data sequence is smaller than that of the first data sequence, determining that the target data sequence comprises the third data sequence and a third identifier, wherein the third identifier is used for representing the identity of the third encoding algorithm.
In some embodiments, further comprising:
and if the length of the third data sequence is greater than or equal to that of the first data sequence, determining that the target data sequence comprises the first data sequence and a first identifier, wherein the first identifier is used for representing the identity of the first coding algorithm.
In some embodiments, the encoding the initial data sequence by using a preset first encoding algorithm to obtain a first data sequence includes:
determining predicted data corresponding to the ith data according to the first two data of the ith data in the initial data sequence, wherein i is more than 2 and less than or equal to N, and N is the number of data in the initial data sequence;
determining a prediction error corresponding to the ith data as a difference between the ith data and prediction data corresponding to the ith data;
it is determined that the first data sequence includes the first two data in the initial data sequence and (N-2) prediction errors.
In some embodiments, the determining the predicted data corresponding to the ith data according to the first two data of the ith data in the initial data sequence includes:
and determining that the predicted data corresponding to the ith data is 2 times of the (i-1) th data minus the (i-2) th data.
In some embodiments, the encoding the first data sequence by using a preset second encoding algorithm to obtain a second data sequence includes:
coding the prediction error corresponding to the ith data to obtain first coded data corresponding to the ith data;
determining that the second data sequence includes the first two data in the initial data sequence and (N-2) first encoded data.
In some embodiments, the encoding the prediction error corresponding to the ith data to obtain first encoded data corresponding to the ith data includes:
determining parameter values corresponding to the initial data sequence according to the (N-2) prediction errors;
carrying out quotient taking operation on the prediction error corresponding to the ith data and the parameter value to obtain a quotient value, and carrying out linear coding on the quotient value to obtain a linear coding result;
carrying out a remainder operation on the prediction error corresponding to the ith data and the parameter value to obtain a remainder value, and carrying out binary coding on the remainder value to obtain a binary coding result;
determining a first sign bit according to the positive and negative attributes of the prediction error corresponding to the ith data;
determining that first encoding data corresponding to the i data comprises the first sign bit, the binary encoding result and the first binary encoding result.
In some embodiments, the encoding the first data sequence by using a preset third encoding algorithm to obtain a third data sequence includes:
removing a symbol byte in a prediction error corresponding to the ith data to obtain an unsigned byte, wherein the symbol byte is used for representing the positive and negative properties of the prediction error;
the second coded data corresponding to the ith data is formed by splicing the byte length, a second sign bit and the unsigned byte of the second coded data, and the second sign bit is used for expressing the positive and negative attributes of the prediction error corresponding to the ith data;
the third data sequence includes the first two data in the initial data sequence and (N-2) second encoded data.
In order to solve the above technical problem, in a second aspect, an electronic device is provided in an embodiment of the present application, and includes a memory and one or more processors, where the one or more processors are configured to execute one or more computer programs stored in the memory, and when the one or more processors execute the one or more computer programs, the electronic device is enabled to implement the method according to the first aspect.
In order to solve the above technical problem, in a third aspect, the present application provides a computer-readable storage medium storing a computer program, the computer program comprising program instructions that, when executed by a processor, cause the processor to perform the method according to the first aspect.
The beneficial effects of the embodiment of the application are as follows: different from the situation in the prior art, in the data compression method provided in this embodiment of the present application, first, a predetermined first coding algorithm is used to code an initial data sequence to be compressed to obtain a first data sequence, so that the length of the first data sequence is reduced relative to the length of the initial data sequence, then, a predetermined second coding algorithm is used to code the first data sequence to obtain a second data sequence, that is, further performing secondary compression, and finally, the length of the second data sequence is compared with the length of the first data sequence, and if the length of the second data sequence is smaller than the length of the first data sequence, it is determined that a target data sequence (that is, finally compressed data) includes the second data sequence and a second identifier, so that transmission is performed with the target data sequence, and the transmission amount can be effectively reduced, where the second identifier is used to represent the identity of the second coding algorithm, the target data sequence is conveniently decompressed. That is, according to the method, the first coding algorithm is firstly adopted to carry out primary compression on the initial data sequence, and then the second coding algorithm is adopted to carry out secondary compression, so that the initial data sequence can be fully compressed, the data volume is reduced as much as possible, and the secondary compression is ensured to be effective by comparing the length of the second data sequence after the secondary compression with the length of the first data sequence after the primary compression, therefore, the data volume after the compression can be accurately controlled to be effectively reduced relative to the data volume before the compression, the data volume of transmission can be reduced, and the transmission efficiency is improved.
Drawings
One or more embodiments are illustrated by way of example in the accompanying drawings, which correspond to the figures in which like reference numerals refer to similar elements and which are not to scale unless otherwise specified.
Fig. 1 is a schematic structural diagram of a polysomnography monitor according to an embodiment of the present disclosure;
fig. 2 is a block diagram of an electronic device according to an embodiment of the present disclosure;
fig. 3 is a schematic flowchart of a data compression method according to an embodiment of the present application;
fig. 4 is a schematic flowchart of a data compression method according to another embodiment of the present application;
FIG. 5 is a schematic flow chart illustrating a sub-process of step S22 in the method of FIG. 3;
FIG. 6 is a schematic diagram of a prediction error provided in an embodiment of the present application;
fig. 7 is a schematic structural diagram of an initial data sequence and a first data sequence provided in an embodiment of the present application;
FIG. 8 is a schematic flow chart illustrating a sub-process of step S23 in the method of FIG. 3;
FIG. 9 is a schematic view of a sub-flow chart of step S231 in the method shown in FIG. 8;
fig. 10 is a schematic view of a sub-flow of step S25 in the method shown in fig. 3.
Detailed Description
The present application will be described in detail with reference to specific examples. The following examples will assist those skilled in the art in further understanding the present application, but are not intended to limit the present application in any way. It should be noted that various changes and modifications can be made by one skilled in the art without departing from the spirit of the application. All falling within the scope of protection of the present application.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It should be noted that, if not conflicted, the various features of the embodiments of the present application may be combined with each other within the scope of protection of the present application. Additionally, while functional block divisions are performed in apparatus schematics, with logical sequences shown in flowcharts, in some cases, steps shown or described may be performed in sequences other than block divisions in apparatus or flowcharts. Further, the terms "first," "second," "third," and the like, as used herein, do not limit the data and the execution order, but merely distinguish the same items or similar items having substantially the same functions and actions.
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 application belongs. The terminology used in the description of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used herein, the term "and/or" includes any and all combinations of one or more of the associated listed items.
In addition, the technical features mentioned in the embodiments of the present application described below may be combined with each other as long as they do not conflict with each other.
In some embodiments, please refer to fig. 1, which is a schematic structural diagram of a polysomnography monitor 100 according to an embodiment of the present disclosure, where the polysomnography monitor 100 includes a main control device 10 and a plurality of data acquisition devices 20, and the plurality of data acquisition devices 20 are respectively in communication connection with the main control device 10. The data acquisition devices 20 are used for acquiring physiological signals (data) of the user in a sleep state, and then respectively transmitting the acquired data to the main control device 10, and the main control device 10 determines the sleep state and the health state of the user according to the data.
Wherein, communication connection can be wired connection (net twine connection) or wireless connection, and wireless connection includes bluetooth, wifi or 4G, 5G etc..
A data acquisition device 20 includes a controller and a sensor (not shown). The sensors may be set according to the data to be acquired, so that each data acquisition device is responsible for acquiring different time-varying signals, for example, the data acquisition device 1# comprises a heart rate sensor for acquiring heart rate signals, and the data acquisition device 2# comprises a temperature sensor for acquiring temperature signals. Each data acquisition device sends data acquired within a preset time (for example, 0.5s or 1s) to the master control device, so that the master control device acquires time-varying signals of each sensor for subsequent analysis or display. In some embodiments, the data acquisition device 20 further includes a memory for caching data to be transmitted or storing some programmatic instructions. In some embodiments, the programmatic instructions comprise instructions for processing acquired data, or instructions for controlling the sensors, such as acquisition frequency, etc.
The master control device 10 includes a controller, a memory or a display (not shown) to increase the operation speed and the smoothness of the communication process. It is understood that the master control device 10 may be paired with a plurality of data acquisition devices 20 and communicate with the data acquisition devices 20, so as to receive data acquired by the data acquisition devices 20 and issue related commands to the data acquisition devices 20. The display screen is used for displaying the acquired time-varying data or an analysis result acquired according to the acquired time-varying data.
In the process of data transmission, the data acquisition device 20 acquires and stores each time-varying signal of the sensor in real time, and transmits each time-varying signal to the main control device 10.
Based on the above-mentioned structure of the polysomnography monitor 100, in order to reduce the amount of data to be transmitted and improve the transmission efficiency, in some embodiments, the data acquisition device 20 compresses the acquired data before transmitting the data, so as to reduce the amount of data to be transmitted.
One of the embodiments of the present application provides an electronic device, where the electronic device may be the data acquisition device, or may be other devices that need to transmit data, such as a radar or an intelligent camera. Referring to fig. 2, a hardware structure diagram of an electronic device according to an embodiment of the present disclosure is shown, specifically, the electronic device 200 includes at least one processor 210 and a memory 220 (fig. 2 illustrates a bus connection and a processor as an example) that are communicatively connected.
The processor 210 is configured to provide computing and control capabilities to control the electronic device 200 to perform corresponding tasks, for example, to control the electronic device 200 to perform any one of the data compression methods provided in at least one of the following embodiments.
It is understood that the Processor 210 may be a general-purpose Processor including a Central Processing Unit (CPU), a Network Processor (NP), etc.; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
The memory 220, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the data compression method in the embodiments of the present application. The processor 210 may implement the data compression method in any of the method embodiments described below by running non-transitory software programs, instructions, and modules stored in the memory 220. In particular, the memory 220 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device.
In the following, a detailed description is given of a data compression method provided by some embodiments of the present application, referring to fig. 3, the data compression method S20 includes, but is not limited to, the following steps:
s21: the method comprises the steps of obtaining an initial data sequence to be compressed, wherein the initial data sequence is time-varying data collected in a preset time period.
S22: and coding the initial data sequence by adopting a preset first coding algorithm to obtain a first data sequence, wherein the length of the first data sequence is less than that of the initial data sequence.
S23: and coding the first data sequence by adopting a preset second coding algorithm to obtain a second data sequence.
S24: and if the length of the second data sequence is smaller than that of the first data sequence, determining that a target data sequence comprises the second data sequence and a second identifier, wherein the target data sequence is used for obtaining the initial data sequence after being decoded, and the second identifier is used for representing the identity of the second coding algorithm.
The initial data sequence may be time-varying data acquired by the data acquisition device in the above embodiment within a preset time, the time-varying data may be data varying with time, and the data arranged in a time axis may be, for example, a heart rate or a temperature acquired within 2 hours of sleep time. Before data is transmitted, the initial data sequence is compressed, that is, on the premise of not losing useful information, the data volume is reduced, which is equivalent to reducing the number of bytes occupied by the initial data, so as to reduce the storage space and improve the transmission, storage and processing efficiency. In some embodiments, the data to be transmitted may also be compressed in packets, for example, in groups of 1s or 0.5s data, without affecting the real-time transmission of the data.
Firstly, a preset first coding algorithm is adopted to code an initial data sequence to obtain a first data sequence, so that the length of the first data sequence is smaller than that of the initial data sequence. Wherein, the length refers to the number of bytes occupied by the data sequence. In this step, it is equivalent to performing one compression on the initial data sequence. Wherein the first encoding algorithm is a data compression algorithm, in some embodiments, the first encoding algorithm may be an existing huffman compression algorithm or LZ77 algorithm, etc.
Then, a preset second coding algorithm is adopted to code the first data sequence to obtain a second data sequence, namely, the second data sequence is further compressed. Wherein the second encoding Algorithm is another data compression Algorithm, and in some embodiments, the second encoding Algorithm may be an existing Lempel-Ziv Markov chain Algorithm (LZMA) or Multi-Layer Perceptron (MLP), etc.
And finally, comparing the length of the second data sequence with the length of the first data sequence, and if the length of the second data sequence is smaller than the length of the first data sequence, namely the number of bytes occupied by the second data sequence is smaller than the number of bytes occupied by the first data sequence, determining that the target data sequence (namely the finally compressed data) comprises the second data sequence and a second identifier, so that the transmission amount can be effectively reduced by transmitting the target data sequence, wherein the second identifier is used for representing the identity of a second encoding algorithm, and the target data sequence is conveniently decompressed. In some embodiments, the second identifier may be a particular symbol, number, or letter.
In this embodiment, the first encoding algorithm is used to perform first compression on the initial data sequence, and then the second encoding algorithm is used to perform second compression, so that the initial data sequence can be sufficiently compressed, and the data amount is reduced as much as possible.
In some embodiments, referring to fig. 4, the method S20 further includes:
s25: and if the length of the second data sequence is greater than or equal to that of the first data sequence, encoding the first data sequence by adopting a preset third encoding algorithm to obtain a third data sequence.
S26: and if the length of the third data sequence is smaller than that of the first data sequence, determining that the target data sequence comprises the third data sequence and a third identifier, wherein the third identifier is used for representing the identity of the third encoding algorithm.
If the length of the second data sequence after the second compression is greater than or equal to the length of the first data sequence, it indicates that the second compression is failed. I.e. using another encoding algorithm for the secondary compression. Where the third encoding algorithm is another data compression algorithm, in some embodiments the third encoding algorithm may be an existing LZR algorithm or DEFLATE algorithm.
And then, comparing the length of the third data sequence with the length of the first data sequence, and if the length of the third data sequence is smaller than the length of the first data sequence, that is, the number of bytes occupied by the third data sequence is smaller than the number of bytes occupied by the first data sequence, determining that the target data sequence comprises the third data sequence and the third identifier. Wherein the third identifier is used for indicating the identity of the third encoding algorithm, so as to facilitate the decompression of the target data sequence. In some embodiments, the third identifier may be a specific symbol, number, or letter.
In this embodiment, after the second compression using the second encoding algorithm fails, another third encoding algorithm is used to perform the second compression on the first data sequence, so that the compression is sufficient, and the data amount is reduced as much as possible, and the length of the third data sequence after the second compression using the third encoding algorithm is compared with the length of the first data sequence after the first compression, so as to ensure that the second compression is effective, thereby effectively avoiding the invalidation of the second compression, accurately controlling the effective reduction of the data amount after the compression relative to the data amount before the compression, reducing the data amount to be transmitted, and improving the transmission efficiency.
In some embodiments, referring to fig. 4, the method S20 further includes:
s27: and if the length of the third data sequence is greater than or equal to that of the first data sequence, determining that the target data sequence comprises the first data sequence and a first identifier, wherein the first identifier is used for representing the identity of the first coding algorithm.
In this embodiment, the first data sequence and the first identifier obtained after the compression by the first coding algorithm are directly used as the target data sequence, that is, the second compression is not performed any more. The first identifier is used for representing the identity of the first encoding algorithm, so that the target data sequence can be decompressed subsequently. After some embodiments, the first identifier may be a specific symbol, number or letter.
In this embodiment, when the second compression performed by using the third encoding algorithm fails, the result after the first compression is used as the final compression result, and the increase of the data amount due to the second compression in the final compression result can be avoided.
In some embodiments, referring to fig. 5, step S22 specifically includes:
s221: and determining the predicted data corresponding to the ith data according to the first two data of the ith data in the initial data sequence, wherein i is more than 2 and less than or equal to N, and N is the number of the data in the initial data sequence.
S222: and determining the prediction error corresponding to the ith data as the difference between the ith data and the prediction data corresponding to the ith data.
S223: it is determined that the first data sequence includes the first two data in the initial data sequence and (N-2) prediction errors.
Based on that 2 < i is not less than N, N is the number of data in the initial data sequence, and N data in the initial data sequence are arranged in time domain sequence, the ith data in the initial data sequence is any data except the first two data (namely the 1 st data and the 2 nd data) in the initial data sequence.
That is, for any data in the initial data sequence except the first two data, the corresponding prediction error is determined by the method in steps S221 to S223. Here, the specific process of step S221 to step S223 will be exemplarily described by taking the ith data as an example.
Firstly, the predicted data corresponding to the ith data is determined according to the first two data of the ith data, namely the predicted data corresponding to the ith data is determined according to the (i-1) th data and the (i-2) th data.
It will be appreciated that the initial data sequence is continuous in the time domain, so that adjacent data fluctuates less, i.e., the difference between every two of the (i-2) th data, the (i-1) th data and the ith data is small, and therefore, the next data can be predicted from the first two data, i.e., the ith data can be predicted from the (i-2) th data and the (i-1) th data, so that the ith data is linked to the (i-2) th data and the (i-1) th data.
In some embodiments, step S221 specifically includes: and determining that the predicted data corresponding to the ith data is 2 times of the (i-1) th data minus the (i-2) th data.
Specifically, the following formula is adopted to calculate the predicted data yi' corresponding to the ith data yi;
yi'-y(i-1)=y(i-1)-y(i-2)
yi'=2*y(i-1)-y(i-2)
in this embodiment, as shown in fig. 6, a first order function related to time is established by the (i-2) th data and the (i-1) th data, and then, the prediction data yi' corresponding to the i-th data can be accurately predicted based on the first order function.
Then, the difference between the ith data yi and the prediction data yi' corresponding to the ith data is taken as the corresponding prediction error. I.e. the prediction error xi ═ yi' -yi.
It will be appreciated that in the initial data sequence, each data when 2 < i ≦ N corresponds to a prediction error, resulting in (N-2) prediction errors.
Finally, as shown in fig. 7, the first two data (i.e., the 1 st data and the 2 nd data) and the (N-2) prediction errors in the initial data sequence are arranged according to the time sequence in the initial data sequence, so as to obtain the first data sequence. When decoding is carried out, the actual yi can be reversely deduced by the prediction error xi, so that the original data information cannot be lost.
It can be understood that, since any prediction error xi in the first data sequence is smaller than the original i-th data yi, the number of bytes occupied by xi is correspondingly smaller, so that the length of the first data sequence is smaller than that of the initial data sequence, i.e., the initial data sequence is effectively compressed.
It can be understood that the closer the predicted data yi' is to the initial data yi, the more accurate the predicted error xi is, the smaller the corresponding prediction error xi is, and the smaller the number of bytes occupied. In order to make the prediction data yi ' more accurate and the prediction error xi smaller, in some embodiments, a more accurate high-order function may also be established according to the (i-2) th data and the (i-1) th data, and the higher-order function is used to predict yi ', so that more accurate yi ' and the smaller prediction error xi can be obtained.
In this embodiment, by the above manner, the length of the first data sequence is smaller than that of the initial data sequence, that is, the first data sequence is effectively compressed, the original data information is not lost, the algorithm is simple, the operation speed is high, the efficiency is high, and the improvement of the transmission efficiency of the data is further facilitated.
For further secondary compression, in some embodiments, referring to fig. 8, step S23 specifically includes:
s231: and coding the prediction error corresponding to the ith data to obtain first coded data corresponding to the ith data.
S232: determining that the second data sequence includes the first two data in the initial data sequence and (N-2) first encoded data.
In this embodiment, (N-2) prediction errors in the first data sequence are encoded to further reduce the number of bytes occupied by each prediction error, and corresponding first encoded data is obtained. That is, the number of bytes occupied by the first coded data corresponding to the ith data is smaller than the number of bytes occupied by the corresponding predicted data.
Then, the first two data in the initial data sequence and the (N-2) first coded data are arranged according to the time sequence in the initial data sequence to obtain a second data sequence. It will be appreciated that the encoding in this embodiment is used to further reduce the prediction error, and in some implementations the prediction error may be subtracted from the set value or divided by the set value to obtain the corresponding first encoded data.
In this embodiment, (N-2) prediction errors in the first data sequence are encoded to further reduce the number of bytes occupied by each prediction error, and corresponding first encoded data is obtained, so that the length of a second data sequence comprising the first two data in the initial data sequence and the (N-2) first encoded data is further reduced, and secondary compression is realized.
In some embodiments, referring to fig. 9, step S231 specifically includes:
s2311: and determining the parameter value corresponding to the initial data sequence according to the (N-2) prediction errors.
S2312: and carrying out quotient taking operation on the prediction error corresponding to the ith data and the parameter value to obtain a quotient value, and carrying out one-system coding on the quotient value to obtain a one-system coding result.
S2313: and carrying out remainder operation on the prediction error corresponding to the ith data and the parameter value to obtain a remainder value, and carrying out binary coding on the remainder value to obtain a binary coding result.
S2314: and determining a first sign bit according to the positive and negative attributes of the prediction error corresponding to the ith data.
S2315, determining that first coded data corresponding to the i data comprise the first sign bit, the binary coding result and the first binary coding result.
In this embodiment, first, according to (N-2) prediction errors xi, i ≦ N or greater than 3, a parameter value M corresponding to the initial data sequence is determined, and the parameter value M is used for encoding each prediction error xi to further reduce each prediction error xi.
In some embodiments, the parameter value M is determined as follows:
M=2k
Figure BDA0003214171820000131
where α is a weighting coefficient, and in some embodiments, α is 0.7.
Then, quotient operation is carried out on the prediction error xi corresponding to the ith data and the parameter value to obtain a quotient qi (qi is xi/M), and the quotient qi is subjected to one-system coding to obtain a one-system coding result ui.
It is understood that the one-ary code may be represented by 0 or 1, and is distinguished by a separator. Taking the encoding with 0 as an example, the corresponding one-system encoding result ui of qi is qi 0 and 1 for distinguishing. The result of the one-ary coding is shown in table 1 below:
TABLE 1
qi One system coding result (output bit)
0 1
1 01
2 001
3 0001
... ...
N 00... 001 (N0)
Then, the prediction error xi corresponding to the ith data is subjected to a remainder operation with the parameter value to obtain a remainder ri, where the remainder ri is abs (xi)% M. And binary coding is performed on the residual ri to obtain a binary coding result bi. The binary encoding results are shown in table 2 below:
TABLE 2
ri Binary coding result (output bit)
0 000
1 001
2 010
3 011
... ...
7 111
A first sign bit is determined according to the positive and negative attributes of the prediction error xi corresponding to the ith data, and it is understood that the first sign bit represents the positive and negative attributes of the ith data. For example, when xi is a negative number, the first sign bit fi is 1, and when xi is a positive number, the first sign bit fi is 0.
Finally, the first sign bit fi, the binary coding result bi, and the binary coding result ui are combined into the first coded data ci. It can be understood that the order of the first sign bit fi, the binary coding result bi, and the binary coding result ui may be arbitrarily set, and it is only necessary that the order is consistent during compression and decompression. For example, the first encoded data ci ═ i (fi, bi, ui).
The following description is given by taking the prediction error xi-10 and k-3 as an example.
Available from k ═ 3:
parameter value M23=8;
The quotient qi/M10/8 1; and performing one-system coding on the qi to obtain a one-system coding result ui which is 01.
Residual ri ═ abs (xi)% M ═ abs (10)% 8 ═ 2; binary coding is performed on ri, and a binary coding result bi is obtained as 010.
The first sign bit fi is 0, where 0 represents a positive number.
The first encoded data ci ═ 001001 (fi, bi, ui) obtained after the combination.
As can be seen, the prediction error xi is 10, which originally occupies 1byte (1byte), and is compressed into one 6-bit data ci.
It will be appreciated that the parameter value k also needs to be stored with the second data sequence, i.e. equivalently, in this embodiment, the target data sequence comprises the parameter value k, the second data sequence and the second identifier, wherein the parameter value k is used for decoding.
In this embodiment, in the above manner, (N-2) prediction errors in the first data sequence can be effectively encoded to further reduce the number of bytes occupied by each prediction error, and obtain corresponding first encoded data, so that the length of a second data sequence including the first two data in the initial data sequence and the (N-2) first encoded data is further reduced, and secondary compression is implemented.
In some embodiments, the second identifier for representing the identity of the second encoding algorithm may be the parameter value k. The first identifier based on the identity used to represent the first encoding algorithm may be a specific symbol, number or letter, and the third identifier used to represent the identity of the third encoding algorithm may be a specific symbol, number or letter, e.g., the first identifier is 0, the third identifier is 1, and the parameter value k > 1 as calculated by the above formula. Therefore, the second identifier is set as the parameter value k, on the one hand, the parameter value k can be distinguished from the first identifier and the third identifier, i.e. the identity of the second encoding algorithm can be characterized, on the other hand, the parameter value k also needs to be stored together with the second data sequence, i.e. the parameter value k is included in the target data sequence for decoding, and the length of the target data sequence can be reduced by using the same data as the parameter value k and the second identifier.
In some embodiments, referring to fig. 10, step S25 specifically includes:
s251: and removing a symbol byte in the prediction error corresponding to the ith data to obtain an unsigned byte, wherein the symbol byte is used for representing the positive and negative properties of the prediction error.
S252: and the second coded data corresponding to the ith data is formed by splicing the byte length, a second sign bit and the unsigned byte of the second coded data, and the second sign bit is used for expressing the positive and negative properties of the prediction error corresponding to the ith data.
S253: the third data sequence includes the first two data in the initial data sequence and (N-2) second encoded data.
It will be appreciated that the prediction error xi is a small value, and therefore the header of the prediction error xi has some sign bytes for indicating its positive and negative properties. For example, if the prediction error xi is an integer of 32 bits, for example 100, the prediction error xi before being compressed by the third encoding algorithm is: 00000000000000000000000001100100, i.e., a 4-byte data, where the first 3 bytes each represent a positive or negative attribute, taking up too many bytes, resulting in wasted bytes, and the last one is the unsigned byte "01100100". It will be appreciated that the unsigned byte "01100100" characterizes the value "100" of the prediction error xi.
In order to reduce the length of the prediction error xi, the sign bytes in the prediction error xi are removed to obtain unsigned bytes, and then the positive and negative attributes of the prediction error are expressed by adopting a second sign bit, wherein the second sign bit can effectively shorten the data length relative to the original plurality of sign bytes. Therefore, the data length can be effectively shortened by concatenating the byte length of the second encoded data, the second sign bit, and the unsigned byte to form the second encoded data corresponding to the prediction error xi.
Specifically, the prediction error xi before compression by the third encoding algorithm is: 00000000000000000000000001100100, the second coded data obtained after compression is: 0100000001100100, wherein the first two bits "01" of the first byte represent that the second encoded data occupies 2 bytes in total, the remaining bits of the first byte represent the sign (positive and negative attributes), and the second byte remains the original unsigned byte. 2 bytes can be saved relative to the prediction error xi before compression.
It is understood that, when the number of bits occupied by the value of the prediction error xi is less than or equal to 5, for example, the unsigned byte corresponding to the prediction error xi (decimal value 3) is "00000011", and the second encoded data obtained by concatenating the unsigned byte and the length (1, corresponding to 1byte) and the second sign bit (0, positive number) of the second encoded data is "10000011". Here, for convenience of description, bits other than the bits occupied by the divisor value in the unsigned byte are referred to as padding bits, for example, the first 6 bits in "00000011" are padding bits.
It is to be understood that, in this embodiment, the sign byte is removed as much as possible, and when the length of the unsigned byte and the second encoded data, and the second sign bit, are concatenated, if the padding bits in the unsigned byte can accommodate the length of the second encoded data and at least one bit for representing a sign, the compressed second encoded data is one byte, and if the padding bits in the unsigned byte cannot accommodate the length of the second encoded data and at least one bit for representing a sign, one byte is added before the unsigned byte, and the added byte includes the length of the second encoded data and the second sign bit.
(N-2) prediction errors are encoded in the manner described above to obtain (N-2) second encoded data. And arranging the first two data and the (N-2) second coded data in the initial data sequence according to the time sequence in the initial data sequence to obtain a third data sequence.
To sum up, in the data compression method provided in this embodiment of the present application, first, a predetermined first coding algorithm is used to code an initial data sequence to be compressed to obtain a first data sequence, so that the length of the first data sequence is reduced relative to the length of the initial data sequence, then, a predetermined second coding algorithm is used to code the first data sequence to obtain a second data sequence, that is, further performing secondary compression, and finally, the length of the second data sequence is compared with the length of the first data sequence, and if the length of the second data sequence is smaller than the length of the first data sequence, it is determined that a target data sequence (that is, finally compressed data) includes the second data sequence and a second identifier, so that the target data sequence is used for transmission, and the transmission amount can be effectively reduced, where the second identifier is used to represent the identity of the second coding algorithm, the target data sequence is conveniently decompressed. That is, according to the method, the first coding algorithm is firstly adopted to carry out primary compression on the initial data sequence, and then the second coding algorithm is adopted to carry out secondary compression, so that the initial data sequence can be fully compressed, the data volume is reduced as much as possible, and the secondary compression is ensured to be effective by comparing the length of the second data sequence after the secondary compression with the length of the first data sequence after the primary compression, therefore, the data volume after the compression can be accurately controlled to be effectively reduced relative to the data volume before the compression, the data volume of transmission can be reduced, and the transmission efficiency is improved. For example, the amount of data compressed is only about 30% of the original amount of PSG data of the whole night.
Another embodiment of the present application also provides a computer-readable storage medium storing a computer program comprising program instructions that, when executed by a processor, cause the processor to perform the data compression method as in any of the above embodiments.
It should be noted that the above-described device embodiments are merely illustrative, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a general hardware platform, and certainly can also be implemented by hardware. It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a computer readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; within the context of the present application, where technical features in the above embodiments or in different embodiments can also be combined, the steps can be implemented in any order and there are many other variations of the different aspects of the present application as described above, which are not provided in detail for the sake of brevity; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (10)

1. A method of data compression, comprising:
acquiring an initial data sequence to be compressed, wherein the initial data sequence is time-varying data acquired within a preset time period;
coding the initial data sequence by adopting a preset first coding algorithm to obtain a first data sequence, wherein the length of the first data sequence is smaller than that of the initial data sequence;
coding the first data sequence by adopting a preset second coding algorithm to obtain a second data sequence;
and if the length of the second data sequence is smaller than that of the first data sequence, determining that a target data sequence comprises the second data sequence and a second identifier, wherein the target data sequence is used for obtaining the initial data sequence after being decoded, and the second identifier is used for representing the identity of the second coding algorithm.
2. The method of claim 1, further comprising:
if the length of the second data sequence is greater than or equal to the length of the first data sequence, encoding the first data sequence by adopting a preset third encoding algorithm to obtain a third data sequence;
and if the length of the third data sequence is smaller than that of the first data sequence, determining that the target data sequence comprises the third data sequence and a third identifier, wherein the third identifier is used for representing the identity of the third encoding algorithm.
3. The method of claim 2, further comprising:
and if the length of the third data sequence is greater than or equal to that of the first data sequence, determining that the target data sequence comprises the first data sequence and a first identifier, wherein the first identifier is used for representing the identity of the first coding algorithm.
4. The method according to any one of claims 1 to 3, wherein the encoding the initial data sequence by using a preset first encoding algorithm to obtain a first data sequence comprises:
determining predicted data corresponding to the ith data according to the first two data of the ith data in the initial data sequence, wherein i is more than 2 and less than or equal to N, and N is the number of data in the initial data sequence;
determining a prediction error corresponding to the ith data as a difference between the ith data and prediction data corresponding to the ith data;
it is determined that the first data sequence includes the first two data in the initial data sequence and (N-2) prediction errors.
5. The method according to claim 4, wherein the determining the predicted data corresponding to the ith data according to the first two data of the ith data in the initial data sequence comprises:
and determining that the predicted data corresponding to the ith data is 2 times of the (i-1) th data minus the (i-2) th data.
6. The method according to claim 4, wherein the encoding the first data sequence by using a predetermined second encoding algorithm to obtain a second data sequence comprises:
coding the prediction error corresponding to the ith data to obtain first coded data corresponding to the ith data;
determining that the second data sequence includes the first two data in the initial data sequence and (N-2) first encoded data.
7. The method according to claim 6, wherein said encoding the prediction error corresponding to the ith data to obtain the first encoded data corresponding to the ith data comprises:
determining parameter values corresponding to the initial data sequence according to the (N-2) prediction errors;
carrying out quotient taking operation on the prediction error corresponding to the ith data and the parameter value to obtain a quotient value, and carrying out linear coding on the quotient value to obtain a linear coding result;
carrying out a remainder operation on the prediction error corresponding to the ith data and the parameter value to obtain a remainder value, and carrying out binary coding on the remainder value to obtain a binary coding result;
determining a first sign bit according to the positive and negative attributes of the prediction error corresponding to the ith data;
determining that first encoding data corresponding to the i data comprises the first sign bit, the binary encoding result and the first binary encoding result.
8. The method according to claim 2 or 3, wherein the encoding the first data sequence by using a preset third encoding algorithm to obtain a third data sequence comprises:
removing a symbol byte in a prediction error corresponding to the ith data to obtain an unsigned byte, wherein the symbol byte is used for representing the positive and negative properties of the prediction error;
the second coded data corresponding to the ith data is formed by splicing the byte length, a second sign bit and the unsigned byte of the second coded data, and the second sign bit is used for expressing the positive and negative attributes of the prediction error corresponding to the ith data;
the third data sequence includes the first two data in the initial data sequence and (N-2) second encoded data.
9. An electronic device comprising memory and one or more processors to execute one or more computer programs stored in the memory, the one or more processors, when executing the one or more computer programs, causing the electronic device to implement the method of any of claims 1-8.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions that, when executed by a processor, cause the processor to carry out the method according to any one of claims 1-8.
CN202110938795.0A 2021-08-16 2021-08-16 Data compression method, electronic equipment and storage medium Pending CN113746485A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110938795.0A CN113746485A (en) 2021-08-16 2021-08-16 Data compression method, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110938795.0A CN113746485A (en) 2021-08-16 2021-08-16 Data compression method, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113746485A true CN113746485A (en) 2021-12-03

Family

ID=78731321

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110938795.0A Pending CN113746485A (en) 2021-08-16 2021-08-16 Data compression method, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113746485A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114331190A (en) * 2021-12-31 2022-04-12 惠州市建设集团工程建设监理有限公司 Method and system for checking and actually measuring engineering supervision quality
CN114817831A (en) * 2022-06-30 2022-07-29 四川公路工程咨询监理有限公司 Computing auxiliary method for building engineering economy
CN115118788A (en) * 2022-06-29 2022-09-27 北京中科心研科技有限公司 Time sequence data compression method and device, wearable intelligent device and storage medium
CN116723251A (en) * 2023-08-09 2023-09-08 江苏太湖锅炉股份有限公司 Intelligent boiler automatic monitoring system based on sensor network

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114331190A (en) * 2021-12-31 2022-04-12 惠州市建设集团工程建设监理有限公司 Method and system for checking and actually measuring engineering supervision quality
CN115118788A (en) * 2022-06-29 2022-09-27 北京中科心研科技有限公司 Time sequence data compression method and device, wearable intelligent device and storage medium
CN115118788B (en) * 2022-06-29 2023-01-31 北京中科心研科技有限公司 Time sequence data compression method and device, wearable intelligent equipment and storage medium
CN114817831A (en) * 2022-06-30 2022-07-29 四川公路工程咨询监理有限公司 Computing auxiliary method for building engineering economy
CN114817831B (en) * 2022-06-30 2022-09-23 四川公路工程咨询监理有限公司 Computing auxiliary method for building engineering economy
CN116723251A (en) * 2023-08-09 2023-09-08 江苏太湖锅炉股份有限公司 Intelligent boiler automatic monitoring system based on sensor network
CN116723251B (en) * 2023-08-09 2023-10-17 江苏太湖锅炉股份有限公司 Intelligent boiler automatic monitoring system based on sensor network

Similar Documents

Publication Publication Date Title
CN113746485A (en) Data compression method, electronic equipment and storage medium
CN109067405B (en) Data compression method, device, terminal and computer readable storage medium
CN111262587B (en) Data compression method, device, equipment and computer readable storage medium
CN109871362A (en) A kind of data compression method towards streaming time series data
CN110784225A (en) Data compression method, data decompression method, related device, electronic equipment and system
US20220114454A1 (en) Electronic apparatus for decompressing a compressed artificial intelligence model and control method therefor
CN111652135A (en) Electrocardiogram data generation method and device and electronic equipment
JP4101034B2 (en) Encoding apparatus and method
US9979415B2 (en) Data compression apparatus, data decompression apparatus, data compression method, data compression method, and computer readable medium
CN115395961A (en) Data lossless compression and encrypted transmission method based on joint middleware
CN107835025B (en) Adaptive compression method and system for historical data of power load
US8878705B1 (en) Variable bit-length reiterative lossless compression system and method
US8525708B2 (en) Decoding device and coding method
CN115268831B (en) Floating point data compression method and device, wearable intelligent device and storage medium
US8638243B2 (en) Data compression device, data compression method, and medium
Chen et al. FPGA design and verification for lossless ECG coding compression
US20230334022A1 (en) System and method for processing and storage of a time-series data stream
US20180018980A1 (en) Frequency envelope vector quantization method and apparatus
EP3796233A1 (en) Information processing device and method, and program
US10931303B1 (en) Data processing system
Lin et al. An FPGA implementation of lossless ECG compressors based on multi-stage Huffman coding
Sarma et al. A VLSI-based hybrid ECG compression scheme for wearable sensor node
EP3824556B1 (en) Systems and methods for low-power encoding of continuous physiological signals in a remote physiological monitor
CN110392262A (en) A kind of method and device for compressing virtual desktop image
CN110175185A (en) A kind of self-adaptive non-loss compression based on time series data distribution characteristics

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination