RLE

Run Length Encoding is a type of lossless compression. It analyses a file and replaces sequences of the same value with a count number and individual value.

E.g.

AAAAABBCCCCCCDDDEEEEEEFFF

5 A 2 B 6 C 3 D 6 E 3 F

You can easily see how less data is used to represent the same characters.

However in real life not many books contains identical sequences of text and so this method does not work well.

E.g.

I will study really well for my GCSEs

1 I 1 Space 1 w 1 i 2 l 1 space 1 s 1 1t 1 u 1 d 1 y 1 space 1 r 1 e 1 a 2 l 1 y 1 space 1 w 1 e 2 l 1 space 1 f 1 o 1 r 1 space 1 m1 y 1 space 1 G 1 C 1 S 1 E 1 s

Again, its easy to see how this takes up much more data than the original sentence.

 

Images

RLE is usually more effective with images. Below you can see that where the image has long runs of identical pixels, the compression is more effective. This would work well with images with a low colour depth as there are fewer colours available and so it is more likely there are sequences of identical pixels. Imagine an image with a blue sky – there could be runs of hundreds of identical pixels.

Uncompressed image

rle1

Image compressed with RLE

rle2

 

Sound

Similarly, sound files are likely to have runs of identical samples if the sample rate is high and the resolution is low. Imagine if an piece of music sampled at 44,100 Hz (44,100 samples per second) – there is a good chance that there will be runs of identical samples. This is particularly true if the resolution is low (the range of different amplitudes available) like the 8 bit music below.

Thanks Kyle for spotting the spelling mistake!

 

 

%d bloggers like this: