2代小波示意程式
from:http://waveletlegend.spaces.live.com/
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 此程式用提升法實現第二代小波變換
%% 我用的是非整數階小波變換
%% 採用時域實現,步驟先列後行
%% 正變換:分裂,預測,更新;
%% 反變換:更新,預測,合併
%% 只做一層(可以多層,而且每層的預測和更新方程不同)
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);
%% 此程式用提升法實現第二代小波變換
%% 我用的是非整數階小波變換
%% 採用時域實現,步驟先列後行
%% 正變換:分裂,預測,更新;
%% 反變換:更新,預測,合併
%% 只做一層(可以多層,而且每層的預測和更新方程不同)
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);
相關文章
- Java新集合示意圖Java
- 世界盃來了!小程式賽事操作來一波~
- 力學示意圖繪製軟體哪個好,怎麼畫力學示意圖
- 小波變換與深度學習深度學習
- 提升小波的學習筆記筆記
- 【影像處理筆記】小波變換筆記
- 影象處理 二維小波變換
- 又一波創業紅利!阿里、騰訊再出手重金扶持小程式!創業阿里
- 小波變換教程(1):基本原理
- 如何抓住下沉市場的商機,微信本地生活小程式這波穩了
- Keepalived高可用叢集工作原理示意圖
- ORACLE:使用ADRCI顯示意外事件Oracle事件
- 一小波DOM騷操作:querySelectorAll和classList
- 小波變換與傅立葉變換的區別
- OpencV_Python影象濾波函式小結OpenCVPython函式
- 【DWT筆記】傅立葉變換與小波變換筆記
- 小程式開發,小程式代理,小程式加盟,小程式創業創業
- 濾波演算法——十大濾波演算法程式大全演算法
- 深度學習-理論學習關鍵示意圖深度學習
- 讀秦小波《設計模式之禪》 -- 單例模式設計模式單例
- 讀秦小波《設計模式之禪》 -- 工廠模式設計模式
- matlab練習程式(波紋扭曲)Matlab
- 小程式3:ATM小程式
- 小波變換在數字影象上的應用(上)
- 程式猿生存指南-4 借錢風波
- 思泉軟體釋出CRM相關業務流程示意圖
- ThinkPHP小程式導航,小程式商店,小程式推薦平臺PHP
- 微信小程式小技巧微信小程式
- 小程式
- 微信小程式:小程式碼、小程式二維碼、普通二維碼微信小程式
- 51超聲波測距簡易程式碼
- 微信小程式掃碼解析小程式碼微信小程式
- 微信小程式教程01:小程式簡介微信小程式
- 【小程式】微信小程式開發實踐微信小程式
- 小程式實戰—答題類小程式
- 【小程式】微信小程式開發準備微信小程式
- 【java規則引擎】簡單規則的rete網路示意圖Java
- Hadoop HDFS結構示意圖以及互動關係說明Hadoop