This example shows how to reconstruct approximation coefficients from a multilevel wavelet decomposition of an image.
Set the DWT extension mode to zero-padding. Load and display an image.
origmode = dwtmode('status','nodisplay');
dwtmode('zpd','nodisp')
load woman
image(X)
colormap(map)
title('Original')
size(X)
ans = 1×2
256 256
Perform a three-level wavelet decomposition of the image using the db1 wavelet. Display the number of elements in the coefficients array cfs, and the contents of the bookkeeping matrix inds. Note that cfs has the same number of elements as X.
wv = 'db1';
[cfs,inds] = wavedec2(X,3,wv);
numel(X)
ans = 65536
numel(cfs)
ans = 65536
inds
inds = 5×2
32 32
32 32
64 64
128 128
256 256
Extract and display the approximation coefficients at level 2.
cfs2 = appcoef2(cfs,inds,wv,2);
figure
imagesc(cfs2)
colormap('gray')
title('Level 2 Approximation Coefficients')
size(cfs2)
ans = 1×2
64 64
Extract and display the approximation coefficients at level 3.
cfs3 = appcoef2(cfs,inds,wv,3);
figure
imagesc(cfs3)
colormap('gray')
title('Level 3 Approximation Coefficients')
size(cfs3)
ans = 1×2
32 32
Restore the original extension mode.
dwtmode(origmode,'nodisplay')