Skip to Main Content Skip to Search
Product Documentation

Adding Your Own Wavelets

This section shows you how to add your own wavelet families to the toolbox.

Preparing to Add a New Wavelet Family

Wavelet Toolbox software contains a large number of the most commonly-used wavelet families. Additionally, using wavemngr, you can add new wavelets to the existing ones to implement your favorite wavelet or try out one of your own design. The toolbox allows you to define new wavelets for use with both the command line functions and the graphical interface tools.

wavemngr affords extensive wavelet management. However, this section focuses only on the addition of a wavelet family. For more complete information, see the wavemngr reference page.

To add a new wavelet, you must

  1. Choose the full name of the wavelet family (fn).

  2. Choose the short name of the wavelet family (fsn).

  3. Determine the wavelet type (wt).

  4. Define the orders of wavelets within the given family (nums).

  5. Build a MAT-file or a MATLAB file (file).

  6. For wavelets without FIR filters: Define the effective support.

These steps are described below.

Choose the Wavelet Family Full Name

The full name of the wavelet family, fn, must be a string. Do not use predefined wavelet family names. To see the predefined wavelet family names, enter:

wavemngr('read')

The predefined wavelet family names are the displayed in the first column of the output. Predefined wavelet family names are Haar, Daubechies, Symlets, Coiflets, BiorSplines, ReverseBior, Meyer, DMeyer, Gaussian, Mexican_hat, Morlet, Complex Gaussian, Shannon, Frequency B-Spline, and Complex Morlet.

Choose the Wavelet Family Short Name

The short name of the wavelet family, fsn, must be a string of four characters or less. Do not use predefined wavelet family short names. To see the predefined wavelet family short names, enter:

wavemngr('read')

The predefined wavelet family short names are the displayed in the second column of the output..

Determine the Wavelet Type

We distinguish five types of wavelets:

  1. Orthogonal wavelets with FIR filters

    These wavelets can be defined through the scaling filter h. The scaling filter is a lowpass filter. For orthogonal wavelets, the same scaling filter is used for decomposition (analysis) and reconstruction (synthesis). Predefined families of such wavelets include Haar, Daubechies, Coiflets, and Symlets.

  2. Biorthogonal wavelets with FIR filters

    These wavelets can be defined through the two scaling filters hr and hd, for reconstruction and decomposition respectively. The BiorSplines wavelet family is a predefined family of this type.

  3. Orthogonal wavelets without FIR filters, but with a scaling function

    These wavelets can be defined through the definition of the wavelet function and the scaling function. The Meyer wavelet family is a predefined family of this type.

  4. Wavelets without FIR filters and without a scaling function

    These wavelets can be defined through the definition of the wavelet function. Predefined families of such wavelets include Morlet and Mexican_hat.

  5. Complex wavelets without FIR filters and without a scaling function

    These wavelets can be defined through the definition of the wavelet function. Predefined families of such wavelets include Complex Gaussian and Shannon.

Define the Orders of Wavelets Within the Given Family

If a family contains many wavelets, the short name and the order are appended to form the wavelet name. Argument nums is a string containing the orders separated with blanks. This argument is not used for wavelet families that only have a single wavelet (Haar, Meyer, and Morlet for example).

For example, for the first extremal-phase Daubechies wavelets,

fsn = 'db'
nums = '1 2 3'

yields the three wavelets db1, db2, and db3.

For the first B-spline biorthogonal wavelets,

fsn = 'bior'
nums = '1.1 1.3 1.5 2.2'

yields the four wavelets bior1.1, bior1.3, bior1.5, and bior2.2.

You can display this information for the predefined wavelets with

wavemngr('read',1)

Build a MAT-File or Code File

wavemngr requires a file argument, which is a string containing a MATLAB function or MAT file name.

If a family contains many wavelets, a MATLAB code file (with a .m extension) must be defined and must be of a specific form that depends on the wavelet type. The specific file formats are described in the remainder of this section.

If a family contains a single wavelet, then a MAT-file can be defined for wavelets of type 1. It must have the wavelet family short name (fsn) argument as its name and must contain a single variable whose name is fsn and whose value is the scaling filter. An code file can also be defined as discussed below.

Type 1 (Orthogonal with FIR Filter).  The syntax of the first line in the MATLAB function is

function w = file(wname)

where the input argument wname is a string containing the wavelet name, and the output argument w is the corresponding scaling filter.

