View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

4.2 | 37 ratings Rate this file 41 Downloads (last 30 days) File Size: 229 KB File ID: #4808 Version: 1.2



Kanchi (view profile)


26 Apr 2004 (Updated )

SPIHT matlab code (without Arithmatic coding stage)

| Watch this File

File Information

MATLAB implementation of SPIHT (without Arithmatic coding stage)


This file inspired 3 D Spiht.

Required Products Image Processing Toolbox
Wavelet Toolbox
MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (49)
19 Feb 2017 ravindra mutta

Input argument "max_bits" is undefined.

Error in ==> func_SPIHT_Enc at 17
out = 2*ones(1,max_bits);

Comment only
19 Feb 2017 ravindra mutta

Input argument "level" is undefined.

Error in ==> func_DWT at 18
[C,S] = func_Mywavedec2(I,level,Lo_D,Hi_D);

Comment only
17 Feb 2017 thisisinsane matlabiscrazy

I think, the most of these lines of programs submitted to the public here are taken from the matlab code available in

Comment only
13 Feb 2017 patnana Adinarayana

can any one mail me matlab coding for image compression using spiht. 3 level wavelet transform image compression method, thank u

11 May 2016 Binh Nguyen

Hi everyone,

It is ok when I run this code with 8 bit depth images and dimension are 256 x 256 or 512 x 512. But it doesn't work with images (8 bit depth) have other dimensions (e.g. 1152 x 768). Is there anyone know why and how to fix it? If you know, please tell me. My email is Thank so much!

Comment only
08 Jul 2015 bebi sekit

07 Jul 2015 bebi sekit

Thank you so much for sharing this great code. It's helping me a lot to learn SPIHT. Can anybody please tell me why 'value' is defined as: value = floor(abs(2^(n_max-n+1)*m(LSP(temp,1),LSP(temp,2))));
instead of just taking the values from LSP? Thank you!

Comment only
21 Jun 2014 hanaa

hanaa (view profile)

Dear all;
many thanks for the code.
Can any one mail me with listless SPIHT code and strip based code, my email is
thanks in advance.

16 Nov 2012 priya das

can any one pls mail me the code for plotting the graph between bit per pixel and mail id is

14 Nov 2012 priya das

nice one. can any one please mail me the code to plot the graph of bits per pixel vs psnr. my mail id is

27 Sep 2012 Ravikant Sinha

Hi Everone,
Can somebody please share the matlab code for colour image compression using SPHIT algorithm and Isphit Algorithm.My email ID:
Many thanks in advance.

13 Oct 2011 mangesh L

give me matlab code for B2 coding

07 Oct 2011 Jan Stolarek

Very nice code, although it could use some refactoring, e.g. this part in the main demo file:

OrigSize = size(Orig_I, 1);
max_bits = floor(rate * OrigSize^2);
OutSize = OrigSize;
image_spiht = zeros(size(Orig_I));
[nRow, nColumn] = size(Orig_I);
n = size(Orig_I,1);
n_log = log2(n);
level = n_log;

Could be simple rewritten as:

[nRow, nColumn] = size(Orig_I);
max_bits = floor(rate * nRow^2);
level = log2(nRow);

OutSize and image_spiht are never used in fact. Last line assumes silently that dimensions of the image are power of 2 and that there are at least as many columns as rows. Perhaps this would be better:
level = floor( log2( min( [ nRow, nColumn ] ) ) );

Matlab code analyzer complains a lot about variables growing inside the loops. I think that optimizing that could improve performance a lot.

06 Aug 2011 Universidad granada

Hello everyone, I have a problem with the SPIHT algorithm, when the images are different from 512x512, someone could help me. thank you very much. My email is If you find the solution, thank you very much

Comment only
05 Jan 2011 Jewel

Jewel (view profile)

I got problem on PSNR when compressing dicom image 512x512x3 using this coding. Is it because it is rgb/truecolor image? Do I need to convert it to indexed image?

Comment only
17 Dec 2009 xiao –

this program has som errors in its psnr,if you want provided with the right one ,plesae contact with me

14 Mar 2009 falgun thakkar

given code is very good, but i want arithmatic code for image compression

Comment only
02 Jul 2008 OLIVIERO oli

good morning
i want to convert a signal with .dat extention to binary signal .bin
because i want to compression ECG
i can't undestand the code gived..please help
thanx a lot

30 Jun 2008 shital khalane

Your code is very helpful for me.but i want explanation for each & every line so that i can understand coding. can u help me?

04 May 2008 Yi ZOU

Your code is very helpful for me. But i found that your root nodes are not in the LL. Am i right? Thank you again.

17 Apr 2008 hbbpapn omo


05 Apr 2008 Nidhi Kulkarni

the code is excellent but i want to access the compressed file and want to know the size of that compressed file in KB/MB as well as in pixels....
can u guide me please...
thanx a lot !!

16 Mar 2008 prasad prasad

25 Jan 2008 nithin nagaraj

Very well written code and very useful. Thanks much.

29 Apr 2007 Grigorios Tsagkatakis

Good work


I am using SPIHT algorithm for imge compression. in C language as specified in the AMIR SAEED IEEE PAPER. i want to go for programming in the MATLAB i am finding problem in C during LINKING and also in MATLAB EXECUTION PLEASE HELP ME OUT.

25 Jul 2006 Humberto Ochoa

Very good, thank you for this program

09 May 2006 rings kanchi

To all: sum2 means the 2-D summation. That is, sum2(X) = sum(sum(X)) for the input 2-D matrix X.

09 May 2006 M Khan

I used the SPIHT coding from your program. It nice. Thank you.

But func_SPIHT_Main.m gives some problems there is call to sum2 but i could not find any method sum2 func_SPIHT_Main.m gives error message. I replace sum2 with sum but it gives some other error.s

06 May 2006 Gabriel Peyré

Amazing toolbox!
Great implementation, great results. The different parts of the process are nicely splited.

04 Apr 2006 Sidharth Modi

Best code see on this Site

31 Jan 2006 Omar Sharif

Excellent....pray for me as i can be like u....

24 Jan 2006 Sundaram RMD

Its an excellent package. I had some problems in implementing the idea, which got cleared after going through. Hats off to the programmer.

16 Jan 2006 Soman KP

Excellent tool for researchers and students to play with and understand the concepts

25 Dec 2005 srinivasarao ronanki

Its nice to interact as well as helping for all,those who are having problems in coding

24 Dec 2005 raj kumar

excellent help you are providing to the people

24 Dec 2005 raj kumar

very good

04 Nov 2005 woshidada woshidada

thank you !It's my need;

30 Aug 2005 avinash bp

can u plz send me the c or c++ code for speck algorithm...thnk you...
my alternate email id is

Comment only
03 Aug 2005 Nissim Nabar

17 May 2005 Solomon Johnsen

please send me a matlab code for haar transform based image compression w/c display compression ratio

08 May 2005 swf 000117

some updata in

thanks for

01 Feb 2005 Dini Franc


25 Oct 2004 Raghad Al_Assadi

please,how can i do if wavelet packet transform?
send me any answer at my e-mail.

Comment only
13 Oct 2004 quer zhu


03 Jun 2004 jin yuan

i wanna somebody could tell me where to get adaptive binary arithmetic coding code,and thanx very much.

Comment only
13 May 2004 Matthew Teow

Well done

10 May 2004 hu wei


02 May 2004 zxda asdas

need yo

Comment only
30 Apr 2004

please change this code to "image processing" section. Thank you.

15 Feb 2011 1.1

update few help lines.

07 Sep 2011 1.2

Correcting few typos.

Contact us