wavemngr

Wavelet manager

Description

Use wavemngr to add, delete, restore, or read wavelets.

example

wavemngr('add',FN,FSN,WT,NUMS,FILE) adds a wavelet family to the toolbox. These parameters define the wavelet family:

  • FN — Family name

  • FSN — Family short name

  • WT — Wavelet family type

  • NUMS — Wavelet parameters

  • FILE — Wavelet definition file

Note

When you use wavemngr to add a wavelet family, three wavelet extension files are created in the current folder: the two ASCII files wavelets.asc and wavelets.prv, and the MAT-file wavelets.inf. If you add a new wavelet family, it is available in this folder only.

wavemngr('add',FN,FSN,WT,{NUMS,TYPNUMS},FILE) adds a wavelet family with parameter NUMS with input format type TYPNUMS.

wavemngr(___,B) adds a wavelet family, where B specifies the effective support for the wavelets. The B input argument is valid only for wavelets of type WT = 3, 4, and 5. You can use this syntax with any of the previous syntaxes.

example

wavemngr('del',WN) deletes the wavelet family specified by WN.

example

wavemngr('restore') restores the previous wavelets.asc ASCII file

wavemngr('restore',IN2) restores the initial wavelets.asc ASCII file. Here IN2 is a dummy argument.

out = wavemngr('read') returns all wavelet family names in a character array.

out = wavemngr('read',IN2) returns all wavelet names in a character array. Here IN2 is a dummy argument.

out = wavemngr('read_asc') reads the wavelets.asc ASCII file and returns all wavelet information.

Examples

collapse all

List the wavelet families available by default.

wavemngr('read')
ans = 18x35 char array
    '==================================='
    '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           '
    'Fejer-Korovkin    ->->fk             '
    '==================================='

List all wavelets.

wavemngr('read',1)
ans = 71x44 char array
    '===================================         '
    '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->                    '
    '===================================         '
    'Mexican_hat       ->->mexh                    '
    '===================================         '
    'Morlet            ->->morl                    '
    '===================================         '
    'Complex Gaussian  ->->cgau                    '
    '------------------------------              '
    'cgau1->cgau2->cgau3->cgau4->                    '
    'cgau5->cgau6->cgau7->cgau8->                    '
    '===================================         '
    '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**->                 '
    '===================================         '
    'Fejer-Korovkin    ->->fk                      '
    '------------------------------              '
    'fk4->fk6->fk8->fk14->                           '
    'fk18->fk22->                                  '
    '===================================         '

This example shows how to add new compactly supported orthogonal wavelets 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é.

Add a new family of orthogonal wavelets. You must define:

  • Family Name: Lemarie

  • Family Short Name: lem

  • Type of wavelet: 1 (orth)

  • Wavelet numbers: 1 2 3 4 5

  • File driver: lemwavf

The source code for lemwavf.m is provided at the end of the example. The input argument of lemwavf is a character vector of the form lemN, where N = 1, 2, 3, 4, or 5.

wavemngr('add','Lemarie','lem',1,'1 2 3 4 5','lemwavf')

The ASCII file wavelets.asc is saved as wavelets.prv, then information defining the new family is added to wavelets.asc, and the MAT-file wavelets.inf is generated.

Note that wavemngr works on the current folder. If you add a new wavelet family, it is available in this folder only.

List the available wavelet families. Confirm the new wavelet family is added.

wavemngr('read')
ans = 19x35 char array
    '==================================='
    '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           '
    'Fejer-Korovkin    ->->fk             '
    'Lemarie           ->->lem            '
    '==================================='

Remove the added family. Regenerate the list of wavelet families.

wavemngr('del','Lemarie')
wavemngr('read')
ans = 18x35 char array
    '==================================='
    '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           '
    'Fejer-Korovkin    ->->fk             '
    '==================================='

Restore the previous ASCII file wavelets.prv, then build the MAT-file wavelets.inf. List the restored wavelets. Because wavemngr reads the ASCII file in the current working directory, the new family appears in the list.

