Method, electronic circuit and computer program product for compressing and decompressing data

WO2025040351A1PCT designated stage expired Publication Date: 2025-02-27PLC2 DESIGN GMBH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/EP2024/070900
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-08-18
Filing Date
2024-07-23
Publication Date
2025-02-27

Smart Images

  • Figure EP2024070900_27022025_PF_FP_ABST
    Figure EP2024070900_27022025_PF_FP_ABST
Patent Text Reader

Abstract

The invention relates to a method for compressing a sequence, preferably with a predetermined length, of data in a predetermined binary format, the method comprising: determining the bit lengths of all the data in the sequence, wherein the bit length is the smallest number of bits for error-free representation of the data; grouping the data in the sequence into classes according to their bit length, such that the data belong to only one class, such that a maximum bit length is specified for each class, and such that the data grouped into a class have bit lengths that are less than or equal to the maximum bit length of said class; and encoding all the data in the sequence as a combination of a unique class indicator for the respective class and a representation of the data having the maximum bit length for its respective class, which is generated in an invertible manner from the representation of the data in the specified binary format. In this way, the number of classes and their maximum bit lengths are chosen such that the number of bits required for the encoding of all the data is minimised.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] Method, electronic circuit and computer program product for compressing and decompressing data

[0002] The present invention relates to methods, electronic circuits and computer program products for compressing and decompressing data, in particular for compressing and decompressing image data.

[0003] A well-known problem with data transmission is that the transmission time, or latency, increases with increasing data volume. For this purpose, various compression / encoding methods have been developed that make it possible to reduce the amount of data required for transmission. A distinction can be made between lossless and lossy compression / encoding.

[0004] Lossy compression allows modifications to the original data that are not detectable or relevant to a human observer or further processing. Accordingly, the original data cannot be restored using lossy compression.

[0005] With lossless compression, however, the compression is completely invertible, i.e. after data transmission, the data can be converted back to its original state if necessary, e.g. to facilitate further processing of the data.

[0006] Data compression is of particular interest when transmitting image data, as this requires the transmission of large amounts of data—especially when the images to be transmitted have a high resolution. This is often not possible for the often desired real-time data transmission without data compression. The use of lossless compression methods is particularly desirable when modification of the data content is unacceptable, e.g., when the original data set is essential for further processing.

[0007] A well-known lossless compression method is the so-called Golomb / RICE

[0008] However, this method is comparatively computationally intensive and often requires a stochastic analysis of the data distribution in the data being transmitted. This cannot usually be performed in real time.

[0009] The object of the present invention is therefore to provide a method for compressing data that compresses the data in a simple, lossless manner. Likewise, the object of the invention is to provide a method for corresponding decompression, as well as an electronic circuit and a computer program product with which the method can be implemented.

[0010] These problems are solved by the subject matter of the independent claims.

[0011] A method for compressing a sequence, preferably of a predetermined length, of data in a predetermined binary format comprises: determining the bit lengths of all data in the sequence, the bit length being the smallest number of bits for error-free representation of the data; grouping the data in the sequence into classes according to their bit length such that the data belongs to only one class, that a maximum bit length is predetermined for each class, and that the data grouped into a class have bit lengths that are less than or equal to the maximum bit length of said class; and encoding all data in the sequence as a combination of a unique class indicator for the respective class and a representation of the data with the maximum bit length of its respective class, which representation is generated in an invertible manner from the representation of the data in the predetermined binary format.The number of classes and their maximum bit lengths are chosen such that the number of bits required to encode all data is minimized.

[0012] The compression process therefore starts with a sequence of data to be transmitted, also referred to below as data packets or sequence elements. The number of these sequence elements / data packets is ideally known, but can also be unknown and / or variable and determined dynamically. The binary format in which the data is present is also known. For example, the sequence of data to be transmitted can be the values ​​of image pixels in a digital image / video. For example, the sequence can be a sequence of 8-bit, 16-bit, or 32-bit words in any binary format, with all sequence elements being represented with the same number of bits. In this respect, the sequence is not ideally compressed because the number of bits specified by the binary format used is usually greater than the minimum number of bits actually required to represent the data content.

[0013] For this reason, the bit length is determined for all data, i.e. for each sequence element, i.e. the smallest number of bits for error-free representation of the data. For example, for a signed 8-bit two's complement representation, the bit length can take on values ​​between 1 (e.g. 0000 0000 or 1111 1111) and 8 (e.g. 0111 1111 or 1000 0000). The bit length determined in this way will in many cases be smaller than the constant number of bits in the binary format used for the sequence. If the binary format is, for example, the signed 8-bit two's complement representation, all data in the sequence is encoded with 8 bits each, whereas the bit length can be between 1 and 8. This means that for each sequence element, in this case, between 0 and 7 bits carry no information. The number of bits to be transmitted could therefore be reduced without loss.

