/// <summary> /// Calculate the Haar inverse fast wavelet transform in 1-dimension. /// </summary> /// <param name="signal">Signal to compute (must be power two)</param> public static void Haar_inverse_FWT_1d(ref double[] signal) { for (int m = 2; m <= signal.Length; m++) { Wavelet.Haar_inverse_pass_1d(m, ref signal); } }
/// <summary> /// Calculate one iteration of the Haar inverse FWT in 2-dimensions. /// </summary> /// <param name="signal">Signal to compute (must be power two)</param> /* static void Haar_inverse_pass_2d(int n, ref double[][] signal) * { * int i, j; * int npts; * * npts = (int) Utilities.NextPowerOfTwo((int) n); * for (i = 0; i < npts; i++) * { * Wavelet.Haar_inverse_pass_1d(n, ref signal[i]); * } * double[] c = new double[npts]; * for (j = 0; j < npts; j++) * { * for (i = 0; i < npts; i++) * c[i] = signal[i][j]; * Wavelet.Haar_inverse_pass_1d(n, ref c); * for (i = 0; i < npts; i++) * signal[i][j] = c[i]; * } * }*/ /// <summary> /// Calculate the Haar inverse fast wavelet transform in 2-dimensions. /// </summary> /// <param name="signal">Signal to compute (must be power two)</param> public static void Haar_inverse_FWT_2d(int width, int height, ref double[] signal) { /*for (int m = 1; m <= signal.Length; m++) * { * Haar_inverse_pass_2d(m, ref signal); * }*/ double[] row = new double[DSPUtilities.NextPowerOfTwo((int)width)]; double[] column = new double[DSPUtilities.NextPowerOfTwo((int)height)]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { column[y] = signal[x + (y * width)]; } Wavelet.Haar_inverse_FWT_1d(ref column); for (int y = 0; y < height; y++) { signal[x + (y * width)] = column[y]; } } for (int y = 0; y < height; y++) { Array.Copy(signal, (int)(y * width), row, 0, (int)width); Wavelet.Haar_inverse_FWT_1d(ref row); Array.Copy(row, 0, signal, (int)(y * width), (int)width); } }
/// <summary> /// Calculate the Haar forward fast wavelet transform in 1-dimension. /// </summary> /// <param name="signal">Signal to compute (must be power two)</param> public static void Haar_forward_FWT_1d(ref double[] signal) { int m; int npts; npts = (int)DSPUtilities.NextPowerOfTwo((int)signal.Length); for (m = signal.Length - 1; m >= 0; m--) { Wavelet.Haar_forward_pass_1d(m + 1, ref signal); //Wavelet.Haar_ip_FFWT_1d(m + 1, ref signal); } /*int i = 0; * int w = signal.Length; * double[] vecp = new double[signal.Length]; * for (i = 0; i < signal.Length; i++) * vecp[i] = 0; * //while (w > 1) * // { * w /= 2; * for (i = 0; i < w; i++) * { * vecp[i] = (signal[2 * i] + signal[2 * i + 1]) / Math.Sqrt(2.0); * vecp[i + w] = (signal[2 * i] - signal[2 * i + 1]) / Math.Sqrt(2.0); * } * for (i = 0; i < (w * 2); i++) * signal[i] = vecp[i]; * // }*/ }