Image compression and decompression method, device, equipment and computer readable storage medium

By grouping industrial camera image data and encoding it using the difference between compressed prediction data and residual data, the problem of insufficient gigabit Ethernet transmission bandwidth is solved, achieving efficient image compression, reducing data redundancy, and improving transmission efficiency.

CN115802050BActive Publication Date: 2025-12-16ZHEJIANG HUARAY TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211139550.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-19
Publication Date
2025-12-16
Estimated Expiration
2042-09-19

AI Technical Summary

Technical Problem

The existing gigabit Ethernet transmission bandwidth cannot meet the data transmission requirements of high-resolution, high-frame-rate industrial cameras, leading to increased hardware costs, and existing compression technologies have failed to effectively reduce data redundancy.

Method used

The pixel data of the original image is divided into multiple data groups, and the compressed data of each data group is determined by the difference between the compressed prediction data and the residual data. Entropy coding table is used for encoding to achieve efficient image compression.

Benefits of technology

Without increasing hardware costs, it improves data transmission efficiency, reduces data redundancy, and achieves high compression ratio image compression.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115802050B_ABST
    Figure CN115802050B_ABST
Patent Text Reader

Abstract

The embodiment of the present application provides a kind of image compression decompression method, device, equipment and computer readable storage medium, wherein compression method includes: the pixel data of original image is divided into multiple data groups;For any data group, the i-th pixel data, determine the compression prediction data of the i-th pixel data (not the first k pixel data in data group);For any first data group, the i-th pixel data, determine its compression data according to its compression prediction data;For any second data group, the i-th pixel data, according to the difference value of the residual error data of each pixel data except the first k pixel data in the first data group corresponding to the second data group and the residual error data of the pixel data at the same position in the second data group, determine the compression data corresponding to the i-th pixel data in the second data group;For any data group, encode according to the compression data of data group, obtain image compression data packet.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to an image compression and decompression method, device, equipment and computer readable storage medium. BACKGROUND

[0002] With the development of industrial technology, the demand for industrial vision is becoming more and more vigorous. The industrial camera based on gigabit Ethernet is widely used in industrial field because of its advantages such as suitable price, convenient wiring and mature technology; but with the development of industrial camera to high resolution and high frame rate, the transmission bandwidth of gigabit Ethernet becomes a bottleneck. In order to transmit higher data volume, industrial camera manufacturers have successively launched 2.5G, 5G and 10G bandwidth industrial cameras, but this has led to an increase in the cost of camera and system equipment hardware. Under the premise of not increasing the hardware cost, in order to fully utilize the transmission bandwidth of the network, reduce the redundant information of the data, and realize the low-cost, fast and lossless compression of image data, it is very important. SUMMARY

[0003] The embodiment of the present application provides an image compression and decompression method, device, equipment and computer readable storage medium, so as to provide an image compression scheme with high compression rate.

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

[0005] According to the rule of dividing the at least part of the continuous pixel data of the original image into a set of a plurality of pixel data sets every xn continuous pixel data, and for any pixel data set, the pixel data is evenly distributed to x data groups, so as to obtain x data groups corresponding to the pixel data set; wherein n is a positive integer greater than k, k is a positive integer, and x is a positive integer greater than 1;

[0006] For the ith pixel data in any data group, the compression prediction data of the ith pixel data is determined according to the ith pixel data in the data group and the continuous k pixel data before the ith pixel data in the data group; wherein i is a positive integer greater than k and less than or equal to n;

[0007] For the jth pixel data in any data group, the jth pixel data is taken as the compression data corresponding to the jth pixel data; wherein j is a positive integer less than the minimum value of i;

[0008] For the ith pixel data in any first data group, the compression data of the ith pixel data in the first data group is determined according to the compression prediction data of the ith pixel data in the first data group; wherein for any pixel data set, the first data group is one of the data groups in the pixel data set;

[0009] For the i-th pixel data in any second data group, the compression data corresponding to the i-th pixel data in the second data group is determined according to the difference between the residual data of each pixel data in the first data group belonging to the same set as the second data group except the first k pixel data and the residual data of the pixel data at the same position in the second data group; wherein the residual data of any pixel data is the difference between the pixel data and the compression prediction data of the pixel data; for any pixel data set, the second data group is at least part of the data groups in the pixel data set except the first data group;

[0010] For any data group, the data group is encoded according to the compression data of the data group to obtain an image compression data packet.

[0011] Optionally, for any pixel data set, the pixel data is evenly distributed to x data groups to obtain x data groups corresponding to the pixel data set, including:

[0012] For any pixel data set, the pixel data is distributed according to the rule that each continuous x pixel data is sequentially distributed to x data groups to obtain x data groups corresponding to the pixel data set.

[0013] Optionally, for the i-th pixel data in any second data group, the compression data corresponding to the i-th pixel data in the second data group is determined according to the sum of the number of occupied bits of the difference between the residual data of each pixel data in the first data group belonging to the same set as the second data group except the first k pixel data and the residual data of the pixel data at the same position in the second data group.

[0014] For the i-th pixel data in any second data group, the compression data corresponding to the i-th pixel data in the second data group is determined according to the sum of the number of occupied bits of the difference between the residual data of each pixel data in the first data group belonging to the same set as the second data group except the first k pixel data and the residual data of the pixel data at the same position in the second data group.

[0015] Optionally, for the i-th pixel data in any second data group, the compression data corresponding to the i-th pixel data in the second data group is determined according to the sum of the number of occupied bits of the difference between the residual data of each pixel data in the first data group belonging to the same set as the second data group except the first k pixel data and the residual data of the pixel data at the same position in the second data group.

[0016] If the sum of the number of occupied bits of each difference value between the residual data of each pixel data in the first data group, which belongs to the same pixel data set and is other than the first k pixel data, and the residual data of the pixel data at the same position in the second data group is greater than the sum of the number of occupied bits of the residual data of each pixel data in the second data group other than the first k pixel data, the residual data of the i-th pixel data in the second data group is taken as the compressed data of the i-th pixel data in the second data group for the i-th pixel data in the second data group.

[0017] If the sum of the number of occupied bits of each difference value between the residual data of each pixel data in the first data group, which belongs to the same pixel data set and is other than the first k pixel data, and the residual data of the pixel data at the same position in the second data group is less than or equal to the sum of the number of occupied bits of the residual data of each pixel data in the second data group other than the first k pixel data, the difference value between the residual data of the i-th pixel data in the second data group and the residual data of the i-th pixel data in the first data group is taken as the compressed data of the i-th pixel data in the second data group for the i-th pixel data in the second data group.

[0018] Optionally, x=2.

[0019] The at least part of the pixel data of the original image is divided into a plurality of pixel data sets according to a rule of dividing each xn continuous pixel data into a set, comprising:

[0020] The whole pixel data of the original image is divided into a plurality of pixel data sets according to a rule of dividing each 2n continuous pixel data into a set.

[0021] For any pixel data set, the first data group is a data group composed of the pixel data at the odd positions in the pixel data set, and the second data group is a data group composed of the pixel data at the even positions in the pixel data set.

[0022] Optionally, for the i-th pixel data, the compressed prediction data of the i-th pixel data satisfies the following relationship:

[0023]

[0024] Wherein, m is the number of the data group, X m (i) is the i-th pixel data, X′ m (i) is the compressed prediction data of the i-th pixel data, △(i) is determined according to the (i-1)-th pixel data, the (i-2)-th pixel data and the (i-3)-th pixel data in the data group, and a and b are preset values.

[0025] Optionally, △(i) satisfies the following relationship:

[0026] △(i) = ||X m (i-2)-X m (i-3)|-|X m (i-1)-X m (i-2)||.

[0027] Optionally, encoding according to the compressed data of the data group obtains an image compressed data packet, including:

[0028] Encoding at least part of the compressed data of the data group using an entropy coding table obtains first encoded data;

[0029] Determining the average bit width and the offset bit width of all the first encoded data, and determining the bit width residual according to the average bit width and the offset bit width;

[0030] For any first encoded data, determining the second encoded data corresponding to the first encoded data; wherein the occupied bit number coding in the second encoded data is equal to the occupied bit number coding in the first encoded data minus the bit width residual;

[0031] Putting the second encoded data, the pixel data number of the data group, the average bit width and the offset bit width, and the identification information indicating the generation mode of the compressed data into the image compressed data packet.

[0032] Optionally, determining the compressed data of the i-th pixel data of the first data group according to the compressed prediction data of the i-th pixel data of the first data group, including:

[0033] Taking the residual data of the i-th pixel data in the first data group as the compressed data of the i-th pixel data in the first data group.

[0034] In a second aspect, based on the same inventive concept, the embodiments of the present application further provide an image decompression method, including:

[0035] Obtaining at least one image compressed data packet corresponding to an original image;

[0036] Decompressing any image compressed data packet to obtain pixel data;

[0037] Generating the original image according to the pixel data obtained by decompressing each image compressed data packet;

[0038] Wherein, for any image compressed data packet, the pixel data is obtained by decompressing through the following steps:

[0039] Determining each compressed data based on the image compressed data packet; wherein at least part of the compressed data is determined according to the encoded data in the image compressed data packet;

[0040] determining the jth compressed data as the jth pixel data; wherein j is a positive integer smaller than i;

[0041] determining the compression mode of the compressed data according to the identification information in the image compressed data packet, and determining the compression prediction data of the ith pixel data according to the ith compressed data and the pixel data corresponding to the k compressed data before the ith compressed data corresponding to the ith compressed data in the image compressed data packet using the compression mode; wherein i is a positive integer greater than k and smaller than or equal to n, n is the number of encoded data in the image compressed data packet, and k is a positive integer;

[0042] determining whether the image compressed data packet corresponds to the first data group or the second data group;

[0043] if the image compressed data packet corresponds to the second data group, determining the pixel data corresponding to the ith compressed data in the second data group according to the compression prediction data of the ith pixel data in the second data group, the ith compressed data in the second data group, and the ith compressed data in the first data group corresponding to the same pixel data set as the second data group;

[0044] if the image compressed data packet corresponds to the first data group, determining the pixel data corresponding to the ith compressed data in the first data group according to the compression prediction data of the ith pixel data in the first data group and the ith compressed data in the first data group.