[0014] To achieve this goal, the sequence elements are classified according to their bit lengths. Each sequence element is assigned to exactly one class, which is defined by a maximum bit length. This means that a sequence element is grouped into a specific class if its bit length is less than or equal to the maximum bit length of the class and greater than the maximum bit length of the next smallest class. The limits for the maximum bit lengths of the classes are defined by the minimum and maximum possible bit lengths in the given binary format. For example, for the signed 8-bit two's complement representation, maximum bit lengths of the classes with values ​​between 1 and 8 are possible. Since the class with the largest bit lengths always has the number of bits of the binary format used as its maximum bit length (e.g.8 for the signed 8-bit two's complement representation), the selection of (n-1) maximum bit lengths is necessary for the division of the sequence elements into n classes.

[0015] All sequence elements grouped into a class are then encoded in a representation that uses a number of bits equal to the maximum bit length of the class.

[0016] This reduces the number of bits required for transmission, as each class no longer uses the full number of bits of the binary representation of the sequence, but rather the maximum number of bits of the respective class, which, with the exception of the class with the longest bit length, is smaller than the full number of bits of the binary representation of the sequence. This achieves the desired data compression. In addition, the representation with the reduced number of bits is generated in a predetermined and invertible manner from the original binary representation of the sequence, e.g., by omitting redundant bits. This ensures that the compression is lossless, as the full information can be restored by inverting the representation reduction.

[0017] In order to reconstruct the type of representation reduction, it is also necessary to encode the reduced representation together with a class indicator from which the maximum bit length used can be determined.

[0018] The number of classes used and the maximum bit lengths of the classes are then chosen to achieve a maximum reduction in the number of bits to be transmitted. It should be noted here that the seemingly intuitive solution of choosing the number of classes equal to the number of bits in the binary representation of the sequence in order to achieve a maximum bit reduction for all sequence elements can be offset by the need to specify each class with a class indicator. The number of classes will therefore typically be smaller than the number of bits in the binary representation of the sequence to prevent the bits required for the class indicators from overcompensating for the bit reduction in the sequence elements. Nevertheless, a suitable choice of the number of classes and the class boundaries or the maximum bit lengths of the classes can achieve a significant reduction in the number of bits to be transmitted.Furthermore, the method is easy to implement, especially without complex computational operations or stochastic analyses of the data distribution. It thus offers a simple and effective way to compress the data in a data sequence.

[0019] To group the data, a histogram can be created in which the number of data items with a certain bit length is plotted against the bit length. In the histogram, a number of bit lengths corresponding to the number of classes is selected and set as the maximum bit lengths of the classes. The number of bits required to encode all data is calculated as the sum across all classes of the sum of the maximum bit length and the class indicator of the respective class times the number of data items in the respective class. Typically, the histogram will have a number of columns / bars that corresponds to the number of bits in the binary representation of the sequence. For each sequence element, its bit length value is checked and a counter for the corresponding bit length is incremented by one. The histogram thus provides an overview of the distribution of the bit lengths in the sequence.Grouping the data can then be understood as grouping adjacent columns / bars of the histogram. The maximum bit lengths then represent boundaries in the histogram. All sequence elements that lie in histogram columns between two class boundaries (including the upper boundary) form a class. This then allows the number of bits required to encode all sequence elements to be calculated from the number of bit lengths occurring in the histogram. For each class, the number of required bits is equal to the product of the elements in the class and the sum of the number of bits of the class indicator and the upper class boundary, i.e., the maximum bit length of this class. The total number of bits is the sum of the bits of all classes. In this way, simple arithmetic can be used to determine which class number and which class boundaries lead to which number of bits to be transmitted.

[0020] The minimum number of bits required to encode all data can be determined by calculating this number for all possible variations of class numbers and maximum bit lengths. This means that for each sequence, all possible combinations of class numbers and class boundaries are explored, and the most favorable result is selected (brute-force calculation). This is particularly feasible when the sequences are sufficiently short (few sequence elements) or the number of bits in the binary representation is small (small maximum number of classes). In more complex cases, it may be advantageous to specify the number of classes and calculate the minimum number of bits to be transmitted for all possible variations of maximum bit lengths. This may result in the maximum bit reduction that would be theoretically possible not being achieved.However, this disadvantage is offset by the advantage that even longer sequences with higher-order bit representations can be processed in real time. In particular, it has been shown that sufficiently good results in terms of computational effort and data reduction can be achieved with four classes.

