www.pudn.com > spiht-0.3.rar > f_SPIHT_Main.m


function [Orig_I,img_spiht]=f_SPIHT_Main(in_file,out_file,nRow,nColumn,level,rate,out_stream) 
% Matlab implementation of SPIHT (without Arithmatic coding stage) 
% 
% Main function  
% 
% input:    in_file : the original image file. 
%           out_file: the decompression image file 
%            nRow:  
%            nColumn: 
%            levels: 
%            rate:bits per pixel 
%            out_stream:decompression file stream 
%             
% output:    Orig_I 
%            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(in_file,nRow,nColumn); 
 
%-----------   Pre-processing   ---------------- 
image_spiht = zeros(nRow,nColumn); 
% "image " is the input of codec 
 
%-----------   Wavelet Decomposition   ---------------- 
%n = size(Orig_I,1); 
%n_log = log2(n);  
%level = 4;%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); 
 
I_W=d2fldwt9_7(Orig_I, level); 
%-----------   Coding   ---------------- 
func_SPIHT_Enc(I_W,level,rate,out_stream); 
 
%-----------   Decoding   ---------------- 
img_dec = func_SPIHT_Dec(out_stream); 
 
%-----------   Wavelet Reconstruction   ---------------- 
% img_spiht = func_InvDWT(img_dec, S, Lo_R, Hi_R, level); 
img_spiht=d2bldwt9_7(img_dec,level); 
 
%-----------  output image file ---------------- 
func_WriteRaw(img_spiht,out_file); 
 
%-----------   PSNR analysis   ---------------- 
Q = 255; 
OrigSize = nRow*nColumn; 
MSE = sum(sum((img_spiht - Orig_I) .^ 2)) / OrigSize; 
psnr = 10*log10(Q*Q/MSE) 
subplot(1,2,1) 
imshow(Orig_I,[0 255]) 
subplot(1,2,2) 
imshow(img_spiht,[0 255])