Main Content


2-D detail coefficients


    y = detcoef2(o,c,s,n) extracts from the wavelet decomposition structure [c,s] the detail coefficients of orientation o at level n. For more information on c and s, see wavedec2.


    [h,v,d] = detcoef2('all',c,s,n) returns the horizontal h, vertical v, and diagonal d detail coefficients at level n.

    detcoef2('a',c,s,n) is equivalent to detcoef2('all',c,s,n).

    y = detcoef2('compact',c,s,n) returns all the detail coefficients stored row-wise.

    detcoef2('c',c,s,n) is equivalent to detcoef2('compact',c,s,n).

    If [H,V,D] = detcoef2('all',c,s,N) and Y = detcoef2('compact',c,s,N), then Y = [H(:)' V(:)' D(:)'].


    collapse all

    This example shows how to extract detail coefficients from a discrete wavelet analysis of an image. This example uses zero-padding.

    Set the extension mode to zero-padding. Load and display an image.

    origmode = dwtmode('status','nodisplay');
    load woman

    Obtain the wavelet decomposition of the image down to level two using the Haar wavelet.

    [c,s] = wavedec2(X,2,'haar');
    ans = 1×2
       256   256
    ans = 1×2
               1       65536
    s = 4×2
        64    64
        64    64
       128   128
       256   256

    Extract the detail coefficients at level 2 in each orientation from the wavelet decomposition structure [c,s]. Display the diagonal detail coefficients.

    [chd2,cvd2,cdd2] = detcoef2('all',c,s,2);
    ans = 1×2
        64    64

    Extract the detail coefficients at level 1 in each orientation. Display the vertical detail coefficients.

    [chd1,cvd1,cdd1] = detcoef2('all',c,s,1);
    ans = 1×2
       128   128

    Restore the original extension mode.


    Input Arguments

    collapse all

    Orientation of detail coefficients, specified as:

    • 'h' — Horizontal

    • 'v' — Vertical

    • 'd' — Diagonal

    Wavelet decomposition vector, specified as a real-valued vector. The vector c contains the approximation and detail coefficients organized by level. The bookkeeping matrix s is used to parse c. See wavedec2.

    Data Types: double

    Bookkeeping matrix, specified as an integer-valued matrix. The matrix s contains the dimensions of the wavelet coefficients by level and is used to parse the wavelet decomposition vector c. See wavedec2.

    Data Types: double

    Detail level to extract from the wavelet decomposition, specified as an integer. The integer n must be in the interval [1,size(s,1)-2].

    Output Arguments

    collapse all

    Detail coefficients, returned as a vector or matrix.

    Data Types: double

    Horizontal detail coefficients, returned as a matrix.

    Data Types: double

    Vertical detail coefficients, returned as a matrix.

    Data Types: double

    Diagonal detail coefficients, returned as a matrix.

    Data Types: double


    • If c and s are obtained from an indexed image analysis or a truecolor image analysis, y is an m-by-n matrix or an m-by-n-by-3 array, respectively.

      For more information on image formats, see the image and imfinfo reference pages.

    Extended Capabilities

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

    Version History

    Introduced before R2006a