Discrete Wavelet Transforms

This chapter describes functions for performing Discrete Wavelet Transforms (DWTs). The library includes wavelets for real data in both one and two dimensions.

Contents:

  1. Definitions

  2. Initialization

  3. Transform methods

    1. Wavelet transforms in one dimension

    2. Wavelet transforms in two dimension

  4. Examples

Definitions

The continuous wavelet transform and its inverse are defined by the relations, and, where the basis functionspsi_{s,tau} are obtained by scaling and translation from a single function, referred to as the mother wavelet.

The discrete version of the wavelet transform acts on evenly sampled data, with fixed scaling and translation steps (s, tau). The frequency and time axes are sampled dyadically on scales of 2^j through a level parameter j. The resulting family of functions {psi_{j,n}} constitutes an orthonormal basis for square-integrable signals.

The discrete wavelet transform is an O(N) algorithm, and is also referred to as the fast wavelet transform.

Initialization




Transform Methods

Wavelet transforms in one dimension


Wavelet transforms in two dimension







Example

#!/usr/bin/env ruby
require("gsl")

n = 256
nc = 20

data = Vector.alloc(n)
data.fscanf("ecg.dat")

w = GSL::Wavelet.alloc("daubechies", 4)
work = GSL::Wavelet::Workspace.alloc(n)

##### Choose as you like...
data2 = w.transform(data, Wavelet::FORWARD, work)
#data2 = w.transform(data, work)
#data2 = w.transform(data)
#data2 = w.transform(data, Wavelet::FORWARD)
#data2 = w.transform_forward(data, work)
#data2 = w.transform_forward(data)
#data2 = Wavelet.transform(w, data, Wavelet::FORWARD, work)
#data2 = Wavelet.transform(w, data, Wavelet::FORWARD)
#data2 = Wavelet.transform(w, data, work)
#data2 = Wavelet.transform_forward(w, data)
#data2 = data.wavelet_transform(w, Wavelet::FORWARD, work)
#data2 = data.wavelet_transform_forward(w, work)

perm = data2.abs.sort_index

i = 0
while (i + nc) < n
  data2[perm[i]] = 0.0
  i += 1
end

#data3 = w.transform(data2, Wavelet::BACKWARD, work)
#data3 = w.transform(data2, Wavelet::BACKWARD)
#data3 = w.transform_inverse(data2, work)
#data3 = w.transform_inverse(data2)
#data3 = Wavelet.transform(w, data2, Wavelet::BACKWARD, work)
#data3 = Wavelet.transform(w, data2, Wavelet::BACKWARD)
#data3 = Wavelet.transform_inverse(w, data2, work)
data3 = Wavelet.transform_inverse(w, data2)
#data3 = data2.wavelet_transform(w, Wavelet::BACKWARD, work)
#data3 = data2.wavelet_transform_inverse(w, work)

#If you have GNU graph utility...
GSL::graph(nil, data, data3, "-T X -C -g 3")

prev next

back