| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1423 人关注过本帖
标题:第二代小波变换源码
只看楼主 加入收藏
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
结帖率:79.17%
收藏
 问题点数:0 回复次数:2 
第二代小波变换源码
%%第二代小波变换源码
%%  此程序用提升法实现第二代小波变换
%%  我用的是非整数阶小波变换
%%  采用时域实现,步骤先列后行
%%  正变换:分裂,预测,更新;
%%  反变换:更新,预测,合并
%%  只做一层(可以多层,而且每层的预测和更新方程不同)

clear;clc;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%  1.调原始图像矩阵

load wbarb;  %  下载图像
f=X;         %  原始图像
% f=[0 0 0 0 0 0 0 0 ;...
%    0 0 0 1 1 0 0 0 ;...
%    0 0 2 4 4 2 0 0 ;...
%    0 1 4 8 8 4 1 0 ;...
%    0 1 4 8 8 4 1 0 ;...
%    0 0 2 4 4 2 0 0 ;...
%    0 0 0 1 1 0 0 0 ;...
%    0 0 0 0 0 0 0 0 ;];  %  原始图像矩阵

N=length(f);         %  图像维数
T=N/2;               %  子图像维数



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%正变换%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%   1.列变换

%  A.分裂(奇偶分开)

f1=f([1:2:N-1],:);  %  奇数
f2=f([2:2:N],:);    %  偶数

% f1(:,T+1)=f1(:,1);  %  补列
% f2(T+1,:)=f2(1,:);  %  补行

%  B.预测

for i_hc=1:T;
    high_frequency_column(i_hc,:)=f1(i_hc,:)-f2(i_hc,:);
end;

% high_frequency_column(T+1,:)=high_frequency_column(1,:);  %  补行

%  C.更新

for i_lc=1:T;
    low_frequency_column(i_lc,:)=f2(i_lc,:)+1/2*high_frequency_column(i_lc,:);
end;

%  D.合并
f_column([1:1:T],:)=low_frequency_column([1:T],:);
f_column([T+1:1:N],:)=high_frequency_column([1:T],:);
   
   
figure(1)
colormap(map);
image(f);

figure(2)
colormap(map);
image(f_column);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%   2.行变换

%  A.分裂(奇偶分开)

f1=f_column(:,[1:2:N-1]);  %  奇数
f2=f_column(:,[2:2:N]);    %  偶数


% f2(:,T+1)=f2(:,1);    %  补行

%  B.预测

for i_hr=1:T;
    high_frequency_row(:,i_hr)=f1(:,i_hr)-f2(:,i_hr);
end;

% high_frequency_row(:,T+1)=high_frequency_row(:,1);  %  补行

%  C.更新

for i_lr=1:T;
    low_frequency_row(:,i_lr)=f2(:,i_lr)+1/2*high_frequency_row(:,i_lr);
end;

%  D.合并
f_row(:,[1:1:T])=low_frequency_row(:,[1:T]);
f_row(:,[T+1:1:N])=high_frequency_row(:,[1:T]);
   

figure(3)
colormap(map);
image(f_row);





%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%反变换%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%   1.行变换

%   A.提取(低频高频分开)

f1=f_row(:,[T+1:1:N]);  %  奇数
f2=f_row(:,[1:1:T]);    %  偶数


% f2(:,T+1)=f2(:,1);    %  补行

%  B.更新

for i_lr=1:T;
    low_frequency_row(:,i_lr)=f2(:,i_lr)-1/2*f1(:,i_lr);
end;

%  C.预测

for i_hr=1:T;
    high_frequency_row(:,i_hr)=f1(:,i_hr)+low_frequency_row(:,i_hr);
end;

% high_frequency_row(:,T+1)=high_frequency_row(:,1);  %  补行


%  D.合并(奇偶分开合并)
f_row(:,[2:2:N])=low_frequency_row(:,[1:T]);
f_row(:,[1:2:N-1])=high_frequency_row(:,[1:T]);
   

figure(4)
colormap(map);
image(f_row);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%   2.列变换

%  A.提取(低频高频分开)

f1=f_row([T+1:1:N],:);  %  奇数
f2=f_row([1:1:T],:);    %  偶数

% f1(:,T+1)=f1(:,1);  %  补列
% f2(T+1,:)=f2(1,:);  %  补行

%  B.更新

for i_lc=1:T;
    low_frequency_column(i_lc,:)=f2(i_lc,:)-1/2*f1(i_lc,:);
end;

%  C.预测

for i_hc=1:T;
    high_frequency_column(i_hc,:)=f1(i_hc,:)+low_frequency_column(i_hc,:);
end;

% high_frequency_column(T+1,:)=high_frequency_column(1,:);  %  补行



%  D.合并(奇偶分开合并)
f_column([2:2:N],:)=low_frequency_column([1:T],:);
f_column([1:2:N-1],:)=high_frequency_column([1:T],:);
   
   
figure(5)
colormap(map);
image(f_column);
搜索更多相关主题的帖子: 第二代 小波变换 源码 
2008-06-07 13:31
hongsedexue
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-7-18
收藏
得分:0 
顶一下,写的蛮清楚的!
2008-07-18 18:43
haihe398
Rank: 1
来 自:上海
等 级:新手上路
帖 子:25
专家分:0
注 册:2008-9-21
收藏
得分:0 
顶一下,现在不懂,以后会懂的,谢谢
2008-10-02 19:06
快速回复:第二代小波变换源码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.043240 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved