2D Cosine Packet Transform

DESCRIPTION:
Computes 2D cosine packet transform.

USAGE:
cpt.2d(x, crystal.names=NULL, basis="block.cpt.2d", cost.fun="threshold",
       n.levels=NULL, taper="poly2", dct.type=2, boundary="periodic",
       n.taper=NULL, scale=NULL, thresh=NULL, p=1, prob=.75)
icpt.2d(x)

REQUIRED ARGUMENTS:
x:
for cpt.2d, an image or matrix. Row length must be divisible by 2^(n.levels) and column length must be divisible by 2^(n.levels). If mean(x) != 0, should de-mean first (see below). For icpt.2d, an object of cpt.2d.

OPTIONAL ARGUMENTS:
crystal.names:
a character vector of crystal names of the form "cj.h-cj.v". where j is an integer giving the level and h is an integer from 0 to 2^j-1 giving the horizontal block number and v is an integer from 0 to 2^j-1 giving the vertical block number. If crystal.names is supplied, then basis is ignored.
basis:
a character string specifying how the cosine packet basis is selected: "best.basis" or "block.cpt.2d". See the respective help files for details.
cost.fun:
character string indicating which cost functional to use: "entropy", "threshold", "sure", and "lp" are available. Only used for "best.basis". See cp.costs.2d for details.
n.levels:
a non-negative integer specifying the blocking factor: x is divided into 2^(2*n.levels) nrow(x)/2^n.levels by ncol(x)/2^n.levels blocks. For "best.basis", n.levels gives the blocking factor for the finest level. When both crystal.names and basis are missing, 2D subband basis of n.levels is computed. If n.levels is bigger than ml, where ml is the maximum possible level, computed from the max.level function, then n.levels is set to ml and a warning message is given.
dct.type:
one of 2 or 4 indicating which of DCT-II or DCT-IV should be used. See the function dct for details.
taper:
a character string, indicating the taper function: "boxcar", "poly1", "poly2", "poly3", "poly4", "poly5", or "trig". See the function cp.table for details.
boundary:
a character string, available boundary rules: "cp.reflect", "periodic" and "zero". See the function cp.table for details.
n.taper:
a non-negative integer. The length of the taper will be 2*n.taper. By default, n.taper is set to length(x)/2^(n.level+1), which is the maximum possible length at the finest blocking level.
scale:
scaling factor for computing the costs. The default depends on cost.fun. See the function cp.costs.2d for details.
p:
a number in the interval (0,2] giving the degree of the lpnorm when cost.fun is "lp". See the function cp.costs.2d for details.
thresh:
a non-negative number giving the threshold for when cost.fun is "threshold" or "sure". See the function cp.costs.2d for details.
prob:
a number in the interval (0,1) used to compute the threshold for when cost.fun is "threshold". See the function cp.costs.2d for details.

VALUE:
cpt.2d returns an object of class cpt.2d, inheriting from the class crystal.matrix. The object is a matrix of the same size as x with crystal names as an attribute.

icpt.2d returns an image if x is an object of class cpt.2d.


DETAILS:
The default optional arguments n.levels, taper, dct.type, boundary can be reset using function wavelet.options, see wavelet.options for details.

The algorithms for the taper functions are given in the S+WAVELETS User's Manual, in the section "Cosine Packet Algorithms". They are discussed in greater depth in Wickerhauser (1994).


REFERENCES:
Wickerhauser, M. V. (1994). Adapted Wavelet Analysis -- from theory to software.

SEE ALSO:
best.basis , block.cpt.2d , cp.costs.2d , dct , max.level , wavelet.options .

EXAMPLES:
xx <- phone-mean(phone)
par(mfrow=c(1,2))
image(xx)
bb2 <- crystal.names("block.dct.2d", 2)
cc2 <- cpt.2d(xx, crystal.names=bb2, taper="poly2")
thresh <- rep(3.7, 16)
ss2 <- shrink(cc2, thresh)
zz <- reconstruct(ss2)
image(zz)