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:
“Acknowledge your will and speak to us all, This alone is what I will to be! Hang your own penal code up above you: we want to be its enforcers!”
—Friedrich Nietzsche (18441900)
“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 (16701733)