0% found this document useful (0 votes)
19 views11 pages

Lossless Compression Techniques-Slides

Lossless compression techniques
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views11 pages

Lossless Compression Techniques-Slides

Lossless compression techniques
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Lossless compression

techniques
Lempel-Ziv algorithm
Lempel-Ziv algorithm
Lossless compression techniques – Lempel-Ziv
Ex 2: Lempel-Ziv algorithm
The LZ (Abraham Lempel1 , Jacob Ziv2, 1977)
algorithm is a statistical modelling algorithm for
text.
Lossless compression techniques
– Lempel-Ziv
• LZ algorithm uses the fact that small
strings within messages often repeat
locally, i.e. the source has memory.

• LZ method uses a history buffer and


looks for matches. If a match is found,
then the position and length of the
match within the buffer are transmitted
instead of the character string.
Lossless compression techniques – Lempel-Ziv

• Assume we want to transmit the string


“the_mat”.
• The history buffer of length 16 (already sent)
is as follows: “_the_cat_sat_on_”.
• We found a match for “the_” in the history
buffer.
• So, encoding “the_” gives: 1 to indicate that a
match has been found, 0001 to indicate that
the match starts at position 1, and 011 to
indicate that the length of the match is 4
(max length is 8) -> 8 bits.
Lossless compression techniques – Lempel-Ziv

• Now we need to encode the string “mat”.


• The history buffer is now as follows:
“_cat_sat_on_the_”.
• There is no match for “m”. So, encoding
“m” gives: 0 to indicate that no match has
been found, and the 8-bit ASCII code for
“m” -> 9 bits.
• Then we need to encode the string “at”,
using the history buffer
“cat_sat_on_the_m”.
Example:

Encode the character stream:


wabbawabba
using LZW encoding algorithm?
Solution
1. At the start, the dictionary contains all possible
individual characters, i.e. we have only individual a,
b, w and
2. we give the index 1,2,3 respectively as shown in the
table and initially P is empty, i.e.,
P = empty
C = insert the 1st character is w
index Dictionary
1 a P + C = (empty + w) = w
2 b
3 w
4 wa
5 ab
6 bb
7 ba
8 aw
9 wab
1. Is the string P + C present in the dictionary?
a) if it is, (Yes) because w is already
exist in the table then
let P P+C
hence , the new P is
P w
3. Repeat the above steps but starting with the new
P=w
C = insert the 2nd character is a
• P + C = w +a = wa
• Is the string (P + C = wa ) present in the dictionary?
(No),
(No
• Then add this to the table and denote
its index with 4
The Character Stream 10 to 8
wabbawabba 31221461
index dictionary
1 a
2 b
3 w
4 wa
5 ab
6 bb
7 ba
8 aw
9 wab
10 bba
END

You might also like