Main Content

upcoef2

Direct reconstruction from 2-D wavelet coefficients

    Description

    upcoef2 is a two-dimensional wavelet analysis function.

    y = upcoef2(o,x,wname) returns the single-step reconstructed coefficients of x of type o using the wavelet wname.

    y = upcoef2(o,x,LoR,HiR) uses the specified lowpass and highpass reconstruction filters LoR and HiR, respectively.

    y = upcoef2(___,n) returns the n-step reconstructed coefficients.

    y = upcoef2(___,n,s) returns the central part of size s.

    example

    Examples

    collapse all

    Load an image. The image is in the workspace variable X. Use the dwtmode function to save the current extension mode, then change the extension mode to zero-padding.

    load tartan
    siz = size(X);
    origMode = dwtmode("status","nodisp");
    dwtmode("zpd","nodisp")
    imagesc(X)
    title("Original Image")
    colormap(gray)

    Figure contains an axes object. The axes object with title Original Image contains an object of type image.

    Obtain the discrete wavelet transform of the image at level 2 using the db4 wavelet.

    wv = "db4";
    lev = 2;
    [c,s] = wavedec2(X,lev,wv);

    Use the appcoef2 function to extract the approximation coefficients from the decomposition structure [c,s]. Then use the upcoef2 function to reconstruct the approximation coefficients at level 1. Obtain the central part of the reconstruction.

    ca1 = appcoef2(c,s,wv,1);
    a1 = upcoef2("a",ca1,wv,1,siz);

    Plot the reconstructed approximation coefficients.

    imagesc(a1)
    title("Reconstructed Approximation Coefficients")
    colormap(gray)

    Figure contains an axes object. The axes object with title Reconstructed Approximation Coefficients contains an object of type image.

    Reconstruct the detail coefficients at level 1 for all orientations. For each orientation, use the detcoef2 function to extract those detail coefficients, and then use upcoef2 to obtain the reconstruction. Plot one of the reconstructions.

    chd1 = detcoef2("h",c,s,1);
    hd1 = upcoef2("h",chd1,wv,1,siz);
    
    
    cvd1 = detcoef2("v",c,s,1);
    vd1 = upcoef2("v",cvd1,wv,1,siz);
    
    cdd1 = detcoef2("d",c,s,1);
    dd1 = upcoef2("d",cdd1,wv,1,siz);
    
    imagesc(dd1)
    title("Reconstructed Diagonal Details")
    colormap(gray)

    Figure contains an axes object. The axes object with title Reconstructed Diagonal Details contains an object of type image.

    Restore the original extension mode.

    dwtmode(origMode,"nodisp")

    Input Arguments

    collapse all

    Type of reconstructed coefficients, specified as one of these:

    • "a" — Approximation coefficients

    • "h" — Horizontal detail coefficients

    • "v" — Vertical detail coefficients

    • "d" — Diagonal detail coefficients

    Coefficients, specified as a matrix or 3-D array.

    If x is obtained from an indexed image analysis or a truecolor image analysis, then x is an M-by-N matrix or M-by-N-by-3 array, respectively. For more information on truecolor images, see Working with Image Types in MATLAB.

    Data Types: double

    Wavelet, specified as a character vector or string scalar. The wavelet must be recognized by wavemngr. See wfilters for the wavelets available in each family.

    Data Types: char | string

    Wavelet reconstruction filters, specified as a pair of even-length real-valued vectors. LoR is the lowpass reconstruction filter, and HiR is the highpass reconstruction filter. The lengths of LoR and HiR must be equal. See wfilters for additional information.

    Data Types: double

    Number of reconstruction steps, specified as a positive integer.

    Data Types: double

    Size of central portion of reconstruction to return, specified as a 1-by-2 vector with nonnegative integer entries. If either entry is 0 , upcoef2 returns the entire reconstruction.

    Data Types: double

    Output Arguments

    collapse all

    Reconstructed coefficients of x, returned as a matrix.

    If x is obtained from an indexed image analysis, y is a matrix. If x is obtained from a truecolor image analysis, y is a 3-D array.

    Algorithms

    upcoef2 is equivalent to an n-time repeated use of the inverse wavelet transform.

    Version History

    Introduced before R2006a

    See Also