Module providing a multi domain image class.
- Provide access to an image in the domains of a compressed sensing context.
Provide access to an image in the domains of a compressed sensing context.
Given a measurement matrix and a dictionary, an image can be supplied in either the measurement domain, the image domain, or the coefficient domain. This class then provides access to the image in all three domains.
- Phi (magni.utils.matrices.Matrix, magni.utils.matrices.MatrixCollection,) – or numpy.ndarray The measurement matrix.
- Psi (magni.utils.matrices.Matrix, magni.utils.matrices.MatrixCollection,) – or numpy.ndarray The dictionary.
The image is only converted to other domains than the supplied when the the image is requested in another domain. The image is, however, stored in up to three versions internally in order to reduce computation overhead. This may introduce a memory overhead.
Define a measurement matrix which skips every other sample:
>>> import numpy as np, magni >>> func = lambda vec: vec[::2] >>> func_T = lambda vec: np.float64([vec, 0, vec]).reshape(3, 1) >>> Phi = magni.utils.matrices.Matrix(func, func_T, (), (2, 3))
Define a dictionary which is simply a rotated identity matrix:
>>> v = np.sqrt(0.5) >>> Psi = np.float64([[ v, -v, 0], ... [ v, v, 0], ... [ 0, 0, 1]])
Instantiate the current class to handle domains:
>>> from magni.imaging.domains import MultiDomainImage >>> domains = MultiDomainImage(Phi, Psi)
An image can the be supplied in any domain and likewise retrieved in any domain. For example, setting the measurements and getting the coefficients:
>>> domains.measurements = np.ones(2).reshape(-1, 1) >>> np.set_printoptions(suppress=True) >>> print(domains.coefficients) [[ 0.70710678] [-0.70710678] [ 1. ]]
Or setting the coefficients and getting the image:
>>> domains.coefficients = np.ones(3).reshape(-1, 1) >>> print(domains.image) [[ 0. ] [ 1.41421356] [ 1. ]]
Or setting the image and getting the measurements:
>>> domains.image = np.ones(3).reshape(-1, 1) >>> print(domains.measurements) [[ 1.] [ 1.]]
Get the image in the coefficient domain.
Returns: coefficients (numpy.ndarray) – The dictionary coefficients of the image.
Get the image in the image domain.
Returns: image (numpy.ndarray) – The image.
Get the image in the measurement domain.
Returns: measurements (numpy.ndarray) – The measurements of the image.