Data compression method and device, electronic equipment and storage medium

The image compression method is used to compress industrial production data, which solves the problem of massive data storage space occupation, realizes the optimization of data storage space and improves system performance.

CN118869892APending Publication Date: 2024-10-29SANY MARINE HEAVY INDUSTRY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410780807.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-17
Publication Date
2024-10-29

AI Technical Summary

Technical Problem

The massive production data generated in industrial production takes up a lot of storage space and lacks effective data processing methods.

Method used

The image compression method is used to compress production data. By establishing a mapping between the original data and the image to be compressed, lossless compression algorithms such as WebP, PNG, GIF and BMP are used to compress the image to be compressed and reduce the storage space occupied.

Benefits of technology

It effectively reduces the occupation of data storage space, reduces the workload of data processing equipment, improves system performance, and ensures the accuracy and reliability of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118869892A_ABST
    Figure CN118869892A_ABST
Patent Text Reader

Abstract

The invention aims to provide a method for compressing production data by various existing perfect image compression methods so as to save storage space. And taking the production data as original data, and recording the data content of the original data in the to-be-compressed image by establishing a mapping relationship between the original data and the to-be-compressed image. Therefore, the to-be-compressed image can be compressed by means of various existing perfect image compression methods, compressed storage of the production data is realized, and the storage space occupied by the production data is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data compression method, device, electronic device and storage medium. Background Art

[0002] In current production practices, production data used to record working conditions is generated, such as sensor data installed at various locations on the equipment. If these production data are directly stored without any processing, as production work continues, a large amount of production data will be generated, occupying a large amount of storage space.

[0003] In current industrial production, most industrial producers are still in the digital transformation stage, and the problem of increasingly large production data is not yet obvious. Therefore, there is no relatively perfect data processing method for the increasingly large amount of production data. Summary of the invention

[0004] In view of this, the present application is dedicated to providing a data compression method, device, electronic device and storage medium, so as to provide a method for compressing production data to save storage space by using various existing perfect image compression methods.

[0005] In a first aspect, an embodiment of the present application provides a data compression method, comprising:

[0006] Acquire original data, where the original data is data stored in at least one continuous memory address;

[0007] Creating an image to be compressed according to the original data, mapping a channel value set consisting of channel values ​​of pixels in the image to be compressed to a memory address set consisting of continuous memory addresses storing the original data one by one;

[0008] The image to be compressed is compressed using a preset image compression method, where the preset image compression method includes at least one of the following lossless compression methods: a WebP compression algorithm, a PNG compression algorithm, a GIF compression algorithm, and a BMP compression algorithm.

[0009] Optionally, after obtaining the original data, the method further includes:

[0010] Grouping the original data to obtain a first grouping result;

[0011] Performing a differential transformation on the first grouping result to obtain processed original data, wherein the differential transformation operation includes: performing a differential operation on the xth group of data in the first grouping result and the x-1th group of data in the first grouping result;

[0012] The step of creating an image to be compressed according to the original data comprises:

[0013] The image to be compressed is created according to the processed original data.

[0014] Optionally, each group of data in the first grouping result includes y bits of data;

[0015] The performing a difference operation on the xth group of data in the first grouping result and the x-1th group of data in the first grouping result includes:

[0016] The following operation is performed on each bit of data in the first grouping result: the data at the zth bit in the xth group of data is replaced by the result of an XOR operation between the data at the zth bit in the xth group of data and the data at the zth bit in the x-1th group of data.

[0017] Optionally, creating the image to be compressed according to the original data includes:

[0018] Grouping the original data to obtain a second grouping result;

[0019] The image to be compressed is created according to the second grouping result, each row in the image to be compressed has p pixels, and each group of data in the second grouping result occupies a memory of p binary bits when stored in binary form.

[0020] Optionally, creating the image to be compressed according to the second grouping result includes:

[0021] According to the second grouping result, a single-channel image to be compressed is created, the second grouping result includes m groups of data, the single-channel image to be compressed has m rows of pixels, and a channel value set consisting of channel values ​​of the nth row of pixels in the single-channel image to be compressed is mapped one to one with a memory address set consisting of continuous memory addresses storing the nth group of data in the second grouping result.

[0022] Optionally, before obtaining the original data, the method further includes:

[0023] Allocating at least two data buffers in the memory for storing the original data;

[0024] The obtaining of original data comprises:

[0025] Acquire the original data and store it in a first data buffer in the data buffer, wherein no data is stored in the first data buffer;

[0026] The method further comprises:

[0027] When the data stored in the first data buffer is compressed and new original data is obtained, the new original data is stored in a data buffer other than the first data buffer in the data buffer and not storing any data.

[0028] Optionally, after compressing the image to be compressed using a preset image compression method, the method further includes:

[0029] Decompressing compressed data obtained by compressing the image to be compressed using a preset image compression method to obtain the image to be compressed;

[0030] Extracting the original data from the image to be compressed according to a mapping relationship between a channel value set formed by channel values ​​of pixels in the image to be compressed and a memory address set formed by continuous memory addresses storing the original data;

