MATLAB examples for Fourier optics, microscopy, and computed tomography. Follow the numbered tutorials to go from a pupil function to simulated microscope images, or use the index to find a specific technique.
- Download the repository from Code → Download ZIP, or clone it with Git.
- Open the repository folder in MATLAB. Start with Tutorial 1 and click Run to calculate a focal-plane point spread function (PSF) from a circular pupil.
- Change the parameters near the top of the script and rerun it. Tutorials 2–4 extend the PSF model to axial propagation, confocal detection, and image formation.
Use MATLAB R2021b or later as a starting point. Extra toolbox, data, and hardware requirements are listed below.
| No. | MATLAB script | What it shows | Zhihu article (中文) |
|---|---|---|---|
| 1–4 | PSF and confocal imaging | ||
| 1 | 2D PSF | Compute the in-focus intensity from a circular pupil. | 理解并模拟 2D PSF |
| 2 | 3D PSF | Propagate the field through focus and inspect lateral and axial sections. | 模拟 3D PSF |
| 3 | Confocal PSF | Combine excitation and detection PSFs and compare the effect of a pinhole. | 宽场和共聚焦显微镜的 PSF |
| 4 | Image formation with a pinhole | Image a simulated 3D object with and without a pinhole, including Poisson noise. | 利用 PSF 模拟显微镜成像 |
| 5, 8 | Structured illumination (SIM) | ||
| 5 | Moiré fringes | Visualize how patterned illumination shifts sample frequencies. | SIM 成像原理 |
| 8 | Raw SIM images | Generate raw frames at multiple illumination phases and orientations and export TIFF stacks. | SIM 超分辨成像模拟 |
| 6–7 | Phase retrieval and wavefront aberrations | ||
| 6 | Phase retrieval | Design a phase-only hologram for a 3 × 3 spot array using Gerchberg–Saxton iterations. | Phase Retrieval 相位恢复 |
| 7 | Zernike aberrations | Apply Zernike phase terms in the pupil and compare the resulting focal PSFs. | Zernike 多项式模拟波前畸变 |
| 9–10 | STED microscopy | ||
| 9 | STED doughnut beam | Compare analytical doughnut intensity profiles for different beam waists. | STED 超分辨成像原理 |
| 10 | 2D STED PSF | Simulate a vortex-generated depletion beam and compare effective PSFs at several depletion strengths. | 2D STED 超分辨成像模拟 |
| 11 | Bessel beams and two-photon imaging | ||
| 11a | 3D Bessel beam | Propagate a hard annular pupil at 920 nm and compare ring radius and width in XY and XZ. | 贝塞尔光模拟 |
| 11b | Bessel two-photon scan | Scan the same 3D bead sample once in XY with a conventional focus and once with a Bessel focus. | 贝塞尔光模拟(双光子扫描) |
| MATLAB script | What it shows |
|---|---|
| 2D FFT animation | Builds a 2D Fourier transform from 1D row and column transforms and exports an MP4. |
| Unfiltered backprojection | Reconstructs a 2D phantom from a sinogram and compares the manual implementation with MATLAB's built-in result. |
| Filtered backprojection | Compares unfiltered backprojection with Ram–Lak and Shepp–Logan filtering. |
| Cone-beam CT forward projection | Simulates cone-beam projections of a 3D TIFF phantom on a GPU. See the requirements below before running. |
- Tutorial 4 uses Statistics and Machine Learning Toolbox for Poisson noise.
- Tutorial 6 and the 2D CT demos use Image Processing Toolbox.
- Cone-beam CT requires Parallel Computing Toolbox, a supported GPU, a multipage TIFF named
3D_phantom.tif, andimstackreadandimstackwriteon the MATLAB path. The phantom and those helper functions need to be supplied separately.
For questions about a script, open an issue or email Ethan Zhao.