DMelt:DSP/5 Fast Wavelet Transform
From HandWiki
Revision as of 21:58, 20 May 2018 by imported>Jworkorg
Member
Fast Wavelet Transform (FWT)
Here is FWT for 1D array using Haar method.
We use Transform class for this task:
from math.jwave import Transform from math.jwave.transforms import * from math.jwave.transforms.wavelets import * t=Transform( FastWaveletTransform( Haar02( ) )) arrTime = [1, 10, 12, 8, 1, 1, 1, 1. ] arrFreq = t.forward( arrTime ) # 1-D FWT Haar forward print arrFreq.tolist() arrReco = t.reverse( arrFreq ) # 1-D FWT Haar reverse print arrReco.tolist()
The output of this code is:
[12.374368670764577, 9.545941546018389, -4.499, 0.0, -6.363, 2.8284, 0.0, 0.0] [1, 10, 12, 8, 1, 1, 1, 1. ]
FWT in 2D
Now let us consider a FWT transformation of 2D array. This is an extension of the above script:
from math.jwave import Transform from math.jwave.transforms import * from math.jwave.transforms.wavelets import * t=Transform( FastWaveletTransform( Haar02( ) )) arrTime = [[1, 10, 12, 8, 1, 1, 1, 1. ], [1, 2, 2, 3, 1, 1, 1, 1. ]] arrFreq = t.forward( arrTime ) # 1-D FWT Haar forward print arrFreq arrReco = t.reverse( arrFreq ) # 1-D FWT Haar reverse print arrReco