Function: thresh
THRESH   Coefficient thresholding
  Usage:  x=thresh(x,lambda,...);
          [x,N]=thresh(x,lambda,...);

  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.
    
    J. Lim and A. Oppenheim. Enhancement and bandwidth compression of noisy
    speech. Proceedings of the IEEE, 67(12):1586--1604, 1979.
    

Url: http://ltfat.github.io/doc/sigproc/thresh.html

See also: largestr, largestn.

Package: ltfat