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_sngl_inv (c09eb)

Purpose

nag_wav_2d_sngl_inv (c09eb) computes the inverse two-dimensional discrete wavelet transform (DWT) at a single level. The initialization function nag_wav_2d_init (c09ab) must be called first to set up the DWT options.

Syntax

[b, ifail] = c09eb(m, n, ca, ch, cv, cd, icomm)
[b, ifail] = nag_wav_2d_sngl_inv(m, n, ca, ch, cv, cd, icomm)

Description

nag_wav_2d_sngl_inv (c09eb) performs the inverse operation of function nag_wav_2d_sngl_fwd (c09ea). That is, given sets of approximation, horizontal, vertical and diagonal coefficients computed by function nag_wav_2d_sngl_fwd (c09ea) using a DWT as set up by the initialization function nag_wav_2d_init (c09ab), on a real matrix, BB, nag_wav_2d_sngl_inv (c09eb) will reconstruct BB.

References

None.

Parameters

Compulsory Input Parameters

1:     m – int64int32nag_int scalar
Number of rows, mm, of data matrix BB.
Constraint: this must be the same as the value m passed to the initialization function nag_wav_2d_init (c09ab).
2:     n – int64int32nag_int scalar
Number of columns, nn, of data matrix BB.
Constraint: this must be the same as the value n passed to the initialization function nag_wav_2d_init (c09ab).
3:     ca(ldca, : :) – double array
The first dimension of the array ca must be at least ncmncm where ncm = nct / (4ncn)ncm=nct/(4ncn) and ncnncn, nctnct are returned by the initialization function nag_wav_2d_init (c09ab)
The second dimension of the array must be at least ncnncn where ncnncn is the parameter nwcn returned by function nag_wav_2d_init (c09ab)
Contains the ncmncm by ncnncn matrix of approximation coefficients, CaCa. This array will normally be the result of some transformation on the coefficients computed by function nag_wav_2d_sngl_fwd (c09ea).
4:     ch(ldch, : :) – double array
The first dimension of the array ch must be at least ncmncm where ncm = nct / (4ncn)ncm=nct/(4ncn) and ncnncn, nctnct are returned by the initialization function nag_wav_2d_init (c09ab)
The second dimension of the array must be at least ncnncn where ncnncn is the parameter nwcn returned by function nag_wav_2d_init (c09ab)
Contains the ncmncm by ncnncn matrix of horizontal coefficients, ChCh. This array will normally be the result of some transformation on the coefficients computed by function nag_wav_2d_sngl_fwd (c09ea).
5:     cv(ldcv, : :) – double array
The first dimension of the array cv must be at least ncmncm where ncm = nct / (4ncn)ncm=nct/(4ncn) and ncnncn, nctnct are returned by the initialization function nag_wav_2d_init (c09ab)
The second dimension of the array must be at least ncnncn where ncnncn is the parameter nwcn returned by function nag_wav_2d_init (c09ab)
Contains the ncmncm by ncnncn matrix of vertical coefficients, CvCv. This array will normally be the result of some transformation on the coefficients computed by function nag_wav_2d_sngl_fwd (c09ea).
6:     cd(ldcd, : :) – double array
The first dimension of the array cd must be at least ncmncm where ncm = nct / (4ncn)ncm=nct/(4ncn) and ncnncn, nctnct are returned by the initialization function nag_wav_2d_init (c09ab)
The second dimension of the array must be at least ncnncn where ncnncn is the parameter nwcn returned by function nag_wav_2d_init (c09ab)
Contains the ncmncm by ncnncn matrix of diagonal coefficients, CdCd. This array will normally be the result of some transformation on the coefficients computed by function nag_wav_2d_sngl_fwd (c09ea).
7:     icomm(180180) – int64int32nag_int array
Contains details of the discrete wavelet transform and the problem dimension as setup in the call to the initialization function nag_wav_2d_init (c09ab).

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

ldca ldch ldcv ldcd ldb

Output Parameters