[0021] Alternatively, the minimum number of bits required to encode all data can be determined recursively by using the previous determination of the number of bits required to encode the data into classes with a longer maximum bit length to determine the number of bits required to encode the data into classes with a shorter maximum bit length. This means that not all possible combinations are calculated; instead, the parameter space is limited by recursion to already optimized classes with a smaller number of bits. Other heuristic methods to avoid brute-force computation are also possible. For example, class boundaries can be set and / or optimized based on the boundaries of a previously compressed sequence. All of these methods can further increase computational speed.

[0022] The data sequence to be transmitted can also be created from a sequence of raw data by applying an invertible arithmetic operation to the raw data. This operation is useful when the raw data is expected to contain a large number of data items with long bit lengths. The arithmetic operation can then be used to generate a sequence from the raw data sequence whose sequence elements have, on average, smaller bit lengths. This leads to a further reduction in the number of bits to be transmitted and, on the other hand, simplifies the determination of class boundaries, since the remaining (few) data items with longer bit lengths can be assigned to the class with the maximum bit length without any disadvantage for the data reduction and without further calculation. The invertibility of the operation guarantees that the raw data can be restored without loss.

[0023] In particular, the arithmetic operation can be the subtraction of adjacent raw data in the sequence of raw data, with the first data in the sequence of raw data being subtracted by zero. This is a particularly simple, invertible operation that leads to a reduction in the average bit lengths under the assumption that consecutive data carry similar information and therefore have a similar (bit) numerical value.

[0024] In particular, the raw data can be image data of image pixels and the sequences of raw data can be the image data of the image pixels of an image row or an image column and the arithmetic operation can be the subtraction of the image data of all adjacent image pixels in an image row / column, whereby the first image data of the image row / column is subtracted by zero. In digital images and in frames of digital videos, the probability is high that neighboring pixels represent similar intensity values, e.g. similar grayscale values. The subtraction of neighboring pixel values ​​will therefore lead to a sequence with comparatively small values ​​and thus comparatively small bit lengths. This can improve data reduction. Alternatively, pixel values ​​of a row / column or of the entire image can be rearranged such that values ​​of a similar size are adjacent to one another.Since the reordering is invertible, data reduction can be further improved.

[0025] For each image pixel, image data from different color channels can be present, and for each color channel, a sequence of raw data can be created. This means that only image data corresponding to the same color channel forms a data sequence. For example, if red, green, and blue image pixels are present (RGB), a sequence of red image data, a sequence of green image data, and a sequence of blue image data is created. In particular, the pixels can be processed row by row (or column by column) (or image / frame by image). The separate treatment of the color channels takes into account the fact that the intensities of different colors occurring in one location can vary greatly. Mixing the data from the different color channels would therefore make data reduction more difficult.

[0026] For the encoded data, i.e. for each sequence, a data header can also be created which contains the specified length of the sequence, the number of data bits in the specified binary format, the number of classes and the maximum bit lengths of the classes. Using this information, lossless reconstruction of the original data from the encoded data is possible. The data header can be transmitted together with the encoded data or separately. The data header can be omitted if the data specified therein is known or implied. In particular, the sequence length and the binary format can be standardized and therefore always the same, so that transmission is not necessary. Likewise, the number of classes can be fixed. The maximum bit lengths can be implied, for example, by the class indicators if each bit length has its own indicator.The data header therefore makes the procedure described above more flexible, but it is not absolutely necessary.

[0027] A method for decompressing data compressed as described above comprises: reading the respective class indicators for each data item; based on the read class indicators, converting the representation of the data with the maximum bit length of its respective class into the representation of the data in the specified binary format. This means that by reversing the steps used for compression, the original data content can be restored. In particular, the class indicators indicate how the encoded data transmitted along with the class indicator can be decoded. This enables lossless compression and decompression of the data to be transmitted.

[0028] In addition, an electronic circuit suitable for carrying out the methods described above is provided. A hardware implementation of the methods described above ensures fast and reliable execution of the methods.

[0029] Furthermore, a computer program product is provided with instructions that cause a computer to perform the methods described above when executed on a computer. A software implementation of the methods described above enables flexible use of the methods on various computer platforms.

[0030] The invention is further explained below with reference to the figures. The following description is purely exemplary and is not intended to limit the subject matter of the invention. This is determined solely by the claims. It shows:

