A data compression method for the Internet of Vehicles

By calculating the average encoding length and determination of the image blocks of pixel points, selecting the preferred blocks, and combining fixed-length binary encoding to save the position and grayscale information of the image blocks, the compression efficiency and accuracy of image data storage in the Internet of Vehicles is solved, and efficient data storage is achieved.

CN115914640BActive Publication Date: 2025-07-08SHAANXI COMM PLANNING & DESIGN RES INST CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211393528.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-08
Publication Date
2025-07-08
Estimated Expiration
2042-11-08

AI Technical Summary

Technical Problem

现有的无损压缩方法在车联网中无法兼顾压缩效率和图像的准确性,传统分块压缩方法在图像数据存储中存在冗余和效率低下的问题。

Method used

By calculating the average encoding length of image blocks corresponding to different sizes for each pixel point, the image block with the minimum average encoding length is selected as the preferred block, the determination block is selected based on the hierarchical sequence number and determination degree, and the position and grayscale information of the determination block are saved, and the fixed-length binary encoding is used for compression.

Benefits of technology

It realizes efficient lossless compression of image data, reduces the amount of data, and improves the efficiency and accuracy of Internet of Vehicles data storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115914640B_ABST
    Figure CN115914640B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of data compression and storage, and particularly relates to a data compression method for the Internet of Vehicles, including: calculating the average coding length of image blocks of different sizes corresponding to each pixel point, and recording the image block corresponding to the smallest average coding length as the preferred block of the pixel point; obtaining the hierarchical serial number and sequential serial number of the preferred block, and calculating the certainty of the preferred block; obtaining all determined blocks according to the hierarchical serial number, sequential serial number and certainty of the preferred block; acquiring all corner pixel points of all determined blocks, and obtaining all position sequences according to the sequential degree of the corner pixel points and the relative relationship between the corner pixel points; obtaining all coding sequences according to the gray values of all determined blocks; and storing all position sequences and coding sequences. The present invention divides the image into blocks, and respectively obtains the position sequence representing the position information and the coding sequence representing the gray information; while losslessly compressing the image, the amount of data is reduced, ensuring the efficient storage of the data of the Internet of Vehicles.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data compression and storage, and particularly relates to a data compression method for the Internet of Vehicles. Background Art

[0002] To meet the increasing application requirements of users, the Internet of Vehicles provides more and more functions, such as driving behavior analysis, fault diagnosis, user portrait construction, etc. The accuracy and reliability of these functions depend on a large amount of data. These data need to be collected by the data acquisition terminals on the vehicles and then stored in the cloud for analysis and mining. The data stored in the cloud is obtained according to CCFD DD2.

[0003] Whether developing new functions subsequently or updating and iterating existing functions, a large amount of accurate data is required. Therefore, higher requirements are put forward for the storage efficiency and accuracy of the cloud. Conventional lossless compression methods such as Huffman coding can ensure the accuracy of data, but the compression efficiency is limited. The present invention takes into account the local similarity of image data and compresses and stores the image data in blocks. However, the compression efficiency and image accuracy of traditional block compression methods cannot be achieved simultaneously. Summary of the Invention

[0004] To solve the above problems, the present invention provides a data compression method for the Internet of Vehicles, and the method includes:

[0005] Obtain an image; for any pixel point in the image, calculate the average coding length of image blocks with different sizes corresponding to the pixel point, and record the image block corresponding to the smallest average coding length as the preferred block of the pixel point; obtain the preferred blocks of all pixel points in the image;

[0006] Obtain the hierarchical sequence numbers and sequential sequence numbers of all preferred blocks according to the average coding length and size of the preferred blocks, calculate the certainty of the preferred blocks, and obtain all determined blocks according to the hierarchical sequence numbers, sequential sequence numbers and certainty of the preferred blocks;

[0007] Obtain all corner pixel points of all determined blocks, obtain the sequential degrees of each type of corner pixel point, and obtain all position sequences according to the sequential degrees of the corner pixel points and the relative relationships between the corner pixel points; obtain all coding sequences according to the gray values of all determined blocks; store all position sequences and coding sequences.

[0008] Preferably, the step of calculating the average coding length of image blocks with different sizes corresponding to the pixel point includes:

[0009] For any pixel point in the image, an image block with a size of K×K centered on this pixel point is obtained, where K×K is the size of the image block, and K = 2i + 1 with the value range of i being [1, 9]. Therefore, for each pixel point, there are 9 image blocks with different sizes;

[0010] For the image block with a size of K×K of this pixel point, obtain the gray values of all pixel points in the image block, record the maximum gray value as the maximum value A1, and record the minimum gray value as the minimum value A2;

[0011] Obtain the average coding length of the image block according to the maximum value and the minimum value. The calculation formula for the average coding length of the image block is:

[0012]