1:     b(ldb,n) – double array
ldbmldbm.
The mm by nn reconstructed matrix, BB, based on the input approximation, horizontal, vertical and diagonal coefficients and the transform options supplied to the initialization function nag_wav_2d_init (c09ab).
2:     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
ldca is too small, the number of wavelet coefficients in the first dimension.
ldcd is too small, the number of wavelet coefficients in the first dimension.
ldch is too small, the number of wavelet coefficients in the first dimension.
ldcv is too small, the number of wavelet coefficients in the first dimension.
  ifail = 2ifail=2
Constraint: ldbmldbm.
  ifail = 4ifail=4
Constraint: m = mm=m, the value of m on initialization (see nag_wav_2d_init (c09ab)).
Constraint: n = nn=n, the value of n on initialization (see nag_wav_2d_init (c09ab)).
  ifail = 6ifail=6
Either the initialization function has not been called first or icomm has been corrupted.
Either the initialization function was called with wtrans = 'M'wtrans='M' or icomm has been corrupted.
  ifail = 999ifail=-999
Dynamic memory allocation failed.

Accuracy

The accuracy of the wavelet transform depends only on the floating point operations used in the convolution and downsampling and should thus be close to machine precision.

Further Comments

None.

Example

function nag_wav_2d_sngl_inv_example
m = int64(6);
n = int64(6);
wavnam = 'DB4';
mode = 'Half';
wtrans = 'Single level';
a = [8, 7, 3, 3, 1, 1;
     4, 6, 1, 5, 2, 9;
     8, 1, 4, 9, 3, 7;
     9, 3, 8, 2, 4, 3;
     1, 3, 7, 1, 5, 2;
     4, 3, 7, 7, 6, 1];






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

nwcm = double(nwct)/(4*double(nwcn));

% Perform Discrete Wavelet transform
[ca, ch, cv, cd, ifail] = nag_wav_2d_sngl_fwd(a, icomm);

fprintf('Approximation coefficients    CA:\n');
disp(ca);
fprintf('Diagonal coefficients         CD:\n');
disp(cd);
fprintf('Horizontal coefficients       CH:\n');
disp(ch);
fprintf('Vertical coefficients         CV:\n');
disp(cv);

% Reconstruct original data
[b, ifail] = nag_wav_2d_sngl_inv(m, n, ca, ch, cv, cd, icomm);
fprintf('Reconstruction       b:\n');
disp(b);
 

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

Approximation coefficients    CA:
    6.3591   10.3477    8.0995   10.3210    8.7587    3.5783
   11.5754    6.3762   12.1704    7.4521    8.6977   14.8535
    2.0630    8.4499   15.4726   12.1764    3.8920    2.7112
   10.2143    6.2445   13.8571    8.1060    7.7701   13.2127
    6.3353    8.7805   10.2727   10.0472    6.8614    7.5814
   11.7141   11.1018    5.2923    8.1272   14.5540    2.5729

Diagonal coefficients         CD:
    0.4777    1.0230   -0.3147    0.0625    0.0831   -1.3316
    1.0689    1.5671   -2.1422    0.5565    1.7593   -2.8097
   -0.9555   -1.9276    0.9195   -0.2228   -0.5125    2.6989
    0.2899    0.4453   -0.5695    0.1541    0.4749   -0.7946
    0.4944    1.4145    0.3488   -0.1187   -0.6212   -1.5177
   -1.3753   -2.5224    1.7581   -0.4316   -1.1835    3.7547

Horizontal coefficients       CH:
    0.4100   -0.1827    1.5354    0.0784    0.8101   -1.3594
    2.3496   -0.9422    2.3780   -1.0540    2.7743   -2.2648
   -1.2690    0.0152   -6.9338   -1.7435   -1.6917    1.2388
    0.6317   -0.0969    2.3300    0.4637    0.6365   -0.1162
   -0.2343    0.3923    5.5457    2.1818    0.2103   -0.8573
   -1.8880    0.8142   -4.8552    0.0736   -2.7395    3.3590

