hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_wav_2d_init (c09ab)

Purpose

nag_wav_2d_init (c09ab) returns the details of the chosen two-dimensional discrete wavelet filter. For a chosen mother wavelet, discrete wavelet transform type (single-level or multi-level DWT) and end extension method, this function returns the maximum number of levels of resolution (appropriate to a multi-level transform), the filter length, the total number of approximation, horizontal, vertical and diagonal coefficients and the number of coefficients in the second dimension for the single-level case. This function must be called before any of the two-dimensional transform functions in this chapter.

Syntax

[nwl, nf, nwct, nwcn, icomm, ifail] = c09ab(wavnam, wtrans, mode, m, n)
[nwl, nf, nwct, nwcn, icomm, ifail] = nag_wav_2d_init(wavnam, wtrans, mode, m, n)

Description

Two-dimensional discrete wavelet transforms (DWT) are characterised by the mother wavelet, the end extension method and whether multiresolution analysis is to be performed. For the selected combination of choices for these three characteristics, and for given dimensions (m × nm×n) of data matrix AA, nag_wav_2d_init (c09ab) returns the dimension details for the transform determined by this combination. The dimension details are: lmaxlmax, the maximum number of levels of resolution that would be computed were a multi-level DWT applied; nfnf, the filter length; nctnct the total number of approximation, horizontal, vertical and diagonal coefficients (over all levels in the multi-level DWT case); and ncnncn, the number of coefficients in the second dimension for a single-level DWT. These values are also stored in the communication array icomm, as are the input choices, so that they may be conveniently communicated to the two-dimensional transform functions in this chapter.

References

None.

Parameters

Compulsory Input Parameters

1:     wavnam – string
The name of the mother wavelet. See the C09 Chapter Introduction for details.
wavnam = 'HAAR'wavnam='HAAR'
Haar wavelet.
wavnam = 'DBn'wavnam='DBn', where n = 2,3,,10n=2,3,,10
Daubechies wavelet with nn vanishing moments (2n2n coefficients). For example, wavnam = 'DB4'wavnam='DB4' is the name for the Daubechies wavelet with 44 vanishing moments (88 coefficients).
wavnam = 'BIORxwavnam='BIORx.y'y', where xx.yy can be one of 1.1, 1.3, 1.5, 2.2, 2.4, 2.6, 2.8, 3.1, 3.3, 3.5 or 3.7
Biorthogonal wavelet of order xx.yy. For example wavnam = 'BIOR3.1'wavnam='BIOR3.1' is the name for the biorthogonal wavelet of order 3.13.1.
Constraint: wavnam = 'HAAR'wavnam='HAAR', 'DB2''DB2', 'DB3''DB3', 'DB4''DB4', 'DB5''DB5', 'DB6''DB6', 'DB7''DB7', 'DB8''DB8', 'DB9''DB9', 'DB10''DB10', 'BIOR1.1''BIOR1.1', 'BIOR1.3''BIOR1.3', 'BIOR1.5''BIOR1.5', 'BIOR2.2''BIOR2.2', 'BIOR2.4''BIOR2.4', 'BIOR2.6''BIOR2.6', 'BIOR2.8''BIOR2.8', 'BIOR3.1''BIOR3.1', 'BIOR3.3''BIOR3.3', 'BIOR3.5''BIOR3.5' or 'BIOR3.7''BIOR3.7'.
2:     wtrans – string (length ≥ 1)
The type of discrete wavelet transform that is to be applied.
wtrans = 'S'wtrans='S'
Single-level decomposition or reconstruction by discrete wavelet transform.
wtrans = 'M'wtrans='M'
Multiresolution, by a multi-level DWT or its inverse.
Constraint: wtrans = 'S'wtrans='S' or 'M''M'.
3:     mode – string (length ≥ 1)
The end extension method.
mode = 'P'mode='P'
Periodic end extension.
mode = 'H'mode='H'
Half-point symmetric end extension.
mode = 'W'mode='W'
Whole-point symmetric end extension.
mode = 'Z'mode='Z'
Zero end extension.
Constraint: mode = 'P'mode='P', 'H''H', 'W''W' or 'Z''Z'.
4:     m – int64int32nag_int scalar
The number of elements, mm, in the first dimension (number of rows of data matrix AA) of the input data.
Constraint: m2m2.
5:     n – int64int32nag_int scalar
The number of elements, nn, in the second dimension (number of columns of data matrix AA) of the input data.
Constraint: n2n2.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     nwl – int64int32nag_int scalar
The maximum number of levels of resolution, lmaxlmax, that can be computed if a multi-level discrete wavelet transform is applied (wtrans = 'M'wtrans='M'). It is such that 2lmaxmin (m,n) < 2lmax + 1 2lmaxmin(m,n)<2lmax+1, for lmaxlmax an integer.
If wtrans = 'S'wtrans='S', nwl is not set.
2:     nf – int64int32nag_int scalar
The filter length, nfnf, for the supplied mother wavelet. This is used to determine the number of coefficients to be generated by the chosen transform.
3:     nwct – int64int32nag_int scalar
The total number of wavelet coefficients, nctnct, that will be generated. When wtrans = 'S'wtrans='S' the number of rows required in each of the output coefficient matrices can be calculated as ncm = nct / (4ncn)ncm=nct/(4ncn). When wtrans = 'M'wtrans='M' the length of the array used to store all of the coefficient matrices must be at least nctnct.
4:     nwcn – int64int32nag_int scalar
For a single-level transform (wtrans = 'S'wtrans='S'), the number of coefficients that would be generated in the second dimension, ncnncn, for each coefficient type. For a multi-level transform (wtrans = 'M'wtrans='M') this is set to 11.
5:     icomm(180180) – int64int32nag_int array
Contains details of the wavelet transform and the problem dimension which is to be communicated to the two-dimensional discrete transform functions in this chapter.
6:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry, wavnam had an illegal value.
  ifail = 2ifail=2
