NAG C Library Function Document

nag_wav_3d_coeff_ins (c09fzc)

1
Purpose

nag_wav_3d_coeff_ins (c09fzc) inserts a selected set of three-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 reconstruction functions nag_idwt_3d (c09fbc) or nag_imldwt_3d (c09fdc).

2
Specification

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

3
Description

nag_wav_3d_coeff_ins (c09fzc) inserts a selected set of three-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_3d_coeff_ins (c09fzc) is preceded by a call to the initialization function nag_wfilt_3d (c09acc) and either the forwards transform function nag_dwt_3d (c09fac) or multi-level forwards transform function nag_mldwt_3d (c09fcc).
Given an initial three-dimensional data set A, a prior call to nag_dwt_3d (c09fac) or nag_mldwt_3d (c09fcc) computes the approximation coefficients (at the highest requested level in the case of nag_mldwt_3d (c09fcc)) and, seven sets of detail coefficients (at all levels in the case of nag_mldwt_3d (c09fcc)) and stores these in compact form in a one-dimensional array c. nag_wav_3d_coeff_ext (c09fyc) can then extract either the approximation coefficients or one of the sets of detail coefficients (at one of the levels following nag_mldwt_3d (c09fcc)) as three-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_3d_coeff_ins (c09fzc). Several extractions and insertions may be performed. nag_idwt_3d (c09fbc) or nag_imldwt_3d (c09fdc) can then be used to reconstruct a manipulated data set A~. The dimensions of the three-dimensional data stored in d depend on the level extracted and are available from either: the arrays dwtlvm, dwtlvn and dwtlvfr as returned by nag_mldwt_3d (c09fcc) if this was called first; or, otherwise from nwct, nwcn and nwcfr as returned by nag_wfilt_3d (c09acc). See Section 2.1 in the c09 Chapter Introduction for a discussion of the three-dimensional DWT.

4
References

None.

5
Arguments

Note: the following notation is used in this section:
1:     ilev IntegerInput
On entry: the level at which coefficients are to be inserted.
If ilev=0, it is assumed that the coefficient array c was produced by a preceding call to the single level function nag_dwt_3d (c09fac).
If ilev>0, it is assumed that the coefficient array c was produced by a preceding call to the multi-level function nag_mldwt_3d (c09fcc).
Constraints:
2:     cindex IntegerInput
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, rows and frames of A (LLL). After a call to the multi-level transform function nag_mldwt_3d (c09fcc) (which implies that ilev>0) the approximation coefficients are present only for ilev=nwl, where nwl is the value used in a preceding call to nag_mldwt_3d (c09fcc).
cindex=1
The detail coefficients produced by applying the low pass filter over columns and rows of A and the high pass filter over frames (LLH).
cindex=2
The detail coefficients produced by applying the low pass filter over columns, high pass filter over rows and low pass filter over frames of A (LHL).
cindex=3
The detail coefficients produced by applying the low pass filter over columns of A and high pass filter over rows and frames (LHH).
cindex=4
The detail coefficients produced by applying the high pass filter over columns of A and low pass filter over rows and frames (HLL).
cindex=5
The detail coefficients produced by applying the high pass filter over columns, low pass filter over rows and high pass filter over frames of A (HLH).
cindex=6
The detail coefficients produced by applying the high pass filter over columns and rows of A and the low pass filter over frames (HHL).
cindex=7
The detail coefficients produced by applying the high pass filter over columns, rows and frames of A (HHH).
Constraints:
  • if ilev=0, 0cindex7;
  • if ilev=nwl, following a call to nag_mldwt_3d (c09fcc) transforming nwl levels, 0cindex7;
  • otherwise 1cindex7.
3:     lenc IntegerInput
On entry: the dimension of the array c.
Constraint: lenc must be unchanged from the value used in the preceding call to either nag_dwt_3d (c09fac) or nag_mldwt_3d (c09fcc)..
4:     c[lenc] doubleInput/Output
On entry: contains the DWT coefficients inserted by previous calls to nag_wav_3d_coeff_ins (c09fzc), or computed by a previous call to either nag_dwt_3d (c09fac) or nag_mldwt_3d (c09fcc).
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 one of the reconstruction functions nag_idwt_3d (c09fbc) (if nag_dwt_3d (c09fac) was called previously) or nag_imldwt_3d (c09fdc) (if nag_mldwt_3d (c09fcc) was called previously).
5:     d[dim] const doubleInput
Note: the dimension, dim, of the array d must be at least ldd×sdd×ncfr.
On entry: the coefficients to be inserted.
If the DWT coefficients were computed by nag_dwt_3d (c09fac) then
  • if cindex=0, the approximation coefficients must be stored in d[k-1×ldd×sdd+j-1×ldd+i-1], for i=1,2,,ncm, j=1,2,,ncn and k=1,2,,ncfr;
  • if 1cindex7, the detail coefficients, as indicated by cindex, must be stored in d[k-1×ldd×sdd+j-1×ldd+i-1], for i=1,2,,ncm, j=1,2,,ncn and k=1,2,,ncfr.
If the DWT coefficients were computed by nag_mldwt_3d (c09fcc) then
  • if cindex=0 and ilev=nwl, the approximation coefficients must be stored in d[k-1×ldd×sdd+j-1×ldd+i-1], for i=1,2,,ncm, j=1,2,,ncn and k=1,2,,ncfr;
  • if 1cindex7, the detail coefficients, as indicated by cindex, for level ilev must be stored in d[k-1×ldd×sdd+j-1×ldd+i-1], for i=1,2,,ncm, j=1,2,,ncn and k=1,2,,ncfr.
6:     ldd IntegerInput
On entry: the stride separating row elements of each of the sets of frame coefficients in the three-dimensional data stored in d.
Constraint: ldd>ncm.
7:     sdd IntegerInput
On entry: the stride separating corresponding coefficients of consecutive frames in the three-dimensional data stored in d.
Constraint: sdd>ncn.
8:     icomm[260] 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_3d (c09acc).
9:     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.
NE_INT
On entry, cindex=value.
Constraint: cindex7.
On entry, cindex=value.
Constraint: cindex0.
On entry, ilev=value.
Constraint: ilev=0 following a call to the single level function nag_dwt_3d (c09fac).
On entry, ilev=value.
Constraint: ilev>0 following a call to the multi-level function nag_mldwt_3d (c09fcc).
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_3d (c09fcc).
On entry, ldd=value and ncm=value.
Constraint: lddncm, where ncm is the number of DWT coefficients in the first dimension following the single level transform.
On entry, lenc=value and nct=value.
Constraint: lencnct, where nct is the number of DWT coefficients computed in a previous call to nag_dwt_3d (c09fac).
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_3d (c09fcc).
On entry, sdd=value and ncn=value.
Constraint: sddncn, where ncn is the number of DWT coefficients in the second dimension following the single level transform.
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_3d (c09fcc).
On entry, ldd=value and ncm=value.
Constraint: lddncm, where ncm is the number of DWT coefficients in the first dimension at the selected level ilev.
On entry, sdd=value and ncn=value.
Constraint: sddncn, where ncn is the number of DWT coefficients in the second dimension at the selected level ilev.
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

Not applicable.

8
Parallelism and Performance

nag_wav_3d_coeff_ins (c09fzc) is not threaded in any implementation.

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 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 (c09fzce.c)

10.2
Program Data

Program Data (c09fzce.d)

10.3
Program Results

Program Results (c09fzce.r)