util.wavelet
Class WaveletTransform

java.lang.Object
  extended by util.wavelet.WaveletTransform

public class WaveletTransform
extends Object

Discrete wavelet transform of a signal using the 1D A-Trous method with a b3-spline smoothing function. The noise for each position in the signal is also required. The WaveletTransform class computes the wavelet coefficients, the 1-sigma threshold for wavelet coefficients, the multiresolution support and it associated fields, structures and object trees for feature extraction and finally a set of signals corresponding to each individual object detected. Converted from the Feb 2004 distribution of the ESO/MIDAS wavelet code originally written by Jean-Luc Starck in 25-Feb-2003. In particular version 19_1 of functions wave_1d_trou() and wave_1d_algo_trou_rec() located in the file contrib/wavelet/libsrc/wave1d.c available by FTP inside the gzip file ftp://ftphost.hq.eso.org/pub/midaspub/04FEB/04FEBpl1.1.tar.gz. For those interested in extending this class to support 2D DWT look into pave_2d_tfo() and pave_2d_build() located in the file contrib/wavelet/libsrc/pave.c Reference: Starck,J.-L., Murtagh, F., Bijaoui,A.: 1998, Image Processing and Data Analysis, ISBN 0521599148 Cambridge Univ. Press.

Author:
John Talbot

Field Summary
 int[][] fieldLabel
          Field labels for contiguous sets of above threshold wavelet coefficients.
 List<Structure> structures
          A list of Structures in this wavelet transform
 float[][] threshold
          The 1-sigma threshold for wavelet coefficients
 float[][] w
          Wavelet coefficients
 
Constructor Summary
WaveletTransform(float[] signal, float[] noise, int scales, BoundaryCondition boundaryCondition)
          Construct a wavelet transform from a signal with non-uniform noise using the 1D A-Trous method with a b3-spline smoothing function.
 
Method Summary
static float[] getContinuum(float[] signal)
          Get the continuum of a signal.
protected  void getFields(float nsigma, boolean positive)
          Computes the field labels for contiguous sets of above threshold wavelet coefficients.
static float getGaussianDeviate()
          Get a normally distributed gaussian deviate with zero mean and unit variance.
static float[][] getGaussianWaveletTransform(int n)
          Get the a wavelet transform of a signal comprised of a normally distributed gaussian deviate
static int[] getMultiResolutionSupportVisualization(float[][] support, boolean positive)
          Get the multiresolution support visualization for this wavelet transform as a 1D GIF image.
static float[] getStandardDeviation(int size)
          Get the standard deviation (sigma) at each scale in the wavelet transform of a random noise signal comprised of a normally distributed gaussian deviates.
protected  float[][] getSupport(float nsigma, boolean positive)
          Get the multiresolution support for this wavelet transform by setting an array of integers set to 1 for significant wavelet coefficients (those which exceed the noise) 0 otherwise.
static void main(String[] args)
           
static void outputSignalAndWaveletTransform(PrintStream out, float[] signal, float[][] wavelet)
           
static void outputWaveletTransform(PrintStream out, float[][] wavelet)
           
 float[] reconstruct(float nsigma, boolean positive)
          Reconstruct a signal from a wavelet transform.
static float[][] transform(float[] signal, int scales, BoundaryCondition boundaryCondition)
          Discrete wavelet transform using the 1D A-Trous method with a b3-spline smoothing function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

w

public float[][] w
Wavelet coefficients


threshold

public float[][] threshold
The 1-sigma threshold for wavelet coefficients


fieldLabel

public int[][] fieldLabel
Field labels for contiguous sets of above threshold wavelet coefficients.


structures

public List<Structure> structures
A list of Structures in this wavelet transform

Constructor Detail

WaveletTransform

public WaveletTransform(float[] signal,
                        float[] noise,
                        int scales,
                        BoundaryCondition boundaryCondition)
Construct a wavelet transform from a signal with non-uniform noise using the 1D A-Trous method with a b3-spline smoothing function. Output : The coefficients of the wavelet transform is in w[0][] to w[scales-2][]. The last row of this array is the smoothed array (w[scales-1][]). The threshold[][] array is the 1-sigma threshold. The support[][] array is the multiresolution support.

