0
4.0kviews
Explain RLE encoding with an example.
1 Answer
0
246views

RLE works by reducing physical size of repeating string of character. This repeating string called as RUN is basically encoded into 2 bytes. The first repersents the number of repeaned cahracter in Run and called as Run count. The second byte is value of charater in the Run which is in range 0-255 and called as Run value.

Following is Uncompressed string:

PPPPPPPPPPPPPPPPPPPPPP

Compressed string with RLE:

enter image description here

The 20P code generated to represent character string is called RLE Packet.

=> Two bytes are required to store '20P'.

First 1 byte require to store 20 and second byte is required to store 'Run value' i.e. 'P' But, initially uncompressed string require 20 bytes to store same data.

Advantages

A black and white image that is mostly white, such as page of book will encode very well due to large amount of contiguous data that is all the same color.

In sequential processing, A bitmap is encoded starting at upper left corner and proceeding from left to right across each scan line(The axis).

enter image description here

Alternative RLE schemes can also be written to encode data down the length of bitmap (the Y-axis).

enter image description here

Encode pixels on a diagonal in zig-zag fashion.

enter image description here

  • Example: Use the RLE method to compress the following sequence of symbols:

AAAACCBBBDDDDDEFF

Sol:

We can compress the given sequence of symbols using RLE as follows:

enter image description here

  • In this way a string of 17 symbols has been compressed into a string of only 12 symbols.
  • In such a case only the count of one of the symblos which occurs between each occurence of the other symbol is used.
Please log in to add an answer.