[0013] In the formula, S(K×K) represents the average coding length of the image block with a size of K×K of this pixel point, 2×8 represents the coding lengths of the maximum value and the minimum value of the image block, C(K×K) represents the coding length of the gray value of each pixel point in the image block with a size of K×K of this pixel point, and In the formula, A1 represents the maximum value of the image block with a size of K×K of this pixel point, A2 represents the minimum value of the image block with a size of K×K of this pixel point, represents rounding up.

[0014] Preferably, the steps of calculating the certainty degree of the preferred block include:

[0015] Denote the set composed of all pixel points that make up all the certainty blocks as the certainty point set, and denote the set composed of the preferred blocks of all pixel points in the image as the initial set; for any preferred block in the initial set, the method of calculating the certainty degree of the preferred block is: denote the set composed of all pixel points that make up the preferred block as the first set, obtain the intersection of the first set and the certainty point set, and denote the ratio of the number of pixel points in the intersection to the number of pixel points in the first set as the certainty degree of the preferred block.

[0016] Preferably, the steps of obtaining all the certainty blocks according to the hierarchical serial number and the sequential serial number of the preferred block and the certainty degree include:

[0017] Obtain two empty sets, denoted as the certainty block set and the certainty point set respectively;

[0018] Take the preferred block with a hierarchical serial number of 1 and a sequential serial number of 1 as the first certainty block, add the first certainty block to the certainty set, add all pixel points that make up the first certainty block to the certainty point set, remove the preferred blocks corresponding to all pixel points in the certainty point set from the initial set, and obtain the updated initial set;

[0019] Obtain a new determined block and update the initial set, specifically: Calculate the determination degrees of all preferred blocks in the updated initial set, mark the preferred block corresponding to the maximum determination degree as the second determined block, add the second determined block to the determined set, add all the pixel points constituting the second determined block to the determined point set, remove the preferred blocks corresponding to all the pixel points in the determined point set from the initial set, and obtain the updated initial set;

[0020] Repeat obtaining a new determined block and updating the initial set until the initial set is an empty set, and obtain all determined blocks.

[0021] Preferably, the step of according to the order degree of corner pixel points and the relative relationship between corner pixel points includes:

[0022] Obtain a position sequence, specifically:

[0023] Obtain the corner pixel point corresponding to the maximum order degree, add the coordinates of this corner pixel point to the position sequence; obtain the determined block with this corner pixel point as the upper left pixel point, obtain the coordinates of the lower right pixel point of this determined block, add the coordinates of the lower right pixel point to the position sequence, use the lower right pixel point as the target pixel point, and remove the lower right pixel point from the set of corner pixel points;

[0024] Obtain a new target pixel point, specifically: Judge whether there is a determined block with the same corner pixel point as the target pixel point: If there is only one determined block, add the coordinates of the relative pixel point of the target pixel point in this determined block to the position sequence, use this relative pixel point as the new target pixel point, and remove this relative pixel point from the set of corner pixel points; If there are multiple determined blocks, obtain the relative pixel points of the target pixel point in multiple determined blocks, add the coordinates of the relative pixel point corresponding to the maximum order degree among the multiple relative pixel points to the position sequence, use this relative pixel point as the target pixel point, and remove this relative pixel point from the set of corner pixel points;

[0025] Repeat obtaining a new target pixel point until there is no determined block with the same corner pixel point as the target pixel point, and obtain a position sequence;

[0026] Repeat obtaining a position sequence multiple times until the set of corner pixel points is empty, and obtain all position sequences.

[0027] Preferably, the step of obtaining all coding sequences according to the gray values of all determined blocks includes:

[0028] For any given block, encode the maximum value and the minimum value of the given block into 8-bit binary numbers respectively through fixed-length binary encoding; calculate the difference between the gray value of each pixel point in the given block and the minimum value, and according to the encoding length C of the image block, encode the differences between the gray values of all pixel points in the given block and the minimum value into C-bit binary numbers through fixed-length binary encoding; denote the sequence composed of the 8-bit binary numbers corresponding to the maximum value and the minimum value of each given block, and the C-bit binary numbers corresponding to the differences between the gray values of each pixel point and the minimum value arranged from left to right and from top to bottom as the encoding sequence of the given block.

[0029] Preferably, the step of obtaining the order degree of each type of corner pixel point includes:

[0030] Obtain the corner pixel points of all given blocks, obtain the set of corner pixel points composed of all corner pixel points, and count the frequency of each type of corner pixel point in the set of corner pixel points, which is denoted as the order degree of each type of corner pixel point.

[0031] Preferably, the step of obtaining the hierarchical serial number and the sequential serial number of all preferred blocks according to the average encoding length and size of the preferred blocks includes:

[0032] Denote the set composed of all preferred blocks as the initial set, denote the set composed of all preferred blocks with the same average encoding length as the hierarchical set, obtain all hierarchical sets according to all different lengths of average encoding lengths, sort all hierarchical sets in ascending order of average encoding length, and the hierarchical serial numbers of all sorted hierarchical sets are 1, 2,..., m,..., M - 1, M in sequence;

