Main Content

mswthresh

Perform multisignal 1-D thresholding

Description

Y = mswthresh(X,sorh,T) returns the soft or hard T-thresholding of the matrix X. T can be a single value, a matrix the same size as X, or a vector. If T is a vector, thresholding is performed row-wise, and LT = length(T) must be such that size(X,1) ≤ LT. Only the first size(X,1) values of T are used.

Y = mswthresh(X,sorh,T,'c') performs thresholding column-wise, and LT = length(T) must be such that size(X,2) ≤ LT. Only the first size(X,2) values of T are used.

example

Examples

collapse all

Create a 3-by-3 matrix and a 1-by-3 vector of threshold values.

mat = [1 1 3; 1 1 3; 2 2 3]
mat = 3×3

     1     1     3
     1     1     3
     2     2     3

thr = [1 2 3]
thr = 1×3

     1     2     3

Apply soft thresholding to the matrix row-wise. The kth threshold in thr is applied to the kth row of mat.

mswthresh(mat,'s',thr)
ans = 3×3

     0     0     2
     0     0     1
     0     0     0

Apply soft thresholding to the matrix column-wise. The kth threshold in thr is applied to the kth column of mat.

mswthresh(mat,'s',thr,'c')
ans = 3×3

     0     0     0
     0     0     0
     1     0     0

Apply hard thresholding to the matrix row-wise.

mswthresh(mat,'h',thr)
ans = 3×3

     0     0     3
     0     0     3
     0     0     0

Apply hard thresholding to the matrix column-wise.

mswthresh(mat,'h',thr,'c')
ans = 3×3

     0     0     0
     0     0     0
     2     0     0

Input Arguments

collapse all

Input data to threshold, specified as a real-valued matrix.

Data Types: double

Type of thresholding to perform, specified as:

  • 's' — Soft thresholding

  • 'h' — Hard thresholding

Threshold value, specified as a real-valued scalar or vector.

Data Types: double

Output Arguments

collapse all

Thresholded data, returned as a real-valued matrix. Y has the same dimensions as X.

Algorithms

  • If sorh is 's', Y is the soft thresholding of X: Y=sign(X)·(|X|T)+ where

    (x)+={xifx00otherwise

    Soft thresholding is wavelet shrinkage.

  • If sorh is 'h', Y is the hard thresholding of X: Y=X·1(|X|>T) where

    1(|X|>T)={1if|X|>T0otherwise

    Hard thresholding is cruder than soft thresholding.

Version History

Introduced in R2007a