1

If the input data is not even, what should I do? And what if the input data is not power of 2? Should I just ignore the rest of the numbers?

Yuhang Lin
  • 149
  • 1
  • 11

1 Answers1

2

There is no such restriction on the signal length. Use some signal extension to handle the samples beyond signal borders. A symmetric extension is a popular choice, as it guarantees the invertibility of the transform without adding any unnecessary coefficients. Such treatment is even easier if you use a lifting scheme (although this does not matter in the case of the Haar wavelet). The same inherently applies to the powers of the two.

DaBler
  • 2,695
  • 2
  • 26
  • 46
  • I don't quite understand. Why do you say "this does not matter in the case of the Haar wavelet"? – Yuhang Lin Sep 04 '17 at 23:15
  • @YuhangLin: The lifting scheme decomposes (using the Euclidean algorithm) long wavelet filters into a series of short filtering steps. The Haar wavelet transform can be implemented with two two-tap FIR filters, specifically h(z) = 1/2 + 1/2 z^{-1}, and g(z) = z^{-1} - 1. However, also the corresponding lifting scheme of the forward transform consists of two two-tap filters (across the subbands). Specifically, the implementation follows from: d_l = d_l - s_l, and s_l = s_l + 1/2 d_l. Thus, there is no simplification for the Haar wavelet. – DaBler Sep 05 '17 at 12:01
  • Thank you for your explanation. I found a page describing signal extension (http://pywavelets.readthedocs.io/en/latest/ref/signal-extension-modes.html). Is that what you meant? – Yuhang Lin Sep 05 '17 at 17:12
  • @YuhangLin: Sorry for the late reply. Yes, this is what I meant. The reflect-padding is what I call the symmetric extension. – DaBler Sep 13 '17 at 15:56
  • I would like to contest your first sentence and be shown why if I am wrong if someone has time; just want to understand this well. Consider an arbitrarily long (but finite) signal of size (2^n + 2^(n+1) / 2), i.e. halfway between powers of 2. Surely however you extend the signal (for Haar or any order discrete Daubechies transform) will have a degrading effect on signal reconstruction for large enough 'n', right? – penovik Mar 08 '23 at 01:06
  • @penovik The size (2^n + 2^(n+1) / 2) = (2^n + 2^n) = 2^(n+1) which is just a power of two. Surely, there is no signal degradation for "for large enough 'n'". – DaBler Mar 08 '23 at 13:41
  • Parentheses messed up which is why I put it in English, apologies -- halfway between powers of 2, [ 2^n + 2^(n+1) ] / 2, is not a power of 2. – penovik Mar 09 '23 at 02:10
  • @penovik Not even 11 is a power of two. To perform a single level DWT, you do not need the signal length to be even. Inherently, you don't need the signal length to be a power of two to perform multiple DWT levels. Just use the lifting scheme and symmetric signal extension. – DaBler Mar 09 '23 at 09:36
  • The ability to “to perform a single level DWT” wasn’t the question, though - we agree you can do that if it’s a power of 2 or not. I was asking specifically about Daubechies transforms and how, if you are maximally away from a power of 2 for large n, then I think extending the signal will produce more reconstruction errors after compression (for n large enough). I’ll be happy to be shown I’m right or wrong; I just want to be on the same page first. – penovik Mar 09 '23 at 22:18
  • I recommend you to start with Daubechies, I., Sweldens, W. Factoring wavelet transforms into lifting steps. The Journal of Fourier Analysis and Applications 4, 247–269 (1998). https://doi.org/10.1007/BF02476026 (Section 7.5. 4-tap orthonormal filter with two vanishing moments (D4) is especially important). It doesn't matter which wavelet you choose. Daubechies transform is the same as any other wavelet transform. It doesn't matter that you are maximally away from a power of 2 for large n. The transforms will work as I wrote in the previous comment (single level, multiple levels). – DaBler Mar 10 '23 at 09:49
  • You don't seem to understand my point. I am not contesting whether or not you can do a transform on a signal, but something else entirely. – penovik Mar 11 '23 at 22:54
  • I suggest you ask a completely new question (do not add additional comments to the current question). Explain everything you need with images and pseudocode. Then you will have a better chance of solving your problem here. – DaBler Mar 12 '23 at 09:42