Closed ghost closed 5 years ago
We do not currently have anything in PyWavelets to do this.
I will leave this open as a feature request. Is this something you might be interested in contributing? I think supporting all edge-modes and arbitraty number of dimensions would be a bit of work, but if you wanted to just support the 1D case and periodic boundary conditions it could be pretty straightforward.
As you indicate, since the DWT is implemented via (downsampled) convolutions, this could be done by using a matrix-representation of the operator. You can get the FIR filters from a Wavelet
object as illustrated below, but we do not currently have a function that directly converts these into the corresponding (convolution + downsampling) matrices.
import pywt
w = pywt.Wavelet('db2')
print(w.dec_lo) # decomposition lowpass
print(w.dec_hi) # decomposition highpass
print(w.rec_lo) # reconstruction lowpass
print(w.rec_hi) # reconstruction highpass
As the matrix will be mostly zeros (at least in the typical case where the signal has many more samples than the FIR filters), the memory usage shouldn't be too high if sparse matrices are used.
What about lifting schemes?
We do not currently have a lifting-based transform in PyWavelets.
Is there a way to obtain the n^2 matrix itself rather than have the library perform the operation?
I want to implement it as simple matrix multiplication on the GPU, and the O(N^2) memory complexity is tolerable.
A function to construct such a matrix based on the desired number of levels and w*h input would be nice.