every iteration is halved until it is 1. for (int i = 0; i < length; ++i) { int sum = input[i * 2] + input[i * 2 + 1]; int difference = input[i * 2] - input[i * 2 + 1]; output[i] = sum; output[length + i] = difference; } if (length == 1) { return output; } //Swap arrays to do next iteration System.arraycopy(output, 0, input, 0, length); } } 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 (archived 5 March 2012). Example of above code This figure shows an example of applying the above code to compute the Haar wavelet coefficients on a sound waveform. This example highlights two key properties of the wavelet transform: Natural signals often have some degree of smoothness, which makes them sparse in the wavelet domain. There are far fewer significant components in the wavelet domain in this example than there are in the time domain, and most of the significant components are towards the coarser coefficients on the left. Hence, natural signals are compressible in the wavelet domain. The wavelet transform is a multiresolution, bandpass representation of a signal. This can be seen directly from the filterbank definition of the discrete wavelet transform given in this article. For a signal of length , the coefficients in the range represent a version of the original signal which is in the pass-band . This is why zooming in on these ranges of the wavelet coefficients looks so similar in structure to the original signal. Ranges which are closer to the left (larger in the above notation), are coarser representations of the signal, while ranges to the right represent finer details. See also Discrete cosine transform (DCT) Wavelet Wavelet transform Wavelet compression List of wavelet-related transforms References External links Stanford's WaveLab in matlab libdwt, a cross-platform DWT library written in C Concise Introduction to Wavelets by René Puschinger Numerical analysis Digital signal processing Wavelets Articles with example Java code Discrete transforms de:Wavelet-Transformation#Diskrete Wavelet-Transformation fr:Ondelette#Transformée en ondelettes discrète