wavemngr('restore')
wavemngr('read',1)
ans = 76x44 char array
    '===================================         '
    '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->                    '
    '===================================         '
    'Mexican_hat       ->->mexh                    '
    '===================================         '
    'Morlet            ->->morl                    '
    '===================================         '
    'Complex Gaussian  ->->cgau                    '
    '------------------------------              '
    'cgau1->cgau2->cgau3->cgau4->                    '
    'cgau5->cgau6->cgau7->cgau8->                    '
    '===================================         '
    '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**->                 '
    '===================================         '
    'Fejer-Korovkin    ->->fk                      '
    '------------------------------              '
    'fk4->fk6->fk8->fk14->                           '
    'fk18->fk22->                                  '
    '===================================         '
    'Lemarie           ->->lem                     '
    '------------------------------              '
    'lem1->lem2->lem3->lem4->                        '
    'lem5->                                       '
    '===================================         '

Restore the initial wavelets. Restore the initial ASCII file wavelets.ini and the initial MAT-file wavelets.bin. Regenerate the list of wavelet families. The list does not include the new family.

wavemngr('restore',0)
wavemngr('read')
ans = 18x35 char array
    '==================================='
    '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           '
    'Fejer-Korovkin    ->->fk             '
    '==================================='

All command line capabilities are available for new families of wavelets. Create a new family. Compute the four associated filters and the scale and wavelet functions.

