[code]public class Daub2 implements Wavelet
{
// forward transform scaling (smoothing) coefficients
protected final float h0 = (float) 0.70710678118655;
protected final float h1 = (float) 0.70710678118655;
// forward transform wavelet coefficients
protected final float g0 = h0;
protected final float g1 = -h1;
// Inverse transform coefficients for smoothed values
protected final float Ih0 = h0;
protected final float Ih1 = g0;
// Inverse transform for wavelet values
protected final float Ig0 = h1;
protected final float Ig1 = g1;
public float[] transformada = null;
/*********************************************************************
* Forward wavelet transform.
* Note that at the end of the computation the
* calculation wraps around to the beginning of
* the signal.
**********************************************************************/
protected void transform(float a[], int n)
{
int i, j;
int half = n >> 1;
float tmp[] = new float[n];
i = 0;
for (j = 0; j <= n - 1; j = j + 2)
{
tmp[i] = a[j] * h0 + a[j + 1] * h1;
tmp[i + half] = 0;
i++;
}
for (i = 0; i < n; i++){
a[i] = tmp[i];
}
} // transform
protected void invTransform(float a[], int n)
{
int i, j;
int half = n >> 1;
float tmp[] = new float[n];
j = 0;
for (i = 0; i <= half - 1; i++)
{
//smooth val coef. val smooth val coef. val
tmp[j] = a[i] * Ih0 + a[i + half] * Ih1;
j++;
tmp[j] = a[i] * Ig0 + a[i + half] * Ig1;
j++;
}
for (i = 0; i < n; i++) a[i] = tmp[i];
}
/*****************************************
* Forward Daubechies D2 transform
*****************************************/
public void daubTrans(float s[], int scale)
{
final int N = s.length;
int n;
for (n = N; n >= scale; n >>= 1){
transform(s, n);
}
}
/*******************************************
* Inverse Daubechies D2 transform
*******************************************/
public void invDaubTrans(float coef[], int scale)
{
final int N = coef.length;
int n;
for (n = scale; n <= N; n <<= 1) invTransform(coef, n);
}
}[/code]
Estou chamando essa classe da seguinte maneira
Daub2 daub2 = new Daub2();
float[] magnitude = new float[eixoy.length];
// copiando o vetor eixoy para o vetor magnitude
System.arraycopy(eixoy, 0, magnitude, 0, eixoy.length);
daub2.daubTrans(magnitude, 2);