⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 db5.m

📁 image compression matlab code
💻 M
字号:
%IMAGE COMPRESSION USING WAVELET TRANSFORM
clear all;
close all;
t=cputime; 
input_ima=imread('cell.tif');

N=5;
[CA,CH,CV,CD] = DWT2(input_ima,'db5');
[C,S] = WAVEDEC2(CA,N,'db5');
THR=20;
 [XC,CXC,LXC,PERF0,PERFL2] = WDENCMP('gbl',C,S,'db5',N,THR,'s',1);
    X = WAVEREC2(CXC,LXC,'db5');
    z = IDWT2(X,CH,CV,CD,'db5')
    out=uint8(z);
    out1=imresize(out,[159,191]);
     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:191
     for x=1:159
        MSE=((input_ima1(x,y))-(out2(x,y)))^2;
        error=MSE+error;
      %  error_sbw1=error_sbw+MSE2;
     end
 end
 MSE_WO=(1/(159*191))*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,30369]);

va=var(in);
disp(va);
snr=10*log10(va/MSE_WO);
disp('signal to noise ratio');
disp(snr);

% The compression ratio using WBC
%    85.6539
% 
% PSNR value for decompression image using wavelet compression only
%    33.4323
% 
% the time need to execute this WBC only
% 
% ans =
% 
%     4.2900
% 
%   206.3347
% 
% signal to noise ratio
%     8.4473

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -