NAG Library Function Document

nag_dwt_2d (c09eac)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

nag_dwt_2d (c09eac) computes the two-dimensional discrete wavelet transform (DWT) at a single level. The initialization function nag_wfilt_2d (c09abc) must be called first to set up the DWT options.

2
Specification

#include <nag.h>
#include <nagc09.h>
void  nag_dwt_2d (Integer m, Integer n, const double a[], Integer lda, double ca[], Integer ldca, double ch[], Integer ldch, double cv[], Integer ldcv, double cd[], Integer ldcd, Integer icomm[], NagError *fail)

3
Description

nag_dwt_2d (c09eac) computes the two-dimensional DWT of a given input data array, considered as a matrix A, at a single level. For a chosen wavelet filter pair, the output coefficients are obtained by applying convolution and downsampling by two to the input, A, first over columns and then to the result over rows. The matrix of approximation (or smooth) coefficients, Ca, is produced by the low pass filter over columns and rows; the matrix of horizontal coefficients, Ch, is produced by the high pass filter over columns and the low pass filter over rows; the matrix of vertical coefficients, Cv, is produced by the low pass filter over columns and the high pass filter over rows; and the matrix of diagonal coefficients, Cd, is produced by the high pass filter over columns and rows. To reduce distortion effects at the ends of the data array, several end extension methods are commonly used. Those provided are: periodic or circular convolution end extension, half-point symmetric end extension, whole-point symmetric end extension and zero end extension. The total number, nct, of coefficients computed for Ca, Ch, Cv, and Cd together and the number of columns of each coefficients matrix, ncn, are returned by the initialization function nag_wfilt_2d (c09abc). These values can be used to calculate the number of rows of each coefficients matrix, ncm, using the formula ncm=nct/4ncn.

4
References

Daubechies I (1992) Ten Lectures on Wavelets SIAM, Philadelphia

5
Arguments

1:     m IntegerInput
On entry: number of rows, m, of data matrix A.
Constraint: this must be the same as the value m passed to the initialization function nag_wfilt_2d (c09abc).
2:     n IntegerInput
On entry: number of columns, n, of data matrix A.
Constraint: this must be the same as the value n passed to the initialization function nag_wfilt_2d (c09abc).
3:     a[lda×n] const doubleInput
Note: the i,jth element of the matrix A is stored in a[j-1×lda+i-1].
On entry: the m by n data matrix A.
4:     lda IntegerInput
On entry: the stride separating matrix row elements in the array a.
Constraint: ldam.
5:     ca[dim] doubleOutput
Note: the dimension, dim, of the array ca must be at least ldca×ncn where ncn is the argument nwcn returned by function nag_wfilt_2d (c09abc).
The i,jth element of the matrix is stored in ca[j-1×ldca+i-1].
On exit: contains the ncm by ncn matrix of approximation coefficients, Ca.
6:     ldca IntegerInput
On entry: the stride separating matrix row elements in the array ca.
Constraint: ldcancm where ncm=nct/4ncn and ncn, nct are returned by the initialization function nag_wfilt_2d (c09abc).
7:     ch[dim] doubleOutput
Note: the dimension, dim, of the array ch must be at least ldch×ncn where ncn is the argument nwcn returned by function nag_wfilt_2d (c09abc).
The i,jth element of the matrix is stored in ch[j-1×ldch+i-1].
On exit: contains the ncm by ncn matrix of horizontal coefficients, Ch.
8:     ldch IntegerInput
On entry: the stride separating matrix row elements in the array ch.
Constraint: ldchncm where ncm=nct/4ncn and ncn, nct are returned by the initialization function nag_wfilt_2d (c09abc).
9:     cv[dim] doubleOutput
Note: the dimension, dim, of the array cv must be at least ldcv×ncn where ncn is the argument nwcn returned by function nag_wfilt_2d (c09abc).
The i,jth element of the matrix is stored in cv[j-1×ldcv+i-1].
On exit: contains the ncm by ncn matrix of vertical coefficients, Cv.
10:   ldcv IntegerInput
On entry: the stride separating matrix row elements in the array cv.
Constraint: ldcvncm where ncm=nct/4ncn and ncn, nct are returned by the initialization function nag_wfilt_2d (c09abc).
11:   cd[dim] doubleOutput
Note: the dimension, dim, of the array cd must be at least ldcd×ncn where ncn is the argument nwcn returned by function nag_wfilt_2d (c09abc).
The i,jth element of the matrix is stored in cd[j-1×ldcd+i-1].
On exit: contains the ncm by ncn matrix of diagonal coefficients, Cd.
12:   ldcd IntegerInput
On entry: the stride separating matrix row elements in the array cd.
Constraint: ldcdncm where ncm=nct/4ncn and ncn, nct are returned by the initialization function nag_wfilt_2d (c09abc).
13:   icomm[180] IntegerCommunication Array
On entry: contains details of the discrete wavelet transform and the problem dimension as setup in the call to the initialization function nag_wfilt_2d (c09abc).
14:   fail NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

6
Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INITIALIZATION
Either the initialization function has not been called first or icomm has been corrupted.
Either the initialization function was called with wtrans=Nag_MultiLevel or icomm has been corrupted.
NE_INT
On entry, ldca=value.
Constraint: ldcavalue, the number of wavelet coefficients in the first dimension.
On entry, ldcd=value.
Constraint: ldcdvalue, the number of wavelet coefficients in the first dimension.
On entry, ldch=value.
Constraint: ldchvalue, the number of wavelet coefficients in the first dimension.
On entry, ldcv=value.
Constraint: ldcvvalue, the number of wavelet coefficients in the first dimension.
On entry, m=value.
Constraint: m=value, the value of m on initialization (see nag_wfilt_2d (c09abc)).
On entry, n=value.
Constraint: n=value, the value of n on initialization (see nag_wfilt_2d (c09abc)).
NE_INT_2
On entry, lda=value and m=value.
Constraint: ldam.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.

7
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.

8
Parallelism and Performance

nag_dwt_2d (c09eac) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the x06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9
Further Comments

None.

10
Example

This example computes the two-dimensional discrete wavelet decomposition for a 6×6 input matrix using the Daubechies wavelet, wavnam=Nag_Daubechies4, with half point symmetric end extension.

10.1
Program Text

Program Text (c09eace.c)

10.2
Program Data

Program Data (c09eace.d)

10.3
Program Results

Program Results (c09eace.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017