Threshold settings manager

`THR = wthrmngr(OPTION,METHOD,VARARGIN)`

`THR = wthrmngr(OPTION,METHOD,VARARGIN)`

returns
a global threshold or level dependent thresholds depending on `OPTION`

.
The inputs, `VARARGIN`

, depend on the `OPTION`

and `METHOD`

values.

This file returns the thresholds used throughout the Wavelet Toolbox™ software for de-noising and compression tools (command line files or Wavelet Analyzer app tools).

Valid options for the `METHOD`

parameter are
listed in the table below.

`METHOD` | Description |
---|---|

`'scarcehi'` | See `wdcbm` or `wdcbm2` when used with `'high'` predefined
value of parameter `M` . |

`'scarceme'` | See `wdcbm` or `wdcbm2` when used with `'medium'` predefined
value of parameter `M` . |

`'scarcelo'` | See `wdcbm` or `wdcbm2` when used with `'low'` predefined
value of parameter `M` . |

`'sqtwolog'` | See `'sqtwolog'` option in `thselect` , and see also `wden` . |

`'sqtwologuwn'` | See '`sqtwolog` ' option in `thselect` , and see also `wden` when used with '`sln` '
option. |

`'sqtwologswn'` | See `'sqtwolog'` option in `thselect` , and see also `wden` when used with `'mln'` option. |

`'rigsure'` | See `'rigsure'` option in `thselect` , and see also `wden` . |

`'heursure'` | See `'heursure'` option in `thselect` , and see also `wden` . |

`'minimaxi'` | See `'minimaxi'` option in `thselect` , and see also `wden` . |

`'penalhi'` | See `wbmpen` or `wpbmpen` when used with `'high'` value
of parameter `ALPHA` . |

`'penalme'` | See `wbmpen` or `wpbmpen` when used with `'medium'` value
of parameter `ALPHA` . |

`'penallo'` | See `wbmpen` or `wpbmpen` when used with `'low'` value
of parameter `ALPHA` . |

`'rem_n0'` | This option returns a threshold close to 0. A typical `THR` value
is `median(abs(coefficients))` . |

`'bal_sn'` | This option returns a threshold such that the percentages of retained energy and number of zeros are the same. |

`'sqrtbal_sn'` | This option returns a threshold equal to the square root of the value such that the percentages of retained energy and number of zeros are the same. |

For 1–D wavelet transforms, the expansion coefficients
are in the vector `C`

and the lengths of the expansion
coefficient vectors are stored in `L`

.

`X`

is the signal to be compressed and `[C,L]`

is
the wavelet decomposition structure of the signal to be compressed.

THR = wthrmngr('dw1dcompGBL','rem_n0',X) THR = wthrmngr('dw1dcompGBL','bal_sn',X)

`X`

is the signal to be compressed and `[C,L]`

is
the wavelet decomposition structure of the signal to be compressed.

`ALFA`

is a sparsity parameter (see `wdcbm`

for more information).

THR = wthrmngr('dw1dcompLVL','scarcehi',C,L,ALFA) ALFA must be such that 2.5 < ALFA < 10 THR = wthrmngr('dw1dcompLVL','scarceme',C,L,ALFA) ALFA must be such that 1.5 < ALFA < 2.5 THR = wthrmngr('dw1dcompLVL','scarcelo',C,L,ALFA) ALFA must be such that 1 < ALFA < 2

`[C,L]`

is the wavelet decomposition structure
of the signal to be de-noised, `SCAL`

defines the
multiplicative threshold rescaling (see `wden`

for
more information) and `ALFA`

is a sparsity parameter
(see `wbmpen`

for more information).

THR = wthrmngr('dw1ddenoLVL','sqtwolog',C,L,SCAL) THR = wthrmngr('dw1ddenoLVL','rigrsure',C,L,SCAL) THR = wthrmngr('dw1ddenoLVL','heursure',C,L,SCAL) THR = wthrmngr('dw1ddenoLVL','minimaxi',C,L,SCAL) THR = wthrmngr('dw1ddenoLVL','penalhi',C,L,ALFA) ALFA must be such that 2.5 < ALFA < 10 THR = wthrmngr('dw1ddenoLVL','penalme',C,L,ALFA) ALFA must be such that 1.5 < ALFA < 2.5 THR = wthrmngr('dw1ddenoLVL','penallo',C,L,ALFA) ALFA must be such that 1 < ALFA < 2

