?? db2.m
字號:
%IMAGE COMPRESSION USING WAVELET TRANSFORM
clear all;
close all;
t=cputime;
input_ima=imread('saturn.tif');
N=5;
[CA,CH,CV,CD] = DWT2(input_ima,'db2');
[C,S] = WAVEDEC2(CA,N,'db2');
THR=20;
[XC,CXC,LXC,PERF0,PERFL2] = WDENCMP('gbl',C,S,'db2',N,THR,'s',1);
X = WAVEREC2(CXC,LXC,'db2');
z = IDWT2(X,CH,CV,CD,'db2')
out=uint8(z);
out1=imresize(out,[328,438]);
disp('The compression ratio using WBC');
disp(PERF0);
figure;
imshow(out1);
title('recons ima using wbc only');
input_ima1=double(input_ima);
out2=double(out1);
error=0;
for y=1:438
for x=1:328
MSE=((input_ima1(x,y))-(out2(x,y)))^2;
error=MSE+error;
% error_sbw1=error_sbw+MSE2;
end
end
MSE_WO=(1/(328*438))*error;
%MSE_SBW=(1/(256*256))*error_sbw1;
disp('PSNR value for decompression image using wavelet compression only');
PSNR_WO=20*log10(255/sqrt(MSE_WO));
disp(PSNR_WO);
diff_ima=imsubtract(input_ima1,out2);
figure;
imshow(diff_ima);
title('difference image');
disp('the time need to execute this WBC only');
cputime-t
in=imresize(input_ima1,[1,143664]);
va=var(in);
disp(va);
snr=10*log10(va/MSE_WO);
disp('signal to noise ratio');
disp(snr);
% The compression ratio using WBC
% 90.3647
%
% PSNR value for decompression image using wavelet compression only
% 36.7295
%
% the time need to execute this WBC only
%
% ans =
%
% 9.7300
%
% 8.9682e+003
%
% signal to noise ratio
% 28.1257
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -