SPC

class colibri.optics.spc.SPC(input_shape, n_measurements=256, trainable=False, initial_ca=None, **kwargs)[source]

Bases: BaseOpticsLayer

Single Pixel Camera (SPC).

Mathematically, SPC systems 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 SPC, \(\xset = \mathbb{R}^{L \times M \times N}\) and \(\yset = \mathbb{R}^{L \times S}\), and \(\forwardLinear_{\learnedOptics}:\xset\rightarrow \yset\) is the forward single pixel acquisition and the modulation of the coded aperture, such as

\[\begin{split}\begin{align*} \forwardLinear_{\learnedOptics}: \mathbf{x} &\mapsto \mathbf{y} \\ \mathbf{y}_{s, l} &= \sum_{i=1}^{M}\sum_{j = 1}^{N} \learnedOptics_{s, i, j} \mathbf{x}_{l, i, j} \end{align*}\end{split}\]

with \(\learnedOptics \in \{0,1\}^{S \times M \times N}\) coded aperture, with \(S\) the number of measurements and \(L\) the number of spectral bands.

Parameters:
  • input_shape (tuple) – Tuple, shape of the input image (L, M, N).

  • n_measurements (int) – Number of measurements.

  • trainable (bool) – Boolean, if True the coded aperture is trainable

  • initial_ca (torch.Tensor) – Initial coded aperture with shape (S, M*N)

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

Forward propagation through the SPC model.

Parameters:

x (torch.Tensor) – Input image tensor of size (B, L, M, N).

Returns:

Output tensor after measurement of size (B, S, L).

Return type:

torch.Tensor