[0045] Optionally, determining the pixel data corresponding to the ith compressed data in the second data group according to the compression prediction data of the ith pixel data in the second data group, the ith compressed data in the second data group, and the ith compressed data in the first data group corresponding to the same pixel data set as the second data group specifically includes:

[0046] if the compression mode of the compressed data determined according to the identification information in the image compressed data packet is the first compression mode, determining the pixel data corresponding to the ith compressed data in the second data group according to the compression prediction data of the ith pixel data in the second data group, the ith compressed data in the second data group, and the ith compressed data in the first data group corresponding to the same pixel data set as the second data group;

[0047] When it is determined according to the identification information in the image compression data packet that the compression manner of the compressed data is the second compression manner, the pixel data corresponding to the i-th compressed data of the second data group is determined according to the compression prediction data of the i-th pixel data of the second data group, and the i-th compressed data of the second data group.

[0048] Optionally, the pixel data corresponding to the i-th compressed data of the second data group is determined according to the compression prediction data of the i-th pixel data of the second data group, the i-th compressed data of the second data group, and the i-th compressed data in a first data group which belongs to the same pixel data set as the second data group.

[0049] When it is determined according to the identification information in the image compression data packet that the compression manner of the compressed data is the first compression manner, the pixel data corresponding to the i-th compressed data of the second data group is obtained by adding the compression prediction data of the i-th pixel data of the second data group and the i-th compressed data in a first data group which belongs to the same pixel data set as the second data group, and then subtracting the i-th compressed data of the second data group.

[0050] When it is determined according to the identification information in the image compression data packet that the compression manner of the compressed data is the second compression manner, the pixel data corresponding to the i-th compressed data of the second data group is obtained by adding the compression prediction data of the i-th pixel data of the second data group and the i-th compressed data of the second data group.

[0051] Optionally, the compression prediction data of the i-th pixel data of the first data group is determined according to the i-th pixel data of the first data group and the k consecutive pixel data before the i-th pixel data of the first data group by using the compression manner.

[0052] If the compression manner is the first compression manner, the compression prediction data of the i-th pixel data of the second data group is:

[0053]

[0054] If the compression manner is the second compression manner, the compression prediction data of the i-th pixel data of the second data group is:

[0055]

[0056] If the compression manner is the third compression manner, the compression prediction data of the i-th pixel data of the second data group is:

[0057] X′ m (i) = 2X m (i-1) - X m (i-2)

[0058] wherein m is the number of the data group, X m (i) is the i-th pixel data, X′ m (i) is the compression prediction data of the i-th pixel data.

[0059] Optionally, determining each compression data based on the image compression data packet comprises:

[0060] acquiring the identification information, the average bit width and the offset bit width, and the number of pixel data from the image compression data packet;

[0061] according to the number of pixel data, sequentially acquiring second encoding data from the image compression data packet;

[0062] determining a bit width residual according to the average bit width and the offset bit width of the encoding data;

[0063] for any second encoding data, determining first encoding data corresponding to the second encoding data according to the bit width residual; wherein the occupied bit number coding in the first encoding data is equal to the occupied bit number coding in the second encoding data plus the bit width residual;

[0064] for any first encoding data, using an entropy coding table to determine compression data corresponding to the first encoding data.

[0065] Optionally, determining pixel data corresponding to the i-th compression data of the first data group based on the compression prediction data of the i-th pixel data of the first data group and the i-th compression data of the first data group comprises:

[0066] adding the compression prediction data of the i-th pixel data of the first data group and the i-th compression data of the first data group to obtain the pixel data corresponding to the i-th compression data of the first data group.

[0067] In a third aspect, based on the same inventive concept, the present application also provides an image compression device, comprising:

[0068] a grouping module, configured to divide at least part of continuous pixel data of an original image into a plurality of pixel data sets according to a rule that each xn continuous pixel data is a set, and for any pixel data set, equally allocate the pixel data to x data groups to obtain x data groups corresponding to the pixel data set; wherein n is a positive integer greater than k, k is a positive integer, and x is a positive integer greater than 1;

[0069] a prediction module configured to determine, for any i-th pixel data in any data group, a compression prediction data of the i-th pixel data according to the i-th pixel data and k pixel data before the i-th pixel data in the data group, wherein i is a positive integer greater than k and less than or equal to n;

[0070] a first compression module configured to, for any j-th pixel data in any data group, take the j-th pixel data as compression data corresponding to the j-th pixel data, wherein j is a positive integer less than the minimum value of i;

[0071] a second compression module configured to, for any i-th pixel data in any first data group, determine compression data of the i-th pixel data in the first data group according to the compression prediction data of the i-th pixel data in the first data group, wherein, for any pixel data set, the first data group is one of the data groups in the pixel data set;

[0072] a third compression module configured to, for any i-th pixel data in any second data group, determine compression data corresponding to the i-th pixel data in the second data group according to a difference between residual data of each pixel data in a first data group belonging to the same set as the second data group and excluding the first k pixel data and residual data of a pixel data at the same position in the second data group, wherein the residual data of any pixel data is a difference between the pixel data and compression prediction data of the pixel data, and, for any pixel data set, the second data group is at least part of the data groups in the pixel data set other than the first data group;

[0073] an encoding module configured to, for any data group, encode the compression data of the data group to obtain an image compression data packet.

[0074] In a fourth aspect, based on the same inventive concept, the present application provides an image decompression device, comprising:

[0075] an acquisition module configured to acquire at least one image compression data packet corresponding to an original image;

[0076] a decompression module configured to decompress any image compression data packet to obtain pixel data;

[0077] a restoration module configured to generate the original image according to the pixel data obtained by decompressing each image compression data packet;

[0078] wherein, for any image compression data packet, the pixel data is obtained by decompressing the image compression data packet through the following steps:

[0079] determining each compression data based on the image compression data packet, wherein at least part of the compression data is determined based on encoding data in the image compression data packet.

[0080] For the jth compressed data, the jth compressed data is determined as the jth pixel data; wherein j is a positive integer less than the minimum value of i;

[0081] For the ith compressed data, a compression mode of the compressed data is determined according to the identification information in the image compression data packet, and a compression prediction data of the ith pixel data is determined by using the compression mode and according to the ith compressed data and pixel data corresponding to the k compressed data before the ith compressed data corresponding to the ith compressed data of the image compression data packet; wherein i is a positive integer greater than k and less than or equal to n, n is the number of encoded data in the image compression data packet, and k is a positive integer;

[0082] It is judged whether the image compression data packet corresponds to a first data group or a second data group;

[0083] If the image compression data packet corresponds to the second data group, for the ith compressed data in the second data group, pixel data corresponding to the ith compressed data of the second data group is determined according to a compression prediction data of the ith pixel data of the second data group, the ith compressed data of the second data group and the ith compressed data corresponding to the first data group belonging to the same pixel data set as the second data group;

[0084] If the image compression data packet corresponds to the first data group, for the ith compressed data in the first data group, pixel data corresponding to the ith compressed data of the first data group is determined according to a compression prediction data of the ith pixel data of the first data group and the ith compressed data of the first data group.

[0085] In a fifth aspect, based on the same inventive concept, the embodiments of the present application also provide an electronic device, comprising: a processor and a memory for storing instructions executable by the processor;

[0086] The processor is configured to execute the instructions to implement the image compression method of the first aspect, or implement the image decompression method of the second aspect.

[0087] In a sixth aspect, based on the same inventive concept, the embodiments of the present application also provide an electronic device, comprising an application specific integrated circuit, which is used to implement the image compression method of the first aspect, or implement the image decompression method of the second aspect.

[0088] In a seventh aspect, based on the same inventive concept, the embodiments of the present application also provide a computer readable storage medium, which stores a computer program, the computer program being used to implement the image compression method of the first aspect, or implement the image decompression method of the second aspect.

[0089] The present application has the following advantages:

[0090] The image compression and decompression method, device, equipment and computer readable storage medium provided by the embodiment of the present application can further compress the pixel data of the second data group by referring to the color rule of the pixel data of the first data group, thereby better compressing the data amount. BRIEF DESCRIPTION OF DRAWINGS

[0091] Figure 1 One of the flowcharts of the image compression method provided by the embodiment of the present application;

[0092] Figure 2 The pixel distribution schematic diagram of the image in Bayer format;

[0093] Figure 3 The second flowchart of the image compression method provided by the embodiment of the present application;

[0094] Figure 4 The structure schematic diagram of the image compression data packet provided by the embodiment of the present application;

[0095] Figure 5 The flowchart of the image decompression method provided by the embodiment of the present application;

[0096] Figure 6 One of the partial flowcharts of the image decompression method provided by the embodiment of the present application;

[0097] Figure 7 The second partial flowchart of the image decompression method provided by the embodiment of the present application;

[0098] Figure 8 The structure schematic diagram of the image compression device provided by the embodiment of the present application;

[0099] Figure 9 The structure schematic diagram of the image decompression device provided by the embodiment of the present application;

[0100] Figure 10 One of the structure schematic diagrams of the electronic equipment provided by the embodiment of the present application;

[0101] Figure 11 The second structure schematic diagram of the electronic equipment provided by the embodiment of the present application. DETAILED DESCRIPTION

[0102] In order to make the above objectives, characteristics and advantages of the present application more apparent, comprehensible and easier to understand, the present application will be further described below in conjunction with the accompanying drawings and embodiments. However, the example embodiments can be implemented in various forms, and should not be understood as being limited to the embodiments set forth herein; on the contrary, these embodiments are provided so as to make the present application more comprehensive and complete, and to fully convey the ideas of the example embodiments to those skilled in the art. The same reference numerals in the drawings represent the same or similar structures, and thus repeated description thereof will be omitted. The words expressing position and direction described in the present application are described with reference to the drawings, but can be changed as needed, and the changes made are included in the scope of protection of the present application. The drawings of the present application are only used to illustrate the relative positional relationship and do not represent the true proportions.

[0103] It should be noted that specific details are set forth in the following description in order to provide a thorough understanding of the present application. However, the present application can be practiced in a variety of ways beyond those described herein, which can be apparent to those skilled in the art without departing from the spirit of the present application. Therefore, the present application is not limited by the specific embodiments disclosed below. The subsequent description of the specification is for the preferred embodiments of the present application, and is intended to illustrate the general principles of the present application, and is not intended to limit the scope of the present application. The scope of protection of the present application is defined by the appended claims.