wavemngr('add','Lemarie','lem',1,'1 2 3 4 5','lemwavf');
[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('lem3');
[phi,psi,xval] = wavefun('lem3');
plot(xval,[phi;psi]);
legend('Scaling Function','Wavelet')
grid on

Remove the added family.

wavemngr('del','Lemarie')

lemwavf.m

function F = lemwavf(wname) 
%LEMWAVF Lemarie wavelet filters. 
%   F = LEMWAVF(W) returns the scaling filter associated with the Lemarie
%   wavelet specified by the character array, 'lemN'. 
%   Possible values for N are 1, 2, 3, 4 or 5. 
%
%   This function is only for use in the "Add Wavelet Families" example. It
%   may change or be removed in a future release.
%
%   Copyright 2019 The MathWorks, Inc.
 
TFlem = startsWith(wname,'lem');
if ~TFlem
    error('Wavelet short name is lem followed by filter number');
end
fnum = regexp(wname,'(\d+)','match','Once');

if isempty(fnum) 
    error('Specify a filter number as 1,2,3,4,or 5'); 
end 

if ~isempty(fnum) 
    num = str2double(fnum);
end

tffilt = ismember(num,[1 2 3 4 5]);

if ~tffilt
    error('Filter number must be 1, 2, 3, 4, or 5');
end

 
switch num 
    case 1 
F = [... 
   0.46069299844871  0.53391629051346  0.03930700681965  -0.03391629578182 ... 
]; 
 
    case 2 
F = [... 
   0.31555164655258  0.59149765057882  0.20045477817080  -0.10034811856888 ... 
  -0.01528128420694  0.00846362066021  -0.00072514051618  0.00038684732960 ... 
        ]; 
 
    case 3 
F = [... 
   0.23108942231941  0.56838231367966  0.33173980738190  -0.09447000132310 ... 
  -0.06203683305244  0.02661631105889  -0.00209952890579  0.00001769381066 ... 
   0.00128429679795  -0.00053703458679  0.00002283826072 -0.00000928544107 ... 
        ]; 
 
    case 4 
F = [... 
   0.17565337503255  0.52257484913870  0.42429244721660  -0.04601056550580 ... 
  -0.11292720306517  0.03198741803409  0.00813124691980  -0.00743764392677 ... 
   0.00548090619143 -0.00140066128481  -0.00054200083128   0.00025607264164 ... 
  -0.00008795126642  0.00003025515674  -0.00000082014466  0.00000027569334 ... 
        ]; 
 
    case 5 
F = [... 
   0.13807658847623  0.47310642622099  0.48217097800239  0.02112933622031 ... 
  -0.15081998732499  0.01935767268926  0.02716532750995  -0.01588522540421 ... 
   0.00671209165995  0.00120022744496  -0.00321203819186  0.00115266788547 ... 
  -0.00018266213413  -0.00002953360842  0.00008433396295  -0.00002997969339 ... 
   0.00000534552866  -0.00000159098026  0.00000003069431 -0.00000000895816 ... 
        ]; 
 
end

This example shows how to take analysis and synthesis filters associated with a biorthogonal wavelet and make them compatible with Wavelet Toolbox™. Wavelet Toolbox requires that analysis and synthesis lowpass and highpass filters have equal even length. This example uses the nearly orthogonal biorthogonal wavelets based on the Laplacian pyramid scheme of Burt and Adelson (Table 8.4 on page 283 in [1]). The example also demonstrates how to examine properties of the biorthogonal wavelets.

Define the analysis and synthesis filter coefficients of the biorthogonal wavelet.

Hd = [-1 5 12 5 -1]/20*sqrt(2);
Gd = [3 -15 -73 170 -73 -15 3]/280*sqrt(2);
Hr = [-3 -15 73 170 73 -15 -3]/280*sqrt(2);
Gr = [-1 -5 12 -5 -1]/20*sqrt(2);

Hd and Gd are the lowpass and highpass analysis filters, respectively. Hr and Gr are the lowpass and highpass synthesis filters. They are all finite impulse response (FIR) filters. Confirm the lowpass filter coefficients sum to sqrt(2) and the highpass filter coefficients sum to 0.

sum(Hd)/sqrt(2)
ans = 1.0000
sum(Hr)/sqrt(2)
ans = 1.0000
sum(Gd)
ans = -1.0061e-16
sum(Gr)
ans = -9.7145e-17

The z-transform of an FIR filter h is a Laurent polynomial h(z) given by h(z)=k=kbkehkz-k. The degree |h| of a Laurent polynomial is defined as |h|=ke-kb. Therefore, the length of the filter h is 1+|h|. Examine the Laurent expansion of the scaling and wavelet filters.

PHd = laurpoly(Hd,'dmin',-2)
 
PHd(z) = - 0.07071*z^(+2) + 0.3536*z^(+1) + 0.8485 + 0.3536*z^(-1) - 0.07071*z^(-2)
PHr = laurpoly(Hr,'dmin',-3)
 
PHr(z) = ...                                                                       
    - 0.01515*z^(+3) - 0.07576*z^(+2) + 0.3687*z^(+1) + 0.8586 + 0.3687*z^(-1)  ...
    - 0.07576*z^(-2) - 0.01515*z^(-3)                                              
PGd = laurpoly(Gd,'dmin',-3)
 
PGd(z) = ...                                                                       
    + 0.01515*z^(+3) - 0.07576*z^(+2) - 0.3687*z^(+1) + 0.8586 - 0.3687*z^(-1)  ...
    - 0.07576*z^(-2) + 0.01515*z^(-3)                                              
PGr = laurpoly(Gr,'dmin',-2)
 
PGr(z) = - 0.07071*z^(+2) - 0.3536*z^(+1) + 0.8485 - 0.3536*z^(-1) - 0.07071*z^(-2)

Since the filters are associated with biorthogonal wavelet, confirm PHd(z)PHr(z)+PG(z)PGr(z)=2.

PHd*PHr + PGd*PGr
 
ans(z) = 2

Wavelet Toolbox requires that filters associated with the wavelet have even equal length. To use the Laplacian wavelet filters in the toolbox, you must include the missing powers of the Laurent series as zeros.

The degrees of PHd and PHr are 4 and 6, respectively. The minimum even-length filter that can accommodate the four filters has length 8, which corresponds to a Laurent polynomial of degree 7. The strategy is to prepend and append 0s as evenly as possible so that all filters are of length 8. Prepend 0 to all the filters, and then append two 0s to Hd and Gr.

Hd = [0 Hd 0 0];
Gd = [0 Gd];
Hr = [0 Hr];
Gr = [0 Gr 0 0];

You can examine properties of the biorthogonal wavelets by creating DWT filter banks. Create two custom DWT filter banks using the filters, one for analysis and the other for synthesis. Confirm the filter banks are biorthogonal.

fb = dwtfilterbank('Wavelet','Custom',...
    'CustomScalingFilter',[Hd' Hr'],...
    'CustomWaveletFilter',[Gd' Gr']);

fb2 = dwtfilterbank('Wavelet','Custom',...
    'CustomScalingFilter',[Hd' Hr'],...
    'CustomWaveletFilter',[Gd' Gr'],...
    'FilterType','Synthesis');

fprintf('fb: isOrthogonal = %d\tisBiorthogonal = %d\n',...
    isOrthogonal(fb),isBiorthogonal(fb));
fb: isOrthogonal = 0	isBiorthogonal = 1
fprintf('fb2: isOrthogonal = %d\tisBiorthogonal = %d\n',...
    isOrthogonal(fb2),isBiorthogonal(fb2));
fb2: isOrthogonal = 0	isBiorthogonal = 1

Plot the scaling and wavelet functions associated with the filter banks at the coarsest scale.

[phi,t] = scalingfunctions(fb);
[psi,~] = wavelets(fb);
[phi2,~] = scalingfunctions(fb2);
[psi2,~] = wavelets(fb2);
subplot(2,2,1)
plot(t,phi(end,:))
grid on
title('Scaling Function - Analysis')
subplot(2,2,2)
plot(t,psi(end,:))
grid on
title('Wavelet - Analysis')
subplot(2,2,3)
plot(t,phi2(end,:))
grid on
title('Scaling Function - Synthesis')
subplot(2,2,4)
plot(t,psi2(end,:))
grid on
title('Wavelet - Synthesis')

Compute the filter bank framebounds.

[analysisLowerBound,analysisUpperBound] = framebounds(fb)
analysisLowerBound = 0.9505
analysisUpperBound = 1.0211
[synthesisLowerBound,synthesisUpperBound] = framebounds(fb2)
synthesisLowerBound = 0.9800
synthesisUpperBound = 1.0528

Input Arguments

collapse all

Wavelet family name, specified as a character vector or string scalar.

Wavelet family short name, specified as a character vector or string scalar. The number of characters in FSN must be less than or equal to 4.

Wavelet family type, specified as one of the following:

  • 1 – Orthogonal wavelets

  • 2 – Biorthogonal wavelets

  • 3 – Wavelet with a scaling function

  • 4 – Wavelet without a scaling function

  • 5 – Complex wavelet without a scaling function

Wavelet parameters, specified as:

  • If the family consists of a single wavelet, NUMS is the empty string ''. For example, the mexh and morl families each contain a single wavelet.

  • If the wavelet is member of a finite family of wavelets, NUMS contains a space-separated list of items representing wavelet parameters. For example, for the biorthogonal wavelet family bior, NUMS = '1.1 1.3 1.5 2.2 2.4 2.6 2.8 3.1 3.3 3.5 3.7 3.9 4.4 5.5 6.8'.

  • If the wavelet is member of an infinite family of wavelets, NUMS contains a space-separated list of items representing wavelet parameters, terminated by the special sequence **. Two examples are listed in the following table.

    Wavelet FamilyNUMS
    dbNUMS = '1 2 3 4 5 6 7 8 9 10 **'
    shanNUMS = '1-1.5 1-1 1-0.5 1-0.1 2-3 **'

Wavelet parameter input format, specified as:

  • 'integer' — Use this option when the parameter is an integer. For example, the Daubechies wavelet family db uses an integer parameter.

  • 'real' — Use this option when the parameter is real. For example, the biorthogonal wavelet family bior uses a real parameter.

  • 'charactervector' — Use this option when the parameter is a character vector. For example, the Shannon wavelet family uses a character vector.

Wavelet definition file, specified as a character vector or string scalar. FILE is the name of a MAT-file or a code file name that defines the wavelet family.

Effective support for wavelets with family type WT equal to 3, 4, or 5, specified as a two-element real-valued vector. If B = [lb ub], then lb specifies the lower bound, and ub specifies the upper bound.

Data Types: double

Wavelet family, specified by the character vector or string scalar WN. The value of WN is either the wavelet family name or wavelet family short name.

Example: wavemngr('del','Lemarie')

Limitations

  • wavemngr allows you to add a wavelet. You must verify that it is truly a wavelet. No check is performed to confirm the addition is a wavelet or to confirm the type of the new wavelet. You can use dwtfilterbank to verify if a wavelet is orthogonal or biorthogonal.

References

[1] Daubechies, I. Ten Lectures on Wavelets. CBMS-NSF Regional Conference Series in Applied Mathematics. Philadelphia, PA: Society for Industrial and Applied Mathematics, 1992.

Introduced before R2006a