This is where navigation should be.

THRESH - Coefficient thresholding

Usage

x=thresh(x,lambda,...);
[x,N]=thresh(x,lambda,...);

Description

thresh(x,lambda) will perform hard thresholding on x, i.e. all elements with absolute value less than scalar lambda will be set to zero.

thresh(x,lambda,'soft') will perform soft thresholding on x, i.e. lambda will be subtracted from the absolute value of every element of x.

The lambda parameter can also be a vector with number of elements equal to numel(xi) or it can be a numeric array of the same shape as xi. lambda is then applied element-wise and in a column major order if lambda is a vector.

[x,N]=thresh(x,lambda) additionally returns a number N specifying how many numbers where kept.

thresh takes the following flags at the end of the line of input arguments:

'hard' Perform hard thresholding. This is the default.
'wiener' Perform empirical Wiener shrinkage. This is in between soft and hard thresholding.
'soft' Perform soft thresholding.
'full' Returns the output as a full matrix. This is the default.
'sparse' Returns the output as a sparse matrix.

The function wthresh in the Matlab Wavelet toolbox implements some of the same functionality.

The following code produces a plot to demonstrate the difference between hard and soft thresholding for a simple linear input:

t=linspace(-4,4,100);
plot(t,thresh(t,1,'soft'),'r',...
     t,thresh(t,1,'hard'),'.b',...
     t,thresh(t,1,'wiener'),'--g');
legend('Soft thresh.','Hard thresh.','Wiener thresh.','Location','NorthWest');

References:

S. Ghael, A. Sayeed, and R. Baraniuk. Improved wavelet denoising via empirical Wiener filtering. In Proceedings of SPIE, volume 3169, pages 389--399. San Diego, CA, 1997. [ http ]

J. Lim and A. Oppenheim. Enhancement and bandwidth compression of noisy speech. Proceedings of the IEEE, 67(12):1586--1604, 1979.