block.dct.2d(x, n.levels=4, dct.type=2) block.cpt.2d(x, n.levels=4, taper="poly2", dct.type=2, boundary="periodic")
2^(n.levels)
and
column length must be divisible by
2^(n.levels)
,
should demean first.
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.
2
or
4
indicating which of DCT-II or DCT-IV should be used.
See the function
dct
for details.
"boxcar", "poly1", "poly2", "poly3", "poly4", "poly5"
, or
"trig"
.
See the function
cp.table
for details.
"cp.reflect", "periodic"
and
"zero"
.
See the function
cp.table
for details.
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.
block.dct.2d
, inheriting from classes
cpt.2d
and
crystal.matrix
.
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.
Wickerhauser, M. V. (1994). Adapted Wavelet Analysis from Theory to Software. A. K. Peters Ltd, Wellesley, MA.
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))