Skip to main content

Module coded_diffraction

Module coded_diffraction 

Source
Expand description

Coded Diffraction Patterns (CDP) and Wirtinger-Flow phase retrieval (Candès, Li & Soltanolkotabi 2015).

In ptychography / coherent diffraction imaging one measures squared magnitudes of a modulated Fourier transform of the unknown (complex) signal x ∈ ℂⁿ:

y_{l} = | F (d_l ⊙ x) |² ,   l = 1, …, L

where d_l ∈ ℂⁿ is a random coded diffraction mask (a per-pixel modulation) and F is the unnormalised DFT. Stacking the L patterns gives m = L·n real, phaseless measurements — enough (for L ≳ 4) to recover x up to a global phase.

This module provides:

  • CodedDiffraction — a set of random complex masks defining the forward operator.
  • CodedDiffraction::forward — the phaseless measurement y = |F(d_l ⊙ x)|².
  • CodedDiffraction::wirtinger_flow — recovery by Wirtinger Flow: spectral initialisation followed by gradient descent on the intensity-domain loss ½ Σ_l ‖ |A_l x|² − y_l ‖² using the Wirtinger gradient.

Signals are stored as interleaved real/imaginary f64 pairs: x[2k] is Re(x_k), x[2k+1] is Im(x_k). All transforms are implemented from scratch (an O(n²) DFT), so the module depends only on std.

§References

  • E. J. Candès, X. Li & M. Soltanolkotabi (2015), “Phase Retrieval from Coded Diffraction Patterns”, Applied and Computational Harmonic Analysis 39(2):277-299.
  • E. J. Candès, X. Li & M. Soltanolkotabi (2015), “Phase Retrieval via Wirtinger Flow: Theory and Algorithms”, IEEE Trans. Information Theory 61(4):1985-2007.

Structs§

CodedDiffraction
A coded-diffraction forward operator: L random complex masks of length n.
WirtingerConfig
Configuration for Wirtinger Flow recovery.

Enums§

MaskKind
Distribution from which coded-diffraction mask entries are drawn.

Functions§

phase_aligned_error
Align two interleaved-complex vectors up to a global phase and return the relative reconstruction error ‖x̂ e^{iφ} − x‖ / ‖x‖ minimised over the global phase φ.