%% 学习目标:二维小波的多层重构
%% 案例1
clear all;
close all;
load woman.mat;
X=ind2gray(X,map);
[C,S]=wavedec2(X,3,'db4'); %二维小波的多层分解
S
C(1:38*38)=0; %将小波的近似系数设置为0
Y=waverec2(C,S,'db4'); %二维小波的多层重构
figure;
subplot(121);
imshow(X);
subplot(122);
imshow(Y,[]);
set(gcf,'position',[100,100,500,400]);%% 案例2
clear all;
close all;
load woman.mat;
X=ind2gray(X,map);
[C,S]=wavedec2(X,2,'db4'); %小波分解
A=wrcoef2('a',C,S,'db4',2); %二维小波系数的单支重构 近似系数
H=wrcoef2('h',C,S,'db4',2); %细节系数
V=wrcoef2('v',C,S,'db4',2); %细节系数
D=wrcoef2('d',C,S,'db4',2); %细节系数
figure;
subplot(221);imshow(A);
subplot(222);imshow(H,[]);
subplot(223);imshow(V,[]);
subplot(224);imshow(D,[]);set(gcf,'position',[50,50,400,400]);
代码直接复制就可使用,欢迎关注文末的公众号!
%% 学习目标:二维小波的多层重构
%% 案例1
clear all;
close all;
load woman.mat;
X=ind2gray(X,map);
[C,S]=wavedec2(X,3,'db4'); %二维小波的多层分解
S
C(1:38*38)=0; %将小波的近似系数设置为0
Y=waverec2(C,S,'db4'); %二维小波的多层重构
figure;
subplot(121);
imshow(X);
subplot(122);
imshow(Y,[]);
set(gcf,'position',[100,100,500,400]);
%% 案例2
clear all;
close all;
load woman.mat;
X=ind2gray(X,map);
[C,S]=wavedec2(X,2,'db4'); %小波分解
A=wrcoef2('a',C,S,'db4',2); %二维小波系数的单支重构 近似系数
H=wrcoef2('h',C,S,'db4',2); %细节系数
V=wrcoef2('v',C,S,'db4',2); %细节系数
D=wrcoef2('d',C,S,'db4',2); %细节系数
figure;
subplot(221);imshow(A);
subplot(222);imshow(H,[]);
subplot(223);imshow(V,[]);
subplot(224);imshow(D,[]);
set(gcf,'position',[50,50,400,400]);