On entry, wtrans had an illegal value.
  ifail = 3ifail=3
On entry, mode had an illegal value.
  ifail = 4ifail=4
Constraint: m2m2.
Constraint: n2n2.

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_wav_2d_init_example
m = int64(6);
n = int64(6);
wavnam = 'Haar';
mode = 'Whole';
wtrans = 'Multilevel';
a = [6, 7, 8, 0, 1, 9;
     9, 1, 9, 9, 2, 8;
     3, 0, 4, 1, 3, 1;
     2, 5, 9, 4, 4, 2;
     1, 8, 3, 3, 5, 3;
     8, 1, 6, 4, 6, 1];


fprintf('\nInput data:\n');
disp(a);
[nwl, nf, nwct, nwcn, icomm, ifail] = nag_wav_2d_init(wavnam, wtrans, mode, m, n);

lenc = nwct;
% Perform Discrete Wavelet transform
[c, dwtlvm, dwtlvn, icomm, ifail] = nag_wav_2d_multi_fwd(a, lenc, nwl, icomm);

fprintf('\nLength of wavelet filter : %d\n', nf);
fprintf('Number of Levels :         %d\n', nwl);
fprintf('Number of coefficients in first dimension for each level :\n');
disp(transpose(dwtlvm(1:double(nwl))));
fprintf('Number of coefficients in second dimension for each level :\n');
disp(transpose(dwtlvn(1:double(nwl))));

fprintf('\nTotal number of wavelet coefficients : %d\n', nwct);
fprintf('\nWavelet coefficients c :\n');
for i=0:length(c)/8-1
  fprintf('%8.4f', c(1+8*i:8*(i+1)) );
  fprintf('\n');
end
fprintf('%8.4f', c(8*int32(length(c)/8)+1:length(c)));
fprintf('\n\n');

% Reconstruct original data
[b, ifail] = nag_wav_2d_multi_inv(nwl, c, m, n, icomm);
fprintf('Reconstruction       b:\n');
disp(b);
 

Input data:
     6     7     8     0     1     9
     9     1     9     9     2     8
     3     0     4     1     3     1
     2     5     9     4     4     2
     1     8     3     3     5     3
     8     1     6     4     6     1


Length of wavelet filter : 2
Number of Levels :         2
Number of coefficients in first dimension for each level :
                    2                    3

Number of coefficients in second dimension for each level :
                    2                    3


Total number of wavelet coefficients : 43