`SWTDEC`

is the stationary wavelet decomposition
structure of the signal to be de-noised, `SCAL`

defines
the multiplicative threshold rescaling (see `wden`

for
more information) and `ALFA`

is a sparsity parameter
(see `wbmpen`

for more information).

THR = wthrmngr('sw1ddenoLVL',METHOD,SWTDEC,SCAL) THR = wthrmngr('sw1ddenoLVL',METHOD,SWTDEC,ALFA)

The options for `METHOD`

are the same as in
the `'dw1ddenoLVL'`

case.

For 2–D wavelet transforms, the expansion coefficients
are in the vector `C`

and the size of the coefficient
matrices at each level is stored in `S`

.

`X`

is the image to be compressed and `[C,S]`

is
the wavelet decomposition structure of the image to be compressed.

THR = wthrmngr('dw2dcompGBL','rem_n0',X) THR = wthrmngr('dw2dcompGBL','bal_sn',C,S) THR = wthrmngr('dw2dcompGBL','sqrtbal_sn',C,S)

`X`

is the image to be compressed and `[C,S]`

is
the wavelet decomposition structure of the image to be compressed. `ALFA`

is
a sparsity parameter (see `wdcbm2`

for
more information).

THR = wthrmngr('dw2dcompLVL','scarcehi',C,S,ALFA) ALFA must be such that 2.5 < ALFA < 10 THR = wthrmngr('dw2dcompLVL','scarceme',C,S,ALFA) ALFA must be such that 1.5 < ALFA < 2.5 THR = wthrmngr('dw2dcompLVL','scarcelo',C,S,ALFA) ALFA must be such that 1 < ALFA < 2

`[C,S]`

is the wavelet decomposition structure
of the image to be de-noised, `SCAL`

defines the
multiplicative threshold rescaling (see `wden`

for
more information) and `ALFA`

is a sparsity parameter
(see `wbmpen`

for more information).

THR = wthrmngr('dw2ddenoLVL','penalhi',C,S,ALFA) ALFA must be such that 2.5 < ALFA < 10 THR = wthrmngr('dw2ddenoLVL','penalme',C,S,ALFA) ALFA must be such that 1.5 < ALFA < 2.5 THR = wthrmngr('dw2ddenoLVL','penallo',C,S,ALFA) ALFA must be such that 1 < ALFA < 2 THR = wthrmngr('dw2ddenoLVL','sqtwolog',C,S,SCAL) THR = wthrmngr('dw2ddenoLVL','sqrtbal_sn',C,S)

`SWTDEC`

is the stationary wavelet decomposition
structure of the image to be de-noised, `SCAL`

defines
the multiplicative threshold rescaling (see `wden`

for
more information) and `ALFA`

is a sparsity parameter
(see `wbmpen`

for more information).

THR = wthrmngr('sw2ddenoLVL',METHOD,SWTDEC,SCAL) THR = wthrmngr('sw2ddenoLVL',METHOD,SWTDEC,ALFA)

The options for `METHOD`

are the same as in
the `'dw2ddenoLVL'`

case.

`X`

is the signal to be compressed and `WPT`

is
the wavelet packet decomposition structure of the signal to be compressed.

THR = wthrmngr('wp1dcompGBL','bal_sn',WPT) THR = wthrmngr('wp1dcompGBL','rem_n0',X)

`WPT`

is the wavelet packet decomposition structure
of the signal to be de-noised.

THR = wthrmngr('wp1ddenoGBL','sqtwologuwn',WPT) THR = wthrmngr('wp1ddenoGBL','sqtwologswn',WPT) THR = wthrmngr('wp1ddenoGBL','bal_sn',WPT) THR = wthrmngr('wp1ddenoGBL','penalhi',WPT) see wbmpen with ALFA = 6.25 THR = wthrmngr('wp1ddenoGBL','penalme',WPT) see wbmpen with ALFA = 2 THR = wthrmngr('wp1ddenoGBL','penallo',WPT) see wbmpen with ALFA = 1.5

`X`

is the image to be compressed and `WPT`

