Today we’ll talk about the implementation of the huffman coding using the Matlab. As you all guys are familiar with the programming language Matlab and it’s various uses in the various fields.
I’ve been working on the Image Processing section of the Matlab and Found out that Image compression using the Matlab can be done only by eliminating the three basic types of redundancies which are stated as follows:-
- coding redundancy : It is present when less than the optimal code words are used to represent any image.
- Interpixel redundancy : It arises due to the correlation between the pixels of an Image.
- PsychoVisual redundancy : It is due to the data ignored by the human visual system.
For more details about the Compression techniques and redundancies found in the image. You can follow this link Compression techniques and redundancies.
Now we’ll move ahead with our topic that is about implementing the huffman coding using the Matlab. Here i assume that you have a sufficient knowledge of Matlab prgramming. Because in this post we’re goin’ to cover the coding part of implementing huffman code with only brief and necessary theory.
When coding the grey level(intensity) of an image or the output of the grey-level mapping operation, Huffman codes contains the smallest possible number of code symbols(e.g. bits) per source symbol(e.g grey-level) subject to the constraint.
The first step in Huffman approach is to create a series of source reductions by ordering the probabilities of the symbols under consideration and combining the lowest probability symbols into a single symbol that replaces them in the next source reduction.The figure shown below illustrates the process for the gray level distributions. This figure shows the process of source reductions.
The second step in Huffman approach is to code each reduced source, starting with smallest source and working back to the original source. The minimum length binary code for a two-symbol source, of course , consists of the symbols 0 and 1.The figure below illustrates the second step of the Huffman’s procedure. The figure below show the process involved in coding the reduced source.
The huffman code represented in the figure above is an instantaneous uniquely decodable block code. It is block code because each source symbol has been mapped into a fixed sequence of code symbols. It is instantaneous because each code word in a string of code symbols can be decoded without referencing succeeding symbols.For the 4 X 4 image, a top-to-bottom, left-to-right encoding based on the figure second would yield the 29 bit string of 0 and 1.
If You found the above text insufficient for learning the huffman algorithm. You can follow this link Huffman coding and Algorithm. But for the time being I hope that you guys are familiar with the huffman coding and we’ll proceed with making a Matlab program which implements the huffman coding for the given input vector.