Parameters:
signal - array of float values representing a discrete signal
noise - the standard deviation of the signal
scales - number of wavelet scales (if scales==0 then the following equation is solved 2^(scales+1) = 3/4 signal array length)
boundaryCondition - treatment of boundary conditions
Method Detail

reconstruct

public float[] reconstruct(float nsigma,
                           boolean positive)
Reconstruct a signal from a wavelet transform. (see Starck 1998 p.24)

Parameters:
nsigma - the threshold in units of standard deviation (e.g. 3 is typical, 0 is equivalent to keeping all data)
positive - if true extract objects that have wavelets coefficients exceeding the threshold, otherwise extract negative features only
Returns:
a reconstructed signal array of float values

getFields

protected void getFields(float nsigma,
                         boolean positive)
Computes the field labels for contiguous sets of above threshold wavelet coefficients.

Parameters:
nsigma - the significance level in number of sigma units
positive - restriction to positive significant wavelet coefficients otherwise negative only

getSupport

protected float[][] getSupport(float nsigma,
                               boolean positive)
Get the multiresolution support for this wavelet transform by setting an array of integers set to 1 for significant wavelet coefficients (those which exceed the noise) 0 otherwise. (see Starck 1998 p.55). threshold wavelet coefficients.

Parameters:
positive - restriction to positive significant wavelet coefficients otherwise negative only

getMultiResolutionSupportVisualization

public static int[] getMultiResolutionSupportVisualization(float[][] support,
                                                           boolean positive)
Get the multiresolution support visualization for this wavelet transform as a 1D GIF image. (see Starck 1998 p.56) Optionally allow negative mr values to produce a reduction in grey intensity.

Parameters:
positive - only check for positive significant wavelet coefficients
Returns:
multiresolution support

transform

public static float[][] transform(float[] signal,
                                  int scales,
                                  BoundaryCondition boundaryCondition)
Discrete wavelet transform using the 1D A-Trous method with a b3-spline smoothing function. (see Starck 1998 p.21-26)

Parameters:
signal - array of float values representing a discrete signal
scales - number of wavelet scales (if scales==0 then the following equation is solved 2^(scales+1) = 3/4 signal array length)
boundaryCondition - treatment of boundary conditions
Returns:
the wavelet transform as a 2-dimensional array of floats with the last row equal to the smoothed array

getContinuum

public static float[] getContinuum(float[] signal)
Get the continuum of a signal. The continuum is computed by iteratively substracting it from the signal; the iteration is required due to border problems. (see Starck 1998 p.127).

Parameters:
signal - array of float values representing a discrete signal
Returns:
the continuum of the signal

main

public static void main(String[] args)

getGaussianDeviate

public static float getGaussianDeviate()
Get a normally distributed gaussian deviate with zero mean and unit variance. (see function gasdev(long *idnum) in Press (1992) Numerical Recipes in C, 2nd ed. page 289).

Returns:
normally distributed floating point number

getGaussianWaveletTransform

public static float[][] getGaussianWaveletTransform(int n)
Get the a wavelet transform of a signal comprised of a normally distributed gaussian deviate

Parameters:
n - the size of the random signal

getStandardDeviation

public static float[] getStandardDeviation(int size)
Get the standard deviation (sigma) at each scale in the wavelet transform of a random noise signal comprised of a normally distributed gaussian deviates. These sigmaNoise values can be used to estimate the sigma of a signal using : where sigma[0] is estimated by equating it with the standard deviation of scale 0 of the wavelet transform of a signal (i.e signalWavelet[0][i]). Then when the absolute value of signalWavelet[scale][i] is greater than 3*sigma[scale] we have a significant coefficient. If the signal to noise is non-uniform then another technique is used.

Parameters:
size - the size of the random signal
Returns:
a list of standard deviations at each scale of the wavelet transform of the noise signal

outputSignalAndWaveletTransform

public static void outputSignalAndWaveletTransform(PrintStream out,
                                                   float[] signal,
                                                   float[][] wavelet)

outputWaveletTransform

public static void outputWaveletTransform(PrintStream out,
                                          float[][] wavelet)