[0031] Fig. 1 is a schematic flow diagram of a method for compressing data;

[0032] Fig. 2 shows an overview table of bit lengths of 8-bit two's complement numbers;

[0033] Fig. 3 is an exemplary representation of the distribution of bit lengths in a sequence of data to be compressed;

[0034] Fig. 4 shows an exemplary representation of the generation of class indicators;

[0035] Fig. 5 shows an exemplary representation of data compression;

[0036] Fig. 6 shows an example of data compression of raw data; Fig. 7 shows an example of separate processing of different color channels;

[0037] Fig. 8 is a schematic representation of the structure of a compressed data sequence;

[0038] Fig. 9 is a schematic flow diagram of a method for decompressing data; and

[0039] Fig. 10 is a schematic block diagram of the execution of the compression / decompression process.

[0040] Fig. 1 shows a schematic diagram of a method for compressing a sequence 100 of a predetermined length of data 110 present in a predetermined binary format. The sequence 100 of data 110 can, in principle, be any information that can be represented in a series of information blocks. Each information / data block is represented using the same data format. For example, a series of numerical values ​​can be represented as a sequence of two's complement numbers or hexadecimal numbers, where each numerical value is an information / data block 110 of the sequence 100. However, any information can also be transmitted in a fixed binary format, e.g., as a binary n-bit word. The data 110 of the sequence 100, also referred to below as sequence elements 110 or data blocks 110, are therefore always represented with the same number of bits, which is predetermined by the binary format used.In addition, the length of the sequence 100 is known in order to be able to make a meaningful distinction between consecutive sequences 100.

[0041] Examples of such sequences 100 represent the intensity values ​​of the pixels in the rows or columns of a digital image or video. For example, the pixel values ​​of an image can be represented as 8-bit or 16-bit numbers. The sequences 100 have a known length, namely the number of pixels per row / column / image / frame. If color information is contained in the digital image / video, it makes sense to consider the intensity values ​​of the different colors separately. A sequence 100 then consists only of the pixel values ​​of a row / column / image / frame that relate to the same color. Although reference is made frequently below to sequences 100 of pixel values, this is to be understood purely as an example. The data compression methods discussed can, in principle, be applied to any data.

[0042] To compress the data 110, the bit length of all data 110 in the sequence 100 is first determined at S110. The bit length specifies the smallest number of bits required for error-free representation of the data 110. The bit length depends on the specific data value, i.e., it varies for the different data 110 in the sequence 100. The bit length of the data 110 should not be confused with the number of bits specified by the binary format used. This number is the same for all sequence elements 110.

[0043] This is illustrated in Fig. 2. It shows the numerical values ​​and bit lengths of various 8-bit two's complement numbers (signed and unsigned). The number of bits in the 8-bit two's complement format is naturally 8. This also corresponds to the maximum bit length of 8, which is achieved, for example, for the binary numbers 0111 1111 or 1000 0000. The information content of these numbers cannot be represented accurately with fewer than 8 bits. However, there are also binary numbers that could be represented with fewer than 8 bits. This is immediately obvious for the binary numbers 0000 0000 or 1111 1111, as these do not carry any more information than a single 0 or 1. The bit length of these numbers is therefore only 1.

[0044] In general, the bit length of signed n-bit two's complement numbers, ie decimal numbers x from the range of -2 n ' 1 up to 2 n-1 -1 , specify:

[0045] Int [Iog2(x)] + 2 for x > 0

[0046] Bit length(x) = 1 for x = 0

[0047] Bit length (-x-1) for x < 0

[0048] Here, Int [ ] rounds down to the next smallest integer, e.g., Int [6,8] is equal to 6. The resulting bit lengths for the signed 8-bit two's complement numbers are given in the table in Fig. 2. The generalization to unsigned two's complement numbers is also shown. Similar definitions for the bit length can be found for any binary format. In general, any measure of the bit length can be used as long as it allows an estimate of the minimum number of bits necessary to represent the data 110 without errors. At S120, the data 110 in the sequence 100 are grouped into classes according to their bit length such that the data 110 belong to only one class, that a maximum bit length is specified for each class, and that the data 110 grouped into a class have bit lengths that are less than or equal to the maximum bit length of said class.

[0049] The data is therefore sorted by its bit length to estimate the compression potential. The closer the bit length is to the number of bits in the binary format used, the fewer bits can be saved per data block 110.