Wavelet coefficients c :
 19.2500 15.5000 18.5000 14.7500 -2.7500 -1.5000 -3.5000 -2.2500
  5.2500  1.5000  4.5000  0.7500  1.2500  2.5000  0.5000  1.7500
  3.5000  0.0000  0.0000  4.0000  4.0000  1.0000 -7.0000  2.0000
  3.5000  1.5000 -2.0000  0.0000 -5.0000 -4.0000 -2.0000  0.0000
 -1.0000  0.5000 -4.5000  3.0000 -7.0000  4.0000 -1.0000 -1.0000
 -1.0000  0.0000 -1.5000

Reconstruction       b:
    6.0000    7.0000    8.0000    0.0000    1.0000    9.0000
    9.0000    1.0000    9.0000    9.0000    2.0000    8.0000
    3.0000    0.0000    4.0000    1.0000    3.0000    1.0000
    2.0000    5.0000    9.0000    4.0000    4.0000    2.0000
    1.0000    8.0000    3.0000    3.0000    5.0000    3.0000
    8.0000    1.0000    6.0000    4.0000    6.0000    1.0000


function c09ab_example
m = int64(6);
n = int64(6);
wavnam = 'Haar';
mode = 'Whole';
wtrans = 'Multilevel';
a = [6, 7, 8, 0, 1, 9;
     9, 1, 9, 9, 2, 8;
     3, 0, 4, 1, 3, 1;
     2, 5, 9, 4, 4, 2;
     1, 8, 3, 3, 5, 3;
     8, 1, 6, 4, 6, 1];


fprintf('\nInput data:\n');
disp(a);
[nwl, nf, nwct, nwcn, icomm, ifail] = c09ab(wavnam, wtrans, mode, m, n);

lenc = nwct;
% Perform Discrete Wavelet transform
[c, dwtlvm, dwtlvn, icomm, ifail] = c09ec(a, lenc, nwl, icomm);

fprintf('\nLength of wavelet filter : %d\n', nf);
fprintf('Number of Levels :         %d\n', nwl);
fprintf('Number of coefficients in first dimension for each level :\n');
disp(transpose(dwtlvm(1:double(nwl))));
fprintf('Number of coefficients in second dimension for each level :\n');
disp(transpose(dwtlvn(1:double(nwl))));

fprintf('\nTotal number of wavelet coefficients : %d\n', nwct);
fprintf('\nWavelet coefficients c :\n');
for i=0:length(c)/8-1
  fprintf('%8.4f', c(1+8*i:8*(i+1)) );
  fprintf('\n');
end
fprintf('%8.4f', c(8*int32(length(c)/8)+1:length(c)));
fprintf('\n\n');

% Reconstruct original data
[b, ifail] = c09ed(nwl, c, m, n, icomm);
fprintf('Reconstruction       b:\n');
disp(b);
 

Input data:
     6     7     8     0     1     9
     9     1     9     9     2     8
     3     0     4     1     3     1
     2     5     9     4     4     2
     1     8     3     3     5     3
     8     1     6     4     6     1


Length of wavelet filter : 2
Number of Levels :         2
Number of coefficients in first dimension for each level :
                    2                    3

Number of coefficients in second dimension for each level :
                    2                    3


Total number of wavelet coefficients : 43

Wavelet coefficients c :
 19.2500 15.5000 18.5000 14.7500 -2.7500 -1.5000 -3.5000 -2.2500
  5.2500  1.5000  4.5000  0.7500  1.2500  2.5000  0.5000  1.7500
  3.5000  0.0000  0.0000  4.0000  4.0000  1.0000 -7.0000  2.0000
  3.5000  1.5000 -2.0000  0.0000 -5.0000 -4.0000 -2.0000  0.0000
 -1.0000  0.5000 -4.5000  3.0000 -7.0000  4.0000 -1.0000 -1.0000
 -1.0000  0.0000 -1.5000

Reconstruction       b:
    6.0000    7.0000    8.0000    0.0000    1.0000    9.0000
    9.0000    1.0000    9.0000    9.0000    2.0000    8.0000
    3.0000    0.0000    4.0000    1.0000    3.0000    1.0000
    2.0000    5.0000    9.0000    4.0000    4.0000    2.0000
    1.0000    8.0000    3.0000    3.0000    5.0000    3.0000
    8.0000    1.0000    6.0000    4.0000    6.0000    1.0000



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013