Main Content

wthcoef2

2-D wavelet coefficient thresholding

Description

NC = wthcoef2('type',C,S,N,T,SORH) returns the horizontal, vertical, or diagonal coefficients obtained from the wavelet decomposition structure [C,S] by soft or hard thresholding defined in vectors N and T.

wthcoef2 is a two-dimensional denoising and compression oriented function.

example

NC = wthcoef2('type',C,S,N) returns the horizontal, vertical, or diagonal coefficients obtained from [C,S] by setting all the coefficients of detail levels defined in N to zero.

NC = wthcoef2('a',C,S) returns the coefficients obtained by setting approximation coefficients to zero.

NC = wthcoef2('t',C,S,N,T,SORH) returns the detail coefficients obtained from the wavelet decomposition structure [C,S] by soft or hard thresholding defined in vectors N and T.

[NC,S] is the modified wavelet decomposition structure.

Examples

collapse all

Load the image data.

load mask

Perform a level 2 wavelet decomposition of the image using the haar wavelet.

[C,S]=wavedec2(X,2,'haar');

Return the vertical coefficients obtained from the wavelet decomposition structure, by soft thresholding defined in the thresholding vectors N =[1 2] and T=[2 4]. N specifies the detail levels, and T specifies the thresholds.

NC = wthcoef2('v',C,S,[1 2],[2 4],'s');

Input Arguments

collapse all

Type of coefficients obtained from the wavelet decomposition structure, specified as one of the following:

  • 'h'— Horizontal coefficients

  • 'v'— Vertical coefficients

  • 'd'— Diagonal coefficients

For more information, see wthresh.

Wavelet decomposition vector. The vector C contains the approximation and detail coefficients organized by level. The function uses the bookkeeping matrix S to parse C.

The vector C is organized as A(N), H(N), V(N), D(N), H(N-1), V(N-1), D(N-1), …, H(1), V(1), D(1), where A, H, V, and D are each a row vector. Each vector is the column-wise storage of a matrix.

  • A contains the approximation coefficients.

  • H contains the horizontal detail coefficients.

  • V contains the vertical detail coefficients.

  • D contains the diagonal detail coefficients.

For more information, see wavedec2.

Bookkeeping matrix. The matrix S contains the dimensions of the wavelet coefficients by level and the function uses it to parse the wavelet decomposition vector C.

  • S(1,:) = size of approximation coefficients(N).

  • S(i,:) = size of detail coefficients(N-i+2) for i = 2, ...N+1 and S(N+2,:) = size(X).

The following diagram shows the relationship between C and S in the wavelet decomposition of a 512-by-512 matrix.

When X represents an indexed image, the output arrays cA, cH, cV, and cD are m-by-n matrices. When X represents a truecolor image, it is an m-by-n-by-3 array, where each m-by-n matrix represents a red, green, or blue color plane concatenated along the third dimension. The size of vector C and the size of matrix S depend on the type of the analyzed image.

For a truecolor image, the decomposition vector C and the corresponding bookkeeping matrix S can be represented as shown.

For more information, see wavedec2.

Threshold vector, specified by a size 1 N(i) size(S,1)-2. N contains the detail levels to be thresholded and T the corresponding thresholds.

Threshold vector, specified as a nonnegative vector. N and T must be of the same length. N contains the detail levels to be thresholded and T the corresponding thresholds.

Soft or hard threshold, specified as 's' or 'h'.

For more information, see wthresh.

Output Arguments

collapse all

Wavelet coefficient threshold, returned as a real-valued vector.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a