Discrete Wavelet Transform - Code Examples

Code Examples

In its simplest form, the DWT is remarkably easy to compute.

The Haar wavelet in Java:

public static int discreteHaarWaveletTransform(int input) { // This function assumes that input.length=2^n, n>1 int output = new int; for (int length = input.length >> 1; ; length >>= 1) { // length = input.length / 2^n, WITH n INCREASING to log(input.length) / log(2) for (int i = 0; i < length; ++i) { int sum = input + input; int difference = input - input; output = sum; output = difference; } if (length == 1) { return output; } //Swap arrays to do next iteration System.arraycopy(output, 0, input, 0, length << 1); } }

Complete Java code for a 1-D and 2-D DWT using Haar, Daubechies, Coiflet, and Legendre wavelets is available from the open source project: JWave. Furthermore, a fast lifting implementation of the discrete biorthogonal CDF 9/7 wavelet transform in C, used in the JPEG 2000 image compression standard can be found here.

Read more about this topic:  Discrete Wavelet Transform

Famous quotes containing the words code and/or examples:

    Many people will say to working mothers, in effect, “I don’t think you can have it all.” The phrase for “have it all” is code for “have your cake and eat it too.” What these people really mean is that achievement in the workplace has always come at a price—usually a significant personal price; conversely, women who stayed home with their children were seen as having sacrificed a great deal of their own ambition for their families.
    Anne C. Weisberg (20th century)

    There are many examples of women that have excelled in learning, and even in war, but this is no reason we should bring ‘em all up to Latin and Greek or else military discipline, instead of needle-work and housewifry.
    Bernard Mandeville (1670–1733)