The filter w must be of even length. If the scaling filter is not of even length, the filter is zero-padded by the toolbox.

For predefined wavelets, the sum of the scaling filter coefficients is 1. This follows the convention followed by Daubechies.

When you access these coefficients using wfilters, the coefficients are scaled by the square root of 2.

The toolbox normalizes your filter so that the resulting sum is 1.

Examples of such files for predefined wavelets are dbwavf.m for Daubechies, coifwavf.m for coiflets, and symwavf.m for symlets.

Type 2 (Biorthogonal with FIR Filter).  The syntax of the first line in the MATLAB function is

function [wr,wd] = file(wname)

where the input argument wname is a string containing the wavelet name and the output arguments wr and wd are the corresponding reconstruction and decomposition scaling filters, respectively.

The filters wr and wd must be of the same even length. In general, initial biorthogonal filters do not meet these requirements, so they are zero-padded by the toolbox.

For predefined wavelets, the sum of the scaling filter coefficients is 1. This follows the convention followed by Daubechies.

When you access these coefficients using wfilters, the coefficients are scaled by the square root of 2.

The toolbox normalizes your filter so that the resulting sum is 1.

The file biorwavf.m (for BiorSplines) is an example of a file for a type 2 predefined wavelet family.

Type 3 (Orthogonal with Scale Function).  The syntax of the first line in the MATLAB function is

function [phi,psi,t] = file(lb,ub,n,wname)

which returns values of the scaling function phi and the wavelet function psi on t, a linearly-spaced n-point grid of the interval [lb ub].

The argument wname is optional (see Note below).

The file meyer.m is an example of a file for a type 3 predefined wavelet family.

Type 4 or Type 5 (No FIR Filter; No Scale Function).  The syntax of the first line in the MATLAB function is

function [psi,t] = file(lb,ub,n,wname)

or

function [psi,t] = file(lb,ub,n,wname, additional arguments)

which returns values of the wavelet function psi ont a linearly-spaced n-point grid of the interval [lb ub].

The argument wname is optional (see Note below).

Examples of type 4 files for predefined wavelet families are mexihat.m (for Mexican_hat) and morlet.m (for Morlet).

Examples of type 5 files for predefined wavelet families are shanwavf.m (for Shannon) and cmorwavf.m (for Complex Morlet).

Define the Effective Support

This definition is required only for wavelets of types 3, 4, and 5, since they are not compactly supported.

Defining the effective support means specifying an upper and lower bound. The following table includes the lower and upper bounds for a few of the toolbox wavelets.

Family

Lower Bound (lb)

Upper Bound (ub)

Meyer

–8

8

Mexican_hat

–5

5

Morlet

–4

4

Adding a New Wavelet Family

To add a new wavelet, usewavemngr in one of two forms:

wavemngr('add',fn,fsn,wt,nums,file) 

or

wavemngr('add',fn,fsn,wt,nums,file,b).

Here are a few examples to illustrate how you would use wavemngr to add some of the predefined wavelet families. New wavelet family names and short names are used for illustration purposes.

Type 1 wavelet — Add wavelets ndb1,ndb2,ndb3,ndb4,ndb5.

wavemngr('add','Ndaubechies','ndb',1,'1 2 3 4 5','dbwavf'); 

Type 1 wavelet — Add wavelets ndaub1,ndaub2,.... dbwavf calls dbaux to compute the Daubechies extremal phase wavelets with more than 10 vanishing moments. The computation in dbaux becomes unstable when the number of vanishing moments becomes large. Therefore dbaux errors when you specify the number of vanishing moments greater than 45.

wavemngr('add','Ndaubwav','ndaub',1,'1 2 3 4 5 **','dbwavf'); 

Type 2 wavelet — Add wavelets nbio1.1, nbio1.3.

wavemngr('add','Nbiorwavf','nbio',2,'1.1 1.3','biorwavf');

Type 3 wavelet — Add the wavelet Nmeyer with effective support [-8,8].

wavemngr('add','Nmeyer','nmey',3,'','meyer',[-8,8]);

Type 4 wavelet — Add the wavelet Nmorlet with effective support [-4,4].

wavemngr('add','Nmorlet','nmor',4,'','morlet',[-4,4]);

You can delete the wavelets you have created with wavemngr('del',familyShortName). For example:

wavemngr('del','nmey');

Example 1

