www.pudn.com > SPIHT(Matlab).rar > 12.m
function [Orig_I,img_spiht,I_W,out,in,S,img_dec,C1]=func_SPIHT_Main(in_file,out_file,level,rate,out_stream) % Matlab implementation of SPIHT (without Arithmatic coding stage) tic % 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 % %----------- Input ---------------- %Orig_I=imread(in_file); %Orig_I(257:512,257:512)=0; Orig_I = imread(in_file); Orig_I = double(Orig_I); [nRow,nColumn]=size(Orig_I); %----------- Pre-processing ---------------- image_spiht = zeros(nRow,nColumn); % "image " is the input of codec %----------- Wavelet Decomposition ---------------- %type = 'db4'; %[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);%%%利用9/7小波作小波变换 %----------- Coding ---------------- out=func_SPIHT_Enc(I_W,level,rate,out_stream,S); %----------- Decoding ---------------- [img_dec,in] = func_SPIHT_Dec(out_stream); %----------- Wavelet Reconstruction ---------------- img_spiht=d2bldwt9_7(img_dec,level);%%利用97小波进行反变换 %type = 'db4'; %[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters(type); %[img_spiht,C1] = func_InvDWT(img_dec, S, Lo_R, Hi_R, 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]); toc