Thursday, February 25, 2010

RLE Encoding




RLE – Run Length Encoding:


It is a famous lossless compression algorithm widely used in many data compression applications and used with many image compression algorithms. In Run Length Encoding method the consecutive same data is compressed. This technique used in few type of BMP image formats particularly 8 bit and 16 bit BMP images, JPEG images and almost all compression application software like winzip, winrar etc..

RLE – Run Length Encoding Example.

Input data : qqqqqqqqqqwwwrrrrqqqqqqqiiioooopppppp
RLE compressed Data : 10q3w4r7q3i4o6p

Let’s consider the above sample data, in RLE compression the count and the data value is represented. i.e q is repeated at 10 times instead of writing ten q it can be written as 10q. likewise all other data’s are written.

Compression ratio = (37 (total number of chars in input data) - 15 (required no of chars to represent the data) ) / 37 * 100
= 59.5 %

Compression ratio for above case is 59.5 %;

Input data : qwertyqwerty
RLE compressed Data : 1q1w1e1r1t1y1q1w1e1r1t1y

In the above sample the compression ratio is -100%. I.e. negative compression. From the above two example RLE compression is good only when the data is repeated one. Otherwise it would give negative compression.

Advantages :

1. During implementation just one pass is required to compress the input data.
2. Easy understanding.
3. Less memory requirement.
4. High compression ratio on repeated data input.

Disadvantages:

1. If the data is not repeated one then the compression ratio would be negative.

0 comments:

Twitter Delicious Facebook Digg Stumbleupon Favorites More