Skip to main content

Module fourier

Module fourier 

Source
Expand description

Fourier-domain filters, following scipy.ndimage: fourier_gaussian, fourier_uniform, fourier_ellipsoid and fourier_shift.

By the convolution theorem, convolving an image with a kernel multiplies its discrete Fourier transform by the kernel’s transform. These functions take a spectrum (the output of a 2D FFT, or of a real FFT along the rows) and multiply it by a transfer function given in closed form: a Gaussian, a box (sinc), a disc or ellipse (the Airy pattern, 2 J₁(x)/x), or a phase ramp (a shift by any fraction of a pixel). The cost is that of the FFTs, whatever the kernel size, and the convolution is circular: the image is treated as periodic.

See the book entry Fourier-domain filters.

Enums§

Spectrum
What kind of spectrum a Fourier filter receives (SciPy’s n argument with axis = -1).

Functions§

fourier_ellipsoid
A uniform ellipse with axes size = (rows, columns) pixels (a disc when they are equal): multiplies by 2 J₁(x)/x with x = π √((s_r f_r)² + (s_c f_c)²), the Airy pattern.
fourier_filter
Filters a real image in the Fourier domain: a 2D FFT, the given filter on the full spectrum, and the real part of the inverse FFT. For example, fourier_filter(&image, |s| fourier_gaussian(s, (2.0, 2.0), Spectrum::Full)).
fourier_gaussian
Gaussian smoothing with standard deviations sigma = (rows, columns) in pixels: multiplies by exp(−2π² (σ_r² f_r² + σ_c² f_c²)), the Fourier transform of the continuous Gaussian.
fourier_shift
A shift by shift = (rows, columns) pixels, which need not be whole: multiplies by the phase ramp exp(−2πi (s_r f_r + s_c f_c)). Content moves towards larger indices for positive shifts, wrapping round the edges.
fourier_uniform
A box (moving average) of size = (rows, columns) pixels: multiplies by sinc(s_r f_r) sinc(s_c f_c), with sinc(x) = sin(πx)/(πx).
frequencies
The frequencies (cycles per sample) of the rows and columns of a spectrum of shape dim.