[0031] The extracting the original data from the image to be compressed according to the mapping relationship between the channel value set formed by the channel values ​​of the pixels in the image to be compressed and the memory address set formed by the continuous memory addresses storing the original data comprises:

[0032] extracting the processed original data from the image to be compressed according to a mapping relationship between a channel value set formed by channel values ​​of pixels in the image to be compressed and a memory address set formed by continuous memory addresses storing the original data;

[0033] According to the first grouping result, the following operation is performed on each bit of the processed original data to obtain the original data: in the processed original data, the data at the zth bit in the xth group of data is replaced with the result of an XOR operation between the data at the zth bit in the xth group of data and the data at the zth bit in the x-1th group of data.

[0034] In a second aspect, an embodiment of the present application provides a data compression device, including:

[0035] An acquisition unit, used for acquiring original data, wherein the original data is data stored in at least one continuous memory address;

[0036] An image creation unit, used to create an image to be compressed according to the original data, wherein a channel value set consisting of channel values ​​of pixel points in the image to be compressed is mapped one-to-one to a memory address set consisting of continuous memory addresses storing the original data;

[0037] A compression unit is used to compress the image to be compressed using a preset image compression method, wherein the preset image compression method includes at least one of the following lossless compression methods: WebP compression algorithm, PNG compression algorithm, GIF compression algorithm and BMP compression algorithm.

[0038] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor;

[0039] The memory is connected to the processor and is used to store programs;

[0040] The processor is used to implement the data compression method as described in the first aspect by running the program in the memory.

[0041] In a fourth aspect, an embodiment of the present application provides a storage medium having a computer program stored thereon. When the computer program is executed by a processor, the data compression method as described in the first aspect is implemented.

[0042] The present application provides a data compression method. The production data is used as the original data, and the data content of the original data is recorded in the image to be compressed by establishing a mapping between the original data and the image to be compressed. Then, the image to be compressed can be compressed by various existing perfect image compression methods to realize the compressed storage of the production data and reduce the storage space occupied by the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of the present application 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 embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.

[0044] Figure 1 A flowchart of a data compression method provided in an embodiment of the present application.

[0045] Figure 2 It is a structural schematic diagram of a data compression device in an embodiment of the present application.

[0046] Figure 3 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION

[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0048] The first embodiment of the present application provides a data compression method, such as Figure 1 As shown, the method may include the following steps:

[0049] Step 101: Acquire original data, where the original data is data stored in at least one continuous memory address.

[0050] Raw data is data that records working conditions in production practice. For example, in industrial automation systems, PLC (Programmable Logic Controller) is the core control unit responsible for collecting and processing point data from field equipment, and uploading these data to data analysis and storage devices such as PCs through the network for storage, analysis and processing. With the continuous development of industrial level and the continuous expansion of industrial production scale, the amount of point data has exploded, and the massive amount of point data will occupy a lot of storage space.

[0051] One way to obtain the original data is to obtain the original data from the register of the data acquisition device through the modbus protocol.

[0052] The original data is stored in the memory in the form of a string of binary data. The memory described in this embodiment is a broad memory, including a volatile memory and a non-volatile memory.

[0053] The original data is data stored in at least one continuous memory address. For example, in a memory space with 10,000 binary bits, data A is stored in the binary bits numbered 1000-1999, and data B is stored in the binary bits numbered 2001-5000. If the original data that needs to be stored in 2000 binary bits is obtained, the original data can be stored in the binary bits 5001-7000 in the memory space. In this case, the original data is data stored in a continuous memory address. Alternatively, the original data can be stored in the binary bits numbered 1-999 and 5001-6000. In this case, the original data is data stored in two continuous memory addresses.

[0054] It should be noted that a theoretically possible situation is that the original data is stored in the binary bits 1-999, 2000, and 5001-5999 of the above memory space. However, according to current computer storage rules, when a group of data is stored in segments, an index needs to be established to ensure that the segmented data can be linked. The index can be in the form of the index of the previous segment of data pointing to the storage location of the next segment of data, or the index of the next segment of data pointing to the storage location of the previous segment of data, or the index of a certain segment of data pointing to both the storage location of the previous segment of data of the segment and the storage location of the next segment of data of the segment. The index is also stored in the memory space. Therefore, when there are too many segments, the index will also take up a lot of storage space. When the segments are stored, the reading speed of the segmented stored data will also be affected due to the change in the memory addressing method. In summary, in actual applications, the extreme situation described in the above example where "the original data is stored in the binary bits 1-999, 2000, and 5001-5999 of the above memory space" will not occur - when a single memory address is used, such as the 2000th binary bit in the above example to store data, the memory and addressing time overhead occupied by indexing it is even greater than the convenience brought by using the binary bit 2000 to store data. Therefore, the computer will choose to store data in this memory only when there is at least a sufficiently long, continuous memory address that has not yet stored data.

[0055] Step 102: Create an image to be compressed based on the original data, and map a channel value set consisting of channel values ​​of pixels in the image to be compressed to a memory address set consisting of continuous memory addresses storing the original data.

