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:

    Faultless honesty is a sine qua non of business life. Not alone the honesty according to the moral code and the Bible. When I speak of honesty I refer to the small, hidden, evasive meannesses of our natures. I speak of the honesty of ourselves to ourselves.
    Alice Foote MacDougall (1867–1945)

    In the examples that I here bring in of what I have [read], heard, done or said, I have refrained from daring to alter even the smallest and most indifferent circumstances. My conscience falsifies not an iota; for my knowledge I cannot answer.
    Michel de Montaigne (1533–1592)