Data compression method based on adaptive coding and compression system thereof
By regionally dividing the image and constructing a local entropy coding dictionary, combined with the neural network model for compression configuration prediction, efficient adaptive compression of image data is achieved, solving the problem of low compression efficiency in traditional methods, reducing costs and improving system efficiency. flexibility.
Patent Information
- Application Number
- CN202410757536.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-09-06
AI Technical Summary
Traditional image data compression methods cannot adaptively adjust according to the characteristics of different areas of the image, resulting in low compression efficiency and high direct transmission and storage costs.
Adopt a data compression method based on adaptive coding, divide the image to be compressed through the lower computer, build a local entropy coding dictionary, and use the pre-trained neural network model to predict the compression configuration, generate primary compression coding values and entropy coding values, and encapsulate into independent data packets for transmission.
It significantly improves the compression efficiency of image data, reduces transmission and storage costs, while maintaining the flexibility and scalability of the system, and avoids the problem of low compression efficiency caused by unified compression algorithms and parameters.
Smart Images

Figure CN118612440A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image compression, and in particular to a data compression method based on adaptive coding and a compression system thereof. Background Art
[0002] With the rapid development of information technology, the demand for transmission and storage of image data is growing. However, image data usually has a large amount of data, and direct transmission and storage is not only inefficient but also costly. Therefore, image data compression technology has become the key to solving this problem.
[0003] Traditional image data compression methods usually use unified compression algorithms and parameters, which cannot be adaptively adjusted according to the characteristics of different regions of the image, resulting in low compression efficiency.
[0004] Therefore, it is necessary to provide a data compression method based on adaptive coding and a compression system thereof to solve the above technical problems. Summary of the invention
[0005] To solve the above technical problems, the present invention provides a data compression method and a compression system based on adaptive coding, which realizes efficient and adaptive compression of image data, significantly improves the compression efficiency, reduces data transmission and storage costs, and maintains the flexibility and scalability of the system.
[0006] The present invention provides a data compression method based on adaptive coding, the compression method comprising the following steps:
[0007] S1: The lower computer divides the region based on the pixel features of the image to be compressed, and obtains multiple partitions and corresponding data to be compressed;
[0008] S2: The lower computer constructs a local entropy coding dictionary based on the pixel features of each partition;
[0009] S3: The lower computer inputs the data to be compressed of each partition into a pre-trained prediction model to predict the compression configuration, and allocates a compression configuration to each partition according to the prediction result, wherein the prediction model is a neural network model trained based on historical compressed image data, and the compression configuration includes a compression algorithm and compression parameters;
[0010] S4: The lower computer performs primary compression on the data to be compressed of each partition based on the predicted compression configuration, and generates a primary compression code value of each partition;
[0011] S5: The lower computer uses the local entropy coding dictionary of each partition to perform entropy coding mapping on the primary compression coding value to generate the entropy coding value of each partition;
[0012] S6: The lower computer encapsulates the entropy coding value of each partition into an independent data packet, and sends the data packet independently to the upper computer, and the upper computer performs a decompression operation according to the compression configuration of each partition.
[0013] Preferably, step S1 specifically includes:
[0014] S101: constructing a gradient map of the image to be compressed and quantifying pixel gradient changes;
[0015] S102: identifying and defining a homogeneous region composed of similar pixels based on pixel gradient changes in the image to be compressed;
[0016] S103: Based on homogeneous regions composed of similar pixels in the image to be compressed, the image to be compressed is divided into regions using a region growing method and data of the image to be compressed is associated to obtain multiple partitions and data to be compressed corresponding to the partitions in the image to be compressed.
[0017] Preferably, step S2 specifically includes:
[0018] S201: For each partition, counting the occurrence frequencies of all pixel values to form a grayscale pixel value frequency distribution table;
[0019] S202: Based on the collected pixel value frequency distribution table, the entropy value of each partition is calculated using the following formula:
[0020] H = -∑p(x)log2p(x)
[0021] Among them, p(x) is the probability of pixel feature x, and H is the entropy value;
[0022] S203: designing an entropy coding rule according to the entropy value and the pixel value frequency distribution in the partition, wherein the entropy coding rule is that high-frequency features correspond to short codes and low-frequency features correspond to long codes;
[0023] S204: Based on the designed entropy coding rules, a local entropy coding dictionary of the partition is constructed using the Huffman coding method.
[0024] Preferably, step S3 specifically includes:
[0025] S301: extracting data features from the data to be compressed in each partition, and constructing the data features of all partitions into a feature matrix;
[0026] S302: Input the feature matrix into a prediction model, perform forward propagation, and obtain a compression configuration prediction result output by the prediction model, wherein the compression configuration prediction result is represented by a category label;
[0027] S303: Based on the category label output by the prediction model, match the compression configuration of each partition from a preset configuration mapping table.
[0028] Preferably, step S303 specifically includes:
[0029] S3031: defining a compression configuration matching each category label output by the prediction model based on previous data to construct a configuration mapping table;
[0030] S3032: According to the category label output by the prediction model, the corresponding compression configuration is searched in the configuration mapping table to match the compression configuration of each partition.
[0031] Preferably, step S4 specifically includes:
[0032] S401: setting corresponding compression parameters for the selected compression algorithm according to the allocated compression configuration;
[0033] S402: Apply the selected compression algorithm and compression parameters to compress the data to be compressed in each partition, and convert the compressed data of each partition into a primary compression code value.
[0034] Preferably, step S5 specifically includes:
[0035] S501: calling the local entropy coding dictionary constructed by the corresponding partition;
[0036] S502: Based on the entropy coding rule, traverse each primary compression coding value, and map it to a corresponding entropy coding value using a corresponding local entropy coding dictionary.
[0037] Preferably, step S6 specifically includes:
[0038] S601: Encapsulate the entropy coded value of the partition into a data packet, and embed metadata in the data packet;
[0039] S602: using multiplexing technology, transmitting the data packets of each partition to the host computer through different network paths;
[0040] S603: The host computer decompresses data packets of different partitions in parallel.
[0041] The present invention also provides a data compression system based on adaptive coding, which is applied to the data compression method based on adaptive coding. The compression system comprises:
[0042] The region division module is used by the lower computer to perform region division based on the pixel features of the image to be compressed, and obtain multiple partitions and corresponding data to be compressed;
[0043] A local entropy coding dictionary construction module is used by the lower computer to construct a local entropy coding dictionary according to the pixel features of each partition;
[0044] A prediction module is used for the lower computer to input the data to be compressed of each partition into a pre-trained prediction model to predict the compression configuration, and to allocate a compression configuration to each partition according to the prediction result, wherein the prediction model is a neural network model trained based on historical compressed image data, and the compression configuration includes a compression algorithm and compression parameters;
[0045] A primary compression module, used for the lower computer to perform primary compression on the to-be-compressed data of each partition based on the predicted compression configuration, and generate a primary compression code value of each partition;
[0046] An entropy coding mapping module is used for the lower computer to use the local entropy coding dictionary of each partition to perform entropy coding mapping on the primary compression coding value to generate the entropy coding value of each partition;
[0047] The decompression module is used for the lower computer to encapsulate the entropy coding value of each partition into an independent data packet, and send the data packet independently to the upper computer, and the upper computer performs the decompression operation according to the compression configuration of each partition.
[0048] Compared with the related art, the data compression method based on adaptive coding and the compression system thereof provided by the present invention have the following beneficial effects:
[0049] The present invention divides the image to be compressed into regions by a lower computer to obtain a plurality of partitions and corresponding data to be compressed, thereby ensuring that image regions with different characteristics are processed independently. The lower computer constructs a local entropy coding dictionary according to the pixel characteristics of each partition. In the compression configuration prediction stage, the pre-trained neural network model is used to predict the best compression algorithm and compression parameters according to the data to be compressed of each partition, thereby realizing adaptive adjustment of the compression configuration. The lower computer performs primary compression on the data to be compressed of each partition based on the predicted compression configuration to generate a primary compression code value of each partition. Then, the local entropy coding dictionary of each partition is used to perform entropy coding mapping on the primary compression code value to generate an entropy code value of each partition. The lower computer encapsulates the entropy code value of each partition into an independent data packet and independently sends the data packet to the upper computer. After receiving the data packet, the upper computer performs a decompression operation according to the compression configuration of each partition to restore the original image data. The present invention can perform partition compression and adaptive compression configuration prediction according to different regional characteristics of the image, thereby avoiding the problem of low compression efficiency caused by unified compression algorithm and parameters in the traditional method. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 A flowchart of a data compression method based on adaptive coding provided by the present invention;
[0051] Figure 2 A module structure diagram of a data compression system based on adaptive coding provided by the present invention. DETAILED DESCRIPTION
[0052] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only the parts related to the present invention, rather than all structures, are shown in the accompanying drawings. In addition, the embodiments of the present invention and the features in the embodiments may be combined with each other without conflict.
[0053] It should also be noted that, for ease of description, only the part relevant to the present invention but not all the content is shown in the accompanying drawings. It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as the processing or method described as a flow chart. Although the flow chart describes each operation (or step) as being processed sequentially, many operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. When its operation is completed, the processing can be terminated, but it can also have additional steps not included in the accompanying drawings. The processing can correspond to a method, a function, a procedure, a subroutine, a subprogram, etc.
[0054] Embodiment 1
[0055] The present invention provides a data compression method based on adaptive coding, referring to Figure 1 As shown, the compression method comprises the following steps:
[0056] S1: The lower computer divides the region based on the pixel features of the image to be compressed to obtain multiple partitions and corresponding data to be compressed.
[0057] In this embodiment, the lower computer (i.e., the device that performs the image compression task) uses an image processing algorithm to analyze the pixel features of the image to be compressed. Based on the pixel features, the image to be compressed is divided into a plurality of partitions with similar properties, each partition containing a group of pixels that are similar in color, texture, or spatial position, so that a specific compression strategy can be applied more effectively, and adaptive compression for different image contents can be achieved, thereby improving compression efficiency and image reconstruction quality. This is because different image regions require different compression algorithms and parameters to achieve the best compression effect.
[0058] S2: The lower computer constructs a local entropy coding dictionary based on the pixel features of each partition.
[0059] In this embodiment, for each partition, the lower computer constructs a local entropy coding dictionary based on its pixel features. This local entropy coding dictionary contains the most common pixel features in the partition and is used in the subsequent entropy coding process. When applied, the local entropy coding dictionary can reduce redundant information and improve coding efficiency. Because entropy coding is encoded based on the probability of symbol occurrence, the use of a partition-specific dictionary can further improve the compression ratio while maintaining the decoded image quality.
[0060] S3: The lower computer inputs the data to be compressed of each partition into a pre-trained prediction model for compression configuration prediction, and allocates compression configuration to each partition according to the prediction result, wherein the prediction model is a neural network model trained based on historical compressed image data, and the compression configuration includes compression algorithm and compression parameters.
[0061] In this embodiment, the lower computer inputs the data to be compressed of each partition into a pre-trained prediction model. The prediction model is trained based on historical compressed image data and can predict the compression algorithm and parameters that are most suitable for the partition. The prediction result will be used to assign compression configuration to each partition. The prediction model can intelligently select the best compression scheme for each partition, thereby achieving efficient and high-quality image compression.
[0062] S4: The lower computer performs primary compression on the data to be compressed of each partition based on the predicted compression configuration, and generates a primary compression code value of each partition.
[0063] In this embodiment, according to the compression configuration predicted in S3, the lower computer performs primary compression on the data to be compressed in each partition and generates a preliminary compression coding value. By adopting the compression configuration recommended by the prediction model, it can be ensured that each partition can obtain the best compression effect during the compression process.
[0064] S5: The lower computer uses the local entropy coding dictionary of each partition to perform entropy coding mapping on the primary compression coding value to generate the entropy coding value of each partition.
[0065] In this embodiment, the local entropy coding dictionary constructed in S2 is used to perform entropy coding mapping on the primary compression coding value generated in S4 to generate a final entropy coding value, which further reduces the redundancy of the encoded data and improves the compression efficiency. By using the local entropy coding dictionary, it can be ensured that the encoding process fully utilizes the statistical characteristics within the partition, thereby achieving a higher compression ratio while ensuring image quality.
[0066] S6: The lower computer encapsulates the entropy coding value of each partition into an independent data packet, and sends the data packet independently to the upper computer, and the upper computer performs a decompression operation according to the compression configuration of each partition.
[0067] In this embodiment, the lower computer encapsulates the entropy coding value of each partition into independent data packets, and sends these data packets independently to the upper computer (i.e., the device that receives and decompresses data). After receiving the data packet, the upper computer performs decompression operation according to the compression configuration of each partition. The independent data packet transmission allows parallel processing, which speeds up the overall transmission speed. In addition, since the upper computer follows the same compression configuration as the lower computer during decompression, it can ensure that the quality of the image after decompression is consistent with expectations, and it can also effectively manage network resources and avoid network congestion caused by a single large data packet.
[0068] Specifically, step S1 specifically includes:
[0069] S101: construct a gradient map of the image to be compressed and quantify pixel gradient changes.
[0070] In this embodiment, the lower computer constructs a gradient map by calculating the grayscale difference between pixels in the image through a gradient operator; then, these gradient values are quantized, that is, the continuous gradient values are mapped to a finite number of discrete levels, which helps to identify the structure and details in the image, which is crucial for subsequent homogeneous region recognition.
[0071] S102: Identify and define a homogeneous region composed of similar pixels based on pixel gradient changes in the image to be compressed.
[0072] In this embodiment, based on the gradient map constructed in S101, the lower computer identifies those areas with relatively small gradient changes, which are usually composed of similar pixels and have similar color and texture characteristics. The recognition process defines homogeneous areas by setting thresholds, that is, when the gradient change between adjacent pixels is lower than a certain threshold, they are considered to belong to the same area, thereby more accurately determining the structure of the image and facilitating subsequent area division. The identification of homogeneous areas allows the compression strategy to be optimized according to different parts of the image, thereby improving compression efficiency while maintaining image quality.
[0073] S103: Based on homogeneous regions composed of similar pixels in the image to be compressed, the image to be compressed is divided into regions using a region growing method and data of the image to be compressed is associated to obtain multiple partitions and data to be compressed corresponding to the partitions in the image to be compressed.
[0074] In this embodiment, the lower computer uses a region growing algorithm, which is an iterative process that starts with a seed pixel and gradually adds neighboring pixels to the same region until a preset stop condition is met. The selection of the seed pixel can be based on the homogeneous region identified in S102, and the stop condition is usually based on a threshold of gradient change or color difference. As the region grows, the image is gradually divided into multiple partitions with similar pixel features, each of which corresponds to a part of the original image and contains a set of data to be compressed.
[0075] Specifically, step S2 specifically includes:
[0076] S201: For each partition, count the occurrence frequencies of all pixel values to form a grayscale pixel value frequency distribution table.
[0077] In this embodiment, the lower computer counts all pixel values in each partition and records the number of occurrences of each gray level. Specifically, each pixel in the partition is traversed to create a frequency distribution table, in which each item represents a specific gray level and the total number of times it appears in the area. By counting the frequency of pixel values, it is possible to determine which pixel values are the most common and which are less common. This provides a basis for subsequent entropy coding, so that the coding rules can be optimized for the most common features, thereby improving coding efficiency.
[0078] S202: Based on the collected pixel value frequency distribution table, the entropy value of each partition is calculated using the following formula:
[0079] H = -∑p(x)log2p(x)
[0080] Among them, p(x) is the probability of pixel feature x, and H is the entropy value.
[0081] In this embodiment, the calculation of the entropy value helps to understand the complexity and predictability of the partition. A high entropy value means that the pixel values are distributed more evenly and are difficult to predict, while a low entropy value indicates that some pixel values appear more frequently and are easier to encode effectively.
[0082] S203: Designing an entropy coding rule according to the entropy value and the pixel value frequency distribution in the partition, wherein the entropy coding rule is that high-frequency features correspond to short codes and low-frequency features correspond to long codes.
[0083] In this embodiment, entropy coding rules are designed based on the frequency distribution of entropy values and pixel values in the partition. This rule usually follows the principle of "high-frequency features correspond to short codes, low-frequency features correspond to long codes", that is, the more common pixel values should be assigned shorter codes, while the less common pixel values use longer codes. This coding rule can significantly reduce the average code length, thereby improving compression efficiency. Since the codes of common features are shorter, they occupy less space in the data stream, which directly leads to an increase in compression rate.
[0084] S204: Based on the designed entropy coding rules, a local entropy coding dictionary of the partition is constructed using the Huffman coding method.
[0085] In this embodiment, based on the entropy coding rules designed in S203, the lower computer uses the Huffman coding method to construct a local entropy coding dictionary. Huffman coding is a commonly used entropy coding method. It assigns a unique code to each pixel value by constructing a Huffman tree. Huffman coding can ensure the prefix property of the code, that is, no code is a prefix of another code, which avoids ambiguity in the decoding process. In addition, Huffman coding can minimize the average length of the code, thereby achieving efficient compression while maintaining the quality of the decoded image.
[0086] Specifically, step S3 specifically includes:
[0087] S301: extracting data features from the data to be compressed in each partition, and constructing the data features of all partitions into a feature matrix.
[0088] In this embodiment, the lower computer needs to perform in-depth analysis on the data to be compressed in each partition to extract data features that can reflect the essential characteristics of the partition image content. These features may include but are not limited to color distribution, texture pattern, edge information, frequency domain characteristics, etc. Once the corresponding features are extracted from each partition, these features will be organized into a feature matrix, where each row represents a feature set of a partition and each column corresponds to a specific feature type, so as to convert the original image information into a machine-readable numerical form, providing the necessary input for the prediction model.
[0089] S302: Input the feature matrix into the prediction model, perform forward propagation, and obtain the compression configuration prediction result output by the prediction model, wherein the compression configuration prediction result is represented by a category label.
[0090] In this embodiment, the feature matrix is passed as input to a pre-trained prediction model. This prediction model is usually a deep neural network that has been trained with a large number of historical compressed image data sets and can identify the association between different image features and the optimal compression configuration. When the feature matrix passes through the forward propagation process of the model, the prediction model automatically calculates the optimal compression configuration prediction results for each partition. These prediction results are usually presented in the form of category labels. For example, "1" may represent the JPEG compression algorithm with specific parameters, "2" may represent the WebP compression algorithm with another set of parameters, and so on. Ultimately, the compression strategy can be dynamically adjusted based on the actual image features of the current partition, rather than adopting a one-size-fits-all approach. This not only significantly improves the overall efficiency of image compression, but also ensures that the image quality is not damaged due to excessive compression.
[0091] S303: Based on the category label output by the prediction model, match the compression configuration of each partition from a preset configuration mapping table.
[0092] In this embodiment, the category labels output by the prediction model represent the recommended compression configuration for each partition. However, in order to actually apply these configurations, the lower computer also needs to consult a pre-set configuration mapping table. This mapping table is essentially a reference list that matches each category label with a specific compression algorithm and parameter combination. By querying the mapping table, the lower computer can clearly know which compression algorithm should be used for each partition, as well as the precise parameter settings of the algorithm.
[0093] The role of the configuration mapping table is to convert abstract category labels into actual usable compression configurations. This step ensures that the model prediction results can be correctly interpreted and applied to the image compression process. In this way, the lower computer can accurately execute the suggestions given by the prediction model and achieve adaptive compression for each partition. In addition, due to the existence of the configuration mapping table, even if the compression algorithm or parameters change in the future, only the mapping table needs to be updated, without the need to retrain the prediction model, which greatly enhances the flexibility and maintainability of the system.
[0094] Specifically, step S303 specifically includes:
[0095] S3031: Based on previous data, a compression configuration matching each category label output by the prediction model is defined to construct a configuration mapping table.
[0096] In this embodiment, the construction of the configuration mapping table involves associating the category label output by the prediction model with a specific compression configuration; illustratively, the output of the prediction model is C=(c1, c2, ..., c i ), where c iis the i-th category label, and the set of compression configurations is K = (k1, k2, ..., k j ), where k j is the jth compression configuration.
[0097] The process of building a configuration map can be described as a function: C→K, which transforms each class label c i Mapped to a compression configuration k j ,This mapping is based on the analysis results of historical data.
[0098] S3032: According to the category label output by the prediction model, the corresponding compression configuration is searched in the configuration mapping table to match the compression configuration of each partition.
[0099] In this embodiment, once the configuration mapping table T is established, step S3042 becomes direct and deterministic. i The matching of compression configuration can be simply expressed as the result of looking up the mapping T. In this way, it can be ensured that each partition is assigned the most appropriate compression configuration, thereby maximizing the overall compression efficiency and image quality.
[0100] Specifically, step S4 specifically includes:
[0101] S401: According to the allocated compression configuration, corresponding compression parameters are set for the selected compression algorithm.
[0102] In this embodiment, the lower computer sets precise compression parameters for the compression algorithm to be applied to each partition based on the compression configuration recommendations given by the prediction model in S3. This includes but is not limited to selecting a specific compression algorithm (such as JPEG, PNG, WebP, etc.) and determining its related parameters, such as compression rate, quantization matrix, color sampling rate, etc. The selection of these parameters is based on the best practices derived from the analysis of historical data by the prediction model, aiming to optimize the balance between compression efficiency and image quality.
[0103] By precisely setting the compression parameters, each partition can be compressed efficiently without sacrificing image quality. This adaptive configuration allows the algorithm to flexibly adjust to different image contents to achieve the best compression effect. Compared with fixed parameter compression methods, this method can significantly improve compression performance, especially when processing images with complex details or diverse textures.
[0104] S402: Apply the selected compression algorithm and compression parameters to compress the data to be compressed in each partition, and convert the compressed data of each partition into a primary compression code value.
[0105] In this embodiment, once the compression algorithm and parameters are set, the lower computer begins the actual compression process. The data to be compressed in each partition is processed by the selected compression algorithm, which works according to the set parameters to convert the original data into compressed data. Subsequently, the compressed data is further converted into a primary compression code value, which is a coded form that is easy to store and transmit, and it contains the compressed information, but has not yet been optimized by entropy coding.
[0106] By applying the algorithms and parameters recommended by the prediction model, we can ensure that the compression processing of each partition is optimal, which not only reduces the storage space requirements but also maintains the visual effect of the image.
[0107] Specifically, step S5 specifically includes:
[0108] S501: Calling the local entropy coding dictionary constructed for the corresponding partition.
[0109] In this embodiment, the lower computer calls the local entropy coding dictionary constructed in step S2 for each partition. This dictionary is customized according to the pixel features in the partition and contains the statistical information of the most common pixel patterns in the area; calling the local entropy coding dictionary can ensure that the entropy coding process fully considers the specific statistical characteristics of the partition, thereby reducing the redundancy of the encoded data and improving the compression efficiency. Because entropy coding is encoded based on the probability of the occurrence of symbols, the use of partition-specific dictionaries can further optimize the code length, making the code of common patterns shorter and the code of uncommon patterns longer, thereby saving more bits in the encoding process while maintaining the quality of the decoded image.
[0110] S502: Based on the entropy coding rule, traverse each primary compression coding value, and map it to a corresponding entropy coding value using a corresponding local entropy coding dictionary.
[0111] In this embodiment, the lower computer starts entropy coding the primary compression code value of each partition generated in step S4. Specifically, each code value is traversed and the corresponding mapping relationship in the local entropy coding dictionary is searched. For each code value, its probability distribution in the dictionary is searched, and the shortest code sequence is calculated according to the entropy coding rule to represent this value. Finally, each primary compression code value is converted into a more compact entropy coding value, which further reduces the redundancy of the coded data and improves the compression efficiency. Because the code value is converted into a shorter code based on its frequency of occurrence, this not only reduces the storage requirement, but also reduces the bandwidth consumption during transmission. More importantly, since the encoding process makes full use of the statistical characteristics within the partition, even at a high compression rate, good image reconstruction quality can be maintained, because common pixel patterns are more efficiently encoded, and rare patterns are given longer codes to adapt to their lower frequency of occurrence. This ensures that the content of the original image can be accurately restored during decoding, while achieving a higher compression ratio.
[0112] Specifically, step S6 specifically includes:
[0113] S601: Encapsulate the entropy coded value of the partition into a data packet, and embed metadata in the data packet.
[0114] In this embodiment, the lower computer is responsible for encapsulating the entropy coded values of each partition into independent data packets. Specifically, a series of entropy coded values are organized into a structured data unit, namely a data packet. In addition to the entropy coded values themselves, the data packet also embeds metadata, including but not limited to the partition identifier, compression configuration details, encoding type, dictionary information, and possible error check codes, etc. These metadata are essential for the upper computer to correctly decompress and reconstruct the image.
[0115] By embedding metadata in the data packets, the host computer can identify the partition to which each data packet belongs and understand the specific configuration and context information required for decompression. This not only helps to decompress the data accurately and without error, but also facilitates the implementation of error detection and potential error correction mechanisms, thereby ensuring the quality and integrity of image decompression.
[0116] S602: Using multiplexing technology, transmit the data packets of each partition to the host computer through different network paths.
[0117] In this embodiment, the lower computer uses multiplexing technology to send the encapsulated data packets to the upper computer through the network. The multiplexing technology refers to the technology of merging multiple data streams into a shared channel for transmission, including but not limited to frequency division multiplexing (FDM), time division multiplexing (TDM) or statistical time division multiplexing (STDM). The lower computer will select different network paths for each partitioned data packet to optimize transmission efficiency, avoid congestion of a single path, and improve the reliability of data transmission.
[0118] By adopting multiplexing technology and utilizing different network paths, the efficiency and robustness of data transmission can be significantly improved. This approach allows parallel processing of data packets, reducing the total transmission time, while avoiding network bottlenecks by distributing the load and enhancing the fault tolerance of the entire system. This is especially important for real-time or high-bandwidth application scenarios, ensuring fast and reliable data transmission.
[0119] S603: The host computer decompresses data packets of different partitions in parallel.
[0120] In this embodiment, after receiving the data packet, the host computer starts the corresponding decompression algorithm and parameters according to the metadata in each data packet. Since each data packet is independent, the host computer can decompress the data packets of different partitions in parallel, which means that the data of multiple partitions can be processed at the same time without waiting for the previous task to be completed. This is usually achieved through multi-threading or distributed computing resources to speed up the decompression process.
[0121] Parallel decompression greatly shortens the total decompression time and improves processing efficiency. At the same time, since the upper computer follows the same compression configuration as the lower computer, the reconstruction quality of the image is guaranteed. This method is particularly suitable for processing large image or video files, and its parallel processing capabilities can significantly reduce latency and improve user experience. In addition, by processing data packets independently, the system can better manage and optimize network resources, prevent network congestion, and ensure smooth data transmission.
[0122] The working principle of a data compression method based on adaptive coding provided by the present invention is as follows: the present invention divides the image to be compressed into regions by a lower computer to obtain multiple partitions and corresponding data to be compressed, so as to ensure that image regions with different characteristics are processed independently; the lower computer constructs a local entropy coding dictionary according to the pixel characteristics of each partition; in the compression configuration prediction stage, the pre-trained neural network model is used to predict the best compression algorithm and compression parameters according to the data to be compressed of each partition, so as to realize the adaptive adjustment of the compression configuration; the lower computer performs primary compression on the data to be compressed of each partition based on the predicted compression configuration to generate the primary compression coding value of each partition; then, the local entropy coding dictionary of each partition is used to perform entropy coding mapping on the primary compression coding value to generate the entropy coding value of each partition; the lower computer encapsulates the entropy coding value of each partition into an independent data packet, and independently sends the data packet to the upper computer; after receiving the data packet, the upper computer performs a decompression operation according to the compression configuration of each partition to restore the original image data; the present invention can perform partition compression and adaptive compression configuration prediction according to the different regional characteristics of the image, so as to avoid the problem of low compression efficiency caused by unified compression algorithm and parameters in the traditional method.
[0123] Embodiment 2
[0124] The present invention also provides a data compression system based on adaptive coding, which is applied to a data compression method based on adaptive coding, referring to Figure 2 As shown, the compression system includes:
[0125] The region division module 100 is used by the lower computer to perform region division based on the pixel features of the image to be compressed, so as to obtain multiple partitions and corresponding data to be compressed.
[0126] The local entropy coding dictionary construction module 200 is used by the lower computer to construct a local entropy coding dictionary according to the pixel features of each partition.
[0127] The prediction module 300 is used for the lower computer to input the data to be compressed of each partition into a pre-trained prediction model for compression configuration prediction, and to allocate compression configuration to each partition according to the prediction result, wherein the prediction model is a neural network model trained based on historical compressed image data, and the compression configuration includes compression algorithm and compression parameters.
[0128] The primary compression module 400 is used by the lower computer to perform primary compression on the data to be compressed of each partition based on the predicted compression configuration, and generate a primary compression code value of each partition.
[0129] The entropy coding mapping module 500 is used for the lower computer to use the local entropy coding dictionary of each partition to perform entropy coding mapping on the primary compression coding value to generate the entropy coding value of each partition.
[0130] The decompression module 600 is used for the lower computer to encapsulate the entropy coding value of each partition into an independent data packet, and send the data packet independently to the upper computer, and the upper computer performs the decompression operation according to the compression configuration of each partition.
[0131] The present application is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0132] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0133] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or includes elements that are inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device that includes the elements.
Claims
1. A data compression method based on adaptive coding, characterized in that: The compression method includes the following steps: S1: The lower computer divides the region based on the pixel features of the image to be compressed, and obtains multiple partitions and corresponding data to be compressed; S2: The lower computer constructs a local entropy coding dictionary based on the pixel features of each partition; S3: The lower computer inputs the data to be compressed of each partition into a pre-trained prediction model to predict the compression configuration, and assigns a compression configuration to each partition based on the prediction result, wherein the prediction model is a neural network model trained based on historical compressed image data, and the compression configuration includes a compression algorithm and compression parameters; S4: The lower computer performs primary compression on the data to be compressed in each partition based on the predicted compression configuration, and generates a primary compression code value for each partition; S5: The lower computer uses the local entropy coding dictionary of each partition to perform entropy coding mapping on the primary compression coding value to generate the entropy coding value of each partition; S6: The lower computer encapsulates the entropy coding value of each partition into an independent data packet and sends the data packet independently to the upper computer. The upper computer performs a decompression operation according to the compression configuration of each partition.
2. The data compression method based on adaptive coding according to claim 1, characterized in that: Step S1 specifically includes: S101: constructing a gradient map of the image to be compressed and quantifying pixel gradient changes; S102: Identifying and defining a homogeneous region composed of similar pixels based on pixel gradient changes in the image to be compressed; S103: Based on homogeneous regions composed of similar pixels in the image to be compressed, the image to be compressed is divided into regions using a region growing method and the data of the image to be compressed is associated to obtain multiple partitions and the data to be compressed corresponding to the partitions in the image to be compressed.
3. The data compression method based on adaptive coding according to claim 2, characterized in that: Step S2 specifically includes: S201: For each partition, counting the occurrence frequencies of all pixel values to form a grayscale pixel value frequency distribution table; S202: Based on the collected pixel value frequency distribution table, the entropy value of each partition is calculated using the following formula: H=-∑p(x)log2p(x) Among them, p(x) is the probability of pixel feature x, and H is the entropy value; S203: Designing an entropy coding rule based on the entropy value and the pixel value frequency distribution in the partition, wherein the entropy coding rule is that high-frequency features correspond to short codes and low-frequency features correspond to long codes; S204: Based on the designed entropy coding rules, a local entropy coding dictionary of the partition is constructed using a Huffman coding method.
4. The data compression method based on adaptive coding according to claim 3, characterized in that: Step S3 specifically includes: S301: Extracting data features from the data to be compressed in each partition, and constructing the data features of all partitions into a feature matrix; S302: Input the feature matrix into the prediction model, perform forward propagation, and obtain the compression configuration prediction result output by the prediction model, wherein the compression configuration prediction result is represented by a category label; S303: Based on the category labels output by the prediction model, the compression configuration of each partition is matched from a preset configuration mapping table.
5. The data compression method based on adaptive coding according to claim 4, characterized in that: Step S303 specifically includes: S3031: defining a compression configuration matching each category label output by the prediction model based on previous data to construct a configuration mapping table; S3032: According to the category label output by the prediction model, the corresponding compression configuration is searched in the configuration mapping table to match the compression configuration of each partition.
6. The data compression method based on adaptive coding according to claim 5, characterized in that: Step S4 specifically includes: S401: setting corresponding compression parameters for the selected compression algorithm according to the allocated compression configuration; S402: Apply the selected compression algorithm and compression parameters to compress the data to be compressed in each partition, and convert the compressed data of each partition into a primary compression code value.
7. The data compression method based on adaptive coding according to claim 6, characterized in that: Step S5 specifically includes: S501: calling the local entropy coding dictionary constructed for the corresponding partition; S502: Based on the entropy coding rule, traverse each primary compression coding value, and use the corresponding local entropy coding dictionary to map it into a corresponding entropy coding value.
8. The data compression method based on adaptive coding according to claim 7, characterized in that: Step S6 specifically includes: S601: Encapsulate the entropy coded value of the partition into a data packet, and embed metadata in the data packet; S602: Using multiplexing technology, transmit the data packets of each partition to the host computer through different network paths; S603: The host computer decompresses data packets of different partitions in parallel.
9. A data compression system based on adaptive coding, applied to the data compression method based on adaptive coding according to any one of claims 1 to 8, characterized in that: The compression system includes: The region division module is used by the lower computer to perform region division based on the pixel features of the image to be compressed, and obtain multiple partitions and corresponding data to be compressed; A local entropy coding dictionary construction module is used by the lower computer to construct a local entropy coding dictionary based on the pixel features of each partition; A prediction module is used by the lower computer to input the data to be compressed in each partition into a pre-trained prediction model to predict the compression configuration, and to assign a compression configuration to each partition based on the prediction result, wherein the prediction model is a neural network model trained based on historical compressed image data, and the compression configuration includes a compression algorithm and compression parameters; A primary compression module is used by the lower computer to perform primary compression on the data to be compressed in each partition based on the predicted compression configuration, and generate a primary compression code value for each partition; The entropy coding mapping module is used for the lower computer to use the local entropy coding dictionary of each partition to perform entropy coding mapping on the primary compression coding value to generate the entropy coding value of each partition; The decompression module is used by the lower computer to encapsulate the entropy coding value of each partition into an independent data packet and send the data packet independently to the upper computer. The upper computer performs the decompression operation according to the compression configuration of each partition.
Citation Information
Cited By
Fractal data compression and storage method and system and related equipment
CN119341575A
Image signal processing system and processing method
CN120263980A