is
the wavelet packet decomposition structure of the image to be compressed.

THR = wthrmngr('wp2dcompGBL','bal_sn',WPT) THR = wthrmngr('wp2dcompGBL','rem_n0',X) THR = wthrmngr('wp2dcompGBL','sqrtbal_sn',WPT)

`WPT`

is the wavelet packet decomposition structure
of the image to be de-noised.

THR = wthrmngr('wp2ddenoGBL','sqtwologuwn',WPT) THR = wthrmngr('wp2ddenoGBL','sqtwologswn',WPT) THR = wthrmngr('wp2ddenoGBL','sqrtbal_sn',WPT) THR = wthrmngr('wp2ddenoGBL','penalhi',WPT) see wbmpen with ALFA = 6.25 THR = wthrmngr('wp2ddenoGBL','penalme',WPT) see wbmpen with ALFA = 2 THR = wthrmngr('wp2ddenoGBL','penallo',WPT) see wbmpen with ALFA = 1.5

This example uses a level-independent threshold based on the finest-scale wavelet coefficients to implement hard thresholding with the stationary wavelet transform.

Load the noisy blocks signal. Obtain the stationary wavelet transform down to level 5 using the Haar wavelet.

load noisbloc; L = 5; swc = swt(noisbloc,L,'db1');

Make a copy of the wavelet transform coefficients. Determine the Donoho-Johnstone universal threshold based on the first-level detail coefficients. Using the `'sln'`

option, `wthrmngr`

returns a 1-by-L vector with every element equal to the same value. Take the mean of the vector to obtain a scalar threshold.

swcnew = swc; ThreshSL = mean(wthrmngr('sw1ddenoLVL','sqtwolog',swc,'sln'));

Use the universal threshold to implement hard thresholding. The same threshold is applied to the wavelet coefficients at every level.

for jj = 1:L swcnew(jj,:) = wthresh(swc(jj,:),'h',ThreshSL); end

Invert the stationary wavelet transform on the thresholded coefficients, `swcnew`

. Plot the original signal and the denoised signal for comparison.

noisbloc_denoised = iswt(swcnew,'db1'); plot(noisbloc); hold on; plot(noisbloc_denoised,'r','linewidth',2);

This example uses a level-dependent threshold derived from the wavelet coefficients at each scale to implement hard thresholding with the stationary wavelet transform.

Load the noisy blocks signal. Obtain the stationary wavelet transform down to level 5 using the Haar wavelet.

load noisbloc; L = 5; swc = swt(noisbloc,L,'db1');

Make a copy of the wavelet transform coefficients. Determine the Donoho-Johnstone universal threshold based on the detail coefficients for each scale. Using the `'mln'`

option, `wthrmngr`

returns a 1-by-L vector with each element of the vector equal to the universal threshold for the corresponding scale.

swcnew = swc; ThreshML = wthrmngr('sw1ddenoLVL','sqtwolog',swc,'mln');

Use the universal thresholds to implement hard thresholding. The thresholds are applied in a scale-dependent manner.

for jj = 1:L swcnew(jj,:) = wthresh(swc(jj,:),'h',ThreshML(jj)); end

Invert the stationary wavelet transform on the thresholded coefficients, `swcnew`

. Plot the original signal and the denoised signal for comparison.

noisbloc_denoised = iswt(swcnew,'db1'); plot(noisbloc); hold on; plot(noisbloc_denoised,'r','linewidth',2);

This example compresses an image using the Birgé-Massart strategy.

Load the image and add white Gaussian noise.

```
load sinsin
x = X+18*randn(size(X));
```

Obtain the 2-D discrete wavelet transform down to level 2 using the Daubechies' least-asymmetric wavelet with 8 vanishing moments. Obtain the compression thresholds using the Birgé-Massart strategy with `alpha`

equal to 2.

[C,L] = wavedec2(x,2,'sym8'); alpha = 2; THR = wthrmngr('dw2dcompLVL','scarcehi',C,L,alpha);

Compress the image and display the result.

Xd = wdencmp('lvd',X,'sym8',2,THR,'s'); image(X); title('Original image'); figure; image(x); title('Noisy image'); figure; image(Xd); title('Denoised image');

Was this topic helpful?