www.pudn.com > ex5-5.rar > func_SPIHT_Main.m


function func_SPIHT_Main 
% Matlab implementation of SPIHT (without Arithmatic coding stage) 
% 
% Main function  
% 
% input:    Orig_I : the original image. 
%           rate : bits per pixel 
% output:   img_spiht  
% 
% Jing Tian 
% Contact me : scuteejtian@hotmail.com 
% This program is part of my undergraduate project in GuangZhou, P. R. China. 
% April - July 1999 
 
%-----------   Input   ---------------- 
Orig_I = func_ReadRaw('lena512.raw', 512*512, 512, 512); 
rate = 0.1; 
 
%-----------   Pre-processing   ---------------- 
 
OrigSize = size(Orig_I, 1); 
max_bits = floor(rate * OrigSize^2); 
 
OutSize = OrigSize; 
image_spiht = zeros(size(Orig_I)); 
% "image " is the input of codec 
[nRow, nColumn] = size(Orig_I); 
 
 
%-----------   Wavelet Decomposition   ---------------- 
n = size(Orig_I,1); 
n_log = log2(n);  
level = n_log; 
% wavelet decomposition level can be defined by users manually. 
 
type = 'bior4.4'; 
[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters(type); 
 
[I_W, S] = func_DWT(Orig_I, level, Lo_D, Hi_D); 
 
%-----------   Coding   ---------------- 
img_enc = func_SPIHT_Enc(I_W, max_bits, nRow*nColumn, level);    
 
%-----------   Decoding   ---------------- 
img_dec = func_SPIHT_Dec(img_enc); 
 
%-----------   Wavelet Reconstruction   ---------------- 
img_spiht = func_InvDWT(img_dec, S, Lo_R, Hi_R, level); 
 
%-----------   PSNR analysis   ---------------- 
Q = 255; 
MSE= sum(sum((img_spiht - Orig_I) .^ 2))/ nRow / nColumn;  
psnr= 10*log10(Q*Q/MSE)