Closed GJBoth closed 6 years ago
I see this issue when running the following minimal code
import numpy as np
import pywt
x = np.random.randn(374, 278)
r = pywt.iswt2(pywt.swt2(x, 'db1', level=1), 'db1')
I will look into why this is. In the meantime, can you use swtn
and iswtn
instead? The above example works in that case. (This would require adjusting your other code to use the dictionary format output by swtn).
Okay, the fix seems to be as simple as removing a check for square shape. see #369
@profgerto: If you want the fix immediately, you can just copy the small change from commit 9b3b6bb to your local installation. The fix is in a python file, so It will not require recompiling any C/Cython code.
@grlee77 Thanks! I'll try doing that.
About iswtn; somehow I get the error that the function doesn't exist. swtn works fine. Right now I've padded with zeros until my data is square, but I think that messes up my (universal) threshold (I'm not sure since I'm rather new to wavelet decomposition), but since the coefficients are spatially localised (again, Im not sure) I can apply the threshold locally to circumvent this.
I think the missing iswtn
is because it was introduced more recently and was not in the last official release. It is probably easier for you to just apply the small change proposed in 9b3b6bb for the existing iswt2
.
Hopefully we will do a new release in the coming month or two, but there is no fixed time set for it at the moment.
The fix is very easy to apply and it worked, so no hurry, thanks a lot!
I am trying to denoise a 374x278 image by applying a SWT2 with db1 wavelet, apply thresholding and inverse transform again. I use a single-level decomposition (thus ensuring that both axes are a multiple of 2**N).
Applying SWT2 works, but when I call ISWT2 on the coefficients (even without filtering, simply transforming back and forth) I get the following error:
RuntimeError: Mismatch in shape of intermediate coefficient arrays
I tried running a SWTN, but I get the error the PyWavelets has no function ISWTN yet? I take it that this hasn't been implemented?
Python: 3.6.4 Numpy version: 1.14.1 PyWavelets version: 0.5.2 OS: Mac OS X 10.13.4