Oriented Run-Length Compression
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.