[ANN] FourierTools.jl | Tools for working with Fourier space


today we can announce the release of FourierTools.jl.

The package, as the name suggests, provides several tools based on Fourier space.
The workhorse behind many algorithms is of course FFTW.jl.


  • sinc interpolation allows to up and downsample a (bandlimited) signal (which replaces FFTResampling.jl)

  • FFT based

    • convolutions

    • array/image rotation

    • array/image shifting (including noteworthy subpixel shifts)

    • array/image shearing

  • several tools like ffts, ft etc. allowing simpler use with Fourier transforms supporting automatic centering in real and Fourier space

Some examples are shown in the docs and with Pluto notebooks on GitHub.
We provide fftshift_view (also rfftshift_view, etc.) which does not copy data but simply manipulates the indices (FFTW.fftshift copies data) based on ShiftedArrays.circshift. Likely, there will be also ShiftedArrays.fftshift in the next release of ShiftedArrays.jl .

Simple Example

Since we are working in the field of optics it is usually much more convenient to have the center frequency in the middle.
The pattern below occurs quite often and is then simplified, slightly faster and more memory efficient:

julia> using FFTW, FourierTools, BenchmarkTools

julia> x = randn((101, 113));

julia> y = randn((101, 113));

f(x, y) = ifft(ifftshift(fftshift(fft(x)) .* y)) # classical version using FFTW
f (generic function with 1 method)

g(x, y) = iffts(ffts(x) .* y)  # simplified version using FourierTools
g (generic function with 1 method)

julia> @btime f($x, $y);
  1.448 ms (84 allocations: 897.72 KiB)

julia> @btime g($x, $y);
  1.401 ms (58 allocations: 718.53 KiB)

A full example showing many functionalities with images is here

It is not yet clear what else we include in the future but good support for CUDA and automatic differentiation is definitely something we have in mind.


Rainer & Felix


Congratulations! I love this work!

1 Like