2D Discrete Wavelet Transform

DESCRIPTION:
Applies 2D discrete wavelet transform to an image or a matrix.

USAGE:
dwt.2d(x, wavelet="s8", n.levels=NULL,
       boundary="periodic", precondition=F, dual=F,
       analysis.filter=NULL, synthesis.filter=NULL)
idwt.2d(x)

REQUIRED ARGUMENTS:
x:
an image (see details below for restrictions), or, for idwt.2d only, an object of class dwt.2d.

OPTIONAL ARGUMENTS:
wavelet:
a character string giving one of the available wavelet names, or a character vector of length two with elements drawn from the set of available wavelet names. If the length of wavelet is one, the same wavelet is used for both row and column. See wavelet for details. For user-provided filter, input the values the filter argument (see below).
n.levels:
a non-negative integer or a non-negative integer vector of length two.
boundary:
a character string giving one of the available boundary rule names or a character vector of length two with elements drawn from the set of available boundary rules. If the length of boundary is one, the same boundary rule is used for both row and column. Available boundary rules are "periodic", "poly0", "poly1", "poly2", "reflection", "interval", "zero". See dwt for more details.
precondition:
logical flag: for boundary="interval" only. If TRUE, then the data will be transformed. The transformation has the following property: the transformed unit vector is invariant under the low-pass filtering and decimation operation.
dual:
logical flag indicating if dual filter is used for analysis instead of synthesis. The default is FALSE.
analysis.filter:
a numerical vector or a list of two vectors for user provided filter. For analysis.
synthesis.filter:
a numerical vector or a list of two vectors for user provided filter. For synthesis.

VALUE:
an object of class "dwt.2d", inheriting from the classes "wpt.2d" and "crystal.matrix". See crystal.matrix.object for details.

idwt.2d returns an image if x is an object of class "dwt.2d".


DETAILS:
Theories and algorithms are described in Chapter 10 of Daubechies (1992) and Mallat (1989).

We can manipulate 2D transforms and apply many of the same generic functions as for 1D discrete wavelet transforms. See the example below.


REFERENCES:
Daubechies, I. (1992). Ten Lectures on Wavelets. SIAM, Philadelphia.

SEE ALSO:
crystal.matrix.object , dwt , reconstruct , wpt.2d .

EXAMPLES:
xx <- phone-mean(phone)
par(mfrow=c(1, 2))
image(xx)
dmat <- dwt.2d(xx, wavelet="s8", n.levels=3)
thresh <- rep(0, 10)
thresh[-10] <- quantile(abs(as.vector(dmat)), 0.7)
smat <- shrink(dmat, threshold=thresh)           # use top 30% coefficients
rec2 <- reconstruct(smat)
image(rec2)