Denoising
WaveletsExt.Denoising.RelErrorShrink
WaveletsExt.Denoising.SureShrink
WaveletsExt.Denoising.SureShrink
WaveletsExt.Denoising.denoiseall
WaveletsExt.Denoising.findelbow
WaveletsExt.Denoising.orth2relerror
WaveletsExt.Denoising.relerrorplot
WaveletsExt.Denoising.relerrorthreshold
WaveletsExt.Denoising.surethreshold
Shrinking Types and Constructors
Public API
WaveletsExt.Denoising.RelErrorShrink
— TypeRelErrorShrink(th, t) <: DNFT
Relative Error Shrink method used in their paper "Efficient Approximation and Denoising of Graph Signals using the Multiscale Basis Dictionary" for IEEE Transactions on Signal and Information Processing over Networks, Vol 0, No. 0, 2016.
Attributes
th::Wavelets.Threshold.THType
: (Default:Wavelets.HardTH()
) Threshold type.t::AbstractFloat
: (Default: 1.0) Threshold size.
Examples
using Wavelets, WaveletsExt
RelErrorShrink() # Using default th and t values
RelErrorShrink(SoftTH()) # Using default t value
RelErrorShrink(HardTH(), 0.5) # Using user input th and t values
See also: SureShrink
, VisuShrink
WaveletsExt.Denoising.SureShrink
— TypeSureShrink(th, t) <: DNFT
Stein's Unbiased Risk Estimate (SURE) Shrink
Attributes
th::Wavelets.Threshold.THType
: (Default:Wavelets.HardTH()
) Threshold type.t::AbstractFloat
: (Default: 1.0) Threshold size.
See also: RelErrorShrink
, VisuShrink
WaveletsExt.Denoising.SureShrink
— MethodSureShrink(xw[, redundant, tree, th])
Struct constructor for SureShrink
based on the signal coefficients xw
.
Arguments
xw::AbstractArray{T} where T<:Number
: Decomposed signal.redundant::Bool
: (Default:false
) Whether the transform type ofxw
is a redundant transform. Autocorrelation and stationary wavelet transforms are examples of redundant transforms.tree::Union{BitVector, Nothing}
: (Default:nothing
) The basis tree for decomposingxw
. Must be provided ifxw
is decomposed usingwpt
,swpd
, oracwpd
.th::Wavelets.Threshold.THType
: (Default:HardTH()
) Threshold type.
Returns
::SureShrink
: SUREShrink object.
Examples
SureShrink(xw) # `xw` is output of dwt, wpt
SureShrink(xw, true) # `xw` is output of sdwt, acdwt, swpt, acwpd
SureShrink(xw, true, tree) # `xw` is output of swpd, acwpd
See also: SureShrink
, surethreshold
Wavelets.Threshold.VisuShrink
— TypeVisuShrink(n, th)
Extension to the VisuShrink
struct constructor from Wavelets.jl
.
Arguments
n::Integer
: Signal length.th::Wavelets.Threshold.THType
: Threshold type.
Returns
::Wavelets.Threshold.VisuShrink
: VisuShrink object.
Examples
using Wavelets, WaveletsExt
VisuShrink(128, SoftTH())
Threshold Determination and Noise Estimation
Public API
Wavelets.Threshold.noisest
— Functionnoisest(x, redundant[, tree])
Extension to the noisest
function from Wavelets.jl
. Estimates the standard deviation of a signal's noise assuming that the noise is distributed normally. This function is generally used in combination with VisuShrink
and SureShrink
in the denoise
/denoiseall
functions.
Arguments
x::AbstractArray{T}
: Decomposed signal.redundant::Bool
: Whether the transform type ofxw
is a redundant transform. Autocorrelation and stationary wavelet transforms are examples of redundant transforms.tree::Union{BitVector, Nothing}
: (Default:nothing
) The basis tree for decomposingxw
. Must be provided ifxw
is decomposed usingwpt
,swpd
, oracwpd
.
Returns
::AbstractFloat
: Estimated standard deviation of the noise of the signal.
Examples
using Wavelets, WaveletsExt
x = randn(128)
wt = wavelet(WT.haar)
# noise estimate for dwt transformation
y = dwt(x, wt)
noise = noisest(y, false)
# noise estimate for wpt transformation
tree = maketree(x, :full)
y = wpt(x, wt, tree)
noise = noisest(y, false, tree)
# noise estimate for sdwt transformation
y = sdwt(x, wt)
noise = noisest(y, true)
# noise estimate for swpd transformation
y = swpd(x, wt)
noise = noisest(y, true, tree)
See also: relerrorthreshold
, VisuShrink
, SureShrink
WaveletsExt.Denoising.relerrorthreshold
— Functionrelerrorthreshold(coef, [redundant, tree, elbows; makeplot])
Takes in a set of expansion coefficients, 'plot' the threshold vs relative error curve and select the best threshold value based on the elbow method. If one wants to see the resulting plot from this computation, simply set makeplot=true
.
Arguments
coef::AbstractArray{T} where T<:Number
: Decomposed signal.redundant::Bool
: (Default:false
) Whether the transform type ofxw
is a redundant transform. Autocorrelation and stationary wavelet transforms are examples of redundant transforms.tree::Union{BitVector, Nothing}
: (Default:nothing
) The basis tree for decomposingxw
. Must be provided ifxw
is decomposed usingswpd
oracwpd
.elbows::Integer
: (Default: 2) Number of elbows used to determine the best threshold value.
Keyword Arguments
makeplot::Bool
: (Default:false
) Whether to return the plot that was used to determine the best threshold value.
Returns
::AbstractFloat
: Best threshold value.::GR.Plot
: Plot that was used to determine the best threshold value. Only returned ifmakeplot = true
.
Examples
x = randn(128)
wt = wavelet(WT.haar)
# noise estimate for dwt transformation
y = dwt(x, wt)
noise = relerrorthreshold(y, false)
# noise estimate for wpt transformation
tree = maketree(x, :full)
y = wpt(x, wt, tree)
noise = relerrorthreshold(y, false, tree)
# noise estimate for sdwt transformation
y = sdwt(x, wt)
noise = relerrorthreshold(y, true)
# noise estimate for swpd transformation
y = swpd(x, wt)
noise = relerrorthreshold(y, true, tree)
See also: noisest
, RelErrorShrink
Denoising Functions
Public API
Wavelets.Threshold.denoise
— Functiondenoise(x, inputtype, wt[; L=maxtransformlevels(size(x,1)),
tree=maketree(size(x,1), L, :dwt), dnt=VisuShrink(size(x,1)),
estnoise=noisest, smooth=:regular])
Extension of the denoise
function from Wavelets.jl
. Denoise a signal of input type inputtype
.
Arguments:
x::AbstractArray{<:Number}
: input signals/coefficients.inputtype::Symbol
: input type ofx
. Current accepted types of inputs are:sig
: original signals;x
should be a 2-D array with each column representing a signal.:dwt
:dwt
-transformed signal coefficients;x
should be a 1-D array with each column representing the coefficients of a signal.:wpt
:wpt
-transformed signal coefficients;x
should be a 1-D array with each column representing the coefficients of a signal.:sdwt
:sdwt
-transformed signal coefficients;x
should be a 2-D array with each column representing the coefficients of a node.:swpd
:swpd
-transformed signal coefficients;x
should be a 2-D array with each column representing the coefficients of a node.:acdwt
:acdwt
-transformed signal coefficients from AutocorrelationShell.jl;x
should be a 2-D array with each column representing the coefficients of a node.:acwpd
:acwpd
-transformed signal coefficients from AutocorrelationShell.jl;x
should be a 2-D array with each column representing the coefficients of a node.
wt::Union{DiscreteWavelet, Nothing}
: the discrete wavelet to be used for decomposition (for input type:sig
) and reconstruction.nothing
can be supplied if no reconstruction is necessary.L::Integer
: the number of decomposition levels. Necessary for input types:sig
,:dwt
, and:sdwt
. Default value is set to bemaxtransformlevels(size(x,1))
.tree::BitVector
: the decomposition tree of the signals. Necessary for input types:wpt
and:swpd
. Default value is set to bemaketree(size(x,1), L, :dwt)
.dnt::DNFT
: denoise type. Default type is set to beVisuShrink(size(x,1))
.estnoise::Union{Function, Vector{<:Number}}
: noise estimation. Input can be provided as a function to estimate noise in signal, or a vector of estimated noise. Default is set to be thenoisest
function.smooth::Symbol
: the smoothing method used.:regular
smoothing thresholds all given coefficients, whereas:undersmooth
smoothing does not threshold the lowest frequency subspace node of the wavelet transform. Default is set to be:regular
.
See also: denoiseall
, noisest
, relerrorthreshold
WaveletsExt.Denoising.denoiseall
— Functiondenoiseall(x, inputtype, wt[; L=maxtransformlevels(size(x,1)),
tree=maketree(size(x,1), L, :dwt), dnt=VisuShrink(size(x,1)),
estnoise=noisest, bestTH=nothing, smooth=:regular])
Denoise multiple signals of input type inputtype
.
Arguments:
x::AbstractArray{<:Number}
: input signals/coefficients.inputtype::Symbol
: input type ofx
. Current accepted types of inputs are:sig
: original signals;x
should be a 2-D array with each column representing a signal.:dwt
:dwt
-transformed signal coefficients;x
should be a 2-D array with each column representing the coefficients of a signal.:wpt
:wpt
-transformed signal coefficients;x
should be a 2-D array with each column representing the coefficients of a signal.:sdwt
:sdwt
-transformed signal coefficients;x
should be a 3-D array with each 2-D slice representing the coefficients of a signal.:swpd
:swpd
-transformed signal coefficients;x
should be a 3-D array with each 2-D slice representing the coefficients of a signal.:acdwt
:acdwt
-transformed signal coefficients from AutocorrelationShell.jl;x
should be a 3-D array with each 2-D slice representing the coefficients of a signal.:acwpd
:acwpd
-transformed signal coefficients from AutocorrelationShell.jl;x
should be a 3-D array with each 2-D slice representing the coefficients of a signal.
wt::Union{DiscreteWavelet, Nothing}
: the discrete wavelet to be used for decomposition (for input type:sig
) and reconstruction.nothing
can be supplied if no reconstruction is necessary.L::Integer
: the number of decomposition levels. Necessary for input types:sig
,:dwt
, and:sdwt
. Default value is set to bemaxtransformlevels(size(x,1))
.tree::BitVector
: the decomposition tree of the signals. Necessary for input types:wpt
and:swpd
. Default value is set to bemaketree(size(x,1), L, :dwt)
.dnt::DNFT
: denoise type. Default type is set to beVisuShrink(size(x,1))
.estnoise::Union{Function, Vector{<:Number}}
: noise estimation. Input can be provided as a function to estimate noise in signal, or a vector of estimated noise. Default is set to be thenoisest
function.bestTH::Union{Function, Nothing}
: method to determine the best threshold value for a group of signals. Ifnothing
is given, then each signal will be denoised by its respective best threshold value determined from the parametersdnt
andestnoise
; otherwise some function can be passed to determine the best threshold value from a vector of threshold values, eg:mean
andmedian
. Default is set to benothing
.smooth::Symbol
: the smoothing method used.:regular
smoothing thresholds all given coefficients, whereas:undersmooth
smoothing does not threshold the lowest frequency subspace node of the wavelet transform. Default is set to be:regular
.
See alse: denoise
, noisest
, relerrorthreshold
Helper Functions for Threshold Determination and Noise Estimation
Private API
WaveletsExt.Denoising.surethreshold
— Functionsurethreshold(coef, redundant[, tree])
Determination of the t
value used for SureShrink
. t
is defined as the threshold value when the standard deviation of the noisy signal is 1.
Arguments
coef::AbstractArray{T} where T<:Number
: Coefficients of decomposed signal.redundant::Bool
: Whether the transform type ofxw
is a redundant transform. Autocorrelation and stationary wavelet transforms are examples of redundant transforms.tree::Union{BitVector, Nothing}
: (Default:nothing
) The basis tree for decomposingxw
. Must be provided ifxw
is decomposed usingwpt
,swpd
, oracwpd
.
Returns
::AbstractFloat
: t
value used for SureShrink
.
See also: SureShrink
WaveletsExt.Denoising.orth2relerror
— Functionorth2relerror(orth)
Given a vector 'orth' of orthonormal expansion coefficients, return a vector of relative approximation errors when retaining the 1,2,...,N largest coefficients in magnitude.
Arguments
orth::AbstractVector{T} where T<:Number
: Vector of coefficients.
Returns
::Vector{T}
: Relative errors.
See also: RelErrorShrink
, relerrorthreshold
, findelbow
WaveletsExt.Denoising.findelbow
— Functionfindelbow(x, y)
Given the x and y coordinates of a curve, return the elbow.
Arguments
x::AbstractVector{T} where T<:Number
: x-coordinates.y::AbstractVector{T} where T<:Number
: y-coordinates.
Returns
::Integer
: Index of the elbow point.::Vector{T}
: Length of adjacent sides.::Vector{T}
: The y-coordinates going in the direction of (x₁, y₁) to (xₙ, yₙ)
See also: RelErrorShrink
, relerrorthreshold
, orth2relerror
WaveletsExt.Denoising.relerrorplot
— Functionrelerrorplot(x, y, ix, A, v)
Relative error plot used for threshold determination using the elbow rule.
Arguments
x::Vector{T} where T<:Number
: x-coordinates.y::Vector{T} where T<:Number
: y-coordinates.ix::Vector{<:Integer}
: Indices for elbow points.A::Vector{S} where {S<:Vector{T}, T<:Number}
: Length of adjacent sides.v::Vector{S} where {S<:Vector{T}, T<:Number}
: The y-coordinates going in the direction of (x[1], y[1]) to (x[ix], y[ix])
Returns
::Plot
: Relative error plot.
See also: relerrorthreshold
, findelbow