2D Local Cosine Transform

DESCRIPTION:
Computes 2D local cosine transform.

USAGE:
block.dct.2d(x, n.levels=4, dct.type=2)
block.cpt.2d(x, n.levels=4, taper="poly2", dct.type=2,
             boundary="periodic")

REQUIRED ARGUMENTS:
x:
an image or matrix. Row length must be divisible by 2^(n.levels) and column length must be divisible by 2^(n.levels), should demean first.

OPTIONAL ARGUMENTS:
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. 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.

VALUE:
an object of classes block.dct.2d, inheriting from classes cpt.2d and crystal.matrix.

DETAILS:
x is divided into 2^(n.level) by 2^(n.level) blocks and DCT of type II or IV is applied to each of the blocks.

block.dct.2d is a special case of block.cpt.2d, in which the taper is always set to be "boxcar".

If only a single integer or string is given for arguments dct.type, taper or boundary, then the same function or rule is used for both rows and columns. Different taper functions, boundary rules, DCT types can be used for rows and columns by using a vector of length two for that argument. The first element of the vector applies to the rows and the second to the columns.

See dct for the algorithms for DCT-II and DCT-IV.

Algorithms are described in the S+WAVELETS User's Manual, in the section "Cosine Packet Algorithms". They are discussed in greater depth in Chapter 4 of Wickerhauser (1994).

All the default optional arguments can be reset using function wavelet.options, see wavelet.options for details.


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

SEE ALSO:
dct , cpt.2d , dct.2d , max.level , wavelet.options .

EXAMPLES:
xx <- phone-mean(phone)
par(mfrow=c(1, 2))
bdct <- block.dct.2d(xx, n.levels=2)
thresh1 <- quantile(unclass(bdct), 0.8)
xx1 <- shrink(bdct, thresh1)  # use top 20% coefficients
image(reconstruct(xx1))
bcpt <- block.cpt.2d(xx, n.levels=2, taper="poly2")
thresh2 <- quantile(unclass(bcpt), 0.8)
xx2 <- shrink(bcpt, thresh2)  # use top 20% coefficients
image(reconstruct(xx2))