Run-Length Encoding (RLE) - Simple Lossless

Test yourself on Compression with exam style questions, marked instantly.

Flashcards that come back just before you would forget them.

A revision plan that remembers what you know and shows what to do next.

See which topics you have nailed and which need another look.

Quiz yourself on CompressionGet your flashcardsBuild my revision planTrack my progress

Run-Length Encoding (RLE) - Simple Lossless

How RLE Works:

Replace repeated values with a count + value. Instead of "AAAAAABBCC", store "6A2B2C".

Example 1: Simple Pattern

  Original: WWWWWWBBBWWW (12 characters)
  RLE:      6W3B3W (6 characters)
  
  Saved: 50% compression ratio
  

Example 2: Binary Data

  Original: 00000000111111110000000 (23 bits)
  RLE:      8×0, 8×1, 7×0 (3 pairs)
  
  Stored as: 8,0,8,1,7,0
  

Example 3: Image Data (Scanline)

  Image row (colors): RRRRRRGGGGBBBBBB (16 pixels)
  RLE:                6R4G6B (3 pairs)
  
  Original: 16 pixels × 3 bytes = 48 bytes
  RLE:      3 pairs × (count + color) = 6 bytes
  Saved:    87.5%!
  

When RLE Works Well:

  • Large blocks of same color: Simple graphics, logos, cartoons
  • Black and white images: Scanned documents, faxes
  • Video frames: Large unchanged areas between frames

When RLE Fails:

  • No repetition: ABCDEFGH → 1A1B1C1D1E1F1G1H (BIGGER!)
  • Random data: Photos, complex images - little to no repetition
  • Can make file larger if there's no pattern

Make this stick

Signing in gives access to all PrepWise features.

PrepWise is a trading name of A3M Quality Solutions Limited, registered in England and Wales, company number 14959172. Registered office: 202 Stroud Road, Gloucester, GL1 5LA. ICO registration ZC267069.