No BSD License  

Highlights from
Wavelet based image compression using segmentation

from Wavelet based image compression using segmentation by THAYAMMAL SUBBURAJ
The optimal wavelet function in wavelet based image compression system was examined using different

decom_29.m
%removes all variables from the workspace. 
clear;
clear all;
close all;

%start clock for calculate time need to execute this algorithm
t=cputime; 

%read the input image
input_ima=imread('saturn.tif');

%Discrete wavelet transform is used to seperate the input as 
%low frequency and high frequency component
[lowfreq_comp,highfreq_compH,highfreq_compV,highfreq_compD] = DWT2(input_ima,'bior2.2');


app_ima=uint8(lowfreq_comp);
%to chow low frequency component 
% figure;
% imshow(app_ima);

deta_ima=imadd(highfreq_compH,highfreq_compV);
detail_ima=imadd(deta_ima,highfreq_compD);
% figure;
% imshow(detail_ima);
CH1=uint8(detail_ima);
out=imadd(app_ima,CH1);
% figure;
% imshow(out); 

Nl=2;Nh=9;
[Cl,Sl] = WAVEDEC2(lowfreq_comp,Nl,'bior5.5');
[Ch,Sh] = WAVEDEC2(CH1,Nh,'bior2.2');
THR=20;
 [XCl,CXCl,LXCl,PERF0l,PERFL2l] = WDENCMP('gbl',Cl,Sl,'bior5.5',Nl,THR,'s',1);
  [XCh,CXCh,LXCh,PERF0h,PERFL2h] =  WDENCMP('gbl',Ch,Sh,'bior2.2',Nh,THR,'s',1);
   X = WAVEREC2(CXCl,LXCl,'bior5.5');
    Y = WAVEREC2(CXCh,LXCh,'bior2.2');
    z = IDWT2(X,Y,Y,Y,'bior2.2')
    %z=imadd(X,Y);
    recons_ima=uint8(z);
    out=imresize(recons_ima,[328,438]);
    figure;
    imshow(out);
    title('Recons ima using SBWC')
    
input_ima1=double(input_ima);
    out1=double(out);
    error=0;
  for y=1:438
     for x=1:328
        MSE=((input_ima1(x,y))-(out1(x,y)))^2;
        error=MSE+error;
      %  error_sbw1=error_sbw+MSE2;
     end
 end
 MSE_WO=((1/(328*438))*error);
 disp(MSE_WO);
 %MSE_SBW=(1/(256*256))*error_sbw1;
    
 disp('PSNR value for decompressed image using segmentation based wavelet compression');
 PSNR_WO=20*log10(255/sqrt(MSE_WO));
 disp(PSNR_WO);
 diff_ima=imsubtract(input_ima1,out1);
figure;
imshow(diff_ima);
title('difference image in SBWC');
disp('the time need to execute this SBWC'); 
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);
disp(PERF0l);
    disp(PERF0h);
    cr=((PERF0l+PERF0h)/2);
    disp(cr);
    
% % 
% % 
% 
% PSNR value for decompressed image using segmentation based wavelet compression
%    37.2569
% 
% the time need to execute this SBWC
% 
% ans =
% 
%    12.3000
% 
%   8.9682e+003
% 
% signal to noise ratio
%    28.6532
%    94.1576

Contact us at files@mathworks.com