[0104] The image compression and decompression method, device, equipment and computer readable storage medium provided by the embodiments of the present application will be described in detail below in conjunction with the accompanying drawings.

[0105] In a first aspect, the embodiments of the present application provide an image compression method. As shown in Figure 1 , the method comprises:

[0106] S110, at least part of the continuous pixel data of the original image is divided into a plurality of pixel data sets according to the rule of dividing each xn continuous pixel data into a set.

[0107] In the implementation process, the process of dividing the pixel data set can divide all the pixel data sets in one time for the pixel data that needs to be compressed by using the image compression method provided by the embodiment of the present application; or xn consecutive pixel data is obtained each time to divide a pixel data set and perform the subsequent step for compression, xn consecutive pixel data is obtained again to divide a pixel data set and perform the subsequent step for compression after the compression process of the pixel data set is completed, and the process is repeated until all the pixel data that needs to be compressed by using the present scheme is completed, and the dynamic process of variable division and variable compression is realized. When the original image is compressed, only part of the pixel data can be compressed by using the image compression method provided by the embodiment of the present application, or all the pixel data of the original image can be compressed by using the image compression method provided by the embodiment of the present application.

[0108] S120, for any pixel data set, the pixel data is evenly distributed to x data groups, and x data groups corresponding to the pixel data set are obtained.

[0109] Wherein, n is a positive integer greater than k, k is a positive integer, and x is a positive integer greater than 1.

[0110] In this way, each data group will include n pixel data.

[0111] S130, for the i-th pixel data in any data group, the compression prediction data of the i-th pixel data is determined according to the i-th pixel data in the data group and the continuous k pixel data before the i-th pixel data in the data group.

[0112] Wherein, i is a positive integer greater than k and less than or equal to n.

[0113] S140, for the j-th pixel data in any data group, the j-th pixel data is taken as the compression data corresponding to the j-th pixel data.

[0114] Wherein, j is a positive integer less than the minimum value of i.

[0115] S150, for the i-th pixel data in any first data group, the compression data of the i-th pixel data in the first data group is determined according to the compression prediction data of the i-th pixel data in the first data group.

[0116] Wherein, for any pixel data set, the first data group is one of the data groups in the pixel data set.

[0117] In the implementation process, the embodiment of the present application does not make too many restrictions on which data group in the pixel data set is selected as the first data group. For example, when x=2, either of the two data groups corresponding to the pixel data set can be selected as the first data group. Since one of the functions of the first data group will be described later, that is, to provide a reference for the compression process of the pixel data of the second data group, in order to compress all the pixel data of the original image with the maximum efficiency, the data group generated first in the allocation order is preferably the first data group. For example, when x=2, two data groups are obtained according to the rule of grouping the pixel data according to the position parity, and the data group in which the pixel data at the odd position in the original image is located is selected as the first data group.

[0118] In S160, for the i-th pixel data in any second data group, the compression data corresponding to the i-th pixel data in the second data group is determined according to the difference between the residual data of each pixel data in the first data group belonging to the same set as the second data group except for the first k pixel data and the residual data of the pixel data at the same position in the second data group.

[0119] wherein the residual data of any pixel data is the difference between the pixel data and the compression prediction data of the pixel data, that is:

[0120] △ X m (i) = X m (i) - X' m (i)

[0121] wherein m is the number of the data group, X m (i) is the i-th pixel data, X' m (i) is the compression prediction data of the i-th pixel data, ΔX m (i) is the residual data of the i-th pixel data.

[0122] For any pixel data set, the second data group is at least part of the data groups in the pixel data set except for the first data group. For example, after the pixel data in the pixel data set is divided into three data groups through the step S120, after one of the data groups is determined as the first data group, the remaining two data groups can be set as the second data group; or one of the remaining two data groups is set as the second data group, and the other data group is neither the first data group nor the second data group, and then the compression scheme for the data group will use other existing technologies for compression. Since this is not the focus of the embodiment of the present application, it will not be described here.

[0123] For any pixel data X2(i) in the second data group other than the first k pixels, the difference △X(i) between the residual data △X1(i) of the pixel data X1(i) at the same position in the first data group (which belongs to the same set as the second data group) and the residual data △X2(i) of the pixel data X2(i) in the second data group is:

[0124] △ X(i)= △ X1(i)- △ X2(i)

[0125] By determining the difference in the residual data of pixels at the same position in two data groups excluding the first k pixels, respectively ( △ X(i min ), ... △ X(n)), and then based on the numerical values ​​of these differences, determine the compressed data of each pixel in the second data group except for the first k pixels.

[0126] S170. For any data group, encode the compressed data of the data group to obtain an image compressed data packet.

[0127] It should be noted that the order of the above steps is only illustrative, and there is no strict order requirement between some steps, as long as it is reasonable. For example, the order of steps S150 and S160 can be interchanged; or, for example, step S170 can be executed after step S150, and then step S160 can be executed after step S170.

[0128] Thus, by using the image compression scheme provided in this embodiment of the invention, after grouping the pixel data of the original image, the compression data of the second data group is determined based on the difference between the residual data of the pixel data of the second data group and the residual data of the pixel data of the first data group. This allows for further compression of the pixel data of the second data group by referring to the color rules of the pixel data of the first data group, thereby better compressing the data volume.

[0129] In specific implementation, the method of evenly distributing xn pixel data in a pixel data set to x data groups in step S120 can be set according to actual needs. Several feasible implementation methods are given below as examples. Of course, other distribution methods not mentioned in the examples are also feasible, and the embodiments of the present invention will not elaborate further.

[0130] That is, step S120, which involves evenly distributing the pixel data into x data groups for any pixel data set to obtain x data groups corresponding to the pixel data set, specifically includes:

[0131] According to the rule that each continuous y pixel data is allocated to one data group, the pixel data is sequentially allocated to the data groups in the order of the data groups, to obtain x data groups corresponding to the pixel data set.

[0132] In the implementation process, according to different values of y, the following cases can be specifically included:

[0133] (1) y = n

[0134] That is, the step S120 specifically includes: for any pixel data set, the pixel data is allocated to the data groups without repetition according to the rule that each continuous n pixel data is allocated to one data group, to obtain x data groups corresponding to the pixel data set.

[0135] For example, y = n = 8, x = 3, and the pixel data of a certain pixel data set is sequentially A, B, …, X. Then, after the allocation according to the above rule, the pixel data in the three data groups is respectively:

[0136] Data group A: A, B, C, D, E, F, G, H

[0137] Data group B: I, J, K, L, M, N, O, P

[0138] Data group C: Q, R, S, T, U, V, W, X

[0139] (2) 1 < y < n

[0140] That is, the step S120 specifically includes: for any pixel data set, the pixel data is sequentially allocated to the data groups in the order of the data groups according to the rule that each continuous y pixel data is allocated to one data group, to obtain x data groups corresponding to the pixel data set.

[0141] For example, n = 8, x = 3, y = 2, and the pixel data of a certain pixel data set is sequentially A, B, …, X. Then, after the allocation according to the above rule, the pixel data in the three data groups is respectively:

[0142] Data group A: A, B, G, H, M, N, S, T

[0143] Data group B: C, D, I, J, O, P, U, V

[0144] Data group C: E, F, K, L, Q, R, W, X

[0145] (3) y = 1

[0146] That is, the step S120 is specifically: for any pixel data set, pixel data is assigned according to the rule that every continuous x pixel data is sequentially assigned to x data groups, so as to obtain x data groups corresponding to the pixel data set.

[0147] For example, n=8, x=3, y=1. The pixel data of a certain pixel data set is sequentially A, B, …, X. Then, after the assignment according to the above rule, the pixel data in the three data groups is respectively:

[0148] Data group A: A, D, G, J, M, P, S, V

[0149] Data group B: B, E, H, K, N, Q, T, W

[0150] Data group C: C, F, I, L, O, R, U, X

[0151] For the compressed prediction data involved in the embodiment of the present application, for the i-th pixel data, the compressed prediction data of the i-th pixel data satisfies the following relationship:

[0152]

[0153] Wherein, m is the number of the data group, X m (i) is the i-th pixel data, X′ m (i) is the compressed prediction data of the i-th pixel data, △(i) is determined according to the (i-1)-th pixel data, the (i-2)-th pixel data and the (i-3)-th pixel data in the data group, a and b are preset values.

[0154] Preferably, a=16, b=32.

[0155] Further, △(i) satisfies the following relationship:

[0156] △(i)=||X m (i-2)-X m (i-3)|-|X m (i-1)-X m (i-2)|

[0157] Of course, it is also possible to determine the compressed prediction data of the pixel data in other ways according to the color rule of the original image, and the above determination scheme is only a relatively optimal scheme provided by the embodiment of the present application, and the embodiment of the present application is not strictly limited.

[0158] Thus, by the compression prediction data calculation method, the change gradient of the pixel data can be determined by using the three pixel data before the current processing pixel data, so as to reflect the change trend of the current processing pixel data compared with the previous pixel data, and the prediction accuracy is high, and the change trend can be used for compression in the subsequent compression process.

[0159] The compression schemes of the first data group and the second data group will be described in detail respectively.

[0160] (I) The first data group

[0161] The step S150 comprises the following steps of:

[0162] The residual data of the i-th pixel data in the first data group is taken as the compression data of the i-th pixel data in the first data group.

[0163] In fact, the residual data reflects the change strength of the change gradient of the adjacent pixel data. For a common image, the residual data of each pixel data generally conforms to the normal distribution rule, and the residual data is mainly distributed in a small numerical range, so as to reduce the data amount of the compressed image data packet.

[0164] (II) The second data group

[0165] The step S160 comprises the following steps of:

[0166] The residual data of the i-th pixel data in the first data group is taken as the compression data of the i-th pixel data in the first data group.

[0167] Specifically, the compression data is determined according to the bit number of the difference value, and any one of the following embodiments can be used, including but not limited to:

