📄 segcmp_bior44a33.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=1;Nh=2;
[Cl,Sl] = WAVEDEC2(lowfreq_comp,Nl,'bior4.4');
[Ch,Sh] = WAVEDEC2(CH1,Nh,'bior3.3');
THR=20;
[XCl,CXCl,LXCl,PERF0l,PERFL2l] = WDENCMP('gbl',Cl,Sl,'bior4.4',Nl,THR,'s',1);
[XCh,CXCh,LXCh,PERF0h,PERFL2h] = WDENCMP('gbl',Ch,Sh,'bior3.3',Nh,THR,'s',1);
X = WAVEREC2(CXCl,LXCl,'bior4.4');
Y = WAVEREC2(CXCh,LXCh,'bior3.3');
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
% 39.0044
%
% the time need to execute this SBWC
%
% ans =
%
% 12.1300
%
% 8.9682e+003
%
% signal to noise ratio
% 30.4006
%
% 89.6550
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -