spyrit.core.meas.DynamicHadamSplit2d.measure_H

DynamicHadamSplit2d.measure_H(x: tensor)[source]

Simulates noiseless measurements leveraging the Kronecker structure of the 2d Hadamard transform H.

Each measurement is acquired as, for \(k \in \{1, ..., M\}\):

\[m_k = \sum_{i, j} H_{1d}[r_k, i] x_{t=k}[i, j] H_{1d}[j, c_k],\]

where \(H_{1d} \in \mathbb{R}^{h\times h}\) is the 1d Hadamard matrix, \(x_{t=k} \in \mathbb{R}^{h \times h}\) is \(k^{\rm{th}}\) frame of the video, \((r_k, c_k) = (\left \lfloor k / h \right\rfloor, k \bmod h)\) are the row and column indices of the 1d Hadamard matrix used to generate the 2d Hadamard pattern used at time \(t=k\).

Example:
>>> import torch
>>> from spyrit.core.noise import Poisson
>>> from spyrit.core.meas import DynamicHadamSplit2d
>>>
>>> x = torch.rand([1, 2 * 32**2, 3, 40, 40])  # dummy RGB video with 2 * 32**2 frames of size 40x40
>>> alpha = 5  # noise level
>>> noise_op = Poisson(alpha=alpha, g=1/alpha)
>>> meas_op = DynamicHadamSplit2d(time_dim=1, h=32, M=32**2, img_shape=(40, 40), noise_model=noise_op)  # acquisition with 2*M splitted Hadamard patterns of size hxh.
>>> print(meas_op)
DynamicHadamSplit2d(
  (noise_model): Poisson()
)
>>>
>>> m = meas_op.measure_H(x)  # simulate noiseless dynamic measurements from matrix H
>>> print(m.shape)
torch.Size([1, 3, 1024])