[0033] For all preferred blocks in any one hierarchical set, sort all preferred blocks in descending order of size, and the sequential serial numbers of all sorted preferred blocks are 1, 2,..., n,..., N - 1, N in sequence.

[0034] The embodiments of the present invention have at least the following beneficial effects:

[0035] 1. By calculating the average encoding length of image blocks with different sizes corresponding to each pixel point, the present invention denotes the image block corresponding to the minimum average encoding length as the preferred block of the pixel point, ensures that the average encoding length of the preferred block corresponding to each pixel point is the minimum, obtains all given blocks according to the hierarchical serial number and the sequential serial number of the preferred block and the certainty degree, ensures that the coincidence degree of all finally retained given blocks is the minimum, thereby minimizing the data volume of the encoded image. Compared with compressing the entire image, the compression effect of block-wise compressing the image is better, the data volume is reduced while the image is losslessly compressed, and the efficient storage of vehicle networking data is ensured.

[0036] 2. The present invention obtains the coding length of a determination block based on the maximum and minimum values of different determination blocks, and compresses and encodes the grayscale information of the determination block according to the coding length of the determination block. Compared with encoding based on the entire image, the coding length is longer when encoding based on the entire image, while the coding length is shorter when encoding based on different determination blocks. As a result, the data volume of the encoded image is small, and the compression effect of block-by-block compression of the image is good, ensuring the efficient storage of vehicle networking data.

[0037] 3. In addition to saving the grayscale information of the determination block, the present invention also needs to save the position information of the determination block, that is, save the position information of two corner pixel points with a relative relationship in the determination block. Considering that there may be a situation where two or more determination blocks share a corner pixel point, the position information of the shared corner pixel point only needs to be saved once, thereby reducing the data volume of the position information of the image block to be saved, improving the compression efficiency of the image, and ensuring the efficient storage of vehicle networking data. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0039] Figure 1 It is a flowchart of the steps of a data compression method for vehicle networking provided by an embodiment of the present invention;

[0040] Figure 2 It is the block division result of an image provided by an embodiment of the present invention;

[0041] Figure 3 It is a determination block after an image is divided into blocks provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0042] In order to further elaborate on the technical means and effects adopted by the present invention to achieve the intended invention purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation manner, structure, features, and effects of a data compression method for vehicle networking proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. In addition, the specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.

