File Exchange

image thumbnail


version (229 KB) by Kanchi
SPIHT matlab code (without Arithmatic coding stage)


Updated 07 Sep 2011

View License

MATLAB implementation of SPIHT (without Arithmatic coding stage)

Comments and Ratings (54)


Please I am using only SPIHT on my image - it is working but the compression is way too high (PSNR 1dB). How to reduce it?

Hi, Code is very well written for the understanding of SPIHT algorithm.But it doesn't seem to work for sizes other than 512x512?Can someone please help me with that?My mail id is

Bits_Header = Bits_Header + 24 ?
bitctr = bitctr + 24 ?

How to find the compression ratio in this code

Input argument "max_bits" is undefined.

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

Input argument "level" is undefined.

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

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

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

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!

bebi sekit

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!


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.

priya das

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

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

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.

mangesh L

give me matlab code for B2 coding

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.

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


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?

xiao –

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

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


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

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?


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.

hbbpapn omo


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 !!

prasad prasad

nithin nagaraj

Very well written code and very useful. Thanks much.

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.

Humberto Ochoa

Very good, thank you for this program

rings kanchi

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

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

Gabriel Peyré

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

Sidharth Modi

Best code see on this Site

Omar Sharif

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

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.

Soman KP

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

srinivasarao ronanki

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

raj kumar

excellent help you are providing to the people

raj kumar

very good

woshidada woshidada

thank you !It's my need;

avinash bp

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

Nissim Nabar

Solomon Johnsen

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

swf 000117

Dini Franc


Raghad Al_Assadi

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

quer zhu


jin yuan

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

Matthew Teow

Well done

hu wei


zxda asdas

need yo


Correcting few typos.

update few help lines.

The program has been revised to support BMP file.

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

MATLAB Release Compatibility
Created with R14SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: 3D-SPIHT

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor