The simplest compression technique: condensing repeating sequences efficiently.
Run-Length Encoding (RLE) is one of the simplest and oldest forms of lossless data compression. Its core idea is to reduce the size of repeating sequences of data, often called "runs." Instead of storing each individual data item in a run, RLE stores the data item and the count of its repetitions.
Imagine you have a sequence of data like: AAAAABBBCCDAA.
RLE would encode this as:
A repeats 5 times: Encode as 5AB repeats 3 times: Encode as 3BC repeats 2 times: Encode as 2CD repeats 1 time: Encode as 1DA repeats 2 times: Encode as 2ASo, the original sequence of 13 characters could be represented more compactly as 5A3B2C1D2A (10 characters in this representation).
Consider a small black and white bitmap image line represented by WWWWBBWWWBBBBW (W for white pixel, B for black pixel).
Using RLE, this could be encoded as: 4W2B3W4B1W. The original string had 14 characters, while the RLE version has 10 characters.