[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which the present invention belongs.

[0044] The following specifically describes the specific solution of a data compression method for the Internet of Vehicles provided by the present invention in conjunction with the accompanying drawings.

[0045] Please refer to Figure 1 , which shows a flowchart of the steps of a data compression method for the Internet of Vehicles provided by an embodiment of the present invention. The method includes the following steps:

[0046] Step S001, obtain all images in the Internet of Vehicles.

[0047] It should be noted that to meet the increasing application requirements of users, the Internet of Vehicles provides more and more functions, such as driving behavior analysis, fault diagnosis, user portrait construction, etc. The accuracy and reliability of these functions depend on a large amount of data, including operating state data and surrounding environment data. Among them, most of the surrounding environment data is image data. Considering the large amount of image data and high redundancy, in order to improve the data storage efficiency, the present invention compresses the image data and then stores the compressed image data in the cloud. The present invention uses CCFD wireless communication devices with the same frequency to receive the analysis results from the cloud while transmitting data to the cloud, and realizes efficient communication of relay forwarding through D2D communication.

[0048] In this embodiment, the required surrounding environment data, that is, image data, is collected by a camera installed on the vehicle. For each image in the image data, the size of the image is recorded as S×T, where S is the number of rows of the image and T is the number of columns of the image.

[0049] Step S002, obtain image blocks of different sizes corresponding to pixel points, calculate the average coding length of the image blocks according to the maximum and minimum values of the image blocks, obtain the preferred blocks of the pixel points according to the average coding length of the image blocks, and obtain the preferred blocks of all pixel points in the image.

[0050] It should be noted that for conventional image compression, it is necessary to encode the gray values of the pixel points in the image. Usually, fixed-length encoding is adopted, that is, the gray value is encoded into an 8-bit binary number. This is because the range of the gray values of all pixel points in the entire image is [0, 255]. The size of the range determines the encoding length, and thus determines the data volume of the encoded image. Encoding based on the entire image has a relatively long encoding length. Therefore, the data volume after encoding based on the entire image is large, and the compression effect of the image is poor. Considering the local similarity of the image, that is, the difference in the gray values of all pixel points within a certain area of the image is small. Therefore, compared with the large range of the gray values of the entire image, the range of the gray values of the area in the image is small. Therefore, the encoding length of the gray values of the area in the image is small, which in turn determines that the data volume after encoding the area in the image is small. Therefore, compared with compressing the entire image, the compression effect of block-wise compressing the image is better.

[0051] The range of the gray values of all pixel points in an image block is fixed, that is, the gray value of a pixel point is not greater than the maximum gray value of the image block and not less than the minimum gray value of the image block. Therefore, for different image blocks, fixed-length encoding with different encoding lengths can be adopted according to the range of the gray values of the image block, that is, the encoding length of the image block is determined according to the range of the gray values of the image block.

[0052] In order to ensure the best compression efficiency for all image blocks of the image after segmentation, it is necessary to divide the image into image blocks of different sizes. Therefore, the information that finally needs to be recorded for each image block includes: the position information of the image block and the gray information of the image block. The gray information of the image block includes the maximum and minimum values of the image block and the gray information of each pixel point in the image block. Among them, the gray information of each pixel point needs to be encoded with fixed length according to the encoding length of the image block.

[0053] The larger the size of the image block, the fewer the number of image blocks corresponding to the entire image, and the less the position information and gray information of the image blocks that need to be recorded. The compression efficiency of the image increases accordingly, that is, the larger the image block size, the greater the compression efficiency. However, as the size of the image block gradually increases, the range of the gray values of the image block increases, resulting in an increase in the encoding length of the image block. Then, the data volume after encoding the gray information of all pixel points in the image block with fixed length according to the encoding length of the image block is larger, and the compression efficiency of the image decreases accordingly, that is, the larger the image block size, the smaller the compression efficiency.

[0054] The ultimate goal of the present invention is to improve the compression efficiency of the image, that is, to reduce the data volume after image encoding. Therefore, the present invention first ensures that the average encoding length of the preferred block corresponding to each pixel point is minimized.

[0055] In this embodiment, taking any pixel point in the image as an example, the specific steps to obtain the preferred block of this pixel point are as follows:

[0056] 1. Obtain a region centered on the pixel point with a size of K×K, denoted as the image block of this pixel point. Among them, for K = 2i + 1, the value range of i is [1, 9], so each pixel point corresponds to 9 image blocks with different sizes.

[0057] 2. For any image block of the pixel point, the specific steps to calculate the average coding length of the image block are as follows:

[0058] (1) For an image block with a size of K×K, obtain the grayscale values of all pixel points in the image block. Denote the maximum grayscale value as the maximum value A1, and the minimum grayscale value as the minimum value A2.

[0059] (2) Since the grayscale values of all pixel points in the image block have a fixed range, that is, the grayscale value of a pixel point is not greater than the maximum value of the image block and not less than the minimum value of the image block. Therefore, according to the maximum value and minimum value of the image block, the coding length of the grayscale value of each pixel point in the image block can be obtained, denoted as the coding length of the image block. The calculation formula for the coding length of the image block is:

[0060]

[0061] In the formula, C(K×K) represents the coding length of the image block with a size of K×K of this pixel point, A1 represents the maximum value of the image block with a size of K×K of this pixel point, A2 represents the minimum value of the image block with a size of K×K of this pixel point, represents rounding up.

[0062] (3) Since the range of grayscale values of all pixel points in the entire image is [0, 255], therefore, encode the maximum value and minimum value of the image block into 8-bit binary numbers, and combine them with the coding length of the image block to obtain the average coding length of the image block. The calculation formula for the average coding length of the image block is:

[0063]

[0064] In the formula, S(K×K) represents the average coding length of the image block with a size of K×K of this pixel point. Encode the maximum value and minimum value of the image block into 8-bit binary numbers, then the total coding length is 2×8, and C(K×K) represents the coding length of the image block with a size of K×K of this pixel point.

[0065] 3. According to the above step 2, obtain the average coding lengths of 9 image blocks with different sizes corresponding to the pixel point, and denote the image block corresponding to the minimum average coding length as the preferred block of this pixel point.

[0066] 4. Obtain all preferred blocks of all pixel points in the image according to the above steps 1 to 3.

[0067] Step S003: Select multiple determined blocks from all preferred blocks in the image according to the determination degree of the preferred blocks, and obtain all determined blocks of the image.

[0068] It should be noted that all preferred blocks in the image obtained by the present invention ensure that the average coding length of these preferred blocks is small. Therefore, the amount of data for encoding these preferred blocks is small and the compression efficiency is high. However, since the above steps obtain corresponding preferred blocks for all pixel points in the image, there is overlap between these preferred blocks, that is, there is a large amount of redundancy, which will increase the amount of encoded data and reduce the compression efficiency. Therefore, the present invention selects from all the preferred blocks obtained in the above steps and tries to retain the preferred blocks with a small average coding length and a large size as much as possible.

[0069] 1. Obtain the hierarchical serial number and sequential serial number of each preferred block.

[0070] (1) Denote the set composed of all preferred blocks as the initial set, and layer all the preferred blocks in the initial set according to the average coding length to obtain all hierarchical sets. Specifically: Denote the set composed of all preferred blocks with the same average coding length as the hierarchical set, obtain different hierarchical sets according to different average coding lengths, obtain all hierarchical sets according to all average coding lengths, and sort all hierarchical sets in ascending order of the average coding length. The hierarchical serial numbers of all sorted hierarchical sets are 1, 2, …, m, …, M - 1, M in turn.

[0071] (2) For all preferred blocks in any one hierarchical set, sort all preferred blocks in descending order of size. The sequential serial numbers of all sorted preferred blocks are 1, 2, …, n, …, N - 1, N in turn.

[0072] 2. Obtain the first determined block, as well as the determined block set and determined point set according to the average coding length and size; update the initial set according to the determined point set.

[0073] (1) Obtain the determined block set and determined point set. At this time, both the determined block set and the determined point set are empty sets.

[0074] (2) Take the preferred block with the smallest average coding length and the largest size among all preferred blocks, that is, the preferred block with the sequential serial number 1 in the hierarchical sequence with the hierarchical serial number 1, as the first determined block and add it to the determined block set; add all pixel points constituting the first determined block to the determined point set, and remove the preferred blocks corresponding to all pixel points in the determined point set from the initial set to obtain the updated initial set.

[0075] 3. Calculate the certainty degree of each preferred block in the updated initial set. Based on the certainty degrees of all preferred blocks, obtain the second determined block and update the initial set.

[0076] (1) For any preferred block in the updated initial set, denote the set composed of all pixel points forming this preferred block as the first set. Obtain the intersection of the first set and the set of determined points, and denote the ratio of the number of pixel points in the intersection to the number of pixel points in the first set as the certainty degree of this preferred block.

[0077] (2) Obtain the preferred block corresponding to the maximum certainty degree: If there is exactly one preferred block corresponding to the maximum certainty degree, use it as the second determined block; if there are multiple preferred blocks corresponding to the maximum certainty degree, for these multiple preferred blocks, obtain the level serial number of the level set corresponding to each preferred block and the sequence serial number of each preferred block in the corresponding level set. The preferred block with the smallest level serial number and the smallest sequence serial number will be used as the second determined block; Add the second determined block to the set of determined blocks, add all pixel points forming the second determined block to the set of determined points. For the repeated pixel points in the set of determined points, only retain one pixel point. Remove the preferred blocks corresponding to all pixel points in the set of determined points from the initial set to obtain the updated initial set.

[0078] 4. Repeat step 3 above, calculate the certainty degree of each preferred block in the updated initial set. Based on the certainty degrees of all preferred blocks, obtain a new determined block and update the initial set until the initial set is empty.

[0079] It should be noted that in the present invention, by calculating the average coding length of image blocks with different sizes corresponding to each pixel point, the image block corresponding to the smallest average coding length is denoted as the preferred block of the pixel point, ensuring that the average coding length of the preferred block corresponding to each pixel point is the smallest. All determined blocks are obtained based on the level serial number, sequence serial number and certainty degree of the preferred block, ensuring that the coincidence degree of all finally retained determined blocks is the smallest, thereby minimizing the data volume of the encoded image. Compared with compressing the entire image, the compression effect of block-based image compression is better. While performing lossless compression on the image, the data volume is reduced, ensuring the efficient storage of vehicle networking data.

[0080] In step S004, obtain all corner pixel points of all determined blocks, obtain the sequence degree of each type of corner pixel point, and based on the sequence degree of the corner pixel points and the relative relationship between the corner pixel points, obtain all position sequences; obtain all coding sequences according to the gray values of all determined blocks; store all position sequences and coding sequences.

[0081] It should be noted that for any given block, due to the different sizes of the given blocks, in order to ensure that the image can be accurately restored according to the compression result of the image, in addition to saving the grayscale information of each given block, it is also necessary to save the position information of each given block. Since the given block is a rectangular block, the conventional way to save the position information of a rectangular block is to save the position information of two corner pixels with a relative relationship in the rectangular block. In this way, two corner pixel position information needs to be saved for each given block. However, considering that there may be a situation where two or more given blocks share a corner pixel, in this case, the position information of the shared corner pixel only needs to be saved once, thereby reducing the amount of data required to save the position information of the image blocks and improving the compression efficiency of the image.

[0082] 1. Construct a rectangular coordinate system.

[0083] In this embodiment, taking the upper left corner of the image as the origin, the direction from the origin downward as the x-axis direction, and the direction from the origin to the right as the y-axis direction, a rectangular coordinate system is established. The abscissa of the x pixel is x, and x ∈ [1, X], and the ordinate of the plaintext pixel is y, and y ∈ [1, Y].

[0084] 2. Encode the position information of all given blocks.

[0085] It should be noted that for any given block, the pixel points at the four corners of the image block are denoted as corner pixels, namely: the upper left corner pixel, the upper right corner pixel, the lower left corner pixel, and the lower right corner pixel. Among them, the upper left corner pixel and the lower right corner pixel have a relative relationship and are relative pixels to each other, and the lower left corner pixel and the upper right corner pixel have a relative relationship and are relative pixels to each other; for a given block, the position of the given block can be restored according to the two corner pixels that are relative to each other. Therefore, the two corner pixels that are relative to each other contain all the position information of the given block, that is, to save the position information of the given block, only the coordinates of the two corner pixels that are relative to each other need to be saved.

[0086] (1) For any given block, the pixel points at the four corners of the image block are denoted as corner pixels, namely: the upper left corner pixel, the upper right corner pixel, the lower left corner pixel, and the lower right corner pixel. Among them, the upper left corner pixel and the lower right corner pixel have a relative relationship and are relative pixels to each other, and the lower left corner pixel and the upper right corner pixel have a relative relationship and are relative pixels to each other. Obtain the corner pixels of all given blocks, obtain the set of corner pixels composed of all corner pixels, and count the frequency of each type of corner pixel in the set of corner pixels as the order degree of each type of corner pixel.

[0087] (2) Obtain the corner pixel point corresponding to the maximum order degree, and add the coordinates of this corner pixel point to the position sequence; obtain the determined block with this corner pixel point as the upper left corner pixel point, obtain the coordinates of the lower right corner pixel point of this determined block, add the coordinates of this lower right corner pixel point to the position sequence, use this lower right corner pixel point as the target pixel point, and remove this lower right corner pixel point from the set of corner pixel points.

[0088] (3) Determine whether there is a determined block with the same corner pixel point as the target pixel point: If there is only one determined block, add the coordinates of the relative pixel point of the target pixel point in this determined block to the position sequence, use this relative pixel point as the new target pixel point, and remove this relative pixel point from the set of corner pixel points; if there are multiple determined blocks, obtain the relative pixel points of the target pixel point in multiple determined blocks, add the coordinates of the relative pixel point with the maximum order degree among multiple relative pixel points to the position sequence, use this relative pixel point as the target pixel point, and remove this relative pixel point from the set of corner pixel points; if not, stop obtaining the current position sequence, and remove the determined blocks corresponding to all pixel points in the position sequence from the determined set.

[0089] (4) Repeat step (3), determine whether there is a determined block with the same corner pixel point as the new target pixel point, and obtain the coordinates of all pixel points constituting the current position sequence.

[0090] (5) Repeat steps (2) to (4) until the set of corner pixel points is empty, obtain all position sequences, and store all position sequences in the obtained order.

[0091] For example, in this embodiment Figure 2 is the result of image block division. The image contains multiple determined blocks. According to the above method, Figure 2 a position sequence composed of the corner pixel points of 11 determined blocks numbered from 1 to 11 in it is obtained. Specifically: {(0,0),(9,6),(19,9),(30,0),(36,9),(32,15),(36,17),(24,20),

[0092] (19,17),(24,9),(32,14),(24,17)}.

[0093] It should be noted that in addition to saving the gray information of the determined block, the present invention also needs to save the position information of the determined block, that is, save the position information of two corner pixel points with a relative relationship in the determined block. Considering that there may be a situation where two or even more determined blocks share a corner pixel point, the position information of the shared corner pixel point only needs to be saved once, thereby reducing the amount of data that needs to be saved for the position information of the image block, improving the compression efficiency of the image, and ensuring the efficient storage of vehicle networking data.

[0094] 3. Encode the grayscale information of all determined blocks to obtain all encoded sequences.

[0095] Store the encoded sequences of all determined blocks in the order of all position sequences. The method for obtaining the encoded sequence of a determined block is as follows: For any determined block, encode the maximum value and the minimum value of the determined block into 8-bit binary numbers respectively through fixed-length binary encoding; calculate the difference between the grayscale value of each pixel point in the determined block and the minimum value, and according to the encoding length C of the image block, encode the differences between the grayscale values of all pixel points in the determined block and the minimum value into C-bit binary numbers through fixed-length binary encoding; record the sequence composed of the 8-bit binary numbers corresponding to the maximum value and the minimum value of each determined block, and the C-bit binary numbers corresponding to the differences between the grayscale values of each pixel point and the minimum value arranged from left to right and from top to bottom as the encoded sequence of the determined block.

[0096] For example, in this embodiment Figure 3 is a determined block in the image. The maximum value and the minimum value of the determined block are A1 = 8 and A2 = 23 respectively. The maximum value and the minimum value of the determined block are encoded into 8-bit binary numbers 00001000 and 00010111 respectively through fixed-length binary encoding. According to the maximum value and the minimum value of the determined block of the image block, determine the encoding length of the image block The differences between the grayscale values of all pixel points in the determined block and the minimum value are 9, 2, 3, 12, 7, 0, 14, 11, 8, 10, 15, 15, 4, 0, 15, 5 respectively. The differences between the grayscale values of all pixel points in the determined block and the minimum value are encoded into 4-bit binary numbers through fixed-length binary encoding, which are 1001, 0010, 0011, 1100, 0111, 0000, 1110, 1011, 1000, 1010, 1111

[0097] , 1111, 0100, 0000, 1111, 0101. Then the encoded sequence of this determined block is 000010000001011101011110010010001111000111000011101011100010101111111101000000

[0098] 11110101. Originally, the length of the data after encoding the grayscale information of the determined block through fixed-length encoding is 128, and the length of the data after encoding the grayscale information of the determined block through the method of the present invention is 80.

[0099] It should be noted that the present invention obtains the coding length of a determination block based on the maximum and minimum values of different determination blocks, and compresses and encodes the grayscale information of the determination block according to the coding length of the determination block; compared with encoding based on the entire image, it has a longer coding length, while when encoding based on different determination blocks, the coding length is shorter, thereby reducing the data volume of the encoded image and achieving a better compression effect for block-based compression of the image, ensuring the efficient storage of vehicle networking data.

[0100] 4. Restore the image according to the compression result of the image. The specific steps are as follows:

[0101] (1) Obtain all empty image blocks according to all position sequences. Specifically: for any one position sequence, obtain all empty image blocks corresponding to the position sequence according to all adjacent two coordinates in the position sequence; obtain all empty image blocks according to all position sequences.

[0102] (2) Fill all empty image blocks according to all coding sequences to obtain the restored image. Specifically: for any one coding sequence, record the decimal number converted from the first 8 bits of the coding sequence as the maximum value of the image block, and record the decimal number converted from the 9th bit to the 16th bit of the coding sequence as the minimum value of the image block. Determine the coding length C of the image block according to the maximum and minimum values of the image block. Divide the remaining coding sequence into multiple subsequences according to the coding length C, and use the sum of the decimal number converted from each subsequence and the minimum value of the image block as the grayscale value of the pixel points in the image block, so as to achieve the filling of the empty image block, and thus restore the image according to the compression result of the image.

[0103] In summary, the present invention calculates the average coding length of image blocks of different sizes corresponding to each pixel point, and records the image block with the smallest average coding length as the preferred block of the pixel point; obtains the hierarchical serial number and sequential serial number of the preferred block, and calculates the determination degree of the preferred block; obtains all determination blocks according to the hierarchical serial number, sequential serial number and determination degree of the preferred block; obtains all corner pixel points of all determination blocks, and obtains all position sequences according to the order degree of the corner pixel points and the relative relationship between the corner pixel points; obtains all coding sequences according to the grayscale values of all determination blocks; stores all position sequences and coding sequences. The present invention divides the image into blocks, and respectively obtains the position sequences representing position information and the coding sequences representing grayscale information; while performing lossless compression on the image, it reduces the data volume, ensuring the efficient storage of vehicle networking data.

[0104] It should be noted that: the above sequence of embodiments of the present invention is only for description and does not represent the superiority or inferiority of the embodiments. And the above specific embodiments of this specification have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require the specific order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0105] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments.