[0056] The image to be compressed in this embodiment is a bitmap, that is, the smallest unit is one pixel (1 pixel), and the image is composed of pixels. Each pixel has at least one channel, and the channel value in the channel records the information of the pixel. For example, an image stored in RGB color mode is a three-channel image, and each pixel has three color channels of red (R), green (G), and blue (B), and each color channel records the channel value of the corresponding color.

[0057] In this embodiment, a channel value A is arbitrarily selected from the channel values ​​of the pixels in the image to be compressed. The channel value A corresponds to and uniquely corresponds to the memory address a in the memory where the original data is stored. The memory address a also uniquely corresponds to the channel value A, so that there is a one-to-one mapping between the channel value set composed of the channel values ​​of the pixels in the image to be compressed and the memory address set composed of the continuous memory addresses storing the original data.

[0058] For example, the original data is stored in the binary bits of 5001-7000 in the memory space, and a two-channel image is established as the image to be compressed, the two-channel image has 1000 pixels, each pixel has two channel values, and the total number of channel values ​​is 2000. Any one of the 2000 channel values ​​uniquely corresponds to one of the binary bits of 5001-7000 in the memory space, and any one of the binary bits of 5001-7000 in the memory space can uniquely correspond to one of the 2000 channel values.

[0059] The corresponding relationship of one-to-one mapping can be set according to actual needs. For example, still continuing to illustrate with the example in the above text, 2000 channel values ​​are numbered 1-2000, and the channel values ​​and memory addresses correspond in the order of numbers, that is, the channel value numbered 1 is equal to the binary value of the 5001th binary bit in the memory, the channel value numbered 2 is equal to the binary value of the 5002th binary bit in the memory... and so on. Alternatively, the reverse corresponding relationship can also be set according to the order of numbers, that is, the channel value numbered 1 is equal to the binary value of the 7000th binary bit in the memory, the channel value numbered 2 is equal to the binary value of the 6999th binary bit in the memory... and so on. In summary, the corresponding relationship of one-to-one mapping only needs to meet actual needs, and this embodiment does not specifically limit the corresponding relationship of one-to-one mapping.

[0060] Step 103: compress the image to be compressed using a preset image compression method, where the preset image compression method includes at least one of the following lossless compression methods: a WebP compression algorithm, a PNG compression algorithm, a GIF compression algorithm, and a BMP compression algorithm.

[0061] Through the above steps, an image to be compressed that is strictly corresponding to the original data has been created. The image to be compressed stores all the contents of the original data. However, the storage space occupied by the image to be compressed is not significantly reduced compared to the storage space occupied by the original data.

[0062] This embodiment proposes to compress the image to be compressed by various mature image compression methods in the prior art to optimize the storage space occupied by the compressed image. The storage space occupied by the compressed image will be greatly reduced relative to the storage space occupied by the original data. In addition, a large amount of data transmission will put pressure on the processor, memory and I / O performance of the data processing device. Without compression, the reading and writing operations of data will become more frequent and time-consuming, which may cause the system performance to decline and even affect the normal operation of other programs. Through compression, the workload of the data processing device can be effectively reduced.

[0063] Since the accuracy of the original data storage needs to be guaranteed, it is necessary to select lossless compression methods in existing image compression technologies to compress images instead of lossy compression methods to avoid damage or loss of original data, such as WebP compression algorithm, PNG compression algorithm, GIF compression algorithm and BMP compression algorithm in lossless compression algorithms. For example, PNG (Portable Network Graphics) is a widely used image compression format, and its lossless compression algorithm can significantly reduce the storage space occupied by image files without losing image quality.

[0064] The second embodiment of the present application further defines the data compression method in the first embodiment in more detail and specificity. Some or all of the technical features in the second embodiment can be combined with or replaced with the first embodiment alone or in combination, so as to obtain more feasible data compression methods.

[0065] The data compression method in the second embodiment of the present application is described in detail below:

[0066] Optionally, after obtaining the original data, it also includes: grouping the original data to obtain a first grouping result; performing a differential transformation on the first grouping result to obtain processed original data, the differential transformation operation includes: performing a differential operation on the xth group of data in the first grouping result and the x-1th group of data in the first grouping result; creating an image to be compressed based on the original data, including: creating an image to be compressed based on the processed original data.

[0067] This embodiment proposes that the original data can be processed to improve the compression efficiency. The original data can be encoded and converted according to certain rules to make it more suitable for the processing requirements of the compression algorithm. Specifically, the original data can be differentially transformed. Difference is a tool for studying discrete mathematics. The result of the differential operation reflects a change between discrete quantities, and the change between adjacent elements in a set of data is described by calculating the difference between adjacent elements. The result of the differential operation is a new set of data, which represents the change between adjacent points of the original sequence.

[0068] In this embodiment, the raw data is divided into several groups. The grouping basis can be set according to actual needs. For example, if the raw data is transmitted in the format of frame data, and the acquired raw data is a plurality of frame data continuously collected by the data acquisition device within a period of time, then the grouping can be performed in frames, for example, the first frame data is the first group, the second frame data is the second group, and so on; or the first frame and the second frame data are the first group, the third and the fourth frame data are the second group, and so on.

