NMath User's Guide

TOC | Previous | Next | Index

11.1 Creating Wavelets (.NET, C#, CSharp, VB, Visual Basic, F#)

NMath provides classes for creating wavelet objects: FloatWavelet and DoubleWavelet. Each derives from an abstract Wavelet base class.

Wavelets are constructed by specifying the wavelet family, using a value from the Wavelet.Wavelets enum. Fives types of built-in wavelets are supported: Harr, Daubechies, Least Asymmetric, Best Localized, and Coiflet. Built-in wavelets are identified by short name: the first letter abbreviates the wavelet family name, and the number that follows indicates the wavelet length. For example, this code builds a single-precision Coiflet wavelet of length 4:

Code Example – C# Wavelet

var wavelet = new FloatWavelet( Wavelet.Wavelets.C4 );

Code Example – VB Wavelet

Dim WaveletInstance As New FloatWavelet(Wavelet.Wavelets.C4)

Custom wavelets can also be created by passing in the wavelet's low and high pass decimation filter values. The wavelet class then imposes the wavelet's symmetry properties to compute the reconstruction filters.

For example, this code builds a custom reverse bi-orthogonal wavelet:

Code Example – C# Custom Wavelet

var low = new double[] {0.0, 0.0, 0.7071068, 0.7071068, 0.0, 0.0};
var high = new double[] {0.0883883, 0.0883883, -0.7071068, 
                         0.7071068, -0.0883883, -0.0883883};
var wavelet = new DoubleWavelet( low, high );

Code Example – VB Custom Wavelet

Dim Low = New Double() {0.0, 0.0, 0.7071068, 0.7071068, 0.0, 0.0}
Dim High = New Double() {0.0883883, 0.0883883, -0.7071068, 
                         0.7071068, -0.0883883, -0.0883883}
Dim WaveletInstance As New DoubleWavelet(Low, High)

After creating a wavelet object, you can access various properties of the wavelet:

FamilyName gets the wavelet family name (long-form), or Custom in the case of a custom wavelet.

ShortName gets the wavelet name abbreviation.

Length gets the length of the wavelet.

HighDecFilter gets the high-pass decimation filter values.

LowDecFilter gets the low-pass decimation filter values.

HighRecFilter gets the high-pass reconstruction filter values.

LowRecFilter gets the low-pass reconstruction filter values.