[0106] The above embodiments are only used to illustrate the technical solutions of the present application, not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of each embodiment of the present application, and should all be included in the protection scope of the present application.

Claims

1. A data compression method for the Internet of Vehicles, characterized in that, The method includes: Obtain an image; for any pixel point in the image, calculate the average coding length of image blocks with different sizes corresponding to the pixel point, and denote the image block corresponding to the minimum average coding length as the preferred block of the pixel point; obtain the preferred blocks of all pixel points in the image; Obtain the hierarchical sequence numbers and sequential sequence numbers of all preferred blocks according to the average coding length and size of the preferred blocks, calculate the certainty degree of the preferred blocks, and obtain all determined blocks according to the hierarchical sequence numbers, sequential sequence numbers and certainty degree of the preferred blocks; Obtain all corner pixel points of all determined blocks, obtain the sequential degree of each type of corner pixel point, and obtain all position sequences according to the sequential degree of the corner pixel points and the relative relationship between the corner pixel points; obtain all coding sequences according to the gray values of all determined blocks; store all position sequences and coding sequences; The step of calculating the certainty degree of the preferred blocks includes: Denote the set composed of all pixel points that make up all determined blocks as the determined point set, and denote the set composed of the preferred blocks of all pixel points in the image as the initial set; for any preferred block in the initial set, the method for calculating the certainty degree of the preferred block is: denote the set composed of all pixel points that make up the preferred block as the first set, obtain the intersection of the first set and the determined point set, and denote the ratio of the number of pixel points in the intersection to the number of pixel points in the first set as the certainty degree of the preferred block; The step of obtaining all determined blocks according to the hierarchical sequence numbers, sequential sequence numbers and certainty degree of the preferred blocks includes: Obtain two empty sets, denoted as the determined block set and the determined point set respectively; Take the preferred block with a hierarchical sequence number of 1 and a sequential sequence number of 1 as the first determined block, add the first determined block to the determined set, add all pixel points that make up the first determined block to the determined point set, and remove the preferred blocks corresponding to all pixel points in the determined point set from the initial set to obtain an updated initial set; Obtain a new determined block and update the initial set, specifically: calculate the certainty degree of all preferred blocks in the updated initial set, denote the preferred block corresponding to the maximum certainty degree as the second determined block, add the second determined block to the determined set, add all pixel points that make up the second determined block to the determined point set, and remove the preferred blocks corresponding to all pixel points in the determined point set from the initial set to obtain an updated initial set; Repeat obtaining a new determined block and updating the initial set until the initial set is an empty set to obtain all determined blocks.

