SingleDOESpectral

class colibri.optics.doe.SingleDOESpectral(input_shape, height_map=None, aperture=None, pixel_size=1e-06, wavelengths=tensor([4.5000e-07, 5.5000e-07, 6.5000e-07]), source_distance=3, sensor_distance=0.05, sensor_spectral_sensitivity=<function ideal_panchromatic_sensor>, doe_refractive_index=None, approximation='fresnel', domain='fourier', trainable=False)[source]

Bases: BaseOpticsLayer

Single Diffractive Optical Element for Spectral Imaging

This optical system allow for the capture of spatio-spectral information through a wavelength dependent phase coding of light through a diffractive optical element.

Mathematically, this system can be described as follows:

\[\mathbf{y} = \forwardLinear_{\learnedOptics}(\mathbf{x}) + \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 SingleDOESpectral, \(\xset = \mathbb{R}^{L \times M \times N}\) and \(\yset = \mathbb{R}^{M \times N}\), and \(\forwardLinear_{\learnedOptics}:\xset\rightarrow \yset\) is the forward operator of the diffractive optical element, such as

\[\begin{split}\begin{align*} \forwardLinear_{\learnedOptics}: \mathbf{x} &\mapsto \mathbf{y} \\ \mathbf{y}_l &= \sum_{l=1}^{L} \psf(\learnedOptics)_l * \mathbf{x}_{, l} \end{align*}\end{split}\]

with \(\psf(\learnedOptics)_l\) the optical-point spread function (PSF) of the diffractive optical element at wavelength \(\lambda_l\), calculated using colibri.optics.functional.psf_single_doe_spectral()

Initializes the SingleDOESpectral layer.

Parameters:
  • input_shape (tuple) – The shape of the input spectral image in the format (L, M, N), where L is the number of spectral bands, M is the height, and N is the width.

  • height_map (torch.Tensor) – The height map of the DOE (Diffractive Optical Element). If None, a default conventional lens will be generated.

  • aperture (float) – The aperture of the DOE. If None, a circular aperture will be generated.

  • wavelengths (torch.Tensor) – The list of wavelengths corresponding to the spectral bands, by default torch.tensor([450, 550, 650])*1e-9.

  • source_distance (float) – The distance between the source and the DOE, by default is 3 meters.

  • sensor_distance (float) – The distance between the DOE and the sensor, by default is 50e-3 meters.

  • pixel_size (float) – The size of a pixel in the sensor.

  • sensor_spectral_sensitivity (torch.Tensor, optional) – The spectral sensitivity of the sensor. Defaults to ideal_panchromatic_sensor.

  • doe_refractive_index (float, optional) – The refractive index of the DOE. Defaults to None.

  • approximation (str, optional) – The approximation used to calculate the PSF. It can be “fresnel”, “angular_spectrum” or “fraunhofer”. Defaults to “fresnel”.

  • domain (str, optional) – The domain used to calculate the PSF. It can be “fourier” or “spatial”. Defaults to “fourier”.

  • trainable (bool, optional) – Whether the height map of the DOE is trainable or not. Defaults to False.

convolution(x, height_map)[source]

Forward operator of the SingleDOESpectral layer.

Parameters:

x (torch.Tensor) – Input tensor with shape (B, L, M, N)

Returns:

Output tensor with shape (B, 1, M, N)

Return type:

torch.Tensor

deconvolution(x, height_map, alpha=0.001)[source]

Backward operator of the SingleDOESpectral layer.

Parameters:

x (torch.Tensor) – Input tensor with shape (B, 1, M, N)

Returns:

Output tensor with shape (B, L, M, N)

Return type:

torch.Tensor

forward(x, type_calculation='forward')[source]

Performs the forward or backward operator according to the type_calculation

Parameters:
  • x (torch.Tensor) – Input tensor with shape (B, L, M, N)

  • type_calculation (str) – String, it can be “forward”, “backward” or “forward_backward”

Returns:

Output tensor with shape (B, L, M, N)

Return type:

torch.Tensor

Raises:

ValueError – If type_calculation is not “forward”, “backward” or “forward_backward”