You are on page 1of 1

clear

load wbarb
whos
figure;
image(X);
colormap(map);
print -depsc2 ex6-1.eps
[c , s]=wavedec2(X,3,'coif2');
a3=appcoef2(c,s,'coif2',3);
dh3=detcoef2('h',c,s,3);
dv3=detcoef2('v',c,s,3);
dd3=detcoef2('d',c,s,3);
a2=appcoef2(c,s,'coif2',2);
dh2=detcoef2('h',c,s,2);
dv2=detcoef2('v',c,s,2);
dd2=detcoef2('d',c,s,2);
a1=appcoef2(c,s,'coif2',1);
dh1=detcoef2('h',c,s,1);
dv1=detcoef2('v',c,s,1);
dd1=detcoef2('d',c,s,1);
figure;
colormap(map);
subplot(2,2,1);image(X);
subplot(2,2,2);image(a1/2);
subplot(2,2,2);image(a2/4);
subplot(2,2,2);image(a3/8);
print -depsc2 ex6-2.eps
img3=[a3/8, dh3*2, dv3*2, dd3*2];
img2=[a2/8, dh2*2, dv2*2, dd2*2];
img1=[a1/8, dh1*2, dv1*2, dd1*2];
figure; colormap(map);
image(img3); print -depsc2 ex6-3.eps
figure; colormap(map);
image(img2); print -depsc2 ex6-4.eps
figure; colormap(map);
image(img1); print -depsc2 ex6-5.eps
ar2=wrcoef2('a',c,s,'coif2',2);
dhr2=wrcoef2('h',c,s,'coif2',2);
figure; image(ar2);
colormap(map); print -depsc2 ex6-6.eps
figure; image(dhr2*16);
colormap(map); print -depsc2 ex6-7.eps
% reconstruction
Xrec=waverec2(c,s,'coif2');
figure; image(Xrec); colormap(map);
print -depsc2 ex6-7.eps

You might also like