Title: | Wavelet Analysis |
---|---|
Description: | Perform wavelet analysis (orthogonal,translation invariant, tensorial, 1-2-3d transforms, thresholding, block thresholding, linear,...) with applications to data compression, denoising/regression or clustering. The core of the code is a port of 'MATLAB' Wavelab toolbox written by D. Donoho, A. Maleki and M. Shahram (<https://statweb.stanford.edu/~wavelab/>). |
Authors: | F. Navarro and C. Chesneau |
Maintainer: | Navarro Fabien <[email protected]> |
License: | LGPL (>= 2) |
Version: | 0.4.1.99999 |
Built: | 2025-01-16 04:38:11 UTC |
Source: | https://github.com/fabnavarro/rwavelet |
Filtering by periodic convolution of x with the time-reverse of f.
aconv(f, x)
aconv(f, x)
f |
filter. |
x |
1-d signal. |
y
filtered result.
iconvv
, UpDyadHi
,
UpDyadLo
, DownDyadHi
, DownDyadLo
.
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) aconv(qmf,x)
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) aconv(qmf,x)
This function is used to group the coefficients into blocks (or groups) of size L.
block_partition(x, L)
block_partition(x, L)
x |
(noisy) wc at a given scale. |
L |
block size. |
out
partition of coefficients by block.
invblock_partition
, BlockThresh
.
x <- MakeSignal('Ramp', 8) j0 <- 0 qmf <- MakeONFilter('Haar') wc <- FWT_PO(x, j0, qmf) L <- 2 wcb <- block_partition(wc, L)
x <- MakeSignal('Ramp', 8) j0 <- 0 qmf <- MakeONFilter('Haar') wc <- FWT_PO(x, j0, qmf) L <- 2 wcb <- block_partition(wc, L)
Group the coefficients into blocks (or groups) of size L.
block_partition2d(x, L)
block_partition2d(x, L)
x |
(noisy) wc at a given scale. |
L |
block size. |
out
partition of coefficients by block.
x <- matrix(rnorm(2^2), ncol=2) j0 <- 0 qmf <- MakeONFilter('Haar') wc <- FWT2_PO(x, j0, qmf) L <- 2 wcb <- block_partition2d(wc, L)
x <- matrix(rnorm(2^2), ncol=2) j0 <- 0 qmf <- MakeONFilter('Haar') wc <- FWT2_PO(x, j0, qmf) L <- 2 wcb <- block_partition2d(wc, L)
This function is used for thresholding coefficients by group (or block) according to the hard or soft thresholding rule.
BlockThresh(wc, j0, hatsigma, L, qmf, thresh = "hard")
BlockThresh(wc, j0, hatsigma, L, qmf, thresh = "hard")
wc |
wavelet coefficients. |
j0 |
coarsest decomposition scale. |
hatsigma |
estimator of noise variance. |
L |
Block size (n mod L must be 0). |
qmf |
Orthonormal quadrature mirror filter. |
thresh |
'hard' or 'soft'. |
wcb
wavelet coefficient estimators.
invblock_partition
, invblock_partition
.
n <- 64 x <- MakeSignal('Ramp', n) sig <- 0.01 y <- x + rnorm(n, sd=sig) j0 <- 1 qmf <- MakeONFilter('Daubechies',8) wc <- FWT_PO(y, j0, qmf) L <- 2 wcb <- BlockThresh(wc, j0, sig, L, qmf, "hard")
n <- 64 x <- MakeSignal('Ramp', n) sig <- 0.01 y <- x + rnorm(n, sd=sig) j0 <- 1 qmf <- MakeONFilter('Daubechies',8) wc <- FWT_PO(y, j0, qmf) L <- 2 wcb <- BlockThresh(wc, j0, sig, L, qmf, "hard")
This function is used to threshold the coefficients by group (or block).
BlockThresh2d( wc, j0, hatsigma, L = 4, qmf, lamb = 4.50524, thresh = "JamesStein" )
BlockThresh2d( wc, j0, hatsigma, L = 4, qmf, lamb = 4.50524, thresh = "JamesStein" )
wc |
wavelet coefficients. |
j0 |
coarsest decomposition scale. |
hatsigma |
estimator of noise variance. |
L |
Block size (n mod L must be 0). |
qmf |
Orthonormal quadrature mirror filter. |
lamb |
Threshold parameter. |
thresh |
Thresholding rule: 'hard', or 'JamesStein'. |
wcb
Thresholded wavelet coefficients.
A dataset containing cameraman image.
data(cameraman)
data(cameraman)
A numeric 512 x 512 matrix.
Pixels that get shifted off one side of the image are put back on the other side.
CircularShift(matrix, colshift = 0, rowshift = 0)
CircularShift(matrix, colshift = 0, rowshift = 0)
matrix |
2-d signal (matrix). |
colshift |
column shift index (integer). |
rowshift |
row shift index (integer). |
result
2-d shifted signal.
A <- matrix(1:4, ncol=2, byrow=TRUE) CircularShift(A, 0, -1)
A <- matrix(1:4, ncol=2, byrow=TRUE) CircularShift(A, 0, -1)
3d counterpart of Donoho's quadlength utilized by the 2d pair. Original matlab code Vicki Yang and Brani Vidakovic.
cubelength(x)
cubelength(x)
x |
3-d array; dim(n,n,n), n = 2^J (hopefully). |
n
length(x).
J
least power of two greater than n.
cubelength(array(1:3, c(2,2,2)))
cubelength(array(1:3, c(2,2,2)))
Selection of the number of wavelet coefficients to be maintained by the cross validation method proposed by Nason in the case of threshold selection. This method is adapted here to select among linear estimators.
CVlinear(Y, L, qmf, D, wc)
CVlinear(Y, L, qmf, D, wc)
Y |
Noisy observations. |
L |
Level of coarsest scale. |
qmf |
Orthonormal quadrature mirror filter. |
D |
Dimension vector of the models considered. |
wc |
1-d wavelet coefficients. |
CritCV
Cross validation criteria.
hat_f_m_2FCV
Nason, G. P. (1996). Wavelet shrinkage using cross-validation. Journal of the Royal Statistical Society: Series B, 58(2), 463–479.
Navarro, F. and Saumard, A. (2017). Slope heuristics and V-Fold model selection in heteroscedastic regression using strongly localized bases. ESAIM: Probability and Statistics, 21, 412–451.
Hi-Pass Downsampling operator (periodized)
DownDyadHi(x, qmf)
DownDyadHi(x, qmf)
x |
1-d signal at fine scale. |
qmf |
filter. |
y
1-d signal at coarse scale.
DownDyadLo
, UpDyadHi
,
UpDyadLo
, FWT_PO
, iconvv
.
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) DownDyadHi(x, qmf)
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) DownDyadHi(x, qmf)
Lo-Pass Downsampling operator (periodized)
DownDyadLo(x, qmf)
DownDyadLo(x, qmf)
x |
1-d signal at fine scale. |
qmf |
filter. |
d
1-d signal at coarse scale.
DownDyadHi
, UpDyadHi
,
UpDyadLo
, FWT_PO
, aconv
.
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) DownDyadLo(x,qmf)
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) DownDyadLo(x,qmf)
Index entire j-th dyad of 1-d wavelet xform
dyad(j)
dyad(j)
j |
integer. |
ix
list of all indices of wavelet coeffts at j-th level.
dyad(0)
dyad(0)
Find length and dyadic length of array
dyadlength(x)
dyadlength(x)
x |
array of length n = 2^J (hopefully). |
n
length(x).
J
least power of two greater than n.
x <- MakeSignal('Ramp', 8) dyadlength(x)
x <- MakeSignal('Ramp', 8) dyadlength(x)
A two-dimensional Wavelet Transform is computed for the array x.
qmf
filter may be obtained from MakeONFilter
.
To reconstruct, use ITWT2_PO
.
FTWT2_PO(x, L, qmf)
FTWT2_PO(x, L, qmf)
x |
2-d image (n by n array, n dyadic). |
L |
coarse level. |
qmf |
quadrature mirror filter. |
wc
2-d wavelet transform.
qmf <- MakeONFilter('Daubechies', 10) L <- 0 x <- matrix(rnorm(2^2), ncol=2) wc <- FTWT2_PO(x, L, qmf)
qmf <- MakeONFilter('Daubechies', 10) L <- 0 x <- matrix(rnorm(2^2), ncol=2) wc <- FTWT2_PO(x, L, qmf)
1. qmf
filter may be obtained from MakeONFilter
.
2. usually, length(qmf) < 2^(L+1)
.
3. To reconstruct use IWT_PO
.
FWT_PO(x, L, qmf)
FWT_PO(x, L, qmf)
x |
1-d signal; length(x) = 2^J. |
L |
Coarsest Level of V_0; L << J. |
qmf |
quadrature mirror filter (orthonormal). |
wc
1-d wavelet transform of x.
x <- MakeSignal('Ramp', 8) L <- 0 qmf <- MakeONFilter('Haar') wc <- FWT_PO(x, L, qmf)
x <- MakeSignal('Ramp', 8) L <- 0 qmf <- MakeONFilter('Haar') wc <- FWT_PO(x, L, qmf)
1. qmf
filter may be obtained from MakeONFilter
.
2. usually, length(qmf) < 2^(L+1)
.
3. To reconstruct use IWT_TI
.
FWT_TI(x, L, qmf)
FWT_TI(x, L, qmf)
x |
array of dyadic length n=2^J. |
L |
degree of coarsest scale. |
qmf |
orthonormal quadrature mirror filter. |
TIWT
stationary wavelet transform table.
x <- MakeSignal('Ramp', 8) L <- 0 qmf <- MakeONFilter('Haar') TIWT <- FWT_TI(x, L, qmf)
x <- MakeSignal('Ramp', 8) L <- 0 qmf <- MakeONFilter('Haar') TIWT <- FWT_TI(x, L, qmf)
A two-dimensional wavelet transform is computed for the array x.
qmf
filter may be obtained from MakeONFilter
.
To reconstruct, use IWT2_PO
.
FWT2_PO(x, L, qmf)
FWT2_PO(x, L, qmf)
x |
2-d image (n by n array, n dyadic). |
L |
coarse level. |
qmf |
quadrature mirror filter. |
wc
2-d wavelet transform.
qmf <- MakeONFilter('Daubechies', 10) L <- 3 x <- matrix(rnorm(128^2),ncol=128) wc <- FWT2_PO(x, L, qmf)
qmf <- MakeONFilter('Daubechies', 10) L <- 3 x <- matrix(rnorm(128^2),ncol=128) wc <- FWT2_PO(x, L, qmf)
1. qmf
filter may be obtained from MakeONFilter
.
2. usually, length(qmf) < 2^(L+1)
.
3. To reconstruct use IWT_TI
.
FWT2_TI(x, L, qmf)
FWT2_TI(x, L, qmf)
x |
2-d image (n by n real array, n dyadic). |
L |
degree of coarsest scale. |
qmf |
orthonormal quadrature mirror filter. |
TIWT
translation-invariant wavelet transform table, (3(J-L)+1)n by n.
x <- matrix(rnorm(2^2), ncol=2) L <- 0 qmf <- MakeONFilter('Haar') TIWT <- FWT2_TI(x, L, qmf)
x <- matrix(rnorm(2^2), ncol=2) L <- 0 qmf <- MakeONFilter('Haar') TIWT <- FWT2_TI(x, L, qmf)
A three-dimensional wavelet transform is computed for the array x.
qmf
filter may be obtained from MakeONFilter
.
To reconstruct, use IWT3_PO
.
FWT3_PO(x, L, qmf)
FWT3_PO(x, L, qmf)
x |
3-d array (n by n by n array, n dyadic). |
L |
coarse level. |
qmf |
quadrature mirror filter. |
3-D counterpart of Donoho's FWT2_PO, original matlab code Vicki Yang and Brani Vidakovic.
wc
3-d wavelet transform.
qmf <- MakeONFilter('Daubechies', 10) L <- 3 x <- array(rnorm(32^3), c(32,32,32)) wc <- FWT3_PO(x, L, qmf)
qmf <- MakeONFilter('Daubechies', 10) L <- 3 x <- array(rnorm(32^3), c(32,32,32)) wc <- FWT3_PO(x, L, qmf)
Generation of Gaussian White Noise
GWN(n, sigma)
GWN(n, sigma)
n |
sample size. |
sigma |
standard deviation. |
epsilon
resulting noise.
GWN(10, 0.1)
GWN(10, 0.1)
Apply Hard Threshold
HardThresh(y, t)
HardThresh(y, t)
y |
Noisy Data. |
t |
Threshold. |
x
filtered result (y 1_|y|>t).
f <- MakeSignal('HeaviSine',2^3) qmf <- MakeONFilter('Daubechies', 10) L <- 0 wc <- FWT_PO(f, L, qmf) thr <- 2 wct <- HardThresh(wc, thr) fhard <- IWT_PO(wct, L, qmf)
f <- MakeSignal('HeaviSine',2^3) qmf <- MakeONFilter('Daubechies', 10) L <- 0 wc <- FWT_PO(f, L, qmf) thr <- 2 wct <- HardThresh(wc, thr) fhard <- IWT_PO(wct, L, qmf)
Filtering by periodic convolution of x with f.
iconvv(f, x)
iconvv(f, x)
f |
filter. |
x |
1-d signal. |
y
filtered result.
aconv
, UpDyadHi
,
UpDyadLo
, DownDyadHi
, DownDyadLo
.
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) iconvv(qmf,x)
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) iconvv(qmf,x)
Inversion of the 1d block partition
invblock_partition(x, n, L)
invblock_partition(x, n, L)
x |
partition of coefficients by block. |
n |
scale. |
L |
block size. |
n <- 8 x <- MakeSignal('Ramp', n) j0 <- 1 qmf <- MakeONFilter('Haar') wc <- FWT_PO(x, j0, qmf) L <- 2 wcb <- block_partition(wc, L) wcib <- invblock_partition(wcb, n, L)
n <- 8 x <- MakeSignal('Ramp', n) j0 <- 1 qmf <- MakeONFilter('Haar') wc <- FWT_PO(x, j0, qmf) L <- 2 wcb <- block_partition(wc, L) wcib <- invblock_partition(wcb, n, L)
Inversion of the 2d block partition
invblock_partition2d(x, n, L)
invblock_partition2d(x, n, L)
x |
partition of coefficients by block. |
n |
scale. |
L |
block size. |
out
coefficients.
n <- 2 x <- matrix(rnorm(n^2), ncol=2) j0 <- 0 qmf <- MakeONFilter('Haar') wc <- FWT2_PO(x, j0, qmf) L <- 2 wcb <- block_partition2d(wc, L) wcib <- invblock_partition2d(wcb, n, L)
n <- 2 x <- matrix(rnorm(n^2), ncol=2) j0 <- 0 qmf <- MakeONFilter('Haar') wc <- FWT2_PO(x, j0, qmf) L <- 2 wcb <- block_partition2d(wc, L) wcib <- invblock_partition2d(wcb, n, L)
If wc
is the result of a forward 2d wavelet transform,
with wc <- FTWT2_PO(x,L,qmf)
, then x <- ITWT2_PO(wc,L,qmf)
reconstructs x
exactly.
qmf
is a nice qmf, e.g. one made by MakeONFilter
.
ITWT2_PO(wc, L, qmf)
ITWT2_PO(wc, L, qmf)
wc |
2-d wavelet transform (n by n array, n dyadic). |
L |
coarse level. |
qmf |
quadrature mirror filter. |
x
2-d signal reconstructed from wc.
qmf <- MakeONFilter('Daubechies', 10) L <- 0 x <- matrix(rnorm(2^2), ncol=2) wc <- FTWT2_PO(x, L, qmf) xr <- ITWT2_PO(wc,L,qmf)
qmf <- MakeONFilter('Daubechies', 10) L <- 0 x <- matrix(rnorm(2^2), ncol=2) wc <- FTWT2_PO(x, L, qmf) xr <- ITWT2_PO(wc,L,qmf)
Suppose wc <- FWT_PO(x,L,qmf)
where qmf
is an orthonormal quad.
mirror filter, e.g. one made by MakeONFilter
.
Then x can be reconstructed by x <- IWT_PO(wc,L,qmf)
.
IWT_PO(wc, L, qmf)
IWT_PO(wc, L, qmf)
wc |
1-d wavelet transform: length(wc) = 2^J. |
L |
Coarsest scale (2^(-L) = scale of V_0); L << J. |
qmf |
quadrature mirror filter (orthonormal). |
x
1-d signal reconstructed from wc.
x <- MakeSignal('Ramp', 8) L <- 0 qmf <- MakeONFilter('Haar') wc <- FWT_PO(x, L, qmf) xr <- IWT_PO(wc,L,qmf)
x <- MakeSignal('Ramp', 8) L <- 0 qmf <- MakeONFilter('Haar') wc <- FWT_PO(x, L, qmf) xr <- IWT_PO(wc,L,qmf)
Invert Translation Invariant Wavelet Transform
IWT_TI(pkt, qmf)
IWT_TI(pkt, qmf)
pkt |
translation-invariant wavelet transform table (TIWT). |
qmf |
orthonormal quadrature mirror filter. |
x
1-d signal reconstructed from translation-invariant transform TIWT.
x <- MakeSignal('Ramp', 8) L <- 0 qmf <- MakeONFilter('Haar') TIWT <- FWT_TI(x, L, qmf) xr <- IWT_TI(TIWT,qmf)
x <- MakeSignal('Ramp', 8) L <- 0 qmf <- MakeONFilter('Haar') TIWT <- FWT_TI(x, L, qmf) xr <- IWT_TI(TIWT,qmf)
If wc
is the result of a forward 2d wavelet transform, with wc <- FWT2_PO(x,L,qmf)
.
then x <- IWT2_PO(wc,L,qmf)
reconstructs x
exactly
qmf
is a nice qmf, e.g. one made by MakeONFilter
.
IWT2_PO(wc, L, qmf)
IWT2_PO(wc, L, qmf)
wc |
2-d wavelet transform (n by n array, n dyadic). |
L |
coarse level. |
qmf |
quadrature mirror filter. |
x
2-d signal reconstructed from wc.
qmf <- MakeONFilter('Daubechies', 10) L <- 3 x <- matrix(rnorm(128^2),ncol=128) wc <- FWT2_PO(x, L, qmf) xr <- IWT2_PO(wc,L,qmf)
qmf <- MakeONFilter('Daubechies', 10) L <- 3 x <- matrix(rnorm(128^2),ncol=128) wc <- FWT2_PO(x, L, qmf) xr <- IWT2_PO(wc,L,qmf)
Invert 2-d Translation Invariant Wavelet Transform
IWT2_TI(tiwt, L, qmf)
IWT2_TI(tiwt, L, qmf)
tiwt |
translation-invariant wavelet transform table, (3(J-L)+1)n by n. |
L |
degree of coarsest scale. |
qmf |
orthonormal quadrature mirror filter. |
x
2-d image reconstructed from translation-invariant transform TIWT.
x <- matrix(rnorm(2^2), ncol=2) L <- 0 qmf <- MakeONFilter('Haar') TIWT <- FWT2_TI(x, L, qmf) xr <- IWT2_TI(TIWT,L,qmf)
x <- matrix(rnorm(2^2), ncol=2) L <- 0 qmf <- MakeONFilter('Haar') TIWT <- FWT2_TI(x, L, qmf) xr <- IWT2_TI(TIWT,L,qmf)
If wc
is the result of a forward 3-d wavelet transform, with wc <- FWT3_PO(x, L, qmf)
.
then x <- IWT3_PO(wc, L, qmf)
reconstructs x
exactly
qmf
is a nice qmf, e.g. one made by MakeONFilter
.
IWT3_PO(wc, L, qmf)
IWT3_PO(wc, L, qmf)
wc |
3-d wavelet transform (n by n by n array, n dyadic). |
L |
coarse level. |
qmf |
quadrature mirror filter. |
3-d counterpart of Donoho's IWT2_PO, original matlab code by Vicki Yang and Brani Vidakovic.
x
3-d signal reconstructed from wc.
qmf <- MakeONFilter('Daubechies', 10) L <- 3 x <- array(rnorm(32^3), c(32, 32, 32)) wc <- FWT3_PO(x, L, qmf) xr <- IWT3_PO(wc, L, qmf)
qmf <- MakeONFilter('Daubechies', 10) L <- 3 x <- array(rnorm(32^3), c(32, 32, 32)) wc <- FWT3_PO(x, L, qmf) xr <- IWT3_PO(wc, L, qmf)
(also called the nonnegative garrote)
JSThresh(y, t)
JSThresh(y, t)
y |
Noisy Data. |
t |
Threshold. |
x
filtered result.
f <- MakeSignal('HeaviSine', 2^3) qmf <- MakeONFilter('Daubechies', 10) L <- 0 wc <- FWT_PO(f, L, qmf) thr <- 2 wct <- JSThresh(wc, thr) fsoft <- IWT_PO(wct, L, qmf)
f <- MakeSignal('HeaviSine', 2^3) qmf <- MakeONFilter('Daubechies', 10) L <- 0 wc <- FWT_PO(f, L, qmf) thr <- 2 wct <- JSThresh(wc, thr) fsoft <- IWT_PO(wct, L, qmf)
A dataset containing Lena image.
data(lena)
data(lena)
A numeric 512 x 512 matrix.
Circular left shift of 1-d signal
lshift(a)
lshift(a)
a |
1-d signal. |
l
1-d signal l(i) = x(i+1) except l(n) = x(1).
x <- MakeSignal('HeaviSine',2^3) lshift(x)
x <- MakeSignal('HeaviSine',2^3) lshift(x)
Compute the median absolute deviation.
MAD(x)
MAD(x)
x |
1-d signal. |
x <- c(1, 1, 2, 2, 4, 6, 9) MAD(x)
x <- c(1, 1, 2, 2, 4, 6, 9) MAD(x)
The Haar filter (which could be considered a Daubechies-2) was the first wavelet, though not called as such, and is discontinuous.
MakeONFilter(Type, Par)
MakeONFilter(Type, Par)
Type |
string, 'Haar', 'Beylkin', 'Coiflet', 'Daubechies' 'Symmlet', 'Vaidyanathan','Battle'. |
Par |
integer, it is a parameter related to the support and vanishing moments of the wavelets, explained below for each wavelet. |
The Beylkin filter places roots for the frequency response function close to the Nyquist frequency on the real axis.
The Coiflet filters are designed to give both the mother and father wavelets 2*Par vanishing moments; here Par may be one of 1,2,3,4 or 5.
The Daubechies filters are minimal phase filters that generate wavelets which have a minimal support for a given number of vanishing moments. They are indexed by their length, Par, which may be one of 4,6,8,10,12,14,16,18 or 20. The number of vanishing moments is par/2.
Symmlets are also wavelets within a minimum size support for a given number of vanishing moments, but they are as symmetrical as possible, as opposed to the Daubechies filters which are highly asymmetrical. They are indexed by Par, which specifies the number of vanishing moments and is equal to half the size of the support. It ranges from 4 to 10.
The Vaidyanathan filter gives an exact reconstruction, but does not satisfy any moment condition. The filter has been optimized for speech coding.
The Battle-Lemarie filter generate spline orthogonal wavelet basis. The parameter Par gives the degree of the spline. The number of vanishing moments is Par+1.
qmf
quadrature mirror filter.
FWT_PO
, IWT_PO
, FWT2_PO
, IWT2_PO
.
Type <- 'Coiflet' Par <- 1 qmf <- MakeONFilter(Type, Par)
Type <- 'Coiflet' Par <- 1 qmf <- MakeONFilter(Type, Par)
Make artificial signal
MakeSignal(name, n)
MakeSignal(name, n)
name |
string, 'HeaviSine', 'Bumps', 'Blocks', 'Doppler', 'Ramp','Cusp', 'Sing', 'HiSine', 'LoSine', 'LinChirp', 'TwoChirp', 'QuadChirp', 'MishMash', 'WernerSorrows' (Heisenberg), 'Leopold' (Kronecker), 'Riemann', 'HypChirps', 'LinChirps', 'Chirps', 'Gabor', 'sineoneoverx', 'Cusp2', 'SmoothCusp', 'Piece-Regular' (Piece-Wise Smooth), 'Piece-Polynomial' (Piece-Wise 3rd degree polynomial). |
n |
desired signal length. |
sig
1-d signal.
FWT_PO
, IWT_PO
, FWT2_PO
,
IWT2_PO
.
name <- 'Cusp' n <- 2^5 sig <- MakeSignal(name,n)
name <- 'Cusp' n <- 2^5 sig <- MakeSignal(name,n)
Make artificial 1-d signal
MakeSignalNewb(name, n)
MakeSignalNewb(name, n)
name |
string, 'Cusp','Step','Wave','Blip','Blocks', 'Bumps','HeaviSine','Doppler','Angles', 'Parabolas','Time Shifted Sine','Spikes','Corner' |
n |
desired signal length. |
sig
1-d signal.
FWT_PO
, IWT_PO
, FWT2_PO
,
IWT2_PO
.
name <- 'Cusp' n <- 2^5 sig <- MakeSignalNewb(name,n)
name <- 'Cusp' n <- 2^5 sig <- MakeSignalNewb(name,n)
Minimax Thresholding
MinMaxThresh(y)
MinMaxThresh(y)
y |
signal upon which to perform thresholding. |
x
result.
D.L. Donoho and I.M. Johnstone (1994). Ideal spatial adaptation by wavelet shrinkage. Biometrika, 81(3), 425–455.
h(t) = (-1)^(t-1) * x(t), 1 <= t <= length(x)
MirrorFilt(x)
MirrorFilt(x)
x |
1-d signal. |
h
1-d signal with DC frequency content shifted
to Nyquist frequency
x <- MakeSignal('HeaviSine',2^3) h <- MirrorFilt(x)
x <- MakeSignal('HeaviSine',2^3) h <- MirrorFilt(x)
Apply Shrinkage with level-dependent Noise level estimation
MultiMAD(wc, L)
MultiMAD(wc, L)
wc |
Wavelet Transform of noisy sequence. |
L |
low-resolution cutoff for Wavelet Transform. |
ws
result of applying VisuThresh to each wavelet level,
after scaling so MAD of coefficienst at each level = .6745
SURE referes to Stein's Unbiased Risk Estimate.
MultiSURE(wc, L)
MultiSURE(wc, L)
wc |
Wavelet Transform of noisy sequence with N(0,1) noise. |
L |
low-frequency cutoff for Wavelet Transform. |
ws
result of applying SUREThresh to each dyadic block.
Apply Universal Thresholding to Wavelet Coefficients
MultiVisu(wc, L)
MultiVisu(wc, L)
wc |
Wavelet Transform of noisy sequence with N(0,1) noise. |
L |
low-frequency cutoff for Wavelet Transform |
x
result of applying VisuThresh to each High Frequency Dyadic Block.
Packet table indexing
packet(d, b, n)
packet(d, b, n)
d |
depth of splitting in packet decomposition. |
b |
block index among 2^d possibilities at depth d. |
n |
length of signal. |
p
linear indices of all coeff's in that block.
packet(1, 1, 8)
packet(1, 1, 8)
Plot 1-d signal as baseline with series of spikes
PlotSpikes(base, t, x, L, J)
PlotSpikes(base, t, x, L, J)
base |
number, baseline level. |
t |
ordinate values. |
x |
1-d signal, specifies spike deflections from baseline. |
L |
level of coarsest scale. |
J |
least power of two greater than n. |
A plot of spikes on a baseline.
## Not run: PlotSpikes(base, t, x, L, J) ## End(Not run)
## Not run: PlotSpikes(base, t, x, L, J) ## End(Not run)
Spike-plot display of wavelet coefficients
PlotWaveCoeff(wc, L, scal)
PlotWaveCoeff(wc, L, scal)
wc |
1-d wavelet transform. |
L |
level of coarsest scale. |
scal |
scale factor (0 ==> autoscale). |
A display of wavelet coefficients (coarsest level NOT included) by level and position.
x <- MakeSignal('Ramp', 128) qmf <- MakeONFilter('Daubechies', 10) L <- 3 scal <- 1 wc <- FWT_PO(x, L, qmf) PlotWaveCoeff(wc,L,scal)
x <- MakeSignal('Ramp', 128) qmf <- MakeONFilter('Daubechies', 10) L <- 3 scal <- 1 wc <- FWT_PO(x, L, qmf) PlotWaveCoeff(wc,L,scal)
h(t) = (-1)^(t-1) * x(t), 1 <= t <= length(x)
quadlength(x)
quadlength(x)
x |
2-d image; dim(n,n), n = 2^J (hopefully). |
n
length(x).
J
least power of two greater than n.
quadlength(matrix(1:16,ncol=4))
quadlength(matrix(1:16,ncol=4))
A dataset containing a NMR signal.
data(RaphNMR)
data(RaphNMR)
A numeric vector of length 1024.
MRS Unit, VA Medical Center, San Francisco. Adrain Maudsley, Ph.D., Professor of Radiology. This NMR signal was obtained from Chris Raphael, then a postdoctoral fellow in the Department of Statistics at Stanford University who was working on Hidden Markov Models for restoring NMR Spectra.
Repeat copies of array (equivalent of the repmat matlab function).
repmat(a, n, m)
repmat(a, n, m)
a |
input array (scalar, vector, matrix). |
n |
number of time to repeat input array in row and column dimensions. |
m |
repetition factor. |
repmat(10,3,2)
repmat(10,3,2)
Circular right shift of 1-d signal
rshift(a)
rshift(a)
a |
1-d signal. |
r
1-d signal r(i) = x(i-1) except r(1) = x(n).
x <- MakeSignal('HeaviSine', 2^3) rshift(x)
x <- MakeSignal('HeaviSine', 2^3) rshift(x)
Make signal a row vector
ShapeAsRow(sig)
ShapeAsRow(sig)
sig |
a row or column vector. |
row
a row vector.
sig <- matrix(1:4) row <- ShapeAsRow(sig)
sig <- matrix(1:4) row <- ShapeAsRow(sig)
A dataset containing a 3d head phantom that can be used to test 3-d reconstruction algorithms. Shepp-Logan phantom is well-known imitation of human cerebral.
data(SLphantom)
data(SLphantom)
A numeric array of size 64x64x64.
Signal/Noise ratio
SNR(x, y)
SNR(x, y)
x |
Original reference signal. |
y |
Restored or noisy signal. |
Signal/Noise ratio.
n <- 2^4 x <- MakeSignal('HeaviSine', n) y <- x + rnorm(n, mean=0, sd=1) SNR(x, y)
n <- 2^4 x <- MakeSignal('HeaviSine', n) y <- x + rnorm(n, mean=0, sd=1) SNR(x, y)
Apply Soft Threshold
SoftThresh(y, t)
SoftThresh(y, t)
y |
Noisy Data. |
t |
Threshold. |
x
filtered result (y 1_|y|>t).
f <- MakeSignal('HeaviSine', 2^3) qmf <- MakeONFilter('Daubechies', 10) L <- 0 wc <- FWT_PO(f, L, qmf) thr <- 2 wct <- SoftThresh(wc, thr) fsoft <- IWT_PO(wct, L, qmf)
f <- MakeSignal('HeaviSine', 2^3) qmf <- MakeONFilter('Daubechies', 10) L <- 0 wc <- FWT_PO(f, L, qmf) thr <- 2 wct <- SoftThresh(wc, thr) fsoft <- IWT_PO(wct, L, qmf)
SURE refers to Stein's Unbiased Risk Estimate.
SUREThresh(y)
SUREThresh(y)
y |
Noisy Data with Std. Deviation = 1. |
x
Estimate of mean vector
thresh
Threshold used.
Hi-Pass Upsampling operator; periodized
UpDyadHi(x, qmf)
UpDyadHi(x, qmf)
x |
1-d signal at coarser scale. |
qmf |
filter. |
u
1-d signal at finer scale.
DownDyadLo
, DownDyadHi
,
UpDyadLo
, IWT_PO
, aconv
.
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) UpDyadHi(x,qmf)
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) UpDyadHi(x,qmf)
Lo-Pass Upsampling operator; periodized
UpDyadLo(x, qmf)
UpDyadLo(x, qmf)
x |
1-d signal at coarser scale. |
qmf |
filter. |
y
1-d signal at finer scale.
DownDyadLo
, DownDyadHi
,
UpDyadHi
, IWT_PO
, iconvv
.
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) UpDyadLo(x,qmf)
qmf <- MakeONFilter('Haar') x <- MakeSignal('HeaviSine',2^3) UpDyadLo(x,qmf)
Upsampling operator
UpSampleN(x, s)
UpSampleN(x, s)
x |
1-d signal, of length n. |
s |
upsampling scale, default = 2. |
y
1-d signal, of length s*n with zeros
interpolating alternate samples
y(s*i-1) = x(i), i=1,...,n
SURE referes to Stein's Unbiased Risk Estimate.
ValSUREThresh(x)
ValSUREThresh(x)
x |
Noisy Data with Std. Deviation = 1. |
thresh
Value of Threshold.
Visually calibrated Adaptive Smoothing
VisuThresh(y, thresh = "soft")
VisuThresh(y, thresh = "soft")
y |
Signal upon which to perform visually calibrated Adaptive Smoothing. |
thresh |
'hard' or 'soft'. |
x
result of applying VisuThresh.
D.L. Donoho and I.M. Johnstone (1994). Ideal spatial adaptation by wavelet shrinkage. Biometrika, 81(3), 425–455.
Todo: add description
WaveFEX(type = "PO", obs, qmf, scale = log2(nrow(obs)), iwt = F, alpha = F)
WaveFEX(type = "PO", obs, qmf, scale = log2(nrow(obs)), iwt = F, alpha = F)
type |
Orthogonal transform: PO or translation invariant transform:TI. |
obs |
A matrix of n x p functional data (n should be a power of 2). |
qmf |
Orthonormal quadrature mirror filter. |
scale |
Finest scale of the decomposition. |
iwt |
Logical to specify forward (FALSE) or inverse (TRUE) wavelet transform. |
alpha |
Logical TRUE to include scaling coefficients at the first scale. |
contj
Matrix scale x p of Squared norm of the wavelet coefficient at each scale.
wc
wavelet coefficients matrix.
Antoniadis, A., Brossat, X., Cugliari, J., & Poggi, J. M. (2013). Clustering functional data using wavelets. Int. J. Wavelets Multiresolution Inf. Process., 11(01), 1350003.
Cheam, A., Fredette, M., Marbac, M., & Navarro, F. (2023). Translation-invariant functional clustering on COVID-19 deaths adjusted on population risk factors. J. R. Stat. Soc., C: Appl. Stat., 72(2), 387-413.