Description Usage Arguments Value References See Also Examples
extract.coefficients
extracts wavelet coefficient vectors (in case of
wd
) and coefficient matrices (in case of
imwd
), so that these can be thresholded by
treethresh
or
wtthresh
. update.coefficients
re-inserts these
vector or matrices into the wd
or imwd
objects, such that the inverse transform can be computed using the
thresholded coefficients.
1 2 3 4 5 6 7 8 | ## S3 method for class 'wd'
extract.coefficients(object, start.level=5)
## S3 method for class 'wd'
insert.coefficients(object, update)
## S3 method for class 'imwd'
extract.coefficients(object, start.level=5)
## S3 method for class 'imwd'
insert.coefficients(object, update)
|
object |
For |
start.level |
The coarsest level of coefficients to be extracted
( |
update |
A list with the matrices that should be copied into the
wd or imwd object. ( |
... |
additional arguments (see above for supported arguments). |
extract.coefficients
returns the coefficient matrices to
be extracted. update.coefficients
returns the updated
wd
or imwd
object.
insert.coefficients
returns the updated
wd
or imwd
object
into which the coefficients from update
have been inserted.
Evers, L. and Heaton T. (2009) Locally adaptive tree-based tresholding.
treethresh
, wtthresh
, wavelet.treethresh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | ## 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)
## (06) Estimate the standard error
dev <- estimate.sdev(corrupted.wt)
## (07) Extract the coefficient matrices to be thresholded
coefs <- extract.coefficients(corrupted.wt)
## (08) Rescale the coefficients using the estimated standard error
## (should be around 1)
for (nm in names(coefs))
coefs[[nm]] <- coefs[[nm]] / dev
## (09) Compute the tree
coefs.tree <- wtthresh(coefs)
## (10) Prune the tree
coefs.pruned.tree <- prune(coefs.tree)
## (11) Threshold according to the pruned tree
coefs.threshed <- thresh(coefs.pruned.tree)
## (12) Undo the rescaling
for (nm in names(coefs))
coefs.threshed[[nm]] <- coefs.threshed[[nm]] * dev
## (13) Update coefficients
denoised.wt <- insert.coefficients(corrupted.wt, coefs.threshed)
## (14) Compute inverse wavelet transform
denoised <- imwr(denoised.wt)
## (15) Display denoised image
par(mai=rep(0,4)) ; image(denoised, col=grey(0:255/255))
## (16) Compute l2 loss
sum((denoised-tiles)^2)
## Equivalently we could have called
## denoised.wt <- wavelet.treethresh(corrupted.wt)
## instead of steps (06) - (13)
|
Loading required package: EbayesThresh
Loading required package: wavethresh
Loading required package: MASS
WaveThresh: R wavelet software, release 4.6.8, installed
Copyright Guy Nason and others 1993-2016
Note: nlevels has been renamed to nlevelsWT
[1] 16245.27
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.