[0050] For this purpose, class boundaries are set, i.e., upper limits for the bit length of the respective classes. All data blocks 110 with bit lengths that are less than or equal to a class boundary but greater than the next smallest class boundary are assigned to the class. Since each class only contains data blocks 110 with a bit length less than or equal to the class boundary, the number of data blocks 110 in the classes is a measure of the data reduction that can be achieved. The number of classes and the class boundaries are naturally chosen such that the number of bits required to encode all data 110 is minimized, i.e., that the greatest possible data reduction can be achieved.

[0051] One way to achieve the above-mentioned grouping is to create a histogram, as shown in Fig. 3. In the histogram, the number of data 110 with a specific bit length is plotted against the bit length. Thus, each data block 110 is assigned a number of bits necessary to represent it error-free. In an n-bit binary format, the histogram therefore has n columns / bars, since bit lengths from 1 to n are possible.

[0052] The upper part of Fig. 3 shows a corresponding example of a 16-bit binary format, e.g., a 16-bit two's complement representation. The entries hj with i = 1, ..., 16 indicate the number of data blocks 110 with bit length i. In the example in Fig. 3, there is a relatively large amount of data with a bit length of less than 7. Larger bit lengths are relatively rare. The lower part of Fig. 3 shows the cumulative numbers Hj of bit lengths up to bit length i, ie Hj = hi + ti2 + ... + hj. In the histogram generated in this way, the classes can then be easily defined by segmenting the histogram. This is shown in Fig. 3 as an example by the dashed lines, which represent the setting of maximum bit lengths at i = 4, i = 7, i = 11, and i = 16. The maximum value i = n (= 16 in this example) does not need to be set separately, since a bit length that is larger than the number of bits in the binary format is not possible.

[0053] For each of the classes, a unique class indicator 120 is set at S130. An exemplary procedure for this is shown in Fig. 4 for four classes. For the first class, "A," the 1-bit indicator "0" is used. For the second class, "B," a "1" is set instead of the "0" used for class "A," which is then followed by a "0." Following the same system, for the third class, "C," the bits for the previous classes are set to "1," followed by a "0." The last class, "D," whose maximum bit length is equal to the number of bits in the binary format, is indexed with three "1s." This scheme can be generalized to m classes: The first class is indexed with "0," each subsequent class k with (k-1) "1s" and once "0," except for the last class, which is indexed with (m-1) "1s."For class indexing, this scheme requires k bits for the kth class, except for the highest class, which is indexed with (m-1) bits. The end of the class indicator is then indicated either by the occurrence of the first "0" or by reaching (m-1) bits. It goes without saying that any other class indexing can be used, as long as it clearly distinguishes the different classes and the end of the class indicators 120 is clearly recognizable.

[0054] Using the class indicators 120, all data 110 in the sequence are then encoded at S130 as a combination of the unique class indicator 120 for the respective class and a compressed representation 130 of the data that uses the maximum bit length of its respective class. The compressed representation 130 of the data is generated in an invertible manner from the representation of the data 110 in the specified binary format.

[0055] This is shown as an example in Fig. 5. The top row of Fig. 5 shows the number "4" as data 110 in 8-bit two's complement format. The bit length of this number is also 4 (cf. Fig. 2). Assuming a first class boundary at i = 4, then the number "4" falls into the first class. The class indicator 120 of the number "4" is therefore "0". The representation 130 of the data, reduced to the maximum bit length of the class, i.e., four, consists of the last four bits, i.e., bits "0100". These are output together with the class indicator 120, i.e., with the value "0". This is shown in the middle row of Fig. 5. The data block compressed in this way now has only 5 bits instead of 8. It should be noted that the maximum reduction to 4 bits is not possible due to the need to specify the class.

[0056] Figure 5 also shows that, based on the class indicator 120, i.e., the "0" bit, it is recognized that the next four bits (corresponding to the maximum bit length of the class) represent the actual data. These can then be converted back to the 8-bit representation by adding zeros.

[0057] As another example, consider the sequence of hexadecimal numbers 38, 3, 7, 1a, b4, f3ac. The class boundaries are set to bit lengths of 4, 8, 12, and 16. The sequence elements 3 and 7 have bit lengths less than or equal to 4. The sequence elements 38 and 1a have bit lengths less than or equal to 8. The sequence element b4 has a bit length less than or equal to 12. The sequence element f3ac has a bit length greater than 12 and less than or equal to 16. Thus, these hexadecimal numbers can be represented in compressed binary notation as

[0058] 38 => 10 00111000,

[0059] 3 => 0 0011 , 7 => 0 0111 , 1a => 10 00011010, b4 => 110 000010110100, f3ac => 111 1111001110101100 .

