CodedPhaseImaging
- class colibri.optics.phase_imaging.CodedPhaseImaging(input_shape, phase_mask=None, pixel_size=1e-06, wavelength=tensor([5.5000e-07]), sensor_distance=0.05, approximation='fresnel', trainable=False)[source]
Bases:
BaseOpticsLayer
Coded Phase Imaging
This optical system allow for the capture of a single intensity image of an object, and the subsequent reconstruction of the phase of the object. The system is composed of a phase mask that modulates the phase of the incoming light, and a sensor that captures the intensity of the light. The phase mask is designed to encode the phase information of the object in the intensity image. The phase of the object can be reconstructed from the intensity image using a phase retrieval algorithm.
Mathematically, this system can be described as follows:
\[\mathbf{y} = \vert \forwardLinear_{\learnedOptics}(\mathbf{x}) \vert^2+ \noise\]where \(\noise\) is the sensor noise, \(\mathbf{x} \in \xset\) is the input optical field, \(\mathbf{y} \in \yset\) are the acquired signal, for CodedPhaseImaging, \(\xset \in \mathbb{C}^{M \times N}\) and \(\yset \in \mathbb{R}^{M \times N}\), and \(\forwardLinear_{\learnedOptics}:\xset\rightarrow \yset\) is the forward operator of the optical system, which is defined as:
\[\begin{split}\begin{align*} \forwardLinear_{\learnedOptics}: \mathbf{x} &\mapsto \mathbf{y} \\ \mathbf{y} &= \left| \mathcal{P}_{(z, \lambda)}(\mathbf{x} \odot \learnedOptics) \right|^2 + \noise \end{align*}\end{split}\]with \(\learnedOptics \in \mathbb{C}^{M \times N}\) being the phase mask, \(\mathcal{P}_{(z, \lambda)}(\cdot)\) the forward operator of the optical system for a given wavelength \(\lambda\) and propagation distance \(z\),, \(\odot\) the element-wise product, and \(\noise\) the sensor noise.
Initializes the CodedPhaseImaging layer.
- Parameters:
input_shape (torch.Size) – The spatial shape of the input tensor, (M, N) used to define the phase mask shape.
phase_mask (torch.Tensor, optional) – The phase mask tensor. Defaults to None.
pixel_size (float, optional) – The size of each pixel in meters. Defaults to 1e-6.
wavelength (torch.Tensor, optional) – The wavelength of the light in meters. Defaults to torch.tensor([550])*1e-9.
sensor_distance (float, optional) – The distance from the sensor to the object in meters. Defaults to 50e-3.
approximation (str, optional) – The type of approximation to use (e.g., “fresnel”). Defaults to “fresnel”.
trainable (bool, optional) – Whether the phase mask is trainable. Defaults to False.
- intensity(x)[source]
Computes the intensity of the input tensor.
- Parameters:
x (torch.Tensor) – Input tensor with shape (B, M, N)
- Returns:
Intensity of the input tensor with shape (B, M, N)
- Return type:
torch.Tensor
- forward(x, type_calculation='forward', intensity=False)[source]
Performs the forward or backward operator according to the type_calculation
- Parameters:
x (torch.Tensor) – Input tensor with shape (B, M, N)
type_calculation (str) – String, it can be “forward”, “backward” or “forward_backward”
intensity (bool)
- Returns:
Output tensor with shape (B, M, N)
- Return type:
torch.Tensor
- Raises:
ValueError – If type_calculation is not “forward”, “backward” or “forward_backward”