[0069] In practical applications, there is often a large amount of repeated or redundant information in the raw data. For example, for a temperature sensor that collects data once a second, the temperature data of the first second and the second second may be exactly the same or very similar, and the temperature data of these two seconds are stored adjacently in the memory according to the collection order. After collecting temperature data for several seconds, the temperature data collected by the temperature sensor is obtained as the raw data. Then, the temperature data collected per second is grouped, the temperature data of the first second is the first group of data, and the temperature data of the second second is the second group of data. The first group of data and the second group of data have a high similarity.

[0070] In the differential transformation in this embodiment, the first group of data does not have the previous control group data, so the original data remains unchanged and is not processed. Starting from the second group of data, the differential operation is performed against the previous group of data, and the result of the differential operation reflects the changes in this group of data relative to the previous group of data. Since the data of adjacent groups are often similar, the result of the differential operation of the latter group of data often shows a large number of repetitions with the previous group of data. When compression is performed in the subsequent steps, these repeated data can be further compressed by the compression algorithm to further reduce the storage space occupied.

[0071] It should be noted that if the original data is subjected to a differential transformation as described in this embodiment, when the original data is needed subsequently, it is necessary not only to decompress the image to be compressed and extract the channel values ​​of the image to be compressed, but also to perform the inverse operation of the above-mentioned differential transformation on the channel values ​​to obtain the original data before the differential transformation.

[0072] Optionally, each group of data in the first grouping result includes y bits of data; performing a differential operation on the xth group of data in the first grouping result and the x-1th group of data in the first grouping result, including: performing the following operation on each bit of data in the first grouping result: replacing the zth bit of the data in the xth group of data with the result of an XOR operation of the zth bit of the data in the xth group of data and the zth bit of the data in the x-1th group of data.

[0073] This embodiment further defines a specific implementation method of the differential transformation. Specifically, the first group of data in the first grouping result corresponds to the data from the 1st to the yth bit in the original data, and starting from the second group of data, each bit of data in each group of data will be XORed with the data at the same position in the previous group of data. For example, the first bit of data in the second group of data needs to be XORed with the first bit of data in the first group of data.

[0074] For a certain group of data, when the data at the zth bit in the group of data is the same as the data at the zth bit in the previous group of data, the result of the XOR operation is 0; when the data at the zth bit in the group of data is the same as the data at the zth bit in the previous group of data, the result of the XOR operation is 1. Through the above-mentioned differential operation, in the processed original data, starting from the second group of data, the number of 0s in the data is much greater than the number of 1s and a large number of continuous 0s appear. These large and repeated 0s can be further compressed by the compression algorithm when compressed in subsequent steps to reduce the storage space occupied.

[0075] For example, please refer to the following formula:

[0076]

[0077] Among them, S n is the nth bit of the original data, ΔS n It is the n-th bit data in the processed original data obtained by differential transformation.

[0078] Optionally, creating an image to be compressed based on the original data includes: grouping the original data to obtain a second grouping result; creating the image to be compressed based on the second grouping result, wherein each row in the image to be compressed has p pixels, and each group of data in the second grouping result occupies p binary bits of memory when stored in binary form.

[0079] This embodiment defines the format of the image to be compressed so that the corresponding relationship between the image to be compressed and the original data is clearer and easier to understand.

[0080] Specifically, if the original data is transmitted in the format of frame data, the acquired original data is multiple frame data continuously collected by the data acquisition device over a period of time, and each frame data occupies p binary bits of memory, or p / 2 binary bits of memory, then it can be grouped in frames, for example, the first frame data is the first group, the second frame data is the second group, and so on; or the first frame and the second frame data are the first group, the third and fourth frame data are the second group, and so on.

[0081] Each row of the image to be compressed has p pixels, and each row of pixels has p*channel number channel values, which can correspond to the second grouping result. A certain group of channel values ​​of each row of pixels is mapped one-to-one with one group of data in the second grouping result. For example, for a three-channel image stored in RGB color mode, the channel value of the R channel of the first row of pixels corresponds to the first group of data in the second grouping result; the channel value of the G channel of the first row of pixels corresponds to the second group of data in the second grouping result; and the channel value of the B channel of the first row of pixels corresponds to the third group of data in the second grouping result.

[0082] Optionally, creating an image to be compressed according to the second grouping result, including: creating a single-channel image to be compressed according to the second grouping result, the second grouping result including m groups of data, the single-channel image to be compressed having m rows of pixels, and a one-to-one mapping between a channel value set consisting of channel values ​​of the nth row of pixels in the single-channel image to be compressed and a memory address set consisting of continuous memory addresses storing the nth group of data in the second grouping result.

[0083] Based on practice, this embodiment proposes to establish a single-channel image as the image to be compressed. In a single-channel image, each pixel has only one channel value. During the compression process, the single-channel image is more stable and more in line with the storage data structure.

