spyrit.core.meas.DynamicLinear
- class spyrit.core.meas.DynamicLinear(H: tensor, Ord: tensor = None, meas_shape: tuple = None, img_shape: tuple = None)[source]
Bases:
_BaseSimulates the measurement of a moving object \(y = H \cdot x(t)\).
Computes linear measurements \(y\) from incoming images: \(y = Hx\), where \(H\) is a linear operator (matrix) and \(x\) is a batch of vectorized images representing a motion picture.
The class is constructed from a matrix \(H\) of shape \((M, N)\), where \(N\) represents the number of pixels in the image and \(M\) the number of measurements and the number of frames in the animated object.
Warning
For each call, there must be exactly as many images in \(x\) as there are measurements in the linear operator used to initialize the class.
- Args:
H(torch.tensor): measurement matrix (linear operator) with shape \((M, N)\).Ord(torch.tensor, optional): Order matrix used to reorder the rows of the measurement matrix \(H\). The first new row of \(H\) will correspond to the highest value in \(Ord\). Must contain \(M\) values. If some values repeat, the order is kept. Defaults to None.meas_shape(tuple, optional): Shape of the measurement patterns. Must be a tuple of two integers representing the height and width of the patterns. If not specified, the shape is suppposed to be a square image. If not, an error is raised. Defaults to None.img_shape(tuple, optional): Shape of the image. Must be a tuple of two integers representing the height and width of the image. If not specified, the shape is taken as equal to meas_shape. Setting this value is particularly useful when using an extended field of view.- Attributes:
H_static(torch.nn.Parameter): The learnable measurement matrix of shape \((M,N)\) initialized as \(H\).M(int): Number of measurements performed by the linear operator.N(int): Number of pixels in the image.h(int): Measurement pattern height.w(int): Measurement pattern width.meas_shape(tuple): Shape of the measurement patterns (height, width). Is equal to (self.h, self.w).img_h(int): Image height.img_w(int): Image width.img_shape(tuple): Shape of the image (height, width). Is equal to (self.img_h, self.img_w).H_dyn(torch.tensor): Dynamic measurement matrix \(H\). Must be set using the methodbuild_H_dyn()before being accessed.H(torch.tensor): Alias forH_dyn.H_dyn_pinv(torch.tensor): Dynamic pseudo-inverse measurement matrix \(H_{dyn}^\dagger\). Must be set using the methodbuild_H_dyn_pinv()before being accessed.H_pinv(torch.tensor): Alias forH_dyn_pinv.
Warning
The attributes
HandH_pinvare used as aliases forH_dynandH_dyn_pinv. If you want to access the static versions of the attributes, be sure to include the suffix _static.- Example:
>>> H_static = torch.rand([400, 1600]) >>> meas_op = DynamicLinear(H_static) >>> print(meas_op) DynamicLinear( (M): 400 (N): 1600 (H.shape): torch.Size([400, 1600]) (meas_shape): (40, 40) (H_dyn): False (img_shape): (40, 40) (H_pinv): False )
Reference: .. _MICCAI24:
[MaBP24] (MICCAI 2024 paper #883) Thomas Maitre, Elie Bretin, Romain Phan, Nicolas Ducros, Michaël Sdika. Dynamic Single-Pixel Imaging on an Extended Field of View without Warping the Patterns. 2024. hal-04533981
Methods
build_H_dyn(motion[, mode])Build the dynamic measurement matrix H_dyn.
build_H_dyn_pinv([reg, eta])Computes the pseudo-inverse of the dynamic measurement matrix H_dyn and stores it in the attribute H_dyn_pinv.
forward(x)Simulates the measurement of a motion picture \(y = H \cdot x(t)\).
pinv(x[, reg, eta])Computes the pseudo inverse solution \(y = H^\dagger x\).
reindex(x[, axis, inverse_permutation])Sorts a tensor along a specified axis using the indices tensor.