[0168] (1) If the total number of occupied bits of each difference value between the residual data of each pixel data in the first data group, except for the first k pixel data, belonging to the same pixel data set and the residual data of the pixel data at the same position in the second data group is less than or equal to a preset threshold value, the residual data of the i-th pixel data in the second data group is taken as the compressed data of the i-th pixel data in the second data group.

[0169] If the total number of occupied bits of each difference value between the residual data of each pixel data in the first data group, except for the first k pixel data, belonging to the same pixel data set and the residual data of the pixel data at the same position in the second data group is greater than the preset threshold value, the difference value between the residual data of the i-th pixel data in the second data group and the residual data of the i-th pixel data in the first data group is taken as the compressed data of the i-th pixel data in the second data group.

[0170] (2) If the total number of occupied bits of each difference value between the residual data of each pixel data in the first data group, except for the first k pixel data, belonging to the same pixel data set and the residual data of the pixel data at the same position in the second data group is greater than the total number of occupied bits of the residual data of each pixel data in the second data group, except for the first k pixel data, the residual data of the i-th pixel data in the second data group is taken as the compressed data of the i-th pixel data in the second data group.

[0171] If the total number of occupied bits of each difference value between the residual data of each pixel data in the first data group, except for the first k pixel data, belonging to the same pixel data set and the residual data of the pixel data at the same position in the second data group is less than or equal to the total number of occupied bits of the residual data of each pixel data in the second data group, except for the first k pixel data, the difference value between the residual data of the i-th pixel data in the second data group and the residual data of the i-th pixel data in the first data group is taken as the compressed data of the i-th pixel data in the second data group.

[0172] For example, there is a pixel data set, including a first data group and a second data group, k=4, n=8. The residual data of each pixel data in the first data group except the first four pixel data is respectively 4, 5, 6, 7, and the residual data of each pixel data in the second data group except the first four pixel data is respectively 3, 4, 5, 6. Then the difference value of the residual data of each pixel data in the corresponding position of the two data groups is 1, 1, 1, 1. Since the total number of bits occupied by each difference value is 4 (the number of bits occupied by the difference value 1 is 1, and the total number of bits occupied by each difference value is 1+1+1+1=4), which is less than the total number of bits occupied by the residual data of the pixel data in the same position in the second data group 11 (the number of bits occupied by the residual data 3 is 2, and the number of bits occupied by the residual data 4, 5, 6 is 3, and the total number of bits occupied by each residual data is 2+3+3+3=11), then each of the difference values 1, 1, 1, 1 is determined as the compressed data of the fifth pixel, the sixth pixel, the seventh pixel, and the eighth pixel in the second data group.

[0173] In this way, by considering the size relationship between the total number of bits occupied by the residual data and the total number of bits occupied by the difference value obtained by again subtracting the residual data, the pixel data is compressed in the manner with smaller total number of bits, thereby further reducing the data amount of the second data group on the basis of the compression scheme of the first data group.

[0174] For the original image in Bayer format, for the pixels in the same row, the pixels of two colors are arranged in an odd-even position order (for example Figure 2 As shown in the case in the first row of pixels, the pixel in the odd position is green (G), and the pixel in the even position is red (R); in the second row of pixels, the pixel in the odd position is blue (B), and the pixel in the even position is green (G)). Then, according to the characteristics of the Bayer format image, the above image compression scheme can be further designed, and the pixel data is grouped and compressed according to the odd-even position, so as to divide the pixel data of the same color into the same data group, thereby constructing the effect that the pixel data in the data group and the pixel data in the same position in different data groups have certain color correlation, so as to facilitate compression.

[0175] Then specifically, x=2 in the above step.

[0176] Correspondingly, the step S110 of grouping the at least part of the pixel data of the original image into a set according to every xn continuous pixel data includes:

[0177] The total pixel data of the original image is grouped into a set according to every 2n continuous pixel data.

[0178] Correspondingly, for any pixel data set, the first data group is composed of pixel data in odd positions in the pixel data set, and the second data group is composed of pixel data in even positions in the pixel data set.

[0179] The following is a specific embodiment given for the compression method of the original image in the Bayer format.

[0180] As shown in Figure 3 , the compression method for the original image in the Bayer format includes:

[0181] S200, judging whether all pixel data of the original image are completed compression process.

[0182] If the result of the step S200 is no, the step S210 is executed; if the result of the step S200 is yes, the compression process is ended.

[0183] S210, obtaining 2n continuous pixel data from the pixel data of the original image as a pixel data set without repetition.

[0184] Wherein n can be set to an integer greater than or equal to 8 and less than or equal to 128 according to actual needs.

[0185] S220, for the pixel data set, the pixel data is evenly distributed to two data groups according to the odd and even positions, to obtain the first data group in which the pixel data in the odd positions of the pixel data set is located and the second data group in which the pixel data in the even positions is located.

[0186] S221, for the pixel data set, the data group is selected in the order of first selecting the first data group and then selecting the second data group.

[0187] For the selected first data group, the step S250 is executed after the step S240; for the selected second data group, the step S261 is executed after the step S240.

[0188] S230, for the jth pixel data in the current data group, the jth pixel data is taken as the compression data corresponding to the jth pixel data.

[0189] Wherein, j∈{1,2,3,4}.

[0190] S240, for the ith pixel data in the current data group, the compression prediction data of the ith pixel data is determined according to the ith pixel data in the data group and the continuous 3 pixel data before the ith pixel data in the data group.

[0191] Wherein i is a positive integer greater than 4 and less than or equal to n.

[0192] For the i-th pixel data, the compressed prediction data of the i-th pixel data satisfies the following relationship:

[0193]

[0194] Δ(i) = ||X m (i-2) - X m (i-3) ||X m (i-1) - X m (i-2) ||

[0195] Wherein m is the number of the data group and m∈{1,2}, X m (i) is the i-th pixel data, X′ m (i) is the compressed prediction data of the i-th pixel data.

[0196] S250, for the i-th pixel data in the first data group, taking the compressed prediction data of the i-th pixel data in the first data group as the compressed data of the i-th pixel data in the first data group. Step S270 is executed.

[0197] S261, calculating the difference value of the residual data of each pixel data in the first data group other than the first four pixel data and the residual data of the pixel data at the same position in the second data group, judging the size relationship between the total number of occupied bits of each of the difference values and the total number of occupied bits of the residual data of each pixel data in the second data group other than the first four pixel data.

[0198] If the total number of occupied bits of each of the difference values is greater than the total number of occupied bits of the residual data of each pixel data in the second data group other than the first four pixel data, step S262 is executed; if the total number of occupied bits of each of the difference values is less than or equal to the total number of occupied bits of the residual data of each pixel data in the second data group other than the first four pixel data, step S263 is executed.

[0199] S262, for the i-th pixel data in the second data group, taking the residual data of the i-th pixel data in the second data group as the compressed data of the i-th pixel data in the second data group. Step S270 is executed.

[0200] S263, for the i-th pixel data in the second data group, taking the difference value of the residual data of the i-th pixel data in the second data group and the residual data of the i-th pixel data in the first data group as the compressed data of the i-th pixel data in the second data group. Step S270 is executed.

[0201] S270, encoding the current data group according to the compressed data of the data group to obtain an image compressed data packet. Return to step S200.

[0202] After the process of compressing the pixel data into compressed data is completed, the compressed data needs to be grouped into a compressed file for storage or transmission.

[0203] Further, as an optional implementation, the step S170, encoding the data group according to the compressed data of the data group to obtain an image compressed data packet, comprises:

[0204] Encoding at least part of the compressed data of the data group using an entropy coding table to obtain first encoded data;

[0205] Putting the first encoded data, the number of pixel data of the data group, and the identification information indicating the generation mode of the compressed data into the image compressed data packet.

