wavelet.treethresh {treethresh} | R Documentation |
wavelet.threshold
is a more user-friendly function for
thresholding wavelet coefficients stored in an wd
or imwd
object. It
combines the functions extract.coefficients
,
estimate.sdev
(rescales the coefficients accordingly),
treethresh
or wtthresh
,
prune
, thresh
, and
insert.coefficients
wavelet.treethresh(object, sdev=NA, dev=mad, start.level=5, levelwise=FALSE, v=5, sd.mult=0.5, postmed=TRUE, ...)
object |
An object of the class wd or
wtthresh to be smoothed by thresholding.
|
sdev |
The standard error of the noise (if known), otherwise
NA . |
dev |
The function used to estimate the standard error. Typical
examples are sd (teh default), or the more
robust mad . Not used if sdev is given. |
start.level |
The level in the wavelet transform from which to commence thresholding the wavelet coefficients. This level and all those finer levels will be thresholded. |
levelwise |
Indicates whether the thresholding should be carried
out independently for each level and type of coefficients as in the
function treethresh (if levelwise=TRUE ), or whether
a common partition is to be found jointly for all coefficients as
in the function wtthresh (if levelwise=FALSE ). |
v |
The number of folds in the cross-validation used to determine
the optimal subtree in the pruning step (see the function
prune for details). NA if no pruning is to be carried out. |
sd.mult |
The smallest subtree that is not sd.mult times
the standard error worse than the best loglikelihood will be chosen as
the optimal tree in the pruning step. (see the function
prune for details). |
postmed |
Controls whether thresholding is to be carried out by
using the posterior median of the coefficient mu|y
(postmed=true ) or by using a hard threshold
(postmed=FALSE ). (See the function thresh for more details.) |
... |
arguments passed to to wtthresh (if
levelwise=FALSE ) or treethresh (if
levelwise=TRUE ). |
Returns an object of the class wd
or
wtthresh
, where the coefficients have
been thresholded using the TreeThresh algorithm.
wavelet.treethresh
combines the functions extract.coefficients
,
estimate.sdev
(and the appropriate scaling), treethresh
/
wtthresh
, prune
,
insert.coefficients
into a single (hopefully) more
user-friendly function.
extract.coefficients
, estimate.sdev
,
treethresh
, wtthresh
, prune
,
thresh
, insert.coefficients
## The following examples shows how an example image can be ## thresholded step by step. All the steps are combined in the more ## user-friendly function wavelet.treethresh ## (01) Load the example image data(tiles) ## (02) Display the image par(mai=rep(0,4)) ; image(tiles,col=grey(0:255/255)) ## (03) Add noise to the image corrupted <- tiles + rnorm(length(tiles)) ## (04) Display the corrupted image par(mai=rep(0,4)) ; image(corrupted,col=grey(0:255/255)) ## (05) Compute the wavelet transform corrupted.wt <- imwd(corrupted) save.image(file="~/holygrail.RData") ## (06) Perform the thresholding denoised.wt <- wavelet.treethresh(corrupted.wt) ## (07) Compute inverse wavelet transform denoised <- imwr(denoised.wt) ## (08) Display denoised image par(mai=rep(0,4)) ; image(denoised,col=grey(0:255/255)) ## (09) Compute l2 loss sum((denoised-tiles)^2) ## The call to wavelet.treethresh is equivalent to steps (06) to (13) ## of the example in the help section "coefficients".