[0060] This sequence requires 2*(4+1) + 2*(8+2) + 1*(12+3) + 1*(16+3) = 64 bits, while a 16-bit representation would have required 96 bits. The compression rate here is therefore 64 / 96 = 67%.

[0061] A corresponding reduction of bits can be performed for all data 110 whose bit length is smaller than the number of bits of the binary format used in the sequence 100. This reduction is partially compensated by the bits required for the class indicators, which must be added to each compressed data block 130. The number of bits required to encode all data 110 therefore also depends on the number of classes and the selected class boundaries. It can be calculated as the sum across all classes of the sum of the maximum bit length and the class indicator 120 of the respective class times the number of data 110 in the respective class.

[0062] If the number of data blocks 110 with a bit length less than or equal to i is given by Hj, as in the lower part of Fig. 3, the number of bits of the binary format by n and the number of classes by m, the number of bits required to encode all data 110 of the sequence 100 is

[0063] Number of bits = (1+a1)H ai + (2+a2)(H a2 - H a i) + ... + (m-1+a{m-1})(H a{m -i} - H a{m -2}) + (m- 1+am)(H am H a {m-1}), where a1 to am represent the maximum bit lengths of classes 1 to m and am = n.

[0064] Based on this formula, the minimum number of bits required to encode all 110 data can be determined by calculating this number for all possible variations of class numbers and maximum bit lengths. This means a brute-force calculation is performed. The runtime for such a calculation scales as n m-1 with the number of classes m and the number of bits n of the binary representation used.

[0065] In order to limit the computational effort, the number of classes can also be specified.

[0066] Then, only the class boundaries need to be varied. It has been shown that for bit counts in the range of 16 bits, good results can be achieved in terms of data reduction and latency if the number of classes is set to 4, as shown in the example in Fig. 3.

[0067] In this example, the sequence length is 224, the class boundaries are 4, 7, 11, and 16, and the cumulative data counts at the class boundaries are H4=110, H?=170, Hn=204, and Hi6=224. This results in a reduction of 224 x 16 bits = 3,584 bits to 1,946 bits, i.e., approximately 45%. This is the typical reduction rate of the compression method described above. In addition to a brute-force calculation of the number of bits required to encode all 110 data, this can also be determined recursively by using the previous method to determine the number of bits required to encode the data 110 into classes with longer maximum bit lengths.

[0068] For example, a recursion algorithm for a grouping into four classes with class boundaries a, b, c, and d=n can have the following recursion steps: r0(a) = (1 + a)H a; n(b) = min{ae[1,b]} (r0(a) + (2 + b)(H b - H a )); r2(c) = min{be[1,c]} (n(b) + (3 + c)(H c - H b )); r3(d) = min{ce[1,d]} (r2(c) + (3 + d)(H d - H c ));

[0069] An alternative recursion algorithm would be: r0(a) = 0; n(b) = max{ae[1 ,b-1]} (ro(a) + (1 + b - a)H a ); r2(c) = max{be[2,c-1]} (n(b) + (1 + c - b)H b ); r3(d) = max{ce[3,d-1]} (r2(c) + (d - c)H c ); r(d) = (3 + d)H d - r3(d)

[0070] It is particularly advantageous to save previously calculated values ​​of rk in order to use them in later recursion steps.

[0071] It goes without saying that the algorithms presented above are purely exemplary. Class boundaries can also be improved using heuristic algorithms other than those explicitly presented above.

[0072] By using recursive / heuristic optimization methods, the latency for classifying the data can be further reduced. This enables improved real-time application of the method. As shown in Fig. 1, the method can have an optional upstream step at S100. At S100, the sequence 100 of data 110 can be created from a sequence of raw data 140 by applying an invertible arithmetic operation to the raw data 140. This step serves to keep the bit lengths of the sequence 100 small from the outset. Accordingly, this step can be applied to any data sequence if a reduction in the bit lengths of the sequence elements is to be expected. Furthermore, any conceivable arithmetic operation that leads to a bit length reduction can be used, as long as it is invertible, i.e., as long as the raw data 140 can be reconstructed from the sequence 100 of data 110 without loss.

[0073] In particular, the arithmetic operation can be, for example, the subtraction of adjacent raw data in the sequence of raw data 140, wherein the first data of the sequence of raw data 140 is subtracted by zero. This assumes that consecutive raw data 140 have similar values, so that subtracting adjacent raw data 140 results in a sequence 100 whose data 110 has shorter bit lengths than was the case for the raw data 140. It is also possible to reorder the raw data 140 before the subtraction such that data blocks with similar values ​​are arranged next to one another, e.g., by reordering in ascending order from the smallest to the largest entries. This then guarantees a reduction in the bit lengths through the reordering.

