Run Length Encoding

Computer Science: OCR A Level, topic 3.1.2

Run Length Encoding

One compression algorithm you need to learn is run length encoding (RLE).

Run length encoding

Run length encoding

  • Run length encoding (RLE) is a form of lossless compression that replaces repeating sequences of 0s and 1s with more efficient representations.
  • Each repeating string will be replaced by a code which represents the character and the amount of times it is to be repeated.
In images

In images

  • In images, adjacent pixels are likely to have similar but slightly different colours.
  • Image compression algorithms can group these pixels together and replace them with a single 'average' colour. This is a lossy process.
  • The RLE algorithm can then be applied to the new image.
  • While the step using RLE is still lossless, the grouping of pixels beforehand makes the whole process lossy.

Test yourself on Run Length Encoding

  • Why is run length encoding difficult in images?

  • What type of compression is run-length encoding?

Practise this topic for free