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

**URL:** https://discourse.julialang.org/t/ann-fouriertools-jl-tools-for-working-with-fourier-space/59930
**Category:** Package Announcements
**Tags:** fftw
**Created:** [April 24, 2021, 1:15pm UTC](https://discourse.julialang.org/t/ann-fouriertools-jl-tools-for-working-with-fourier-space/59930 "2021-04-24T13:15:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![roflmaostc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/roflmaostc/32/30123_2.png) [@roflmaostc](https://discourse.julialang.org/u/roflmaostc)
#### Post date: [April 24, 2021, 1:15pm UTC](https://discourse.julialang.org/t/ann-fouriertools-jl-tools-for-working-with-fourier-space/59930/1 "2021-04-24T13:15:57Z")

</div>

Hey,

today we can announce the release of [FourierTools.jl](https://github.com/bionanoimaging/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](https://github.com/JuliaMath/FFTW.jl).

## Features

- sinc interpolation allows to up and downsample a (bandlimited) signal (which replaces [FFTResampling.jl](https://github.com/roflmaostc/FFTResampling.jl))

- FFT based

- 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](https://bionanoimaging.github.io/FourierTools.jl/dev/) and with Pluto notebooks on [GitHub](https://github.com/bionanoimaging/FourierTools.jl/tree/main/examples).  
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`](https://github.com/JuliaArrays/ShiftedArrays.jl/blob/master/src/fftshift.jl) 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
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](https://github.com/bionanoimaging/FourierTools.jl/blob/main/examples/more_complex_example.jl)

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.

Thanks,

Rainer & Felix

---

<div class="post-metadata">

### Author: ![liuyxpp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/liuyxpp/32/9870_2.png) [@liuyxpp](https://discourse.julialang.org/u/liuyxpp)
#### Post date: [April 24, 2021, 1:17pm UTC](https://discourse.julialang.org/t/ann-fouriertools-jl-tools-for-working-with-fourier-space/59930/2 "2021-04-24T13:17:29Z")

</div>

Congratulations! I love this work!
