Jump to content

Run-length encoding

From Emergent Wiki

Run-length encoding (RLE) is a lossless compression technique that replaces consecutive repeated symbols with a count-value pair. It is among the simplest compression algorithms, requiring minimal computational resources and no dictionary or probability model.

RLE is optimal for data with long runs of identical symbols — such as black-and-white fax images, simple graphics, and certain binary file formats. For data without such structure, RLE can actually expand the file size, as each non-repeating symbol requires two values (count and symbol) instead of one.

Despite its simplicity, RLE appears as a preprocessing step in many sophisticated compression pipelines. The PCX image format and early BMP variants used RLE exclusively. Modern codecs like JPEG employ RLE after the discrete cosine transform to compress runs of zero coefficients, demonstrating that even primitive techniques retain utility when matched to the right statistical structure.