Let us take the example of Binlets proposed by Strang and Nguyen in pages 216-217 of the book Wavelets and Filter Banks (see [StrN96] in References).

The full family name is Binlets.

The short name of the wavelet family is binl.

The wavelet type is 2 (Biorthogonal with FIR filters).

The order of the wavelet within the family is 7.9 (we just use one in this example).

The file used to generate the filters is binlwavf.m

Then to add the new wavelet, type

% Add new family of biorthogonal wavelets. 
     wavemngr('add','Binlets','binl',2,'7.9','binlwavf')

% List wavelets families.
     wavemngr('read')

ans =

=================================== 
Haar                haar           
Daubechies          db             
Symlets             sym            
Coiflets            coif           
BiorSplines         bior           
ReverseBior         rbio           
Meyer               meyr           
DMeyer              dmey           
Gaussian            gaus           
Mexican_hat         mexh           
Morlet              morl           
Complex Gaussian    cgau           
Shannon             shan           
Frequency B-Spline  fbsp           
Complex Morlet      cmor 
Binlets             binl 
===================================

If you want to get online information on this new family, you can build an associated help file which would look like the following:

function binlinfo
%BINLINFO Information on biorthogonal wavelets (binlets).
%
%   Biorthogonal Wavelets (Binlets)
%
%   Family                  Binlets
%   Short name              binl
%   Order Nr,Nd             Nr = 7 , Nd = 9
%
%   Orthogonal              no
%   Biorthogonal            yes
%   Compact support         yes
%   DWT                     possible
%   CWT                     possible
%
%   binl Nr.Nd              ld                      lr      
%                      effective length        effective length
%                        of LoF_D                of HiF_D
%   binl 7.9                 7                       9

The associated file to generate the filters (binlwavf.m) is

function [Rf,Df] = binlwavf(wname)
%BINLWAVF Biorthogonal wavelet filters (Binlets).
%   [RF,DF] = BINLWAVF(W) returns two scaling filters
%   associated with the biorthogonal wavelet specified
%   by the string W.
%   W = 'binlNr.Nd' where possible values for Nr and Nd are:
               Nr = 7  Nd = 9
%   The output arguments are filters:
%           RF is the reconstruction filter
%           DF is the decomposition filter

% Check arguments.
if errargn('binlwavf',nargin,[0 1],nargout,[0:2]), error('*'); 
end
% suppress the following line for extension
Nr = 7; Nd = 9;

% for possible extension
% more wavelets in 'Binlets' family
%----------------------------------
if nargin==0
    Nr = 7; Nd = 9;
elseif  isempty(wname)
    Nr = 7; Nd = 9;
else
    if ischar(wname)
        lw = length(wname);
        ab = abs(wname);
        ind = find(ab==46 | 47<ab | ab<58);
        li = length(ind);
        err = 0;
        if      li==0
            err = 1;
        elseif  ind(1)~=ind(li)-li+1
            err = 1;
        end 
        if err==0 , 
            wname = str2num(wname(ind));
            if isempty(wname) , err = 1; end
        end
    end     
    if err==0
        Nr = fix(wname); Nd = 10*(wname-Nr);
    else
        Nr = 0; Nd = 0;
    end
end

% suppress the following lines for extension
% and add a test for errors.
%-------------------------------------------
if Nr~=7 , Nr = 7; end
if Nd~=9 , Nd = 9; end

if Nr == 7
   if Nd == 9
      Rf = [-1 0 9 16 9 0 -1]/32;
      Df = [ 1 0 -8 16 46 16 -8 0 1]/64;
   end
end

Example 2

In the following example, new compactly supported orthogonal wavelets are added to the toolbox. These wavelets, which are a slight generalization of the Daubechies wavelets, are based on the use of Bernstein polynomials and are due to Kateb and Lemarié in an unpublished work.

% List initial wavelets families. 
    wavemngr('read')
ans =
=================================== 
Haar                haar           
Daubechies          db             
Symlets             sym            
Coiflets            coif           
BiorSplines         bior           
ReverseBior         rbio           
Meyer               meyr           
DMeyer              dmey           
Gaussian            gaus           
Mexican_hat         mexh           
Morlet              morl           
Complex Gaussian    cgau           
Shannon             shan           
Frequency B-Spline  fbsp           
Complex Morlet      cmor 
===================================
% List all wavelets. 
    wavemngr('read',1)

ans =

