小波变换

一.作业内容

1 任意给定一离散的1D数字信号(或实际采集1D信号),编成实现Harr小波的一尺度快速分解,画出原始信号及分解后近似分量及细节分量图。 

2)利用上述分解得到的近似分量和细节分量,进行Harr小波反变换,即重构信号。画出重构信号的曲线。 

3)计算重构信号与原始信号的残差,画出残差曲线示意图,并对残差曲线作进一步分析。

二.作业分析

1.任意给定一离散的1D数字信号(或实际采集1D信号),编成实现Harr小波的一尺度快速分解,画出原始信号及分解后近似分量及细节分量图。

[plain]  view plain  copy
  1. %装载离散的1D数字信号  
  2. load leleccum;  
  3. s = leleccum(1:1000);%1000个采样点  
  4. %用小波函数db1对信号进行单尺度小波分解  
  5. [cA1,cD1]=dwt(s,'haar');  
  6. subplot(3,2,1); plot(s);   
  7. title('原始信号');  
  8. subplot(3,2,2); plot(cA1);  
  9. title('近似分量');  
  10. subplot(3,2,3); plot(cD1);  
  11. title('细节分量');  

2.利用上述分解得到的近似分量和细节分量,进行Harr小波反变换,即重构信号。画出重构信号的曲线。

[plain]  view plain  copy
  1. s_1 = idwt(cA1,cD1,'haar');%重构信号  
  2. subplot(3,2,4); plot(s_1);  
  3. title('重构信号');  

3.计算重构信号与原始信号的残差,画出残差曲线示意图,并对残差曲线作进一步分析。

[plain]  view plain  copy
  1. d = s_1 - s;%残差  
  2. subplot(3,2,5); plot(d);  
  3. title('残差');  


分析:Haar小波分解与重构的残差很小,证明重构很有效果。

小波变换的图像处理%MATLAB2维小波变换经典程序 % FWT_DB.M; % 此示意程序用DWT实现二维小波变换 % 编程时间2004-4-10,编程人沙威 %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%% clear; clc; T=256; % 图像维数 SUB_T=T/2; % 子图维数 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 1.调原始图像矩阵 load wbarb; % 下载图像 f=X; % 原始图像 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 2.进行二维小波分解 l=wfilters('db10','l'); % db10(消失矩为10)低通分解滤波器冲击响应(长度为20) L=T-length(l); l_zeros=[l,zeros(1,L)]; % 矩阵行数与输入图像一致,为2的整数幂 h=wfilters('db10','h'); % db10(消失矩为10)高通分解滤波器冲击响应(长度为20) h_zeros=[h,zeros(1,L)]; % 矩阵行数与输入图像一致,为2的整数幂 for i=1:T; % 列变换 row(1:SUB_T,i)=dyaddown( ifft( fft(l_zeros).*fft(f(:,i)') ) ).'; % 圆周卷积FFT row(SUB_T+1:T,i)=dyaddown( ifft( fft(h_zeros).*fft(f(:,i)') ) ).'; % 圆周卷积FFT end; for j=1:T; % 行变换 line(j,1:SUB_T)=dyaddown( ifft( fft(l_zeros).*fft(row(j,:)) ) ); % 圆周卷积FFT line(j,SUB_T+1:T)=dyaddown( ifft( fft(h_zeros).*fft(row(j,:)) ) ); % 圆周卷积FFT end; decompose_pic=line; % 分解矩阵 % 图像分为四块 lt_pic=decompose_pic(1:SUB_T,1:SUB_T); % 在矩阵左上方为低频分量--fi(x)*fi(y) rt_pic=decompose_pic(1:SUB_T,SUB_T+1:T); % 矩阵右上为--fi(x)*psi(y) lb_pic=decompose_pic(SUB_T+1:T,1:SUB_T); % 矩阵左下为--psi(x)*fi(y) rb_pic=decompose_pic(SUB_T+1:T,SUB_T+1:T); % 右下方为高频分量--psi(x)*psi(y) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 3.分解结果显示 figure(1); colormap(map); subplot(2,1,1); image(f); % 原始图像 title('original pic'); subplot(2,1,2); image(abs(decompose_pic)); % 分解后图像 title('decomposed pic'); figure(2); colormap(map); subplot(2,2,1); image(abs(lt_pic)); % 左上方为低频分量--fi(x)*fi(y) title('\Phi(x)*\Phi(y)'); subplot(2,2,2); image(abs(rt_pic)); % 矩阵右上为--fi(x)*psi(y) title('\Phi(x)*\Psi(y)'); subplot(2,2,3); image(abs(lb_pic)); % 矩阵左下为--psi(x)*fi(y) title('\Psi(x)*\Phi(y)'); subplot(2,2,4); image(abs(rb_pic)); % 右下方为高频分量--psi(x)*psi(y) title('\Psi(x)*\Psi(y)'); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 5.重构源图像及结果显示 % construct_pic=decompose_matrix'*decompose_pic*decompose_matrix; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% l_re=l_zeros(end:-1:1); % 重构低通滤波 l_r=circshift(l_re',1)'; % 位置调整 h_re=h_zeros(end:-1:1); % 重构高通滤波 h_r=circshift(h_re',1)'; % 位置调整 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% top_pic=[lt_pic,rt_pic]; % 图像上半部分 t=0; for i=1:T; % 行插值低频 if (mod(i,2)==0) topll(i,:)=top_pic(t,:); % 偶数行保持 else t=t+1; topll(i,:)=zeros(1,T); % 奇数行为零 end end; for i=1:T; % 列变换 topcl_re(:,i)=ifft( fft(l_r).*fft(topll(:,i)') )'; % 圆周卷积FFT end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bottom_pic=[lb_pic,rb_pic]; % 图像下半部分 t=0; for i=1:T; % 行插值高频 if (mod(i,2)==0) bottomlh(i,:)=bottom_pic(t,:); % 偶数行保持 else bottomlh(i,:)=zeros(1,T); % 奇数行为零 t=t+1; end end; for i=1:T; % 列变换 bottomch_re(:,i)=ifft( fft(h_r).*fft(bottomlh(:,i)') )'; % 圆周卷积FFT end; construct1=bottomch_re+topcl_re; % 列变换重构完毕 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% left_pic=construct1(:,1:SUB_T); % 图像左半部分 t=0; for i=1:T; % 列插值低频 if (mod(i,2)==0) leftll(:,i)=left_pic(:,t); % 偶数列保持 else t=t+1; leftll(:,i)=zeros(T,1); % 奇数列为零 end end; for i=1:T; % 行变换 leftcl_re(i,:)=ifft( fft(l_r).*fft(leftll(i,:)) ); % 圆周卷积FFT end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% right_pic=construct1(:,SUB_T+1:T); % 图像右半部分 t=0; for i=1:T; % 列插值高频 if (mod(i,2)==0) rightlh(:,i)=right_pic(:,t); % 偶数列保持 else rightlh(:,i)=zeros(T,1); % 奇数列为零 t=t+1; end end; for i=1:T; % 行变换 rightch_re(i,:)=ifft( fft(h_r).*fft(rightlh(i,:)) ); % 圆周卷积FFT end; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% construct_pic=rightch_re+leftcl_re; % 重建全部图像 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 结果显示 figure(3); colormap(map); subplot(2,1,1); image(f); % 源图像显示 title('original pic'); subplot(2,1,2); image(abs(construct_pic)); % 重构源图像显示 title('reconstructed pic'); error=abs(construct_pic-f); % 重构图形与原始图像误值 figure(4); mesh(error); % 误差三维图像 title('absolute error display');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值