Thresholding functions¶
The thresholding helper module implements the most popular signal
thresholding functions.
Thresholding¶
-
pywt.threshold(data, value, mode='soft', substitute=0)¶ Thresholds the input data depending on the mode argument.
In
softthresholding, the data values where their absolute value is less than the value param are replaced with substitute. From the data values with absolute value greater or equal to the thresholding value, a quantity of(signum * value)is subtracted.In
hardthresholding, the data values where their absolute value is less than the value param are replaced with substitute. Data values with absolute value greater or equal to the thresholding value stay untouched.In
greaterthresholding, the data is replaced with substitute where data is below the thresholding value. Greater data values pass untouched.In
lessthresholding, the data is replaced with substitute where data is above the thresholding value. Less data values pass untouched.Parameters: data : array_like
Numeric data.
value : scalar
Thresholding value.
mode : {‘soft’, ‘hard’, ‘greater’, ‘less’}
Decides the type of thresholding to be applied on input data. Default is ‘soft’.
substitute : float, optional
Substitute value (default: 0).
Returns: output : array
Thresholded array.
Examples
>>> import numpy as np >>> import pywt >>> data = np.linspace(1, 4, 7) >>> data array([ 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. ]) >>> pywt.threshold(data, 2, 'soft') array([ 0. , 0. , 0. , 0.5, 1. , 1.5, 2. ]) >>> pywt.threshold(data, 2, 'hard') array([ 0. , 0. , 2. , 2.5, 3. , 3.5, 4. ]) >>> pywt.threshold(data, 2, 'greater') array([ 0. , 0. , 2. , 2.5, 3. , 3.5, 4. ]) >>> pywt.threshold(data, 2, 'less') array([ 1. , 1.5, 2. , 0. , 0. , 0. , 0. ])