NAG Library Routine Document

c09fzf  (dim3_coeff_ins)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

c09fzf 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 routines c09fbf or c09fdf.

2
Specification

Fortran Interface
Subroutine c09fzf ( ilev, cindex, lenc, c, d, ldd, sdd, icomm, ifail)
Integer, Intent (In):: ilev, cindex, lenc, ldd, sdd
Integer, Intent (Inout):: icomm(260), ifail
Real (Kind=nag_wp), Intent (In):: d(ldd,sdd,*)
Real (Kind=nag_wp), Intent (Inout):: c(lenc)
C Header Interface
#include nagmk26.h
void  c09fzf_ ( const Integer *ilev, const Integer *cindex, const Integer *lenc, double c[], const double d[], const Integer *ldd, const Integer *sdd, Integer icomm[], Integer *ifail)

3
Description

c09fzf 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 c09fzf is preceded by a call to the initialization routine c09acf and either the forwards transform routine c09faf or multi-level forwards transform routine c09fcf.
Given an initial three-dimensional data set A, a prior call to c09faf or c09fcf computes the approximation coefficients (at the highest requested level in the case of c09fcf) and, seven sets of detail coefficients (at all levels in the case of c09fcf) and stores these in compact form in a one-dimensional array c. c09fyf can then extract either the approximation coefficients or one of the sets of detail coefficients (at one of the levels following c09fcf) into a three-dimensional 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 c09fzf. Several extractions and insertions may be performed. c09fbf or c09fdf can then be used to reconstruct a manipulated data set A~. The dimensions of d depend on the level extracted and are available from either: the arrays dwtlvm, dwtlvn and dwtlvfr as returned by c09fcf if this was called first; or, otherwise from nwct, nwcn and nwcfr as returned by c09acf. 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 routine c09faf.
If ilev>0, it is assumed that the coefficient array c was produced by a preceding call to the multi-level routine c09fcf.
Constraints:
  • ilev=0 (following a call to c09faf);
  • 0ilevnwl, where nwl is as used in a preceding call to c09fcf;
  • if cindex=0, ilev=nwl (following a call to c09fcf).
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 routine c09fcf (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 c09fcf.
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 c09fcf transforming nwl levels, 0cindex7;
  • otherwise 1cindex7.
3:     lenc – IntegerInput
On entry: the dimension of the array c as declared in the (sub)program from which c09fzf is called.
Constraint: lenc must be unchanged from the value used in the preceding call to either c09faf or c09fcf..
4:     clenc – Real (Kind=nag_wp) arrayInput/Output
On entry: contains the DWT coefficients inserted by previous calls to c09fzf, or computed by a previous call to either c09faf or c09fcf.
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 routines c09fbf (if c09faf was called previously) or c09fdf (if c09fcf was called previously).
5:     dlddsdd* – Real (Kind=nag_wp) arrayInput
Note: the last dimension of the array d must be at least ncfr.
On entry: the coefficients to be inserted.
If the DWT coefficients were computed by c09faf then
  • if cindex=0, the approximation coefficients must be stored in dijk, 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 dijk, for i=1,2,,ncm, j=1,2,,ncn and k=1,2,,ncfr.
If the DWT coefficients were computed by c09fcf then
  • if cindex=0 and ilev=nwl, the approximation coefficients must be stored in dijk, 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 dijk, for i=1,2,,ncm, j=1,2,,ncn and k=1,2,,ncfr.
6:     ldd – IntegerInput
On entry: the first dimension of the array d as declared in the (sub)program from which c09fzf is called.
Constraint: ldd>ncm.
7:     sdd – IntegerInput
On entry: the second dimension of the array d as declared in the (sub)program from which c09fzf is called.
Constraint: sdd>ncn.
8:     icomm260 – Integer arrayCommunication Array
On entry: contains details of the discrete wavelet transform and the problem dimension as setup in the call to the initialization routine c09acf.
9:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, ilev=value.
Constraint: ilev=0 following a call to the single level routine c09faf.
On entry, ilev=value.
Constraint: ilev>0 following a call to the multi-level routine c09fcf.
On entry, ilev=value and nwl=value.
Constraint: ilevnwl, where nwl is the number of levels used in the call to c09fcf.
ifail=2
On entry, cindex=value.
Constraint: cindex7.
On entry, cindex=value.
Constraint: cindex0.
ifail=3
On entry, lenc=value and nct=value.
Constraint: lencnct, where nct is the number of DWT coefficients computed in a previous call to c09faf.
On entry, lenc=value and nct=value.
Constraint: lencnct, where nct is the number of DWT coefficients computed in a previous call to c09fcf.
ifail=4
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, 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, sdd=value and ncn=value.
Constraint: sddncn, where ncn is the number of DWT coefficients in the second 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 following the single level transform.
ifail=5
On entry, ilev=value and nwl=value, but cindex=0.
Constraint: cindex>0 when ilev<nwl in the preceding call to c09fcf.
ifail=6
Either the initialization routine has not been called first or icomm has been corrupted.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

Not applicable.

8
Parallelism and Performance

c09fzf is not threaded in any implementation.

9
Further Comments

None.

10
Example

The following example demonstrates using the coefficient extraction and insertion routines 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 (c09fzfe.f90)

10.2
Program Data

Program Data (c09fzfe.d)

10.3
Program Results

Program Results (c09fzfe.r)

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