Sie sind auf Seite 1von 20

HUFFMAN ENCODING AND DECODING

USING MATLAB
Internal Guide : SVMG Phani Kumar C
ECE-B Coordinator : Mrs. Neha Jain
S. Poojitha (14321A0474)
M. Rupa (14321A04A0)
B. Sai Sruthi (14321A04A6)
Contents
 Aim
 Block Diagram
 Huffman Coding
 Flow Chart of Huffman algorithm
 Nature of Huffman coding
 Matlab
 Specific Syntaxes
 Result
 Advantages and Applications
 Conclusion and Future scope
Aim

 The Main Aim of the project “HUFFMAN ENCODING AND


DECODING USING MATLAB” is to compress the data in lossless
manner in order to achieve better efficiency.
Block Diagram
Huffman Coding

 Huffman coding is a lossless data compression algorithm. The idea


is to assign variable-length codes to input characters, lengths of
assigned codes are based on the frequencies of corresponding
characters.

 The most frequent character gets the smallest code and the least
frequent character gets the largest code.
Why Huffman coding is preferred?

 The name Huffman code proper refers to optimal choice of code


given a distribution on the value of block.

 Huffman code satisfy optimal property.

 It is a fixed to variable code.


Flow chart of Huffman
algorithm
• All the symbol sources or message must be listed
in decreasing order of their probabilities.

• Now combine the probabilities of two source


symbols which are having the lowest
probabilities and rearrange them again in the
decreasing order.
• Repeat the above step until two ordered probabilities remain.

• Now start encoding with last reduction which contains two ordered
probabilities. Assign ‘0’ to higher probability and ‘1’ to the lower.

• Trace back and assign 0 & 1 in the second digit for the two
probabilities by which it was obtained in the previous reduction
process.

• Repeat this process until first column is reached.

• Write the code for each symbol.


Representation of a binary code

100 %

0 1

45 % 55 %
a = 0
0 1

25 % 30 %

0 1 0 1

12 % 13 % 14 % 16 %
c = 100 b = 101 d = 111
0 1

5% 9%
f = 1100 e = 1101
Nature of Huffman Coding

• Prefix Code:

A prefix code is a type of code system(typically a variable-length


code) distinguished by its possession of the “Prefix property”.

• Uniquely decodable code:

A Uniquely decodable code is a variable length code in which bit

strings can always be uniquely decomposed into its codewords.


• Entropy:

The average amount of information present in the symbol is known


as Entropy. Denoted by ‘H’.

• Efficiency:

It is defined as the ratio of amount of information present in the


symbol to the average code word length.
Matlab

• Matlab started developing in 1970’s.

• Matlab is a high performance language for technical computating.

• It integrates computation, visualization and programming in an


easy-to-use environment where problems and solutions are
expressed in familiar mathematical notation.
Specific Syntaxes used in the code

 [dict,avglen]= huffmandict(symbols,p)

It generates a binary huffman code dictionary using the maximum


variance algorithm.

 temp{i,2}=num2str(temp{I,2})

It converts numeric array into a character array that represents the


numbers.
 encod=huffmanenco(sym,dict)

This encodes signal system using the Huffman codes described by the
code dictionary dict.

 decod=huffmandeco(bits,dict)

This decodes the numeric Huffman code vector bits using the code
dictionary dict.
RESULT
Advantages

• Algorithm is easy to implement.

• Produce a lossless compression.

Applications

Huffman coding has various applications like.,

 Compressing text files in Windows Operating System.

 JPEG frame compression.

 Text compression in ZIP files.


Conclusion

 The result shows that higher code redundancy helps to achieve more
compression.

 The result also reveals that original data used for coding is almost
same as the decoded output.

 Hence, Huffman Coding is efficient technique for data compression


and decompression.
Future Scope

 Other methods of data compression can be carried out as Lempel-ziv


coding, Arithmetic coding, etc.
References

 D.A. Huffman, “A method for the construction of minimum


redundancy codes”, proceeding of the I.R.E, September 1952, pp
1098-1102, Huffman’s original article.

 Introduction of data compression, K. Sayood, Morgan Kauffman,


second edition. 2000

 http://www.prepressure.com/library/compression-
algorithms/huffman

Das könnte Ihnen auch gefallen