?? example2_4_1.m
字號(hào):
load wbarb; %裝載圖像信號(hào)
whos
figure(1);
image(X); colormap(map); colorbar; %顯示圖像
[cA1,cH1,cV1,cD1] = dwt2(X,'bior3.7'); %完成圖像的單尺度小波分解
A1 = upcoef2('a',cA1,'bior3.7',1); %從系數(shù)中重構(gòu)低頻和高頻部分
H1 = upcoef2('h',cH1,'bior3.7',1);
V1 = upcoef2('v',cV1,'bior3.7',1);
D1 = upcoef2('d',cD1,'bior3.7',1);
figure(2);
colormap(map); %顯示低頻和高頻部分
subplot(2,2,1); image(wcodemat(A1,192));
title('Approximation A1')
subplot(2,2,2); image(wcodemat(H1,192));
title('Horizontal Detail H1')
subplot(2,2,3); image(wcodemat(V1,192));
title('Vertical Detail V1')
subplot(2,2,4); image(wcodemat(D1,192));
title('Diagonal Detail D1')
Xsyn = idwt2(cA1,cH1,cV1,cD1,'bior3.7'); %由小波逆變換恢復(fù)原圖像信號(hào)
[C,S] = wavedec2(X,2,'bior3.7'); %圖像的多尺度二維小波分解
cA2 = appcoef2(C,S,'bior3.7',2); %從上面的C中提取第二層的低頻系數(shù)
cH2 = detcoef2('h',C,S,2); %從上面的C中提取第1、2層的高頻系數(shù),或采用[cH2,cV2,cD2] = detcoef2('all',C,S,2);[cH1,cV1,cD1] = detcoef2('all',C,S,1);
cV2 = detcoef2('v',C,S,2);
cD2 = detcoef2('d',C,S,2);
cH1 = detcoef2('h',C,S,1);
cV1 = detcoef2('v',C,S,1);
cD1 = detcoef2('d',C,S,1);
A2 = wrcoef2('a',C,S,'bior3.7',2); %A2 = wrcoef2('a',C,S,'bior3.7',2);
H1 = wrcoef2('h',C,S,'bior3.7',1); %重構(gòu)第1、2層的高頻信號(hào)
V1 = wrcoef2('v',C,S,'bior3.7',1);
D1 = wrcoef2('d',C,S,'bior3.7',1);
H2 = wrcoef2('h',C,S,'bior3.7',2);
V2 = wrcoef2('v',C,S,'bior3.7',2);
D2 = wrcoef2('d',C,S,'bior3.7',2);
colormap(map); %顯示多尺度二維分解結(jié)果
figure(3);
subplot(2,4,1);image(wcodemat(A1,192));
title('Approximation A1')
subplot(2,4,2);image(wcodemat(H1,192));
title('Horizontal Detail H1')
subplot(2,4,3);image(wcodemat(V1,192));
title('Vertical Detail V1')
subplot(2,4,4);image(wcodemat(D1,192));
title('Diagonal Detail D1')
subplot(2,4,5);image(wcodemat(A2,192));
title('Approximation A2')
subplot(2,4,6);image(wcodemat(H2,192));
title('Horizontal Detail H2')
subplot(2,4,7);image(wcodemat(V2,192));
title('Vertical Detail V2')
subplot(2,4,8);image(wcodemat(D2,192));
title('Diagonal Detail D2')
X0 = waverec2(C,S,'bior3.7'); %重構(gòu)原始圖像信號(hào)
[thr,sorh,keepapp] = ddencmp('cmp','wv',X); %壓縮圖像
[Xcomp,CXC,LXC,PERF0,PERFL2] =wdencmp('gbl',C,S,'bior3.7',2,thr,sorh,keepapp);
colormap(map); %顯示壓縮后的圖像
figure(4);
subplot(121);
image(X);
title('Original Image');
axis square
subplot(122);
image(Xcomp);
title('Compressed Image');
axis square
PERF0 %置0系數(shù)百分比
PERFL2 %壓縮后的能量損失情況
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -