hufman coding basic

17
DIGITAL IMAGE PROCESSING TOPIC: HUFFMAN CODING NAME :J.RADTHEES R.NO :15MFS04

Upload: radthees

Post on 15-Apr-2017

183 views

Category:

Education


0 download

TRANSCRIPT

Page 1: Hufman coding basic

DIGITAL IMAGE PROCESSINGTOPIC: HUFFMAN CODING

NAME :J.RADTHEESR.NO :15MFS04

Page 2: Hufman coding basic

Introduction

Digital image coding and compression:

Techniques and algorithms concerned with the minimization of

the memory needed to represent and store digital images.

Compression factors:

Transmission and storing of large images

Reduce of baud rate

Baud rate means number of data bits transmitted in one second.

Reduce of transmission time.

Page 3: Hufman coding basic

Lossless compression techniques:

These are used when raw image data are difficult to obtain or

contain vital information that may be destroyed by compression.

EX:-Medical diagnostic imaging.

Lossy compression techniques:

These can be used when raw image data can be easily

reproduced or when the information loss can be tolerated at the receiver

site.

EX:-Facebook images.

Page 4: Hufman coding basic

Huffman Coding

• There are many ways to store information.Computer

sceintists are always looking for new and better ways to

store strings of data with little space as possible.

• Huffman coding is a method of storing strings of data as

binary code in an efficient manner.

• Huffman coding uses ‘lossless data compression ‘,which

means no information is lost.

Page 5: Hufman coding basic

5

• It makes use of a binary tree to develop codes of varying lengths for

the letters used in the original message. which means that symbols in

the data you are encoded are converted to a binary symbol based on

how often that symbol is used. For example : If the character ‘a’ is

used in your data a lot,the binary symbol representing it is shorter.If it

is used rarely,the symbol representing it is longer.This way all the

data will take less physical space when encoded.

• Huffman code is also part of the JPEG image compression scheme.

• The algorithm was introduced by David Huffman in 1952 as part of a

course assignment at MIT.

Page 6: Hufman coding basic

Algorithm:

Page 7: Hufman coding basic

Example:

Char Frequency

a 1

b 6

c 7

d 2

e 8

a:1 b:6 c:7 d:2 e:8

Imagine these as 5 separate trees and combine two smallest trees in order

1. List all the letters used,along with the frequency with which they occur in the message.

2. Consider each of these (character,frequency) pairs to be nodes; they are actually leaf nodes, as we will see.

3. Pick the two nodes with the lowest frequency, and if there is a tie, pick randomly amongst those with equal frequencies.

Page 8: Hufman coding basic

Char Frequency

a 1

b 6

c 7

d 2

E 8a:1

b:6 c:7

d:2

e:8

3

4. Make a new node out of these two, and make the two nodes its children.

5. This new node is assigned the sum of the frequencies of its children.

6.Continue the process of combining the two nodes of lowest frequency until

only one node, the root, remains.

Page 9: Hufman coding basic

Char Frequency

a 1

b 6

c 7

d 2

e 8 a:1

b:6

c:7

d:2

e:8

3

9

Page 10: Hufman coding basic

Char Frequency

a 1

b 6

c 7

d 2

e 8

a:1

b:6

d:2

3

9

c:7 e:8

15

Page 11: Hufman coding basic

Char Frequency

a 1

b 6

c 7

d 2

e 8Now we have large tree containing all characters,we now assign binary data to each symbol by gong down the tree.

a:1

b:6

d:2

3

9

c:7 e:8

15

24

Page 12: Hufman coding basic

Char Frequency

a 1

b 6

c 7

d 2

e 8a:1

b:6

d:2

3

9

c:7 e:8

15

24

0

0

0

1

1

1

10

7. Start at the root. Assign 0 to left branch and 1 to the right branch.

8.Repeat the process down the left and right subtrees.

9. To get the code for a character, traverse the tree from the root to the

character leaf node and read off the 0 and 1 along the path.

Page 13: Hufman coding basic

A=000B=01C=10D=001E=11

a:1

b:6

d:2

3

9

c:7 e:8

15

24

0

0

0

1

1

1

10

This is what a,b,c,d,e each will be converted to,

Char Frequency

Bits Huffman bits

a 1 000 3

b 6 01 12

c 7 10 14

d 2 001 6

e 8 11 16

Total 51

Page 14: Hufman coding basic

Encoding:

Encoding is the process of putting a sequence of characters

into a specialized format for efficient transmission or storage.

A=000b=01c=10d=001e=11

Encode abcde using the results from huffman coding.

Abcde=000011000111

Page 15: Hufman coding basic

Decoding:Decoding is the conversion of an encoded format back into the

original sequence of characters.•Decode 1011001000011101•Compare the above representations above to the binary code bit by bit to fill only the possible result. 101100100001101= c 11001000011101(only c starts with 1,then 0)

= c e 001000011101(only e starts with 1,then 1) = c e d 000011101(only d starts with 0,then 0,then = c e d a01101(only a starts with 0,then 0,then 0) = c e d a b1101(only b starts with 0,then 1) = c e d a b e01(only e starts with 1,then 1) = c e d a b e b(only b starts with 0,then 1)

Page 16: Hufman coding basic

Applications:

•Supports various file types.

ZIP(Multichannel compression including text and other data

types)

JPEG

MPEG(only 2 layers)

•Also used in stegnography for JPEG carrier compression.

Page 17: Hufman coding basic

Thank you…