nag_wav_2d_coeff_ins (c09ezc) (PDF version)
c09 Chapter Contents
c09 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_wav_2d_coeff_ins (c09ezc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_wav_2d_coeff_ins (c09ezc) inserts a selected set of two-dimensional discrete wavelet transform (DWT) coefficients into the full set of coefficients stored in compact form, which may be later used as input to the multi-level reconstruction function nag_imldwt_2d (c09edc).

2  Specification

#include <nag.h>
#include <nagc09.h>
void  nag_wav_2d_coeff_ins (Integer ilev, Integer cindex, Integer lenc, double c[], const double d[], Integer pdd, Integer icomm[], NagError *fail)

3  Description

nag_wav_2d_coeff_ins (c09ezc) inserts a selected set of two-dimensional DWT coefficients into the full set of coefficients stored in compact form in a one-dimensional array c. It is required that nag_wav_2d_coeff_ins (c09ezc) is preceded by a call to the initialization function nag_wfilt_2d (c09abc) and the forward multi-level transform function nag_mldwt_2d (c09ecc).
Given an initial two-dimensional data set A, a prior call to nag_mldwt_2d (c09ecc) computes the approximation coefficients (at the highest requested level) and three sets of detail coeficients at all levels and stores these in compact form in a one-dimensional array c. nag_wav_2d_coeff_ext (c09eyc) can then extract either the approximation coefficients or one of the sets of detail coefficients at one of the levels as two-dimensional data into the array, d. Following some calculation on this set of coefficients (for example, denoising), the updated coefficients in d are inserted back into the full set c using nag_wav_2d_coeff_ins (c09ezc). Several extractions and insertions may be performed at different levels. nag_imldwt_2d (c09edc) can then be used to reconstruct a manipulated data set A~. The dimensions of the two-dimensional data stored in d depend on the level extracted and are available from the arrays dwtlvm and dwtlvn as returned by nag_mldwt_2d (c09ecc) which contain the first and second dimensions respectively. See Section 2.1 in the c09 Chapter Introduction for a discussion of the multi-level two-dimensional DWT.

4  References

None.

5  Arguments

Note: the following notation is used in this section:
1:     ilevIntegerInput
On entry: the level at which coefficients are to be inserted.
Constraints:
2:     cindexIntegerInput
On entry: identifies which coefficients to insert. The coefficients are identified as follows:
cindex=0
The approximation coefficients, produced by application of the low pass filter over columns and rows of the original matrix (LL). The approximation coefficients are present only for ilev=nwl, where nwl is the value used in a preceding call to nag_mldwt_2d (c09ecc).
cindex=1
The vertical detail coefficients produced by applying the low pass filter over columns of the original matrix and the high pass filter over rows (LH).
cindex=2
The horizontal detail coefficients produced by applying the high pass filter over columns of the original matrix and the low pass filter over rows (HL).
cindex=3
The diagonal detail coefficients produced by applying the high pass filter over columns and rows of the original matrix (HH).
Constraint: 0cindex3 when ilev=nwl as used in nag_mldwt_2d (c09ecc), otherwise 1cindex3.
3:     lencIntegerInput
On entry: the dimension of the array c.
Constraint: lenc must be unchanged from the value used in the preceding call to nag_mldwt_2d (c09ecc)..
4:     c[lenc]doubleInput/Output
On entry: contains the DWT coefficients inserted by previous calls to nag_wav_2d_coeff_ins (c09ezc), or computed by a previous call to nag_mldwt_2d (c09ecc).
On exit: contains the same DWT coefficients provided on entry except for those identified by ilev and cindex, which are updated with the values supplied in d, inserted into the correct locations as expected by the reconstruction function nag_imldwt_2d (c09edc).
5:     d[dim]const doubleInput
Note: the dimension, dim, of the array d must be at least pdd×ncn.
On entry: the coefficients to be inserted.
If ilev=nwl (as used in nag_mldwt_2d (c09ecc)) and cindex=0, the ncm  by ncn  manipulated approximation coefficients aij  must be stored in d[j-1×pdd+i-1], for i=1,2,,ncm and i=1,2,,ncn.
Otherwise the ncm  by ncn  manipulated level ilev detail coefficients (of type specified by cindex) dij  must be stored in d[j-1×pdd+i-1] , for i=1,2,,ncm and j=1,2,,ncn.
6:     pddIntegerInput
On entry: the stride separating row elements in the two-dimensional data stored in the array d.
Constraint: pdd>ncm.
7:     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).
8:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
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_SingleLevel or icomm has been corrupted.
NE_INT
On entry, cindex=value.
Constraint: cindex3.
On entry, cindex=value.
Constraint: cindex0.
On entry, ilev=value.
Constraint: ilev1.
NE_INT_2
On entry, ilev=value and nwl=value.
Constraint: ilevnwl, where nwl is the number of levels used in the call to nag_mldwt_2d (c09ecc).
On entry, lenc=value and nct=value.
Constraint: lencnct, where nct is the number of DWT coefficients computed in a previous call to nag_mldwt_2d (c09ecc).
On entry, pdd=value and ncm=value.
Constraint: pddncm, where ncm is the number of DWT coefficients in the first dimension at the selected level ilev.
NE_INT_3
On entry, ilev=value and nwl=value, but cindex=0.
Constraint: cindex>0 when ilev<nwl in the preceding call to nag_mldwt_2d (c09ecc).
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.

7  Accuracy

Not applicable.

8  Parallelism and Performance

Not applicable.

9  Further Comments

None.

10  Example

The following example demonstrates using the coefficient extraction and insertion functions in order to apply denoising using a thresholding operation. The original input data, which is horizontally striped, has artificial noise introduced to it, taken from a normal random number distribution. Reconstruction then takes place on both the noisy data and denoised data. The Mean Square Errors (MSE) of the two reconstructions are printed along with the reconstruction of the denoised data. The MSE of the denoised reconstruction is less than that of the noisy reconstruction.

10.1  Program Text

Program Text (c09ezce.c)

10.2  Program Data

Program Data (c09ezce.d)

10.3  Program Results

Program Results (c09ezce.r)


nag_wav_2d_coeff_ins (c09ezc) (PDF version)
c09 Chapter Contents
c09 Chapter Introduction
NAG Library Manual

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