Wavelet transform image compression based --MATLAB

Wavelet transform to a function as follows :
wavedec2 () function: a two-dimensional wavelet decomposition of a multilayer signal
appcoef2 () function: the ability to extract two-dimensional low frequency wavelet coefficients
wrcoef2 () function: the ability to extract two-dimensional high-frequency wavelet coefficients i.e. (wavelet coefficients)
wcodemat () function: the data matrix for pseudo-color coding
ddencmp () function: the default values can be used to obtain the threshold value (soft or hard) standard entropy, or to dry for compression. ,
Wdencmp () function: to dry or can be used to perform compression work.
wfusimg () function: the job is a fusion of two input images.

[ Notes ] 'a' refers to the low-frequency component reconstructed high-frequency component reconstructed hvd respectively horizontal, vertical and oblique components

clear all;
clc;
load wbarb
subplot(221);
image(X);
colormap(map)
title('原始图像');
axis square
disp('压缩前图像X的大小');
whos('X')
% 对图像用小波进行层分解
[c,s] = wavedec2(X,2,'bior3.7');
ca1 = appcoef2(c,s,'bior3.7',1);  % 提取小波分解结构中的一层的低频系数和高频系数
ch1 = detcoef2('h',c,s,1);   % 水平方向
cv1 = detcoef2('v',c,s,1);   % 垂直方向
cd1 = detcoef2('d',c,s,1);   % 斜线方向
a1 = wrcoef2('a',c,s,'bior3.7',1);
h1 = wrcoef2('h',c,s,'bior3.7',1);
v1 = wrcoef2('v',c,s,'bior3.7',1);
d1 = wrcoef2('d',c,s,'bior3.7',1);  % 各频率成分重构成各自图像
c1 = [a1,h1;v1,d1];
subplot(222);
image(c1);
axis square;
title('分解后低频和高频信息');
% 进行图像压缩
% 保留小波分解第一层低频信息
% 首先对第一层信息进行量化编码
ca1 = appcoef2(c,s,'bior3.7',1);
ca1 = wcodemat(ca1,440,'mat',0);
ca1 = 0.5*ca1;
subplot(223);
image(ca1);
colormap(map);
axis square;
title('第一次压缩图像');
disp('第一次压缩图像的大小为:');
whos('ca1')
ca2 = appcoef2(c,s,'bior3.7',2);
ca2 = wcodemat(ca2,440,'mat',0);
ca2 = 0.25*ca2;
subplot(224);
image(ca2);
colormap(map);
axis square;
title('第二次压缩图像');
disp('第二次压缩图像的大小为:');
whos('ca2')



Results are as follows:

压缩前图像X的大小
  Name        Size              Bytes  Class     Attributes

  X         256x256            524288  double              

第一次压缩图像的大小为:
  Name        Size              Bytes  Class     Attributes

  ca1       135x135            145800  double              

第二次压缩图像的大小为:
  Name       Size            Bytes  Class     Attributes

  ca2       75x75            45000  double   

Pictures show as follows:
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/Prince_IT/article/details/90112021