Closed adhaka3 closed 2 years ago
This looks like Image[:, :].shape
is 3d (155, 240, 240)
? Is your intention to do a batch of 155 2d transforms? (By default swt2
will transform the last two axes). The output of the forward transform looks as expected. This issue is just that iswt2
doesn't support batch transforms (it doesn't have an axes
argument).
You can use swtn
and iswtn
to do batch 2d transforms. In each case, specify axes=(-2, -1)
so that only the last two axes are transformed (assuming a batch 2D transform was your intention). The coefficient format will be a list of dictionaries as described in the docstring.
I do think having axes
available for swt2
, but not iswt2
is a little odd from an API standpoint. Internally, swt2
just calls swtn
which has axes support, so it works there. iswt2
is an older implementation that did not support axes
(it does not call iswtn
internally). I think the simpler iswt2
implementation was retained because it is a little easier to read and follow the logic than the more general iswtn
case and so may be useful to future maintainers/developers as a reference.
I am trying to do image fusion by doing a batch transform through SWT on 3d images of shape (155,240,240). Hence, I wanted to get the coefficients, make some modifications and then get the inverse. Now, on implementing the solution you gave, wavelet = 'db1' cooef1 = pywt.swtn(I1, wavelet, level=2, axes=(-2, -1)) cooef2 = pywt.swtn(I2, wavelet, level=2, axes=(-2, -1)) It gives me 2 array of shape (2, ).
On running, np.shape(cooef1[0]), I get () as the output.
I am not able to merge the set of coefficients anymore bcoz of this. P.S- Thanks for this library and the help!!
I do think having
axes
available forswt2
, but notiswt2
is a little odd from an API standpoint.
Indeed, that seems like a wart. Let's leave this issue open for resolving that, probably by adding an axes
keyword to iswt2
.
Indeed, that seems like a wart. Let's leave this issue open for resolving that, probably by adding an axes keyword to iswt2.
That was also addressed as part of #527, which I just merged, so we can now close this as well!
While running, wavelet='db1' Cooef = pywt.swt2(Image[:,:], wavelet, level=2) Image = pywt.iswt2(Cooef, wavelet) it gives the error: ValueError: iswt2 only supports 2D arrays. see iswtn for a general n-dimensionsal ISWT
Shape of Cooef= (2, 2) Shape of Cooef[0][0]= (155, 240, 240) #(approx. coeff) Shape of Cooef[0][1]= (3, 155, 240, 240) #(detailed coeff) Shape of Cooef[1][0]= (155, 240, 240) #(approx. coeff) Shape of Cooef[1][1]= (3, 155, 240, 240) #(detailed coeff)
I am pretty new to the concept of Wavelets; this might be a stupid question to ask but I can't get my head around this!!!!