[0084] For example, the original data is obtained from the data acquisition device. Each time the data acquisition device performs data acquisition, the data collected occupies p binary bits of storage space. The acquisition cycle of the data acquisition device is c, and the total data acquisition time included in the original data is t. Then each group of data in the second grouping result includes p bits of binary data, and the number of data groups in the second grouping result = the number of rows of the single-channel image to be compressed = m = t / c.

[0085] The qth pixel in the nth row of the single-channel image to be compressed uniquely corresponds to the memory address where the qth data in the nth group of data in the second grouping result is located. Specifically, the channel value of the qth pixel in the nth row is equal to the binary value of the qth data in the nth group of data, thereby making a one-to-one mapping between the channel value set composed of the channel values ​​of the pixels in the nth row of the single-channel image to be compressed and the memory address set composed of the continuous memory addresses storing the nth group of data in the second grouping result, where n is a natural number and its value range is [1, m].

[0086] Optionally, before obtaining the original data, it also includes: allocating at least two data buffers in the memory for storing the original data; obtaining the original data includes: obtaining the original data and storing it in a first data buffer in the data buffer, wherein no data is stored in the first data buffer; the data compression method also includes: when compressing the data stored in the first data buffer and obtaining new original data, storing the new original data in a data buffer in the data buffer other than the first data buffer and which does not store data.

[0087] This embodiment proposes to pre-allocate at least two memory areas as data buffers for storing raw data. The size of each data buffer should be as equal as possible to the memory space occupied by the raw data obtained by performing the step of obtaining raw data once, so as to avoid dividing a continuous piece of raw data into multiple segments for storage. In addition, a memory can also be allocated as a result buffer to store the compressed image.

[0088] Take the case where the memory space occupied by the raw data acquired each time is equal, and two data buffers are allocated in total. The size of each data buffer is equal to the memory space occupied by the raw data. For example, the raw data is acquired from the data acquisition device. Each time the data acquisition device performs data acquisition, the data collected occupies p binary bits of storage space. The acquisition cycle of the data acquisition device is c, and the total data acquisition time included in the raw data is t. Then the memory size of a data buffer is as follows:

[0089]

[0090] In the above formula, B is the memory size allocated for a data buffer, in bytes, and one byte includes 8 binary bits.

[0091] In general, after acquiring the original data, the first data buffer area in the two data buffers that does not store data is selected to store the original data acquired this time, and other steps of the data compression method described in the above method embodiment are continued in the first data buffer. In practical applications, the original data is generally transmitted continuously, that is, when the first data buffer is filled, new original data will continue to be acquired. This embodiment proposes that the new original data can be stored in the second data buffer area that does not store data. Obviously, at this time, the other steps of the data compression method described in the above method embodiment can also be performed in the second data buffer area.

[0092] By pre-allocating multiple data buffers and alternately using the multiple data buffers to store original data, a data processing pipeline can be established for continuously acquiring original data and compressing and storing the acquired original data uninterruptedly.

[0093] In addition, in order to effectively manage and maintain the compressed images, or in other words, in order to effectively manage and maintain the compressed original data, a distributed storage architecture can be used to store the compressed data in different physical nodes to improve the scalability and fault tolerance of data storage. At the same time, redundant data storage is reduced to further save storage space. In addition, data security and reliability can be ensured by establishing a data backup and recovery strategy.

[0094] Optionally, after compressing the image to be compressed using a preset image compression method, it also includes: decompressing the compressed data obtained by compressing the image to be compressed using the preset image compression method to obtain the image to be compressed; extracting the original data from the image to be compressed according to the mapping relationship between the channel value set composed of the channel values ​​of the pixels in the image to be compressed and the memory address set composed of the continuous memory addresses storing the original data; extracting the original data from the image to be compressed according to the mapping relationship between the channel value set composed of the channel values ​​of the pixels in the image to be compressed and the memory address set composed of the continuous memory addresses storing the original data, including: extracting the processed original data from the image to be compressed according to the mapping relationship between the channel value set composed of the channel values ​​of the pixels in the image to be compressed and the memory address set composed of the continuous memory addresses storing the original data; according to the first grouping result, performing the following operation on each bit of the processed original data to obtain the original data: replacing the data at the zth bit in the xth group of data in the processed original data with the result of an exclusive OR operation between the data at the zth bit in the xth group of data and the data at the zth bit in the x-1th group of data.

[0095] By using the data compression method described in the above embodiment, the storage of the original data occupies a smaller space. However, the compressed data cannot be used directly, and this embodiment specifically defines a method for restoring the compressed data when the original data needs to be used.

[0096] In the case of directly compressing an image, the compressed data can be directly decompressed to obtain the image to be compressed, and then the original data can be extracted from the image to be compressed based on the mapping relationship between the channel value set composed of the channel values ​​of the pixels in the image to be compressed and the memory address set composed of the continuous memory addresses storing the original data. For example, the image to be compressed has 2000 channel values, which are numbered 1-2000 respectively. The mapping relationship is that the channel value and the memory address correspond to each other in the positive order of the numbers, that is, the channel value numbered 1 corresponds to the first bit of the original data, the channel value numbered 2 corresponds to the second bit of the original data... and so on. It should be noted that when restoring the original data, it is only necessary to restore the storage order of the original data. As for whether to restore the original data to the memory address where the original data was located before compression in the storage order, or to restore the original data to a new section of continuous memory addresses for storage, it can be selected according to actual needs.

