WOLFRAM|DEMONSTRATIONS PROJECT

Oriented Run-Length Compression

​
rule
217
init
1328528019
compression
not transposed
transposed
1536
961
296
961
1.59834
0.308012
Run-length encoding splits data into runs of identical elements and stores just the length of each run with its first element. For run-length encoding of square arrays of binary data, it is sufficent to store the value repeated in the first run. In this Demonstration our data matrices are generated by evolutions of elementary cellular automata. The compressed run lengths are stored by a self-delimited ternary representation that stores each ternary digit as a pair of bits and ends each run specification by a pair of ones. The number of bits required to store generated data and compressed data are given as plot labels. Observe that some matrices compress better if they are transposed first. Note that the distinction between transposition or non-transposition of input requires one additional bit.