lwtcoef2
Extract or reconstruct 2-D LWT wavelet coefficients
Syntax
Y = lwtcoef2(TYPE,XDEC,LS,LEVEL,LEVEXT)
Y = lwtcoef2(TYPE,XDEC,W,LEVEL,LEVEXT)
Description
Y = lwtcoef2(TYPE,XDEC,LS,LEVEL,LEVEXT) returns
the coefficients or the reconstructed coefficients of level LEVEXT,
extracted from XDEC, the LWT decomposition at level LEVEL obtained
with the lifting scheme LS.
The valid values for TYPE are listed in this
table.
TYPE ValuesDescription'a'Approximations
'h'Horizontal details
'v'Vertical details
'd'Diagonal details
'ca'Coefficients of approximations
'ch'Coefficients of horizontal details
'cv'Coefficients of vertical details
'cd'Coefficients of diagonal details
Y = lwtcoef2(TYPE,XDEC,W,LEVEL,LEVEXT) returns
the same output using W, which is the name of a
lifted wavelet.
Examples
% Start from the Haar wavelet and get the
% corresponding lifting scheme.
lshaar = liftwave('haar');
% Add a primal ELS to the lifting scheme.
els = {'p',[-0.125 0.125],0};
lsnew = addlift(lshaar,els);
% Perform LWT at level 2 of a simple image.
x = reshape(1:16,4,4);
xDec = lwt2(x,lsnew,2)
xDec =
27.4375 4.0000 17.0000 4.0000
1.0000 0 1.0000 0
4.2500 4.0000 0.0000 4.0000
1.0000 0 1.0000 0
% Extract approximation coefficients of level 1.
ca1 = lwtcoef2('ca',xDec,lsnew,2,1)
ca1 =
5.7500 22.7500
10.0000 27.0000
% Reconstruct approximations and details.
a1 = lwtcoef2('a',xDec,lsnew,2,1)
a1 =
2.8750 2.8750 11.3750 11.3750
2.8750 2.8750 11.3750 11.3750
5.0000 5.0000 13.5000 13.5000
5.0000 5.0000 13.5000 13.5000
a2 = lwtcoef2('a',xDec,lsnew,2,2)
a2 =
6.8594 6.8594 6.8594 6.8594
6.8594 6.8594 6.8594 6.8594
6.8594 6.8594 6.8594 6.8594
6.8594 6.8594 6.8594 6.8594
h1 = lwtcoef2('h',xDec,lsnew,2,1)
h1 =
-0.3750 -0.3750 -0.3750 -0.3750
0.6250 0.6250 0.6250 0.6250
-0.5000 -0.5000 -0.5000 -0.5000
0.5000 0.5000 0.5000 0.5000
v1 = lwtcoef2('v',xDec,lsnew,2,1)
v1 =
-1.5000 2.5000 -2.0000 2.0000
-1.5000 2.5000 -2.0000 2.0000
-1.5000 2.5000 -2.0000 2.0000
-1.5000 2.5000 -2.0000 2.0000
d1 = lwtcoef2('d',xDec,lsnew,2,1)
d1 =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
h2 = lwtcoef2('h',xDec,lsnew,2,2)
h2 =
-0.7969 -0.7969 -0.7969 -0.7969
-0.7969 -0.7969 -0.7969 -0.7969
1.3281 1.3281 1.3281 1.3281
1.3281 1.3281 1.3281 1.3281
v2 = lwtcoef2('v',xDec,lsnew,2,2)
v2 =
-3.1875 -3.1875 5.3125 5.3125
-3.1875 -3.1875 5.3125 5.3125
-3.1875 -3.1875 5.3125 5.3125
-3.1875 -3.1875 5.3125 5.3125
d2 = lwtcoef2('d',xDec,lsnew,2,2)
d2 =
1.0e-015 *
0.2498 0.2498 -0.4163 -0.4163
0.2498 0.2498 -0.4163 -0.4163
-0.4163 -0.4163 0.6939 0.6939
-0.4163 -0.4163 0.6939 0.6939
% Check perfect reconstruction.
err = max(max(abs(x-a2-h2-v2-d2-h1-v1-d1)))
err =
3.5527e-015
Tips
If XDEC is obtained from an indexed image analysis or a truecolor
image analysis, it is an m-by-n matrix
or an m-by-n-by-3 array, respectively.
For more information on image formats, see the image and imfinfo reference
pages.
See Also
Introduced before R2006a