===================================         
Haar                haar                    
===================================         
Daubechies          db                      
------------------------------              
db1  db2   db3  db4
db5  db6   db7  db8
db9  db10  db** 
===================================         
Symlets             sym                     
------------------------------              
sym2  sym3  sym4  sym5 
sym6  sym7  sym8  sym** 
===================================         
Coiflets            coif                    
------------------------------              
coif1  coif2  coif3  coif4
coif5 
===================================         
BiorSplines         bior                    
------------------------------              
bior1.1  bior1.3  bior1.5  bior2.2 
bior2.4  bior2.6  bior2.8  bior3.1 
bior3.3  bior3.5  bior3.7  bior3.9 
bior4.4  bior5.5  bior6.8 
===================================         
ReverseBior         rbio                    
------------------------------              
rbio1.1  rbio1.3  rbio1.5  rbio2.2 
rbio2.4  rbio2.6  rbio2.8  rbio3.1 
rbio3.3  rbio3.5  rbio3.7  rbio3.9 
rbio4.4  rbio5.5  rbio6.8 
===================================         
Meyer               meyr                    
===================================         
DMeyer              dmey                    
===================================         
Gaussian            gaus                    
------------------------------              
gaus1  gaus2  gaus3  gaus4 
gaus5  gaus6  gaus7  gaus8 
gaus** 
===================================         
Mexican_hat         mexh                    
===================================         
Morlet              morl                    
===================================         
Complex Gaussian    cgau                    
------------------------------              
cgau1  cgau2  cgau3  cgau4 
cgau5  cgau** 
===================================         
Shannon             shan                    
------------------------------              
shan1-1.5  shan1-1  shan1-0.5  shan1-0.1 
shan2-3  shan** 
===================================         
Frequency B-Spline  fbsp                    
------------------------------              
fbsp1-1-1.5  fbsp1-1-1    fbsp1-1-0.5  fbsp2-1-1
fbsp2-1-0.5  fbsp2-1-0.1  fbsp**	             
===================================         
Complex Morlet      cmor                    
------------------------------              
cmor1-1.5  cmor1-1    cmor1-0.5  cmor1-1
cmor1-0.5  cmor1-0.1  cmor** 
=================================== 
% Add new family of orthogonal wavelets. 
% You must define: 
% 
%     Family Name:          Lemarie 
%     Family Short Name:    lem 
%     Type of wavelet:      1 (orth) 
%     Wavelets numbers:     1 2 3 4 5 
%     File driver:          lemwavf 
% 
%     The function lemwavf.m must be as follow: 
%     function w = lemwavf(wname) 
%     where the input argument wname is a string: 
%     wname = 'lem1' or 'lem2' ... i.e., 
%     wname = sh.name + number 
%     and w the corresponding scaling filter. 
%     The addition is obtained using:
wavemngr('add','Lemarie','lem',1,'1 2 3 4 5','lemwavf'); 

% The ascii file 'wavelets.asc' is saved as 
% 'wavelets.prv', then it is modified and 
% the MAT file 'wavelets.inf' is generated.

% List wavelets families.
    wavemngr('read')

ans =
=================================== 
Haar                haar           
Daubechies          db             
Symlets             sym            
Coiflets            coif           
BiorSplines         bior           
ReverseBior         rbio           
Meyer               meyr           
DMeyer              dmey           
Gaussian            gaus           
Mexican_hat         mexh           
Morlet              morl           
Complex Gaussian    cgau           
Shannon             shan           
Frequency B-Spline  fbsp           
Complex Morlet      cmor 
Lemarie             lem 
===================================

After Adding a New Wavelet Family

When you use the wavemngr command to add a new wavelet, the toolbox creates three wavelet extension files in the current folder: the two ASCII files wavelets.asc and wavelets.prv, and the MAT-file wavelets.inf.

If you want to use your own extended wavelet families with the Wavelet Toolbox software, you should

  1. Create a new folder specifically to hold the wavelet extension files.

  2. Move the previously mentioned files into this new folder.

  3. Prepend this folder to the MATLAB folder search path (see the reference entry for the path command).

  4. Use this same folder for subsequent modifications. Allowing many wavelet extension files to proliferate in different folders may lead to unpredictable results.

  5. Define a file called <fsn>info.m (for example, see dbinfo.m or morlinfo.m).

    This file will be associated automatically with the Wavelet Family button in the Wavelet Display option of the graphical tools.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS