Chapter I.3. Basic interface

Table of Contents

I.3.1. Usage
I.3.2. Choice of wavelet
I.3.3. Ordering of coefficients
I.3.3.1. KW interlaced ordering
I.3.3.2. Classical ordering

I.3.1. Usage

The basic interface consists of only two functions:

				namespace wavelet_library {
					error_code forward_wavelet_transform(
						unsigned int rank, 
						const size_t* size, 
						double* in, 
						double* out, 
						const char* filter = "coiflet_2", 
						wt_flags flags = WT_DEFAULT, 
						int levels = -1);
					error_code inverse_wavelet_transform(
						unsigned int rank, 
						const size_t* size, 
						double* in, 
						double* out, 
						const char* filter = "coiflet_2", 
						wt_flags flags = WT_DEFAULT, 
						int levels = -1);
				}
				

which are both declared in wavelet_library/basic.hpp. The meaning of the arguments are as follows:

  • rank : number of dimensions in input data
  • size : C-array of size rank specifying the size of the input data
  • in : pointer to input data in row-major ordering
  • out : pointer to output data in row-major ordering
  • filter : C-string giving the name of the wavelet filter (possible choices are listed below)
  • flags : integer constant used to customize the ordering of wavelet coefficients (see below)
  • levels : number of wavelet transform levels to apply

The integer returned by the routines is an error code declared as the typedef spectral::wavelet_library::error_code, which can take the following values:

  • NO_ERROR
  • RANK_NOT_CONFIGURED : the rank passed as first argument has not been configured when compiling KIWIWALI
  • FILTER_NOT_FOUND : the string passed as 5-th argument does not correspond to any existing wavelet filter

The calling sequence when using the Basic interface is pretty straigtforward: first initialize the data, then call the forward wavelet transform routine, and continue working with the output data. Both the input and the output memory locations must be fully initialized prior to calling the wavelet transform routines. As a very simple example, we may compute the wavelet transform of a 1D array as follows:

					#include "wavelet_library/basic.hpp"
					#include <algorithm>
					#include <iostream>	
					int main(int argc, char** argv)
					{
						const size_t N = 8;			
						
						double x[N];
						double y[N];
						
						x[0] = 1;
						std::fill(x+1, x+N, 0.0);
						
						std::cout << "Input : " ;
						for(int i = 0; i != N; ++i)
						{
							std::cout << x[i] << ", ";
						}
						std::cout << std::endl;
						
						spectral::wavelet_library::forward_wavelet_transform(1, &N, x, y);
						
						std::cout << "Output : " ;
						for(int i = 0; i != N; ++i)
						{
							std::cout << y[i] << ", ";
						}
						std::cout << std::endl;
						
						return 0;
					}			
				

The wavelet coefficients of the array "1 0 0 0 0 0 0 0" are displayed as a result of this simple program. By default, "coiflet 2" wavelets were applied, and the KW interlaced ordering was used.

I.3.2. Choice of wavelet

The wavelet filter can be customized by passing a C-string descriptor as fifth parameter to the wavelet transform routines. In the default configuration for KIWIWALI, the following choices are possible:

  • haar
  • daubechies_2 to daubechies_6
  • coiflet_1 to coiflet_3
  • rcoiflet_1 to rcoiflet_3

For precise mathematical definitions of every wavelet family, see this page.

For instructions on the configuration of additional filters, see the documentation of the advanced interface below.

I.3.3. Ordering of coefficients

Two options are available: either use the KW interlaced ordering, or the more classical 'non-standard' ordering. The default behavior is to use KW ordering.

I.3.3.1. KW interlaced ordering

When using this ordering, the output wavelet coefficients are grouped by position rather than by scale. In 1D, the odd-indexed elements correspond to the finest scale.

The detailed explanation for the KW interlaced ordering may be found in chapter 2 of my PhD thesis.

I.3.3.2. Classical ordering

In the classical ordering, the wavelet coefficients are grouped by cubic blocks, each block corresponding to a given scale and direction. The specification for this ordering may defined recursively as follows.

Consider an N-dimensional array consisting of scaling function coefficients. When the first level of wavelet transform is applied in each direction, the scaling function coefficents for the next level are placed in the first half of the resulting generalized array row, and the wavelet coefficients in the second half. Once all the directions have been processed in this manner, the scaling coefficients ready for the next level of wavelet transform are thus located in a subcube whose size is divided by 2 in each direction compared to the original array. This process is iterated until only one scaling coefficient remains.

Note that the wavelet coefficients are actually first computed using the internal interlaced ordering of KW, and then re-ordered, which implies a small computational overhead.