[0097] If a differential operation is performed on the original data to increase compression efficiency, then when restoring the data, an inverse operation of the differential operation is required to restore the processed original data to the original data without differential operation.

[0098] In this embodiment, the differential operation is performed by XOR, which is similar to the negation operation, and the inverse operation is itself. Therefore, for the result obtained by the XOR operation, the result of the XOR operation is XORed with the original data at the same position in the previous set of data again to complete the data restoration, which can be referred to the following formula:

[0099]

[0100] Among them, S n is the nth bit of the original data, ΔS n It is the n-th bit data in the processed original data obtained by differential transformation.

[0101] The third embodiment of the present application also provides a data compression device, such as Figure 2 As shown, including:

[0102] An acquisition unit 201 is used to acquire original data, where the original data is data stored in at least one continuous memory address;

[0103] The image creation unit 202 is used to create a to-be-compressed image according to the original data, and to map a channel value set consisting of channel values ​​of pixels in the to-be-compressed image to a memory address set consisting of continuous memory addresses storing the original data one by one;

[0104] The compression unit 203 is used to compress the image to be compressed using a preset image compression method, where the preset image compression method includes at least one of the following lossless compression methods: WebP compression algorithm, PNG compression algorithm, GIF compression algorithm, and BMP compression algorithm.

[0105] Optionally, after obtaining the original data, the following steps are also included:

[0106] Grouping the original data to obtain a first grouping result;

[0107] Performing differential transformation on the first grouping result to obtain processed original data, the differential transformation operation includes: performing differential operation on the xth group of data in the first grouping result and the x-1th group of data in the first grouping result;

[0108] Create the image to be compressed based on the original data, including:

[0109] Create an image to be compressed based on the processed original data.

[0110] Optionally, each group of data in the first grouping result includes y bits of data;

[0111] Performing a difference operation on the xth group of data in the first grouping result and the x-1th group of data in the first grouping result includes:

[0112] The following operation is performed on each bit of data in the first grouping result: the data at the zth bit in the xth group of data is replaced by the result of an XOR operation of the data at the zth bit in the xth group of data and the data at the zth bit in the x-1th group of data.

[0113] Optionally, creating an image to be compressed according to the original data includes:

[0114] Grouping the original data to obtain a second grouping result;

[0115] According to the second grouping result, an image to be compressed is created, each row in the image to be compressed has p pixels, and each group of data in the second grouping result occupies a memory of p binary bits when stored in binary mode.

[0116] Optionally, creating an image to be compressed according to the second grouping result includes:

[0117] According to the second grouping result, a single-channel image to be compressed is created, the second grouping result includes m groups of data, the single-channel image to be compressed has m rows of pixels, and a channel value set consisting of channel values ​​of the nth row of pixels in the single-channel image to be compressed is mapped one to one with a memory address set consisting of continuous memory addresses storing the nth group of data in the second grouping result.

[0118] Optionally, before obtaining the original data, the following steps are also included:

[0119] Allocate at least two data buffers in the memory for storing the original data;

[0120] Get raw data, including:

[0121] Acquire original data and store it in a first data buffer in the data buffer, wherein no data is stored in the first data buffer;

[0122] The method further comprises:

[0123] When the data stored in the first data buffer is compressed and new original data is obtained, the new original data is stored in a data buffer other than the first data buffer and not storing any data in the data buffer.

[0124] Optionally, after compressing the image to be compressed using a preset image compression method, the method further includes:

[0125] Decompressing compressed data obtained by compressing the image to be compressed using a preset image compression method to obtain the image to be compressed;

[0126] Extracting original data from the image to be compressed according to a mapping relationship between a channel value set formed by channel values ​​of pixels in the image to be compressed and a memory address set formed by continuous memory addresses storing original data;

[0127] Extracting original data from the image to be compressed according to a mapping relationship between a channel value set formed by channel values ​​of pixels in the image to be compressed and a memory address set formed by continuous memory addresses storing original data, including:

[0128] Extracting processed raw data from the image to be compressed according to a mapping relationship between a channel value set formed by channel values ​​of pixels in the image to be compressed and a memory address set formed by continuous memory addresses storing raw data;

[0129] According to the first grouping result, the following operation is performed on each bit of the processed original data to obtain the original data: in the processed original data, the data at the zth bit in the xth group of data is replaced with the result of an XOR operation between the data at the zth bit in the xth group of data and the data at the zth bit in the x-1th group of data.

[0130] The data compression device provided in this embodiment belongs to the same application concept as the data compression method provided in the above embodiments of this application, and can execute the data compression method provided in any of the above embodiments of this application, and has the corresponding functional modules and beneficial effects of the execution method. For the technical details not fully described in this embodiment, please refer to the specific processing content of the data compression method provided in the above embodiments of this application, and will not be repeated here.

