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:
“Wise Draco comes, deep in the midnight roll
Of black artillery; he comes, though late;
In code corroborating Calvins creed
And cynic tyrannies of honest kings;
He comes, nor parlies; and the Town, redeemed,
Gives thanks devout; nor, being thankful, heeds
The grimy slur on the Republics faith implied,
Which holds that Man is naturally good,
Andmoreis Natures Roman, never to be
scourged.”
—Herman Melville (18191891)
“Histories are more full of examples of the fidelity of dogs than of friends.”
—Alexander Pope (16881744)