convolve2D not supporting "boundary=wrap"
See original GitHub issueHi JAX developers,
I am trying to filter periodic images with jax.scipy.signal.convolve2d, but it seems that the flag boundary=‘wrap’ is not supported, although it was mentioned in the doc.
Here is a MVE:
from jax.scipy.signal import convolve2d
import jax.numpy as jnp
a1 = jnp.ones((3,3))
a = convolve2d(a1, a1,mode='same',boundary='wrap')
Here is the error: raise NotImplementedError(“convolve2d() only supports boundary=‘fill’, fillvalue=0”) NotImplementedError: convolve2d() only supports boundary=‘fill’, fillvalue=0
Thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
signal.convolve2d performs unexpectedly with boundary='wrap'
The signal.convolve2d(sig_1, sig_2, boundary='wrap') function behaves unexpectedly when the input signals match a certain criteria.
Read more >scipy.signal.convolve2d — SciPy v1.9.3 Manual
Convolve two 2-dimensional arrays. Convolve in1 and in2 with output size determined by mode, and boundary conditions determined by boundary and fillvalue. ...
Read more >Convolving a periodic image with python - Stack Overflow
convolve2d 's optional boundary='wrap' which gives periodic boundary conditions as padding for the convolution. The mode option here is 'same' ...
Read more >Comparison between pyFFS and SciPy 2-D convolution. The ...
Comparison between pyFFS and SciPy 2-D convolution. The former uses pyffs.convolve while the latter uses scipy.signal.convolve2d with boundary='wrap'.
Read more >scipy.signal.convolve2d Example - Program Talk
Learn how to use python api scipy.signal.convolve2d. ... T, np.atleast_2d(mask_even), mode=method, boundary='wrap') odd = signal.convolve2d(coords.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The best way to implement this is probably to explicitly form the padding values as part of the input to the convolution. Note that
jnp.pad
supports wrapping padding modes, so perhaps the implementation is as simple as composing the two?One more thing: the reason this has not yet been implemented is because convolutions are computed via XLA’s ConvWithGeneralPadding, and I’m not certain whether it is able to compute the equivalent of scipy’s wrapped convolutions.