12. Practical: Fourier Optics and Image Processing#
12.1. Introduction#
Digital images are two-dimensional intensity functions \(f(x,y)\). The information in an image is encoded in a pattern of variation — bright and dark regions, sharp edges, smooth gradients. Fourier analysis gives us a way to decompose any such pattern into a sum of simple sinusoidal waves, each characterised by a frequency, an amplitude, and a phase. This decomposition is not merely mathematical convenience: in electron microscopy it is the physical basis of image formation (through the contrast transfer function) and of reconstruction algorithms (through the Fourier slice theorem).
This practical builds up Fourier intuition from the ground up:
What is a wave?
Fourier series — decomposing arbitrary 1D signals
Frequency spectra — looking at signals through the lens of their frequency content
2D Fourier analysis — extending to images
The convolution theorem — efficient filtering
The contrast transfer function — how the microscope shapes the signal
Interactive elements
Click Live Code in the top toolbar to activate the kernel, then expand each Show code toggle and click ▶ to run the cell.
12.1.1. Setup#
12.2. Part 1 – What is a wave?#
A sinusoidal wave has three fundamental parameters:
Parameter |
Symbol |
Effect |
|---|---|---|
Amplitude |
\(A\) |
Height of the wave |
Frequency |
\(f\) |
Number of cycles per unit time |
Phase |
\(\varphi\) |
Horizontal shift |
12.3. Part 2 – Fourier series#
Any periodic signal can be expressed as a sum of sinusoidal waves (Fourier series):
where \(F\) is the maximum frequency, \(P\) the period, and \(A_k\), \(\varphi_k\) the amplitude and phase at frequency \(k\).
The amplitudes and phases are computed from the signal via the Fourier coefficients:
12.3.1. The box function#
A classic example is the box (rectangular) function:
Its Fourier series contains only odd harmonics, and the coefficients decay as \(1/k\). As we add more terms, the reconstruction improves but Gibbs ringing remains at the edges.
12.4. Part 3 – Frequency spectrum (1D FFT)#
Instead of computing Fourier coefficients term by term, the discrete Fourier transform (DFT) computes all of them at once:
The fast Fourier transform (FFT) computes this in \(O(N \log N)\) rather than \(O(N^2)\). The frequency spectrum (plot of \(|F(k)|\) vs \(k\)) reveals which frequencies are present in the signal.
12.4.1. Nyquist sampling theorem#
If a signal contains no frequencies higher than \(W\) Hz, it is fully determined by samples taken every \(1/(2W)\) seconds:
The Nyquist frequency \(f_N = 1/(2\Delta t)\) is the highest frequency measurable at a given sampling rate. In EM images, the pixel size \(\Delta x\) sets \(f_N = 1/(2\Delta x)\), and only features larger than \(2\Delta x\) can be resolved.
Question 1
Given a detector that records 15 frames per 100 s. What is the maximum frequency component that can be recovered? What does this imply for the pixel size required to resolve a feature of width 2 Å in a cryo-EM image?
12.5. Part 4 – 2D Fourier analysis#
Images are 2D signals. A 2D sinusoidal wave has the form:
with separate spatial frequencies \(f_x\) (cycles per pixel along \(x\)) and \(f_y\) (cycles per pixel along \(y\)). The 2D Fourier transform of an image gives the amplitude and phase at every spatial frequency \((f_x, f_y)\).
12.5.1. Properties#
Translation property: Shifting an image in real space does not change the amplitude spectrum — only the phase spectrum.
Rotation property: Rotating an image rotates its Fourier transform by the same angle.
The interactive below shows 2D sine waves at different spatial frequencies, and the effects of translation and rotation on the Fourier transform of a real image.
12.5.2. 2D FT of real images#
Different image features produce characteristic Fourier signatures. A ring in real space produces a ring in Fourier space; a line produces a perpendicular line through the origin.
12.5.3. Translation and rotation properties#
Question 2
Play with the translation and rotation of the image and observe the amplitude spectrum. What changes and what stays the same in each case? Can you explain why?
12.6. Part 5 – The convolution theorem#
Convolution describes how one function modifies another by sweeping over all positions:
In image processing, convolving an image with a kernel (a small matrix) applies a local operation: smoothing, sharpening, or edge detection. The convolution theorem states:
Convolution in real space equals multiplication in Fourier space. This makes filtering in Fourier space much faster for large kernels than direct spatial convolution.
12.6.1. Common kernels#
12.6.2. Interactive kernel#
Question 3
What does the FT of a Gaussian blur kernel look like? What does this tell you about which spatial frequencies are attenuated? How does this compare to the Laplacian kernel?
12.7. Part 6 – Low-pass and high-pass filtering in Fourier space#
We can design filters by directly modifying the Fourier transform: set Fourier coefficients outside (or inside) a radius to zero before inverse-transforming. This is equivalent to convolving with the Fourier transform of the mask function.
12.8. Part 7 – The contrast transfer function (CTF)#
In phase-contrast electron microscopy, the image intensity is related to the projected potential of the specimen through the contrast transfer function (CTF). The CTF modulates the Fourier amplitudes as a function of spatial frequency \(k\):
where:
Symbol |
Quantity |
|---|---|
\(k\) |
spatial frequency (Å⁻¹) |
\(C_s\) |
spherical aberration coefficient |
\(\lambda\) |
relativistic electron wavelength |
\(\Delta_f\) |
defocus (positive = underfocus) |
\(\Delta\varphi\) |
additional phase shift (e.g. from phase plate) |
The electron wavelength depends on the accelerating voltage \(V\) (in eV):
Defocusing causes phase reversals at specific spatial frequencies (the CTF zeros). Frequencies near these zeros are not faithfully transferred to the image.
12.8.1. CTF correction#
To recover the true image from a CTF-modulated observation, we need to correct for the CTF. Three standard methods:
Method 1 – Phase flipping: Multiply Fourier amplitudes by the sign of the CTF. Brings all amplitudes to positive, but does not correct their magnitudes.
Method 2 – Full CTF correction with threshold: Divide by the CTF, but ignore frequencies where \(|\text{CTF}| < \epsilon\) (near zeros) to avoid division instability.
Method 3 – Wiener filter: Divide by CTF with regularisation: $\( \hat{F}(k) = \frac{F_\text{obs}(k) \cdot \text{CTF}(k)}{\text{CTF}(k)^2 + \text{SNR}^{-1}} \)$
Question 4
Compare the three CTF correction methods. What are the trade-offs?
Phase flipping: what information is still lost?
Full CTF correction with threshold: what happens to frequencies near the CTF zeros?
Wiener filter: what is the optimal SNR for your simulated data?
12.9. Summary#
Topic |
Key concept |
|---|---|
Sinusoidal waves |
\(f(t) = A\cos(2\pi f t - \varphi)\); three parameters: \(A\), \(f\), \(\varphi\) |
Fourier series |
Any periodic signal = sum of sinusoids; coefficients via \(a_k\), \(b_k\) integrals |
FFT |
Fast algorithm (\(O(N\log N)\)) for discrete FT; frequency spectrum = $ |
Nyquist |
Sampling at \(\Delta t\) can recover frequencies up to \(1/(2\Delta t)\) |
2D FT |
Generalises 1D; amplitude spectrum = $ |
Convolution theorem |
\(\mathcal{F}\{f*g\} = \mathcal{F}\{f\}\cdot\mathcal{F}\{g\}\); filter in Fourier space |
CTF |
\(-\sin(\gamma(k))\); phase reversals at zeros; correct by phase flip, division, or Wiener filter |