2. The data compression method for an Internet of Vehicles according to claim 1, wherein The step of calculating the average coding length of image blocks with different sizes corresponding to the pixel point includes: For any pixel point in the image, an image patch centered on the pixel point with a size of is obtained, where is the size of the image patch, and , where ranges from . Therefore, for each pixel point, there are 9 image patches with different sizes; For the image block with the size of the pixel point being obtain the grayscale values of all pixel points in the image block, and record the maximum grayscale value as the maximum value , and record the minimum grayscale value as the minimum value ; Obtain the average coding length of the image block according to the maximum value and the minimum value, and the calculation formula of the average coding length of the image block is: Wherein, represents the average coding length of an image block with the size of ; represents the coding lengths of the maximum and minimum values of the image block; represents the coding length of the gray value of each pixel of an image block with the size of ; and , wherein represents the maximum value of an image block with the size of ; represents the minimum value of an image block with the size of ; represents rounding up.

3. A data compression method for an Internet of Vehicles according to claim 1, characterized in that The step of obtaining all position sequences according to the sequential degree of the corner pixel points and the relative relationship between the corner pixel points includes: Obtain a position sequence, specifically: Obtain the corner pixel point corresponding to the maximum order degree, and add the coordinates of this corner pixel point to the position sequence; obtain the determined block with this corner pixel point as the upper left corner pixel point, obtain the coordinates of the lower right corner pixel point of this determined block, add the coordinates of the lower right corner pixel point to the position sequence, use the lower right corner pixel point as the target pixel point, and remove the lower right corner pixel point from the set of corner pixel points; Obtain a new target pixel point, specifically: determine whether there is a determined block with a corner pixel point the same as the target pixel point: if there is only one determined block, add the coordinates of the relative pixel point of the target pixel point in this determined block to the position sequence, use this relative pixel point as the new target pixel point, and remove this relative pixel point from the set of corner pixel points; if there are multiple determined blocks, obtain the relative pixel points of the target pixel point in multiple determined blocks, add the coordinates of the relative pixel point corresponding to the maximum order degree among the multiple relative pixel points to the position sequence, use this relative pixel point as the target pixel point, and remove this relative pixel point from the set of corner pixel points; Repeat obtaining a new target pixel point until there is no determined block with a corner pixel point the same as the target pixel point, and obtain a position sequence; Repeat obtaining a position sequence multiple times until the set of corner pixel points is empty, and obtain all position sequences.

