This example shows how to extract detail coefficients from a discrete wavelet analysis of an image. This example uses zero-padding.
Set the extension mode to zero-padding. Load and display an image.
origmode = dwtmode('status','nodisplay');
dwtmode('zpd','nodisplay');
load woman
imagesc(X)
colormap(gray)
Obtain the wavelet decomposition of the image down to level two using the Haar wavelet.
[c,s] = wavedec2(X,2,'haar');
size(X)
ans = 1×2
256 256
size(c)
ans = 1×2
1 65536
s
s = 4×2
64 64
64 64
128 128
256 256
Extract the detail coefficients at level 2 in each orientation from the wavelet decomposition structure [c,s]. Display the diagonal detail coefficients.
[chd2,cvd2,cdd2] = detcoef2('all',c,s,2);
size(cdd2)
ans = 1×2
64 64
imagesc(cdd2)
colormap(gray)
Extract the detail coefficients at level 1 in each orientation. Display the vertical detail coefficients.
[chd1,cvd1,cdd1] = detcoef2('all',c,s,1);
size(cvd1)
ans = 1×2
128 128
imagesc(cvd1)
colormap(gray)
Restore the original extension mode.
dwtmode(origmode,'nodisplay')