Vertical coefficients         CV:
    1.5365    5.9678    3.4309   -1.0585   -5.0275   -4.8492
    0.6779   -0.0294   -5.3274    1.6483    4.8689   -1.8383
   -1.1065   -2.8791    0.1535    0.0982    0.8417    2.8923
   -0.1359   -2.6633   -5.8549    1.8440    6.2403    0.5697
    1.4244    5.2140    1.6410   -0.4669   -3.2369   -4.5757
    1.0288    2.2521    0.0574   -0.1359   -0.5170   -2.6854

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


function c09eb_example
m = int64(6);
n = int64(6);
wavnam = 'DB4';
mode = 'Half';
wtrans = 'Single level';
a = [8, 7, 3, 3, 1, 1;
     4, 6, 1, 5, 2, 9;
     8, 1, 4, 9, 3, 7;
     9, 3, 8, 2, 4, 3;
     1, 3, 7, 1, 5, 2;
     4, 3, 7, 7, 6, 1];






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

nwcm = double(nwct)/(4*double(nwcn));

% Perform Discrete Wavelet transform
[ca, ch, cv, cd, ifail] = c09ea(a, icomm);

fprintf('Approximation coefficients    CA:\n');
disp(ca);
fprintf('Diagonal coefficients         CD:\n');
disp(cd);
fprintf('Horizontal coefficients       CH:\n');
disp(ch);
fprintf('Vertical coefficients         CV:\n');
disp(cv);

% Reconstruct original data
[b, ifail] = c09eb(m, n, ca, ch, cv, cd, icomm);
fprintf('Reconstruction       b:\n');
disp(b);
 

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

Approximation coefficients    CA:
    6.3591   10.3477    8.0995   10.3210    8.7587    3.5783
   11.5754    6.3762   12.1704    7.4521    8.6977   14.8535
    2.0630    8.4499   15.4726   12.1764    3.8920    2.7112
   10.2143    6.2445   13.8571    8.1060    7.7701   13.2127
    6.3353    8.7805   10.2727   10.0472    6.8614    7.5814
   11.7141   11.1018    5.2923    8.1272   14.5540    2.5729

Diagonal coefficients         CD:
    0.4777    1.0230   -0.3147    0.0625    0.0831   -1.3316
    1.0689    1.5671   -2.1422    0.5565    1.7593   -2.8097
   -0.9555   -1.9276    0.9195   -0.2228   -0.5125    2.6989
    0.2899    0.4453   -0.5695    0.1541    0.4749   -0.7946
    0.4944    1.4145    0.3488   -0.1187   -0.6212   -1.5177
   -1.3753   -2.5224    1.7581   -0.4316   -1.1835    3.7547

Horizontal coefficients       CH:
    0.4100   -0.1827    1.5354    0.0784    0.8101   -1.3594
    2.3496   -0.9422    2.3780   -1.0540    2.7743   -2.2648
   -1.2690    0.0152   -6.9338   -1.7435   -1.6917    1.2388
    0.6317   -0.0969    2.3300    0.4637    0.6365   -0.1162
   -0.2343    0.3923    5.5457    2.1818    0.2103   -0.8573
   -1.8880    0.8142   -4.8552    0.0736   -2.7395    3.3590

Vertical coefficients         CV:
    1.5365    5.9678    3.4309   -1.0585   -5.0275   -4.8492
    0.6779   -0.0294   -5.3274    1.6483    4.8689   -1.8383
   -1.1065   -2.8791    0.1535    0.0982    0.8417    2.8923
   -0.1359   -2.6633   -5.8549    1.8440    6.2403    0.5697
    1.4244    5.2140    1.6410   -0.4669   -3.2369   -4.5757
    1.0288    2.2521    0.0574   -0.1359   -0.5170   -2.6854

Reconstruction       b:
    8.0000    7.0000    3.0000    3.0000    1.0000    1.0000
    4.0000    6.0000    1.0000    5.0000    2.0000    9.0000
    8.0000    1.0000    4.0000    9.0000    3.0000    7.0000
    9.0000    3.0000    8.0000    2.0000    4.0000    3.0000
    1.0000    3.0000    7.0000    1.0000    5.0000    2.0000
    4.0000    3.0000    7.0000    7.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