[0206] In the specific implementation process, the remaining compressed data of the data group except the first k compressed data can be encoded to obtain the first encoded data, and the first k compressed data is directly put into the corresponding position in the image compressed data packet. For example, the remaining compressed data of the data group except the first 4 compressed data shown in Table 2 is encoded using the entropy coding table of Joint Photographic Experts Group (JPEG) shown in Table 1, and the first encoded data shown in Table 2 will be obtained. (For example, the pixel data X m The compressed data of (9) is 4, and according to the fifth encoding value corresponding to the compressed data 4 with an encoding bit width of 3 shown in Table 1, the binary encoding of the compressed data is 100. The remaining pixel data is the same, and thus is not described again.

[0207] Table 1 baseline entropy coding table of symbol-2 structure

[0208]

[0209]

[0210] Table 2 corresponding table of part of compressed data of a data group and first encoded data

[0211]

[0212] Further, as another optional implementation, the step S170, encoding the data group according to the compressed data of the data group to obtain an image compressed data packet, comprises:

[0213] For any data group, at least part of the compressed data of the data group is encoded using an entropy coding table to obtain first encoded data;

[0214] An average bit width and an offset bit width of all the first encoded data are determined, and a bit width residual is determined according to the average bit width and the offset bit width;

[0215] For any first encoded data, second encoded data corresponding to the first encoded data is determined; wherein the number of occupied bits in the second encoded data is equal to the number of occupied bits in the first encoded data minus the bit width residual;

[0216] The second encoded data, the number of pixel data of the data group, the average bit width and the offset bit width, and identification information for indicating the generation mode of the compressed data are put into an image compression data packet.

[0217] In the specific implementation process, the average bit width is determined in the following manner:

[0218]

[0219] Alternatively,

[0220]

[0221] wherein, w t is the bit width value of the first encoded data in the image compression data packet, t is the serial number of the bit width value, n t is the number of bit width values w t in the first encoded data in the image compression data packet, n0 is the number of pixels encoded in the image compression data packet, p t is the ratio of the number of bit width values w t to the number of pixels n0 encoded in the image compression data packet.

[0222] For example, the data group shown in Table 2 is finally compressed into an image compression data packet, the bit width value 1 is 1, the bit width value 2 is 4, and the bit width value 3 is 3. Then, when the average bit width is rounded down:

[0223]

[0224] The offset bit width w' is determined in the following manner:

[0225]

[0226] Alternatively,

[0227]

[0228] wherein, w minw is the minimum bit width value of the first encoding data in the image compression data packet max w is the maximum bit width value of the first encoding data in the image compression data packet.

[0229] For example, when the image compression data packet is finally generated according to the data group shown in Table 2, wherein the minimum bit width value is 1 and the maximum bit width value is 3. Then if both the average bit width and the offset bit width are rounded down, the offset bit width is:

[0230]

[0231] The bit width residual can be determined in the following way:

[0232]

[0233] Then, the second encoding data corresponding to the data group shown in Table 2 will be as shown in Table 3. Then the second encoding data is put into the corresponding position in the image compression data packet.

[0234] Table 3: Partial compression data and encoding data corresponding table of a certain data group

[0235]

[0236] In this way, by further simplifying the encoding of the occupied bit number in the encoding data, the value of the occupied bit number encoding can be distributed as close to 0 as possible, so as to further reduce the occupied bit number of the encoding when the encoding is converted into binary.

[0237] In addition, for the parity grouping compression scheme described above, the image compression data packet described above can be composed of a structure as shown in Table 4. Figure 4 Table 4: Structure of the image compression data packet

[0238] If the technical solution provided by the embodiment of the present application is applied to an industrial camera or the like, in the communication process between the industrial camera and the connected control device, the transmission of the image can adopt the image compression method described above to compress the original image, and then the obtained plurality of image compression data packets are transmitted in sequence.

[0239] Then, after the step S170, the method further includes (not shown in the figure):

[0240] For any image compression data packet, the image compression data packet is sent to the receiving device.

[0241] In the specific implementation process, the image compression data packet can be sent to the receiving device by using the GigE Vision Streaming Protocol (GVSP), and then the image compression data packet can be constructed as the structure defined by the GVSP.

[0242] In a second aspect, based on the same inventive concept, the embodiment of the present application further provides an image decompression method for decompressing the image compressed by the image compression method of the first aspect into an original image. As shown in Figure 5 , the method includes:

[0243] S310, obtaining at least one image compression data packet corresponding to the original image.

[0244] S320, decompressing any image compression data packet to obtain pixel data.

[0245] S330, generating the original image according to the pixel data obtained by decompressing each image compression data packet.

[0246] For any image compression data packet, as shown in Figure 6 , the pixel data is obtained by decompression through the following steps:

[0247] S321, determining each compression data based on the image compression data packet. At least part of the compression data is determined according to the encoded data in the image compression data packet.

[0248] In the specific implementation process, if only part of the compression data in the image compression data packet is encoded when the image compression data packet is generated, the part of the compression data can be restored according to the encoded data in the compression data packet. If the remaining compression data that is not encoded is not processed after compression, the compression data can be directly obtained from the corresponding position in the image compression data packet (for example, in the embodiment of the first aspect, only the compression data of the remaining pixels except the first k pixels is encoded when encoding, and the compression data of the first k pixels is directly put into the image compression data packet, so that the compression data of the first k pixels can be directly obtained when decompressing).

[0249] S322, for the jth compressed data, determining the jth pixel data as the jth compressed data.

[0250] wherein j is a positive integer less than the minimum value of i.

[0251] S323, for the ith compressed data, determining the compression mode of the compressed data according to the identification information in the image compression data packet, and determining the compression prediction data of the ith pixel data using the compression mode and according to the ith compressed data and the pixel data corresponding to the k compressed data before the ith compressed data corresponding to the ith compressed data in the image compression data packet.

[0252] wherein i is a positive integer greater than k and less than or equal to n, n is the number of encoded data in the image compression data packet, and k is a positive integer.

[0253] S324, determining whether the image compression data packet corresponds to the first data group or the second data group.

[0254] If the image compression data packet corresponds to the first data group, step S325 is performed; if the image compression data packet corresponds to the second data group, step S326 is performed.

[0255] S325, for the ith compressed data in the first data group, determining the pixel data corresponding to the ith compressed data in the first data group according to the compression prediction data of the ith pixel data in the first data group and the ith compressed data in the first data group.

[0256] S326, for the ith compressed data in the second data group, determining the pixel data corresponding to the ith compressed data in the second data group according to the compression prediction data of the ith pixel data in the second data group, the ith compressed data in the second data group, and the ith compressed data corresponding to the first data group belonging to the same pixel data set as the second data group.

[0257] Further, if the first encoded data of the first aspect is put into the image compression data packet in the compression process, step S321 of determining each compressed data based on the image compression data packet specifically includes:

[0258] obtaining the identification information and the number of pixel data from the image compression data packet.

[0259] obtaining the first encoded data from the image compression data packet in sequence according to the number of pixel data;

[0260] for any first encoded data, using an entropy encoding table to determine the compressed data corresponding to the first encoded data.

[0261] Further, if the second encoded data of the first aspect is put into the image compression data packet during the compression process, the step S321 of determining each compressed data based on the image compression data packet specifically comprises:

[0262] Obtaining the identification information, the average bit width and the offset bit width, and the pixel data quantity from the image compression data packet.

[0263] According to the pixel data quantity, sequentially obtaining the second encoded data from the image compression data packet;

[0264] Determining the bit width residual according to the average bit width and the offset bit width of the encoded data.

[0265] For any second encoded data, determining the first encoded data corresponding to the second encoded data according to the bit width residual; wherein the occupied bit number encoding in the first encoded data is equal to the occupied bit number encoding in the second encoded data plus the bit width residual.

[0266] For any first encoded data, determining the compressed data corresponding to the first encoded data using the entropy encoding table.

[0267] In the specific implementation process, the process of restoring the compressed data according to the encoded data is opposite to the process of encoding the compressed data in the compression process of the first aspect, so the corresponding content of the first aspect can be implemented reversely here, which will not be described again.

[0268] In the specific implementation process, if the technical solution provided by the embodiment of the present application is applied to industrial cameras and other devices, in the communication process between the industrial camera and the connected control device, the industrial camera can compress the acquired original image into an image compression data packet using the image compression method as described in the first aspect, and then sequentially send the image compression data packet to the control device.

[0269] Then, if the device performing the image decompression process is the control device, before the step S310, the method further comprises (not shown in the figure):

[0270] Sequentially receiving the image compression data packet.

[0271] In the specific implementation process, the image compression data packet can be sent to the receiving device using the GVSP protocol, so that when the step S321 is executed, the encoded data is extracted according to the structure defined by GVSP.

[0272] The decompression processes of the first data group and the second data group will be described respectively as follows.

[0273] (I) First data group

[0274] Further, for step S325, for the i-th compressed data in the first data group, determining the pixel data corresponding to the i-th compressed data in the first data group based on the compression prediction data of the i-th pixel data in the first data group and the i-th compressed data in the first data group specifically includes:

[0275] The compressed prediction data of the i-th pixel data in the first data group is added to the i-th compressed data in the first data group to obtain the pixel data corresponding to the i-th compressed data in the first data group.

[0276] (II) Second Data Group

[0277] Furthermore, such as Figure 7 As shown, step S326, determining the pixel data corresponding to the i-th compressed data in the second data group based on the compressed prediction data of the i-th pixel data in the second data group, the i-th compressed data in the second data group, and the i-th compressed data in the first data group belonging to the same pixel data set as the second data group, specifically includes:

[0278] S3261. Determine whether the compression method of the compressed data is a first type of compression method or a second type of compression method based on the identification information in the image compression data packet.

[0279] If it is the first type of compression method, proceed to step S3262; if it is the second type of compression method, proceed to step S3263.

[0280] S3262. Determine the pixel data corresponding to the i-th compressed data in the second data group based on the compressed prediction data of the i-th pixel data in the second data group, the i-th compressed data in the second data group, and the i-th compressed data in the first data group that belongs to the same pixel data set as the second data group.

[0281] S3263. Based on the compressed prediction data of the i-th pixel data in the second data group and the i-th compressed data in the second data group, determine the pixel data corresponding to the i-th compressed data in the second data group.

[0282] Furthermore, step S3262 specifically includes:

[0283] Add the compressed prediction data of the i-th pixel data in the second data group to the i-th compressed data in the first data group that belongs to the same pixel data set as the second data group, and then subtract the i-th compressed data in the second data group to obtain the pixel data corresponding to the i-th compressed data in the second data group.

[0284] The step S3263 specifically includes:

[0285] The compressed prediction data of the i th pixel data of the second data group is added to the i th compressed data of the second data group, to obtain pixel data corresponding to the i th compressed data of the second data group.

[0286] Further, in the step S323, the compressed prediction data of the i th pixel data of the first data group is determined according to the i th pixel data of the first data group and the k continuous pixel data before the i th pixel data of the first data group by using the compression mode, and the compressed prediction data of the i th pixel data of the first data group includes:

[0287] If the compression mode is the first compression mode, the compressed prediction data of the i th pixel data of the second data group is:

[0288]

[0289] If the compression mode is the second compression mode, the compressed prediction data of the i th pixel data of the second data group is:

[0290]

[0291] If the compression mode is the third compression mode, the compressed prediction data of the i th pixel data of the second data group is:

[0292] X′ m (i)=2X m (i-1)-X m (i-2)

[0293] Wherein, m is the number of the data group, X m (i) is the i th pixel data, X′ m (i) is the compressed prediction data of the i th pixel data.

[0294] In a third aspect, based on the same inventive concept, the embodiments of the present application also provide an image compression device, as shown in Figure 8 The image compression device includes:

[0295] The grouping module M11 is configured to divide at least part of the continuous pixel data of the original image into a plurality of pixel data sets according to a rule that each xn continuous pixel data is a set, and for any pixel data set, the pixel data is evenly distributed to x data groups, to obtain x data groups corresponding to the pixel data set; wherein n is a positive integer greater than k, k is a positive integer, and x is a positive integer greater than 1.

[0296] a prediction module M12 configured to determine, for any i-th pixel data in any data group, a compression prediction data of the i-th pixel data according to the i-th pixel data and k pixel data before the i-th pixel data in the data group, wherein i is a positive integer greater than k and less than or equal to n;

[0297] a first compression module M13 configured to, for any j-th pixel data in any data group, take the j-th pixel data as compression data corresponding to the j-th pixel data, wherein j is a positive integer less than the minimum value of i;

[0298] a second compression module M14 configured to, for any i-th pixel data in any first data group, determine compression data of the i-th pixel data in the first data group according to the compression prediction data of the i-th pixel data in the first data group, wherein, for any pixel data set, the first data group is one of the data groups in the pixel data set;

[0299] a third compression module M15 configured to, for any i-th pixel data in any second data group, determine compression data corresponding to the i-th pixel data in the second data group according to a difference between residual data of each pixel data in a first data group belonging to the same set as the second data group and excluding the first k pixel data and residual data of a pixel data at the same position in the second data group, wherein the residual data of any pixel data is a difference between the pixel data and compression prediction data of the pixel data, and for any pixel data set, the second data group is at least part of the data groups in the pixel data set other than the first data group;

[0300] an encoding module M16 configured to, for any data group, encode the compression data of the data group to obtain an image compression data packet.

[0301] Optionally, for any pixel data set, pixel data is evenly distributed to x data groups to obtain x data groups corresponding to the pixel data set, including:

[0302] For any pixel data set, pixel data is distributed according to a rule that each continuous x pixel data is sequentially distributed to x data groups to obtain x data groups corresponding to the pixel data set.

[0303] Optionally, the third compression module M15 is specifically configured to:

[0304] For the i-th pixel data in any second data group, according to the sum of the number of occupied bits of each difference value between the residual data of each pixel data in the first data group belonging to the same pixel data set as the second data group except the first k pixel data and the residual data of the pixel data at the same position in the second data group, the compression data corresponding to the i-th pixel data in the second data group is determined.

[0305] Optionally, the third compression module M15 is specifically configured to:

[0306] If the sum of the number of occupied bits of each difference value between the residual data of each pixel data in the first data group belonging to the same pixel data set as the second data group except the first k pixel data and the residual data of the pixel data at the same position in the second data group is greater than the sum of the number of occupied bits of the residual data of each pixel data in the second data group except the first k pixel data, the residual data of the i-th pixel data in the second data group is taken as the compression data of the i-th pixel data in the second data group for the i-th pixel data in the second data group.

[0307] If the sum of the number of occupied bits of each difference value between the residual data of each pixel data in the first data group belonging to the same pixel data set as the second data group except the first k pixel data and the residual data of the pixel data at the same position in the second data group is less than or equal to the sum of the number of occupied bits of the residual data of each pixel data in the second data group except the first k pixel data, the difference value between the residual data of the i-th pixel data in the second data group and the residual data of the i-th pixel data in the first data group is taken as the compression data of the i-th pixel data in the second data group for the i-th pixel data in the second data group.

[0308] Optionally, x=2.

[0309] The at least part of the pixel data of the original image is divided into a plurality of pixel data sets according to the rule of dividing each xn continuous pixel data into a set, including:

[0310] The whole pixel data of the original image is divided into a plurality of pixel data sets according to the rule of dividing each 2n continuous pixel data into a set.

[0311] For any pixel data set, the first data group is a data group composed of the pixel data at the odd positions in the pixel data set, and the second data group is a data group composed of the pixel data at the even positions in the pixel data set.

[0312] Optionally, for the i-th pixel data, the compression prediction data of the i-th pixel data satisfies the following relationship:

[0313]

[0314] wherein m is the number of the data group, X m (i) is the i-th pixel data, X' m (i) is the i-th pixel data, X' (i) is determined according to the (i-1)-th pixel data, the (i-2)-th pixel data and the (i-3)-th pixel data in the data group, a and b are preset values.

[0315] Optionally, Δ(i) satisfies the following relationship:

[0316] Δ(i) = ||X m (i-2)-X m (i-3)|-|X m (i-1)-X m (i-2)||.

[0317] Optionally, the image compression data packet is obtained by encoding the compression data of the data group, comprising:

[0318] encoding at least part of the compression data of the data group using an entropy encoding table to obtain first encoding data;

[0319] determining the average bit width and the offset bit width of all the first encoding data, and determining a bit width residual according to the average bit width and the offset bit width;

[0320] for any first encoding data, determining second encoding data corresponding to the first encoding data; wherein the occupied bit number encoding in the second encoding data is equal to the occupied bit number encoding in the first encoding data minus the bit width residual;

[0321] putting the second encoding data, the number of pixel data of the data group, the average bit width and the offset bit width, and identification information for indicating the generation mode of the compression data into the image compression data packet.

[0322] Optionally, the second compression module M14 is specifically configured to:

[0323] use the residual data of the i-th pixel data in the first data group as the compression data of the i-th pixel data in the first data group.

[0324] In a fourth aspect, based on the same inventive concept, the embodiments of the present application also provide an image decompression device, as shown in Figure 9 The image decompression device comprises:

[0325] an acquisition module M21 configured to acquire at least one image compression data packet corresponding to an original image;

[0326] a decompression module M22 configured to decompress any image compression data packet to obtain pixel data.

[0327] a restoring module M23, configured to generate an original image according to pixel data obtained by decompressing each image compression data packet;

[0328] wherein, for any image compression data packet, the pixel data is obtained by decompressing the image compression data packet through the following steps:

[0329] determining each compression data based on the image compression data packet; wherein at least part of the compression data is determined according to the encoding data in the image compression data packet;

[0330] for the jth compression data, determining the jth compression data as the jth pixel data; wherein j is a positive integer smaller than the minimum value of i;

[0331] for the ith compression data, determining a compression mode of the compression data according to the identification information in the image compression data packet, and determining compression prediction data of the ith pixel data by using the compression mode and according to the ith compression data and pixel data corresponding to the k compression data before the ith compression data corresponding to the ith compression data in the image compression packet; wherein i is a positive integer greater than k and less than or equal to n, n is the number of encoding data in the image compression data packet, and k is a positive integer;

[0332] judging whether the image compression data packet corresponds to a first data group or a second data group;

[0333] if the image compression data packet corresponds to the second data group, for the ith compression data in the second data group, determining pixel data corresponding to the ith compression data in the second data group according to the compression prediction data of the ith pixel data in the second data group, the ith compression data in the second data group and the ith compression data in the first data group corresponding to the same pixel data set as the second data group;

[0334] if the image compression data packet corresponds to the first data group, for the ith compression data in the first data group, determining pixel data corresponding to the ith compression data in the first data group according to the compression prediction data of the ith pixel data in the first data group and the ith compression data in the first data group.

[0335] Optionally, determining pixel data corresponding to the ith compression data in the second data group according to the compression prediction data of the ith pixel data in the second data group, the ith compression data in the second data group and the ith compression data in the first data group corresponding to the same pixel data set as the second data group specifically includes:

[0336] when it is determined according to the identification information in the image compression data packet that the compression manner of the compression data is the first compression manner, determining the pixel data corresponding to the i-th compression data of the second data group according to the compression prediction data of the i-th pixel data of the second data group, the i-th compression data of the second data group and the i-th compression data in the first data group which belongs to the same pixel data set as the second data group;

[0337] when it is determined according to the identification information in the image compression data packet that the compression manner of the compression data is the second compression manner, determining the pixel data corresponding to the i-th compression data of the second data group according to the compression prediction data of the i-th pixel data of the second data group and the i-th compression data of the second data group.

[0338] Optionally, the pixel data corresponding to the i-th compression data of the second data group is determined according to the compression prediction data of the i-th pixel data of the second data group, the i-th compression data of the second data group and the i-th compression data in the first data group which belongs to the same pixel data set as the second data group, and specifically includes:

[0339] when it is determined according to the identification information in the image compression data packet that the compression manner of the compression data is the first compression manner, adding the compression prediction data of the i-th pixel data of the second data group and the i-th compression data in the first data group which belongs to the same pixel data set as the second data group, and then subtracting the i-th compression data of the second data group to obtain the pixel data corresponding to the i-th compression data of the second data group;

[0340] when it is determined according to the identification information in the image compression data packet that the compression manner of the compression data is the second compression manner, adding the compression prediction data of the i-th pixel data of the second data group and the i-th compression data of the second data group to obtain the pixel data corresponding to the i-th compression data of the second data group.

[0341] Optionally, the compression prediction data of the i-th pixel data of the first data group is determined according to the i-th pixel data of the first data group and the k continuous pixel data before the i-th pixel data of the first data group by using the compression manner, and specifically includes:

[0342] when the compression manner is the first compression manner, the compression prediction data of the i-th pixel data of the second data group is:

[0343]

[0344] when the compression manner is the second compression manner, the compression prediction data of the i-th pixel data of the second data group is:

[0345]

[0346] If the compression mode is the third compression mode, the compression prediction data of the i-th pixel data of the second data group is:

[0347] X′ m (i) = 2X m (i-1) - X m (i-2)

[0348] wherein m is the number of the data group, X m (i) is the i-th pixel data, X′ m (i) is the compression prediction data of the i-th pixel data.

[0349] Optionally, determining each compression data based on the image compression data packet comprises:

[0350] obtaining the identification information, the average bit width and the offset bit width, and the number of pixel data from the image compression data packet;

[0351] obtaining second encoding data from the image compression data packet in sequence according to the number of pixel data;

[0352] determining a bit width residual according to the average bit width and the offset bit width of the encoding data;

[0353] for any second encoding data, determining first encoding data corresponding to the second encoding data according to the bit width residual; wherein the number of occupied bits in the first encoding data is equal to the number of occupied bits in the second encoding data plus the bit width residual;

[0354] for any first encoding data, determining compression data corresponding to the first encoding data using an entropy encoding table.

[0355] Optionally, determining pixel data corresponding to the i-th compression data of the first data group according to the compression prediction data of the i-th pixel data of the first data group and the i-th compression data of the first data group comprises:

[0356] adding the compression prediction data of the i-th pixel data of the first data group and the i-th compression data of the first data group to obtain the pixel data corresponding to the i-th compression data of the first data group.

[0357] In several embodiments provided in the present application, it should be understood that the above-described apparatus embodiments are merely illustrative, for example, the division of the modules is merely a logical function division, and actual implementation can have another division manner, for example, a plurality of modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed modules can be indirect coupling or communication connection through some interfaces, devices or modules, and can be electrical, mechanical or other forms.

[0358] The modules described as separate components can or can not be physically separated, and the components displayed as modules can or can not be physical modules, that is, can be located in one place, or can be distributed to a plurality of network modules. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.

[0359] In addition, the functional modules in each embodiment of the present application can be integrated in one processing module, or each module can be physically present alone, or two or more modules can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software functional module. When the integrated module is realized in the form of a software functional module and sold or used as an independent product, it can be stored in a computer readable storage medium.

[0360] Since the specific manner in which each module of the third aspect image compression device / the fourth aspect image decompression device performs the operation has been described in detail in the embodiments of the corresponding first aspect image compression method / the second aspect image decompression method, it will not be repeated here.

[0361] In a fifth aspect, based on the same inventive concept, the embodiments of the present application also provide an electronic device, as shown in the figure, comprising: a processor 110 and a memory 120 for storing instructions executable by the processor 110. Figure 10

[0362] The processor 110 is configured to execute the instructions to implement the image compression method of the first aspect, or implement the image decompression method of the second aspect.

[0363] ​In a specific implementation, the device can have a large difference in configuration or performance, and can include one or more processors 110, memories 120, computer readable storage media 130, one or more application programs 131 or data 132 included in the memories 120 and / or computer readable storage media 130. The memories 120 and / or computer readable storage media 130 can also include one or more operating systems 133, such as Windows, Mac OS, Linux, IOS, Android, Unix, FreeBSD, etc. Among them, the memories 120 and the computer readable storage media 130 can be temporary storage or persistent storage. The application programs 131 can include one or more modules (not shown in the Figure 10 application) described above, and each module can include a series of instruction operations. Further, the processor 110 can be configured to communicate with the computer readable storage medium 130 to execute a series of instruction operations in the computer readable storage medium 130 on the device. The device can also include one or more power supplies (not shown in the Figure 10 application), one or more network interfaces 140 including wired network interfaces 141 and / or wireless network interfaces 142, and one or more input / output interfaces 143.

[0364] In a sixth aspect, embodiments of the present application also provide an electronic device including an application specific integrated circuit (ASIC) used to implement the image compression method according to the first aspect or the image decompression method according to the second aspect.

[0365] In a specific implementation, the ASIC can be designed based on a complex programmable logic device (CPLD) or a field programmable gate array (FPGA) device, etc. according to actual needs. The ASIC code for executing the image compression / decompression method provided by the embodiments of the present application can be written in any combination of one or more hardware description languages, such as Verilog HDL, VHDL, System Verilog, etc.

[0366] For example, the electronic device for implementing the image compression method according to the first aspect can be an industrial camera that acquires and transmits an image after compression to a control device connected at the other end. The circuit including a FPGA design in the industrial camera can be as Figure 11As shown, the circuit function modules include:

[0367] A packet data request module M31 is configured to extract image data of a complete packet length from a double data rate (DDR) memory according to the negotiated GVSP packet length.

[0368] A data prediction module M32 is configured to calculate compression prediction data and residual error of pixel data.

[0369] A data encoding module M33 is configured to calculate compression data of pixel data, calculate required encoding data bit width, and encode the compression data.

[0370] A data statistics module M34 is configured to be responsible for statistics of effective data length of GVSP original data after encoding, and to be used as effective data length of a GVSP data packet.

[0371] A GVSP packet module M35 is configured to be responsible for composing image compression data packets according to GVSP packet format, by using GVSP packet header information, encoding data, and effective data length information.

[0372] A sending module M36 is configured to send the image compression data packets to a receiving device.

[0373] Since the current main popular lossless compression algorithms, such as JPEG-LS, LZ77, RLE and the like, need to perform probability type statistics on data, need to repeatedly scan the data, and the data compression process can cause a long delay from the camera trigger to the image acquisition, the image data cannot meet the low delay requirement in the industrial detection field. The data transmission of the Ethernet industrial camera is based on the IPV4 / UDP Ethernet transmission protocol, and the image data is packaged according to the data packet of the GVSP protocol standard. The compressed data can also be transmitted through GVSP. Since the existing lossless compression algorithms are mostly based on multi-row pixels for pixel prediction and residual coding of the entire image. In the pixel prediction algorithm, most of them are based on correlation for prediction, and need to refer to the pixels of the previous row or the surrounding pixels, for example, JPEG-LS, CALIC algorithm and the like. When decoding the compressed image on the receiving side, the complete data needs to be received to normally decode; considering that there are problems such as packet loss, retransmission, packet loss and the like in the network transmission process, the waiting delay of the receiving side can be large, which seriously affects the performance of the system. In this way, the image compression and decompression method provided by the embodiment of the application is adopted, and the image compression process is realized by the pipeline form of ASIC, and the timing delay of hardware can be basically ignored. Correspondingly, for the control device of the receiving end, when the circuit based on ASIC designed for realizing the image decompression method of the second aspect is used for image decompression, only one complete message needs to be buffered, and the decoding is completed, and the data transmission and receiving process is completed. Therefore, the entire data transmission process only increases the delay of one data message decoding. And the scheme provided by the embodiment of the application can reduce the length of the data message, thereby further reducing the delay of the data transmission time.

[0374] The embodiment of the application further provides a computer readable storage medium, the computer readable medium stores a computer program, the computer program is used for realizing the image compression method as described in the first aspect, or realizing the image decompression method as described in the second aspect.

[0375] The image compression and decompression method, device, equipment and computer readable storage medium provided by the embodiment of the application can further compress the pixel data of the second data group by referring to the color law of the pixel data of the first data group, thereby better compressing the data amount.

[0376] Those skilled in the art will appreciate that embodiments of the present application can be devised for a variety of other systems which are currently developed or later developed. Therefore, the present application is intended to cover all such modifications and variations of this application that are within the scope of the appended claims and their equivalents. It is intended that each element of claim 1 and 2 is independent of one another. No element of claim 1 and 2, or any other claim, is implied to depend on any other element or limitation of claim 1 and 2 or any other claim except where expressly recited in that claim.

[0377] The present application is described in reference to the flowchart and / or block diagrams of the method, apparatus (system) and computer program product according to this application. It will be understood that each block of the flowchart and / or block diagrams, and combinations of blocks in the flowchart and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.

[0378] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.

[0379] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks. Figure 1 one or more functions specified in the flowchart and / or block diagram block or blocks.

[0380] Obviously, numerous modifications and variations of the present application are possible in light of the above teachings. It is therefore to be understood that within the scope of the appended claims and their equivalents, the application can be practiced otherwise than as specifically described.

Claims

1. An image compression method characterized by, The method comprises the following steps: Divide the at least partially continuous pixel data of the original image into a plurality of pixel data sets according to a rule of dividing each xn continuous pixel data into a set, and for any pixel data set, divide the pixel data into x data groups in an equal manner to obtain x data groups corresponding to the pixel data set; wherein n is a positive integer greater than k, k is a positive integer, and x is a positive integer greater than 1; For the ith pixel data in any data group, determine the compression prediction data of the ith pixel data according to the ith pixel data in the data group and the continuous k pixel data before the ith pixel data in the data group; Wherein i is a positive integer greater than k and less than or equal to n; For the jth pixel data in any data group, take the jth pixel data as the compression data corresponding to the jth pixel data; Wherein j is a positive integer less than the minimum value of i; For the ith pixel data in any first data group, determine the compression data of the ith pixel data in the first data group according to the compression prediction data of the ith pixel data in the first data group; wherein for any pixel data set, the first data group is one of the data groups in the pixel data set; For the ith pixel data in any second data group, determine the compression data corresponding to the ith pixel data in the second data group according to the difference between the residual data of each pixel data in the first data group belonging to the same set as the second data group and excluding the first k pixel data and the residual data of the pixel data at the same position in the second data group; Wherein the residual data of any pixel data is the difference between the pixel data and the compression prediction data of the pixel data; for any pixel data set, the second data group is at least part of the data groups in the pixel data set except the first data group; For any data group, encode the compression data of the data group to obtain an image compression data packet.

2. The method of claim 1, wherein, For any pixel data set, divide the pixel data into x data groups in an equal manner to obtain x data groups corresponding to the pixel data set, which comprises: For any pixel data set, divide the pixel data according to a rule of sequentially assigning each continuous x pixel data to x data groups to obtain x data groups corresponding to the pixel data set.

3. The method of claim 1, wherein, For the ith pixel data in any second data group, determine the compression data corresponding to the ith pixel data in the second data group according to the difference between the residual data of each pixel data in the first data group belonging to the same set as the second data group and excluding the first k pixel data and the residual data of the pixel data at the same position in the second data group, which comprises: For the ith pixel data in any second data group, determine the compression data corresponding to the ith pixel data in the second data group according to the total number of occupied bits of the difference between the residual data of each pixel data in the first data group belonging to the same pixel data set as the second data group and excluding the first k pixel data and the residual data of the pixel data at the same position in the second data group.

4. The method of claim 3, wherein, The compression data corresponding to the i-th pixel data in the second data group is determined according to the sum of the bit numbers of the differences between the residual data of each pixel data in the first data group, except the first k pixel data, belonging to the same pixel data set as the second data group and the residual data of the pixel data at the same position in the second data group, including: If the sum of the bit numbers of the differences between the residual data of each pixel data in the first data group, except the first k pixel data, belonging to the same pixel data set as the second data group and the residual data of the pixel data at the same position in the second data group is greater than the sum of the bit numbers of the residual data of each pixel data in the second data group, except the first k pixel data, the residual data of the i-th pixel data in the second data group is taken as the compression data of the i-th pixel data in the second data group; If the sum of the bit numbers of the differences between the residual data of each pixel data in the first data group, except the first k pixel data, belonging to the same pixel data set as the second data group and the residual data of the pixel data at the same position in the second data group is less than or equal to the sum of the bit numbers of the residual data of each pixel data in the second data group, except the first k pixel data, the difference between the residual data of the i-th pixel data in the second data group and the residual data of the i-th pixel data in the first data group is taken as the compression data of the i-th pixel data in the second data group.

5. The method of claim 2, wherein, x=2; The at least part of the pixel data of the original image is divided into a plurality of pixel data sets according to the rule of dividing each xn continuous pixel data into a set, including: The whole pixel data of the original image is divided into a plurality of pixel data sets according to the rule of dividing each 2n continuous pixel data into a set; For any pixel data set, the first data group is composed of the pixel data at the odd positions in the pixel data set, and the second data group is composed of the pixel data at the even positions in the pixel data set.

6. The method of claim 1, wherein, For the i-th pixel data, the compression prediction data of the i-th pixel data satisfies the following relationship: Δ(i) = ||X m (i-2) - X m (i-3) | | X m (i-1) - X m (i-2) || wherein m is the number of the data group, X m (i) is the i-th pixel data, X ′ m (i) is the i-th pixel data, X 7. The method of claim 1, wherein, Encoding is performed according to the compression data of the data group to obtain an image compression data packet, including: At least part of the compression data of the data group is encoded using an entropy coding table to obtain first encoding data; The average bit width and the offset bit width of all the first encoding data are determined, and the bit width residual is determined according to the average bit width and the offset bit width; For any first encoding data, the second encoding data corresponding to the first encoding data is determined; wherein the occupied bit number coding in the second encoding data is equal to the occupied bit number coding in the first encoding data minus the bit width residual; The second encoding data, the number of pixel data of the data group, the average bit width and the offset bit width, and the identification information for indicating the generation mode of the compression data are put into the image compression data packet.

8. The method of claim 1, wherein, Determining compressed data of the i-th pixel data of the first data set according to the compression prediction data of the i-th pixel data of the first data set comprises: Taking residual data of the i-th pixel data in the first data set as the compressed data of the i-th pixel data in the first data set.

9. An image decompression method characterized by, Comprises: Obtaining at least one image compression data packet corresponding to the original image; Decompressing any image compression data packet to obtain pixel data; Generating the original image according to the pixel data obtained by decompressing each image compression data packet; Wherein, for any image compression data packet, the pixel data is obtained by decompressing through the following steps: Determining each compressed data based on the image compression data packet; wherein at least part of the compressed data is determined according to the encoding data in the image compression data packet; For the j-th compressed data, the j-th compressed data is determined as the j-th pixel data; wherein j is a positive integer smaller than the minimum value of i; For the i-th compressed data, determining the compression mode of the compressed data according to the identification information in the image compression data packet, and determining the compression prediction data of the i-th pixel data by using the compression mode and according to the i-th compressed data of the image compression data packet and the pixel data corresponding to the previous k compressed data of the i-th compressed data; wherein i is a positive integer greater than k and less than or equal to n, n is the number of encoding data in the image compression data packet, and k is a positive integer; Judging whether the image compression data packet corresponds to the first data set or the second data set; If the image compression data packet corresponds to the second data set, then for the i-th compressed data in the second data set, the pixel data corresponding to the i-th compressed data of the second data set is determined according to the compression prediction data of the i-th pixel data of the second data set, the i-th compressed data of the second data set, and the i-th compressed data of the first data set belonging to the same pixel data set as the second data set; If the image compression data packet corresponds to the first data set, then for the i-th compressed data in the first data set, the pixel data corresponding to the i-th compressed data of the first data set is determined according to the compression prediction data of the i-th pixel data of the first data set and the i-th compressed data of the first data set.

10. The method of claim 9, wherein, Determining the pixel data corresponding to the i-th compressed data of the second data set according to the compression prediction data of the i-th pixel data of the second data set, the i-th compressed data of the second data set, and the i-th compressed data in the first data set belonging to the same pixel data set as the second data set comprises: When the compression mode of the compressed data is determined to be the first type of compression mode according to the identification information in the image compression data packet, the pixel data corresponding to the i-th compressed data of the second data set is determined according to the compression prediction data of the i-th pixel data of the second data set, the i-th compressed data of the second data set, and the i-th compressed data in the first data set belonging to the same pixel data set as the second data set. When the compression method of the compressed data is determined to be the second type of compression method based on the identification information in the image compressed data packet, the pixel data corresponding to the i-th compressed data in the second data group is determined based on the compression prediction data of the i-th pixel data in the second data group and the i-th compressed data in the second data group.

11. The method of claim 10, wherein, Based on the compressed prediction data of the i-th pixel data in the second data group, the i-th compressed data in the second data group, and the i-th compressed data in the first data group belonging to the same pixel data set as the second data group, the pixel data corresponding to the i-th compressed data in the second data group is determined, specifically including: When the compression method of the compressed data is determined to be the first type of compression method based on the identification information in the image compressed data packet, the compression prediction data of the i-th pixel data of the second data group is added to the i-th compressed data in the first data group that belongs to the same pixel data set as the second data group, and then the i-th compressed data of the second data group is subtracted to obtain the pixel data corresponding to the i-th compressed data of the second data group. When the compression method of the compressed data is determined to be the second type of compression method based on the identification information in the image compressed data packet, the compression prediction data of the i-th pixel data of the second data group and the i-th compressed data of the second data group are added together to obtain the pixel data corresponding to the i-th compressed data of the second data group.

12. The method of claim 9, wherein, The compression prediction data for the i-th pixel in the first data group is determined using the compression method and based on the i-th pixel data in the first data group and the k consecutive pixels preceding the i-th pixel data in the first data group, including: If the compression method is the first compression method, then the compressed prediction data of the i-th pixel data in the second data group is: If the compression method is the second compression method, then the compressed prediction data of the i-th pixel data in the second data group is: If the compression method is the third compression method, then the compressed prediction data of the i-th pixel data in the second data group is: X ′ m (i) = 2X m (i-1) - X m (i-2) where m is the number of the data group, X m (i) is the i-th pixel data, X ′ m (i) is the compressed prediction data of the i-th pixel data.

13. The method of claim 9, wherein, Based on the image compression data packet, each compressed data item is determined to include: The identification information, average bit width, offset bit width, and number of pixel data are obtained from the image compression data packet; Based on the number of pixel data, the second encoded data is sequentially obtained from the image compression data packet; The bit width residual is determined based on the average bit width and offset bit width of the encoded data; For any second encoded data, the first encoded data corresponding to the second encoded data is determined according to the bit width residual; wherein the bit-occupying bit code in the first encoded data is equal to the bit-occupying bit code in the second encoded data plus the bit width residual; For any of the first encoded data, the compressed data corresponding to the first encoded data is determined using an entropy encoding table.

14. The method of claim 9, wherein, Based on the compressed prediction data of the i-th pixel data in the first data group and the i-th compressed data in the first data group, the pixel data corresponding to the i-th compressed data in the first data group is determined, including: Add the compression prediction data of the i-th pixel data of the first data group to the i-th compressed data of the first data group to obtain pixel data corresponding to the i-th compressed data of the first data group.

15. An image compression apparatus characterized by comprising: Comprise: The grouping module is used for dividing at least part of continuous pixel data of an original image into a plurality of pixel data sets according to a rule of dividing each xn continuous pixel data into a set, and for any pixel data set, pixel data is evenly distributed to x data groups to obtain x data groups corresponding to the pixel data set; wherein n is a positive integer greater than k, k is a positive integer, and x is a positive integer greater than 1; The prediction module is used for determining the compression prediction data of the i-th pixel data in any data group according to the i-th pixel data in the data group and the continuous k pixel data before the i-th pixel data in the data group; Wherein i is a positive integer greater than k and less than or equal to n; The first compression module is used for taking the j-th pixel data as the compression data corresponding to the j-th pixel data for the j-th pixel data in any data group; Wherein j is a positive integer less than the minimum value of i; The second compression module is used for determining the compression data of the i-th pixel data in any first data group according to the compression prediction data of the i-th pixel data in the first data group; wherein for any pixel data set, the first data group is one of the data groups in the pixel data set; The third compression module is used for determining the compression data corresponding to the i-th pixel data in the second data group according to the difference between the residual data of each pixel data in the first data group belonging to the same set as the second data group except for the first k pixel data and the residual data of the pixel data at the same position in the second data group; wherein the residual data of any pixel data is the difference between the pixel data and the compression prediction data of the pixel data; for any pixel data set, the second data group is at least part of the data groups in the pixel data set except for the first data group; The encoding module is used for encoding any data group according to the compression data of the data group to obtain an image compression data packet.

16. An image decompression apparatus characterized by comprising: Comprise: The acquisition module is used for acquiring at least one image compression data packet corresponding to an original image; The decompression module is used for decompressing any image compression data packet to obtain pixel data; The restoration module is used for generating an original image according to the pixel data obtained by decompressing each image compression data packet; Wherein, for any image compression data packet, the pixel data is obtained by decompressing through the following steps: Determine each compression data based on the image compression data packet; wherein at least part of the compression data is determined according to the encoding data in the image compression data packet; For the j-th compression data, the j-th compression data is determined as the j-th pixel data; wherein j is a positive integer less than the minimum value of i; For the i-th compressed data, a compression mode of the compressed data is determined according to the identification information in the image compression data packet, and a compression prediction data of the i-th pixel data is determined by using the compression mode and according to the i-th compressed data and pixel data corresponding to the k compressed data before the i-th compressed data corresponding to the i-th pixel data of the image compression data packet; wherein i is a positive integer greater than k and less than or equal to n, n is the number of encoded data in the image compression data packet, and k is a positive integer; It is judged whether the image compression data packet corresponds to a first data group or a second data group; If the image compression data packet corresponds to the second data group, for the i-th compressed data in the second data group, pixel data corresponding to the i-th compressed data in the second data group is determined according to the compression prediction data of the i-th pixel data in the second data group, the i-th compressed data in the second data group, and the i-th compressed data corresponding to the first data group belonging to the same pixel data set as the second data group; If the image compression data packet corresponds to the first data group, for the i-th compressed data in the first data group, pixel data corresponding to the i-th compressed data in the first data group is determined according to the compression prediction data of the i-th pixel data in the first data group and the i-th compressed data in the first data group.

17. An electronic device, comprising: It comprises: a processor and a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image compression method of any one of claims 1-8, or implement the image decompression method of any one of claims 9-14.

18. An electronic device, comprising: It comprises an application specific integrated circuit used to implement the image compression method of any one of claims 1-8, or implement the image decompression method of any one of claims 9-14.

19. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the image compression method of any one of claims 1-8, or implement the image decompression method of any one of claims 9-14.

Citation Information

Patent Citations

  • Methods and apparatus for intra coding a block having pixels assigned to groups

    CN102893606A

  • Video decoding method and device therefor, and video encoding method and device therefor

    CN109792534A