[0131] The functions implemented by the above acquisition unit 201, image creation unit 202 and compression unit 203 may be implemented by the same or different processors respectively, which is not limited in the embodiment of the present application.

[0132] It should be understood that the units in the above devices can be implemented in the form of a processor calling software. For example, the device includes a processor, the processor is connected to a memory, and instructions are stored in the memory. The processor calls the instructions stored in the memory to implement any of the above methods or realize the functions of each unit of the device, wherein the processor can be a general-purpose processor, such as a CPU or a microprocessor, etc., and the memory can be a memory in the device or a memory outside the device. Alternatively, the units in the device can be implemented in the form of hardware circuits, and the functions of some or all units can be realized by designing the hardware circuits. The hardware circuit can be understood as one or more processors; for example, in one implementation, the hardware circuit is an ASIC, and the functions of some or all of the above units are realized by designing the logical relationship of the components in the circuit; for another example, in another implementation, the hardware circuit can be implemented by PLD, taking FPGA as an example, which can include a large number of logic gate circuits, and the connection relationship between the logic gate circuits is configured by the configuration file, so as to realize the functions of some or all of the above units. All units of the above devices can be implemented in the form of a processor calling software, or in the form of hardware circuits, or in part by a processor calling software, and the remaining part is implemented in the form of hardware circuits.

[0133] In an embodiment of the present application, a processor is a circuit with the ability to process signals. In one implementation, the processor may be a circuit with the ability to read and run instructions, such as a CPU, a microprocessor, a GPU, or a DSP; in another implementation, the processor may implement certain functions through the logical relationship of a hardware circuit, and the logical relationship of the hardware circuit is fixed or reconfigurable, such as a hardware circuit implemented by an ASIC or PLD, such as an FPGA. In a reconfigurable hardware circuit, the process of the processor loading a configuration document to implement the hardware circuit configuration can be understood as the process of the processor loading instructions to implement the functions of some or all of the above units. In addition, it can also be a hardware circuit designed for artificial intelligence, which can be understood as an ASIC, such as an NPU, TPU, DPU, etc.

[0134] It can be seen that each unit in the above device can be one or more processors (or processing circuits) configured to implement the above method, such as: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.

[0135] In addition, all or part of the units in the above device can be integrated together, or can be implemented independently. In one implementation, these units are integrated together and implemented in the form of a SOC. The SOC may include at least one processor for implementing any of the above methods or implementing the functions of each unit of the device. The type of the at least one processor may be different, for example, including a CPU and an FPGA, a CPU and an artificial intelligence processor, a CPU and a GPU, etc.

[0136] The fourth embodiment of the present application also provides an electronic device, see Figure 3 As shown, the device includes:

[0137] Memory 300 and processor 310;

[0138] The memory 300 is connected to the processor 310 and is used to store programs;

[0139] The processor 310 is used to implement the data compression method disclosed in any of the above embodiments by running the program stored in the memory 300.

[0140] Specifically, the data compression device may further include: a bus, a communication interface 320 , an input device 330 and an output device 340 .

[0141] The processor 310, the memory 300, the communication interface 320, the input device 330 and the output device 340 are connected to each other via a bus.

[0142] A bus may include a pathway that transfers information between components of a computer system.

[0143] The processor 310 may be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the scheme of the present invention. It may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0144] The processor 310 may include a main processor, and may also include a baseband chip, a modem, and the like.

[0145] The memory 300 stores a program for executing the technical solution of the present invention, and may also store an operating system and other key services. Specifically, the program may include a program code, and the program code includes a computer operation instruction. More specifically, the memory 200 may include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk storage, a flash, and the like.

[0146] The input device 330 may include a device for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor.

[0147] Output device 340 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.

[0148] The communication interface 320 may include any transceiver or the like to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.

[0149] The processor 310 executes the program stored in the memory 300 and calls other devices, which can be used to implement each step of any data compression method provided in the above embodiments of the present application.

[0150] A fifth embodiment of the present application provides a storage medium having a computer program stored thereon. The computer program is used by a processor to execute the steps of the data compression method described in the above “Exemplary Method” section of this specification. Specifically, the following steps can be implemented:

[0151] Obtaining original data, where the original data is data stored in at least one continuous memory address;

[0152] An image to be compressed is created according to the original data, and a channel value set consisting of channel values ​​of pixel points in the image to be compressed is mapped one-to-one with a memory address set consisting of continuous memory addresses storing the original data;

[0153] The image to be compressed is compressed using a preset image compression method, where the preset image compression method includes at least one of the following lossless compression methods: a WebP compression algorithm, a PNG compression algorithm, a GIF compression algorithm, and a BMP compression algorithm.

[0154] The sixth embodiment of the present application also proposes a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the data compression method in each embodiment described in the above "Exemplary Method" section of this specification.

[0155] The computer program product may be written in any combination of one or more programming languages ​​to write program codes for performing the operations of the embodiments of the present application, including object-oriented programming languages, such as Java, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as an independent software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0156] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.

[0157] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0158] The steps in the methods of each embodiment of the present application can be adjusted in order, combined and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.

