Periodic convolution, equivalent to convolution2d from scipy

Hi! I am new to convolutions. I am looking to implement a convolution with wrapped/toroidal boundaries (i.e. for CircularArrays).

# matrix = N x M matrix
# smaller_matrix = some sort of kernel
convolve2d(matrix, smaller_matrix, mode='same', boundary='wrap')

In other words, a smoothing filter that acts periodically. I know

DSP.conv(vector, vector, matrix)

achieves something similar, but I don’t know how to implement wrapped boundaries.

Thanks!

Hi,
I know the reply comes a bit late, but have a look at ImageFiltering.jl. In particular the function imfilter(matrix, kernel; border="circular") supports a keyword argument border that can be set to (amongst other things) “circular” to achieve what you want.
Despite having the word “Image” in its name, the package works for general nd-arrays.

1 Like

thanks a bunch

1 Like