[0074] The subtraction method is shown as an example in Figure 6 for a sequence of raw data 140. This sequence consists of eight raw data blocks 140, which are in signed 8-bit two's complement format. The values ​​of the raw data 140 are specified in decimal notation, and their bit lengths are displayed below the corresponding raw data 140.

[0075] In this sequence of raw data 140, the preceding raw data block 140 is subtracted from each raw data block 140. The subtrahend for the first raw data block 140 in the sequence is set to zero, i.e., this raw data block 140 remains unchanged. If the values ​​of the raw data 140 are denoted by a, and the values ​​of the data 110 of the output sequence by bj, the following applies: bi = ai; bi = aj — an for i > 1; ai = bi + b2 + ... bi. The raw data 140 can thus be uniquely retrieved from the sequence elements 110.

[0076] As can be seen from the example in Fig. 6, the bit lengths of almost all sequence elements are reduced, even though the values ​​of neighboring raw data 140 are only moderately similar. The reduction will be greater the more similar the data values ​​are.

[0077] This is particularly advantageous when transmitting or compressing image data, since larger, contiguous areas with similar intensity are usually present here, i.e. areas in which neighboring data values ​​are very similar. In this case, the raw data 140 is image data from 200 image pixels. The sequences of raw data 140 can be the image data of the image pixels 200 of an image row or an image column (or even the entire image), and the arithmetic operation, as above, is the subtraction of the image data of all adjacent image pixels 200 in an image row / column / image / frame, whereby the first image data of the image row / column / image / frame is subtracted by zero. The sequence length can also be selected to be greater or smaller than the row / column length if required.

[0078] In this way, image data, i.e. still images or video frames, can be compressed line by line or column (or even completely) and transmitted without any data loss. With the commonly used 8-bit or 16-bit binary formats in which the image data is encoded, real-time compression can be achieved by dividing the bit lengths into 3, 4 or 5 classes, even with a brute-force calculation of the class boundaries. The compression rate, including the subtraction achieved by subtracting the neighboring pixel values ​​(or other arithmetic operations), is typically in the range of 1.25 to 5. This corresponds to a typical data reduction of 20% to 80%. With turbulent images, i.e. images with a large intensity bandwidth, the data reduction can be less significant.Thus, a reliable, easy-to-implement and powerful lossless compression method for image data is provided.

[0079] Color images / videos usually have different color channels, i.e., image pixels 200 are divided into subpixels that are sensitive to different wavelength ranges, or image pixels 200 are provided for different wavelength ranges. Common color channels are RGB, CMYK, YUV, or YCbCr. An example of this is shown schematically in Fig. 7. In Fig. 7, pixels 200 (or subpixels® for red (R), green (G), and blue (B)) are arranged in a Bayer pattern.

[0080] If such color channels are present, the image data of the various color channels are treated as different sequences 100. This means that the image data of all R pixels in a row / column are encoded as one sequence, while the other color values ​​in the same row / column form a separate sequence. This is symbolized in Fig. 7 by the arrows shown. The separate encoding ensures that neighboring sequence elements have similar pixel values, so that the subtraction method explained above already leads to a data reduction in the sense of a reduction in the average bit length. This further improves the compression rate, while lossless reconstruction of the original data remains possible due to the arrangement of the color pixels.

[0081] The form of the encoded data 160 is shown in Figure 8. The encoded data 160 is also structured sequentially. Each sequence element of the encoded data 160 corresponds to a sequence element 110 of the original sequence 100 and is composed of the class indicator 120 and the compressed representation 130 of the data 110.

[0082] In addition, a data header 150 for the coded data 160 can be prefixed to the sequence of coded data 160. The data header 150 can contain the specified length of the sequence 100, the number of bits of the data 110 in the specified binary format, the number of classes, and the maximum bit lengths of the classes. The data header thus allows for flexible selection of these parameters required for decompression. If these parameters are fixed and (implicitly) known, the data header can be omitted. For example, an encoder can be designed to compress only 16-bit data from the color channels of images with a specified, fixed resolution by selecting class boundaries for four classes. This means that all parameters are fixed except for the class boundaries. However, these can be implied by the class indicators 120 used, so that a data header 150 is not necessary. However, the use of a data header 150 is generally preferable, e.g.to handle images with different resolutions, i.e., different sequence lengths. If the data header 150 is present, a decompression / decoding process starts by reading the parameters stored in the data header 150 so that they can be used in subsequent data processing.