[0159] The modules and sub-modules in the devices and terminals of the various embodiments of the present application can be combined, divided and deleted according to actual needs.

[0160] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are only schematic, for example, the division of modules or submodules is only a logical function division, and there may be other division methods in actual implementation, for example, multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0161] The modules or submodules described as separate components may or may not be physically separated, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place, or they may be distributed on multiple network modules or submodules. Some or all of the modules or submodules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0162] In addition, each functional module or submodule in each embodiment of the present application may be integrated into one processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into one module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or in the form of software functional modules or submodules.

[0163] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0164] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly by hardware, software units executed by a processor, or a combination of the two. The software units may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0165] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0166] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A data compression method, characterized in that: include: Acquire original data, where the original data is data stored in at least one continuous memory address; Creating an image to be compressed according to the original data, mapping a channel value set consisting of channel values ​​of pixels in the image to be compressed to a memory address set consisting of continuous memory addresses storing the original data one by one; The image to be compressed is compressed using a preset image compression method, where the preset image compression method includes at least one of the following lossless compression methods: a WebP compression algorithm, a PNG compression algorithm, a GIF compression algorithm, and a BMP compression algorithm.

2. The method according to claim 1, characterized in that After obtaining the original data, the method further includes: Grouping the original data to obtain a first grouping result; Performing a differential transformation on the first grouping result to obtain processed original data, wherein the differential transformation operation includes: performing a differential operation on the xth group of data in the first grouping result and the x-1th group of data in the first grouping result; The step of creating an image to be compressed according to the original data comprises: The image to be compressed is created according to the processed original data.

3. The method according to claim 2, characterized in that Each group of data in the first grouping result includes y bits of data; The performing a difference operation on the xth group of data in the first grouping result and the x-1th group of data in the first grouping result includes: The following operation is performed on each bit of data in the first grouping result: the data at the zth bit in the xth group of data is replaced by the result of an XOR operation between the data at the zth bit in the xth group of data and the data at the zth bit in the x-1th group of data.

4. The method according to claim 1, characterized in that The step of creating an image to be compressed according to the original data comprises: Grouping the original data to obtain a second grouping result; The image to be compressed is created according to the second grouping result, each row in the image to be compressed has p pixels, and each group of data in the second grouping result occupies a memory of p binary bits when stored in binary form.

5. The method according to claim 4, characterized in that The step of creating an image to be compressed according to the second grouping result includes: According to the second grouping result, a single-channel image to be compressed is created, the second grouping result includes m groups of data, the single-channel image to be compressed has m rows of pixels, and a channel value set consisting of channel values ​​of the nth row of pixels in the single-channel image to be compressed is mapped one to one with a memory address set consisting of continuous memory addresses storing the nth group of data in the second grouping result.

6. The method according to claim 1, characterized in that Before obtaining the original data, the method further includes: Allocating at least two data buffers in the memory for storing the original data; The obtaining of original data comprises: Acquire the original data and store it in a first data buffer in the data buffer, wherein no data is stored in the first data buffer; The method further comprises: When the data stored in the first data buffer is compressed and new original data is obtained, the new original data is stored in a data buffer other than the first data buffer in the data buffer and not storing any data.

7. The method according to claim 3, characterized in that After compressing the image to be compressed using a preset image compression method, the method further includes: Decompressing compressed data obtained by compressing the image to be compressed using a preset image compression method to obtain the image to be compressed; Extracting the original data from the image to be compressed according to a mapping relationship between a channel value set formed by channel values ​​of pixels in the image to be compressed and a memory address set formed by continuous memory addresses storing the original data; The extracting the original data from the image to be compressed according to the mapping relationship between the channel value set formed by the channel values ​​of the pixels in the image to be compressed and the memory address set formed by the continuous memory addresses storing the original data comprises: extracting the processed original data from the image to be compressed according to a mapping relationship between a channel value set formed by channel values ​​of pixels in the image to be compressed and a memory address set formed by continuous memory addresses storing the original data; According to the first grouping result, the following operation is performed on each bit of the processed original data to obtain the original data: in the processed original data, the data at the zth bit in the xth group of data is replaced with the result of an XOR operation between the data at the zth bit in the xth group of data and the data at the zth bit in the x-1th group of data.

8. A data compression device, characterized in that: include: An acquisition unit, used to acquire original data, where the original data is data stored in at least one continuous memory address; An image creation unit, used to create an image to be compressed according to the original data, wherein a channel value set consisting of channel values ​​of pixel points in the image to be compressed is mapped one-to-one to a memory address set consisting of continuous memory addresses storing the original data; A compression unit is used to compress the image to be compressed using a preset image compression method, wherein the preset image compression method includes at least one of the following lossless compression methods: WebP compression algorithm, PNG compression algorithm, GIF compression algorithm and BMP compression algorithm.

9. An electronic device, characterized in that: including memory and processor; The memory is connected to the processor and is used to store programs; The processor is used to implement the data compression method according to any one of claims 1 to 7 by running the program in the memory.

10. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the data compression method according to any one of claims 1 to 7 is implemented.