No BSD License  

Highlights from
Huffman Coding and Arithmetic Coding

2.66667

2.7 | 9 ratings Rate this file 78 Downloads (last 30 days) File Size: 47.08 KB File ID: #2818

Huffman Coding and Arithmetic Coding

by Karl Skretting

 

05 Dec 2002 (Updated 09 Dec 2002)

Functions that compress integer sequences.

| Watch this File

File Information
Description

This file contains MATLAB functions, m-files, that do Huffman coding and arithmetic coding of integer (symbol) sequences. Complete coding may be done by calling an easy to use main program (or main function), where input argument is the sequences you want to compress and the output is the compressed bitstream, as a vector of bytes. Decoding is done just by switching the arguments. These main programs are: the Huffman coder, Huff06 an updated version of the Huff03 function sbmitted earlier, and two versions of the arithmetic coder, Arith06.m and Arith07.m. The zipped file also contains examples and a contents file.

Example of use:
 y=Huff06(xC); % encoding
 xC=Huff06(y); % decoding
where xC is a cell array of column vectors of integers representing the symbol sequences and y is a column vector of non-negative itegers (bytes) representing the code, 0 <= y(i) <= 255.

For more information see the web page: http://www.ux.his.no/~karlsk/proj99/

MATLAB release MATLAB 6.1 (R12.1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (14)
13 Mar 2003 Norbert Marwan

I'm rather frustrated with this programme.

First, the names of the functions contain uppercase letters. However, sometimes these functions are called with lowercase letters (eg in Huff06 the HuffLen), which will lead to an error on case sensitive systems. It is much better to use only lower case letters!

The encoder/decoder is very slow. Maybe some vectorization of the loops can be applied in order to speed up the algorithm.

The help and Contents are not correctly formatted, eg the mentioned functions in the Contents cannot be used as links. An workung example, how the encoder/decoder works, should be given in the helptext.

26 Jun 2003 Antti Stenvall

I think that this isn't working properly.
I have a sequence (propabilities for symbols)
p = [49 26 12 4 4 3 2];
And HuffLen+HuffCode gives me coding:
  Symbol 1 gets code: 0
  Symbol 2 gets code: 10
  Symbol 3 gets code: 110
  Symbol 4 gets code: 11100
  Symbol 5 gets code: 11101
  Symbol 6 gets code: 11110
  Symbol 7 gets code: 11111

The First Three rounds are okay, but then it makes wrong encoding. It just switches somehow the symbols. Or am I just stupid?

05 Sep 2003 Arsalan Naeem

need to improve more, but overall good work

30 Sep 2003 asem eshtyeh

please can you send to me code in matlab abuot 2.4Kbps linear predcition coding
  i will very thanks

20 Mar 2004 derasriya sunil  
20 Apr 2004 Yeditepe University

poor programming and documentation.

19 Jul 2004 Enrique Estalayo

Poor documentation and non-clear programming algorithms. Difficult to follow the structure of the code

17 Oct 2005 jeya shree

nice

14 Dec 2005 M Khan

I got the following error message when I tried to execute TestHuff.m
-----------------------
BitsUsed=2090 bits=2109
??? エラー: ==> Huff06>EncodeVector
Huff06-EncodeVector: Logical error, (BitsUsed~=bits).

01 May 2006 Matlab User

I also get errors just by running TestHuff:

BitsUsed=2090 bits=2109
??? Error using ==> Huff06>EncodeVector
Huff06-EncodeVector: Logical error, (BitsUsed~=bits).

Error in ==> Huff06 at 140
      [bits, ent]=EncodeVector(x); % store the (abs and/or log) values

Error in ==> TestHuff at 38
[y, Res]=Huff06(xC, Level, Speed);

Using Matlab 7 R14 SP3

21 Mar 2007 hassan abid

 also get errors just by running TestHuff:

BitsUsed=2090 bits=2109
??? Error using ==> Huff06>EncodeVector
Huff06-EncodeVector: Logical error, (BitsUsed~=bits).

Error in ==> Huff06 at 140
[bits, ent]=EncodeVector(x); % store the (abs and/or log) values

Error in ==> TestHuff at 38
[y, Res]=Huff06(xC, Level, Speed);

Using Matlab 7 R14 SP3
reply as soon as possible

29 Aug 2007 Matlab User

"coding of integer (symbol) sequences", but double data is used?! -> Just theoretical value.

10 Jan 2008 Burak Olcay  
09 May 2011 Karl Skretting

Authors remark May 2011: An updated version is available from web-page: http://www.ux.uis.no/~karlsk/proj99/index.html (comp.zip). Some few errors has been corrected the last 10 years, but the program is essential like before.
My e-mail is now: karl.skretting@uis.no

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
coding theory Karl Skretting 22 Oct 2008 06:54:41
information theory Karl Skretting 22 Oct 2008 06:54:41
arithmetic coding Karl Skretting 22 Oct 2008 06:54:41
huffman coding Karl Skretting 22 Oct 2008 06:54:41
matlab Karl Skretting 22 Oct 2008 06:54:41
mfiles Karl Skretting 22 Oct 2008 06:54:41
compression Karl Skretting 22 Oct 2008 06:54:41
arithmetic coding Aik 03 Jun 2009 15:50:46
arithmetic coding Ryszard maciol 28 Jul 2009 17:03:47
mfiles mohammeed 14 Oct 2009 07:40:58
huffman coding JALIL UR REHMAN KAZIM 02 Dec 2009 08:22:44
arithmetic coding Udaya 16 Feb 2011 07:49:31
coding theory Udaya 16 Feb 2011 07:49:40
arithmetic coding Ankitha 28 Apr 2011 02:03:28
huffman coding prashant phanse 29 Apr 2011 19:41:10
mfiles Shrinivas bhat 14 Nov 2011 00:53:10

Contact us at files@mathworks.com