Compression one example

Post on 28-Oct-2014

351 views 1 download

Tags:

description

 

transcript

Different compression methods one example

Agenda

LZW Example

Huffman Example

Shanon Fano Example

Arithmetic Coding Example

Advantages for Every method

BILLGATES

B BILLGATESB

1B

ILLGATESIB I

1B

2I

LLGATESLB I L

1B

2I

3L

LGATESLB I L 3

1B

2I

3L

GATESGB I L 3 G

1B

2I

3L

4G

ATESAB I L 3 G A

2I

3L

4G

1B

5A

TESTB I L 3 G A T

2I

3L

4G

1B

5A

6T

ESEB I L 3 G A T E

2I

3L

4G

1B

5A

6T

7E

SSB I L 3 G A T E S

2I

3L

4G

1B

5A

6T

7E

8S

Advantages and Disadvantages of LZWAdvantage:

Is a lossless compression algorithm.Hence no information is lost.

One need not pass the code table between the two compression and the decompression.

Simple ,fast and good compression

Disadvantage:

What happens when the dictionary becomes too large

One approach is to throw the dictionary away when it reaches a certain size

Useful only for a large amount of test data where redundancy is high

Shannon–Fano Algorithm

BILLGATES

Symbols B I L G A T E S

Probabilities 1/9 1/9 2/9 1/9 1/9 1/9 1/9 1/9

B

B IL G A T E SA

BL

L BL I G A T E S

For a given list of symbols, develop a corresponding list of probabilities or frequency counts so that each symbol’s relative frequency of occurrence is known.

Sort the lists of symbols according to frequency, with the most frequently occurring symbols at the left and the least common at the right.

Divide the list into two parts, with the total frequency counts of the left part being as close to the total of the right as possible.

BL I G A TE

S

C

BL I G A TE

S

D

BL I G A TE

S

E

BL I G A TE

S

F

0

01

1

0

1

0

0

1

1 0 10

1

Symbols

L : 00

B: 01

I : 100

G: 101

A: 1100

T: 1101

E: 1110

S: 1111

2Bit(1+1)+3Bit*(1+1)+4Bit*(1+1+1+1)/9

=2.888888Bits/symbol

What are the disadvantages of shanon fano coding?

What is better shannon fano and huffman coding?

huffman has a better compression rate.

Huffman Algorithm

BILLGATES Symbols B I L G A T E S

Probabilities 1/9 1/9 2/9 1/9 1/9 1/9 1/9 1/9

B

B ILG A T E S

A

LI G A T E SB

Create a leaf node for each symbol and add it to frequency of occurrence.

While there is more than one node in the queue:

Remove the two nodes of lowest probability or frequency from the queue

Prepend 0 and 1 respectively to any code already assigned to these nodes

Create a new internal node with these two nodes as children and with probability equal to the sum of the two nodes' probabilities.

Add the new node to the queue.

The remaining node is the root node and the tree is complete.

LI G A T E SB

LI G A T E SB

0

1

0

1

0 1

0

1

0

1

0

1

01

Symbols :

B: 00

I:01

G:100

A:101

T:1100

E:1101

L:1110

S:1111

2Bit*(1+1)+3Bit*(1+1)+4Bit*(1+1+1+1)/9=2.888888 Bits/symbol

Advantages and disadvantages of Huffman

This compression algorithm is mainly efficient in compressing text or program files. Images like they are often used in prepress are better handled by other compression algorithms.

What are the advantages of Huffman coding?

Algorithm is easy to implement

Produce a lossless compression of images

Adaptive Huffman Coding(Dynamic Huffman Coding)

Advantage: Source is encoded in real time.

Disadvantage: More chance for transmission error.

Arithmetic Coding

What are the Advantages of arithmetic coding over Huffman coding?

1.the compression ratio is higher compared to huffman coding.

2.efficiency is greater comparatively.

3.Redundancy is much reduced.

THANK YOU