Main Content

waverec3

Multilevel 3-D discrete wavelet transform reconstruction

    Description

    x = waverec3(wdec) reconstructs the 3-D array x based on the multilevel wavelet decomposition structure wdec.

    c = waverec3(wdec,type,n) reconstructs or extracts at level n the multilevel components specified by type. If type begins with 'c' or 'C', waverec3 extracts the specified components. Otherwise, waverec3 reconstructs the components.

    x = waverec3(wdec,'a',0) and x = waverec3(wdec,'ca',0) are equivalent to x = waverec3(wdec), where 'a' specifies the lowpass component. x is the reconstruction of the coefficients in wdec at level 0.

    c = waverec3(wdec,type) is equivalent to c = waverec3(wdec,type,wdec.level).

    example

    Examples

    collapse all

    Construct a 3-D matrix, obtain the wavelet transform down to level 2 using the 'db2' wavelet, and reconstruct the matrix to verify perfect reconstruction.

    Create 3-D matrix.

    M = magic(8);
    X = repmat(M,[1 1 8]);

    Obtain the 3-D discrete wavelet transform of the matrix and reconstruct the input based on the 3-D approximation and detail coefficients.

    wd = wavedec3(X,2,'db2');
    XR = waverec3(wd);

    Verify perfect reconstruction using the wavelet decomposition down to level 2.

    err1 = max(abs(X(:)-XR(:)))
    err1 = 
    8.6050e-11
    

    Verify that the data matrix is the sum of the approximation and the details from levels 2 and 1. Reconstruct the sum of components different from the lowpass component and check that X = A + D.

    A = waverec3(wd,'LLL');
    D = waverec3(wd,'d');
    err2 = max(abs(X(:)-A(:)-D(:)))
    err2 = 
    8.6054e-11
    

    Compare level-1 reconstructions based on the filtering operations 'LLH' using idwt3 and waverec3.

    M = magic(8);
    X = repmat(M,[1 1 8]);
    wd = wavedec3(X,2,'db2','mode','per');
    dwtOut = dwt3(X,'db2');
    Xr = idwt3(dwtOut,'LLH');
    Xrec = waverec3(wd,'LLH',1);
    norm(Xr(:)-Xrec(:))
    ans = 
    2.2773e-14
    

    Input Arguments

    collapse all

    Wavelet decomposition, specified as a structure. The structure is the output of wavedec3 and has the following fields:

    Size of the 3-D array, specified as a 1-by-3 vector.

    Level of the decomposition, specified as an integer.

    Name of the wavelet transform extension mode, specified as a character vector.

    Wavelet filters used for the decomposition, specified as a structure with the following fields:

    • LoD — lowpass decomposition filter

    • HiD — highpass decomposition filter

    • LoR — lowpass decomposition filter

    • HiR — highpass decomposition filter

    Decomposition coefficients, specified as an N-by-1 cell array, where N equals wdec.level+1.

    dec{1} contains the lowpass component (approximation) at the level of the decomposition. The approximation is equivalent to the filtering operations 'LLL'.

    dec{k+2},...,dec{k+8} with k = 0,7,14,...,7*(wdec.level-1) contain the 3-D wavelet coefficients for the multiresolution starting with the coarsest level when k=0.

    For example, if wdec.level=3, dec{2},...,dec{8} contain the wavelet coefficients for level 3 (k=0), dec{9},...,dec{15} contain the wavelet coefficients for level 2 (k=7), and dec{16},...,dec{22} contain the wavelet coefficients for level 1 (k=7*(wdec.level-1)).

    At each level, the wavelet coefficients in dec{k+2},...,dec{k+8} are in the following order: 'HLL','LHL','HHL','LLH','HLH','LHH','HHH'.

    The sequence of letters gives the order in which the separable filtering operations are applied from left to right. For example, 'LHH' means that the lowpass (scaling) filter with downsampling is applied to the rows of x, followed by the highpass (wavelet) filter with downsampling applied to the columns of x. Finally, the highpass filter with downsampling is applied to the 3rd dimension of x.

    Successive sizes of the decomposition components, specified as a wdec.level+1-by-2 matrix.

    Type of reconstruction or extraction, specified as a character vector or string scalar. For reconstruction, valid values of type are:

    • A group of three characters 'xyz', one per direction, with 'x','y' and 'z' selected in the set {'a', 'd', 'l', 'h'} or in the corresponding uppercase set {'A','D', 'L', 'H'}, where 'A' (or 'L') is a lowpass filter and 'D' (or 'H') is a highpass filter.

    • The char 'd' (or 'h' or 'D' or 'H') gives the sum of all the components different from the lowpass component.

    • The char 'a' (or 'l' or 'A' or 'L') gives the lowpass component (the approximation at level n).

    To extract coefficients, the valid values for type are the same but prefixed by 'c' or 'C'.

    Decomposition level, specified as an integer.

    Output Arguments

    collapse all

    Reconstruction, returned as a 3-D array of size sz(1)-by-sz(2)-by-sz(3), where sz = wpdec.sizeINI.

    Extracted coefficients, returned as a 3-D array.

    Version History

    Introduced in R2010a

    See Also

    | |