• 大小: 5KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-18
  • 语言: Matlab
  • 标签: 压缩感知  

资源简介

可以直接运行,我用的matlab2018a测试的。

资源截图

代码片段和文件信息

%  此示意程序用DWT实现二维小波变换
%  编程人    沙威(Wei Sha) 安徽大学(Anhui University) ws108@ahu.edu.cn

%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%
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=[lzeros(1L)];    %  矩阵行数与输入图像一致,为2的整数幂

h=wfilters(‘db10‘‘h‘);    %  db10(消失矩为10)高通分解滤波器冲击响应(长度为20)
h_zeros=[hzeros(1L)];    %  矩阵行数与输入图像一致,为2的整数幂

for i=1:T;   %  列变换
    row(1:SUB_Ti)=dyaddown( ifft( fft(l_zeros).*fft(f(:i)‘) ) ).‘;    %  圆周卷积<->FFT
    row(SUB_T+1:Ti)=dyaddown( ifft( fft(h_zeros).*fft(f(:i)‘) ) ).‘;  %  圆周卷积<->FFT
end;

for j=1:T;   %  行变换
    line(j1:SUB_T)=dyaddown( ifft( fft(l_zeros).*fft(row(j:)) ) );    %  圆周卷积<->FFT
    line(jSUB_T+1:T)=dyaddown( ifft( fft(h_zeros).*fft(row(j:)) ) );  %  圆周卷积<->FFT
end;

decompose_pic=line;  %  分解矩阵

%  图像分为四块

lt_pic=decompose_pic(1:SUB_T1:SUB_T);      %  在矩阵左上方为低频分量--fi(x)*fi(y)
rt_pic=decompose_pic(1:SUB_TSUB_T+1:T);    %  矩阵右上为--fi(x)*psi(y)
lb_pic=decompose_pic(SUB_T+1:T1:SUB_T);    %  矩阵左下为--psi(x)*fi(y)
rb_pic=decompose_pic(SUB_T+1:TSUB_T+1:T);  %  右下方为高频分量--psi(x)*psi(y)



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  3.分解结果显示

figure(1);
colormap(map);

subplot(211);
image(f);  %  原始图像   
title(‘original pic‘);

subplot(212);
image(abs(decompose_pic));  %  分解后图像
title(‘decomposed pic‘); 

figure(2);
colormap(map);

subplot(221);
image(abs(lt_pic));  %  左上方为低频分量--fi(x)*fi(y)
title(‘\Phi(x)*\Phi(y)‘);

subplot(222);
image(abs(rt_pic));  %  矩阵右上为--fi(x)*psi(y)
title(‘\Phi(x)*\Psi(y)‘);

subplot(223);
image(abs(lb_pic));  %  矩阵左下为--psi(x)*fi(y)
title(‘\Psi(x)*\Phi(y)‘);

subplot(224);
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_picrt_pic];  %  图像上半部分

t=0;
for i=1:T;  %  行插值低频
  
    if (mod(i2)==0)
        topll(i:)=top_pic(t:); %  偶数行保持
    else
        t=t+1;
        topll(i:)=zeros(1T);   %  奇数行为零
    end
end;

for i=1:T;  %  列变换
    topcl_re(:i)=ifft( fft(l_r).*fft(topll(:i)‘) )‘;  %  圆周卷积<->FFT
end;



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
bottom_pic=[lb_picrb_pic];  %  图像下半部分

t=0;
for i=1

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        1142  2018-09-18 16:33  DWT_1D.zip
     文件        5054  2007-06-12 10:46  DWT_2D.m
     文件        1599  2018-09-18 16:31  DWT_2D.zip

评论

共有 条评论