[0083] As briefly explained above with reference to Fig. 5, the decompression of the compressed data 160 occurs by inverting the compression steps. As shown schematically in Fig. 9, at S210, the respective class indicators 120 are read out for all compressed data 160. At S220, based on the read class indicators 120, the representation 130 of the data with the maximum bit length of its respective class is converted into the representation of the data 110 in the specified binary format. This means that the class indicator 120 is used to determine which class the sequence element belongs to. This determines the class boundary (either implicitly or by reference to the information present in the data header 150). The class boundary, in turn, represents the number of bits with which the data was encoded in compressed form. Since the originally used binary format is known, the original representation can then be retrieved.In this way (if necessary supplemented by the inverted arithmetic operation) the original data 110 can be restored without loss.

[0084] The methods described above can be implemented as hardware solutions or as software. Both solutions are symbolized in Fig. 10. In the first case, an electronic circuit 300 executes the methods, which was specifically developed for this purpose. This allows reliable and fast compression / decompression at the hardware level. The software solution, i.e., a computer program product with instructions that cause a computer 400 to execute the above-mentioned methods when executed on the computer 400, offers the advantage that it can be flexibly executed on any computer 400. In this way, the compression algorithm explained above can be easily utilized.

Claims

Claims 1 . Method for compressing a sequence (100), preferably with a predetermined length, of data (110) present in a predetermined binary format, with Determining the bit lengths of all data (110) in the sequence (100), wherein the bit length is the smallest number of bits for the error-free representation of the data (110); Grouping the data (110) in the sequence (100) into classes according to their bit length such that the data (110) belong to only one class, that a maximum bit length is specified for each class, and that the data (110) grouped into a class have bit lengths that are less than or equal to the maximum bit length of said class; and Encoding all data (110) in the sequence as a combination of a unique class indicator (120) for the respective class and a representation of the data (130) having the maximum bit length of its respective class, which is generated in an invertible manner from the representation of the data (110) in the predetermined binary format; wherein the number of classes and their maximum bit lengths are selected such that the number of bits necessary for encoding all data (110) is minimized.

2. Method according to claim 1, wherein for grouping the data (110) a histogram is created in which the number of data (110) with a certain bit length is plotted against the bit length, a number of bit lengths corresponding to the number of classes is selected in the histogram and set as the maximum bit lengths of the classes and the number of bits required for coding all data (110) is calculated as the sum over all classes of the sum of the maximum bit length and the class indicator (120) of the respective class times the number of data (110) in the respective class.

3. Method according to one of the preceding claims, wherein the minimum number of bits necessary for encoding all data (110) is determined by calculating this number for all possible variations of class numbers and maximum bit lengths, preferably for all possible variations of maximum bit lengths for a given number of classes, more preferably for four classes.

4. Method according to one of claims 1 or 2, wherein the minimum number of bits necessary for encoding all data (110) is determined recursively by using the previous determination of the number of bits for encoding the data (110) in classes with a shorter maximum bit length to determine the number of bits for encoding the data (110) in classes with a longer maximum bit length.

5. Method according to one of the preceding claims, further comprising Creating the sequence (100) of data (110) from a sequence of raw data (140) by applying an invertible arithmetic operation to the raw data (140).

6. The method of claim 5, wherein the arithmetic operation is the subtraction of adjacent raw data in the sequence of raw data (140); and the first data of the sequence of raw data (140) is subtracted by zero.

7. The method according to claim 6, wherein the raw data (140) is image data of image pixels (200), sequences of raw data (140) are the image data of the image pixels (200) of an image row or an image column, and the arithmetic operation is the subtraction of the image data of all adjacent image pixels (200) in an image row, the first image data of the image row / image column being subtracted by zero.

8. The method according to claim 7, wherein for each image pixel (200) image data from different color channels are present and a sequence of raw data (140) is formed for each color channel.

9. Method according to one of the preceding claims, further comprising Creating a data header (150) for the encoded data (160) containing the predetermined length of the sequence (100), the number of bits of the data (110) in the predetermined binary format, the number of classes and the maximum bit lengths of the classes.

10. A method for decompressing data (160) compressed by the method according to one of claims 1 to 9, comprising Reading the respective class indicators (120); Based on the read class indicators (120), converting the representation of the data (130) with the maximum bit length of its respective class into the representation of the data (110) in the predetermined binary format.

11. An electronic circuit (300) suitable for carrying out the method according to one of claims 1 to 10.

12. A computer program product comprising instructions which, when executed on the computer (400), cause a computer (400) to carry out the method according to any one of claims 1 to 10.