4. A data compression method for vehicle networking according to claim 1, characterized in that The step of obtaining all coding sequences according to the gray values of all determined blocks includes: For any given block, the maximum value and the minimum value of the given block are respectively encoded into 8-bit binary numbers by fixed-length binary encoding; calculate the difference between the gray value of each pixel point in the given block and the minimum value, and according to the encoding length of the image block , the differences between the gray values of all pixel points in the given block and the minimum value are encoded into -bit binary numbers by fixed-length binary encoding; the 8-bit binary numbers corresponding to the maximum value and the minimum value of each given block, and the corresponding -bit binary numbers of the differences between the gray values of each pixel point arranged from left to right and from top to bottom and the minimum value are recorded as the encoding sequence of the given block.

5. A data compression method for an Internet of Vehicles according to claim 1, characterized in that, The step of obtaining the order degree of each type of corner pixel point includes: Obtain the corner pixel points of all determined blocks, obtain the set of corner pixel points composed of all corner pixel points, count the frequency of each type of corner pixel point in the set of corner pixel points, and record it as the order degree of each type of corner pixel point.

6. A data compression method for an Internet of Vehicles according to claim 2, characterized in that, The step of obtaining the hierarchical serial numbers and order serial numbers of all preferred blocks according to the average coding length and size of the preferred blocks includes: Denote the set composed of all preferred blocks as the initial set, and denote the set composed of all preferred blocks with the same average coding length as the hierarchical set. Obtain all hierarchical sets according to the average coding lengths of all different lengths, and sort all hierarchical sets in ascending order of the average coding length. The hierarchical numbers of all sorted hierarchical sets are successively ; For all the preferred blocks in any hierarchical set, sort all the preferred blocks in descending order of size, and the sequence numbers of all the sorted preferred blocks are successively .

Citation Information

Patent Citations

  • Image compression method and device

    CN111131828A

  • Data compression method and device

    CN1200857A