magni.imaging.dictionaries.utils module¶
Module providing support functionality for the dictionaries subpackage.
Routine listings¶
- get_function_handle(type_, transform)
- Function to get a function handle to a transform method.
- get_transform_names()
- Function to get a tuple of names of the available transforms.
-
magni.imaging.dictionaries.utils.
get_function_handle
(type_, transform)[source]¶ Return a function handle to a given transform method.
Parameters: - type_ ({‘matrix’, ‘transform_matrix’, ‘visualisation’}) – Identifier of the type of method to return a handle to.
- transform (str) – Identifier of the transform method to return a handle to.
Returns: f_handle (function) – Handle to transform.
Notes
The available types are:
- matrix : 2D transform matrix object.
- transform_matrix : 1D transform matrix.
- visualisation : Coefficient visualisation preparation function.
Examples
For example, return a handle to the matrix method for a DCT:
>>> from magni.imaging.dictionaries.utils import get_function_handle >>> get_function_handle('matrix', 'DCT').__name__ 'get_DCT'
or return a handle to the 1D DCT transform matrix method:
>>> get_function_handle('transform_matrix', 'DCT').__name__ 'get_DCT_transform_matrix'
or return a handle to the visualisation method for a DFT:
>>> get_function_handle('visualisation', 'DFT').__name__ 'visualise_DFT'
-
magni.imaging.dictionaries.utils.
get_transform_names
()[source]¶ Return a tuple of names of the available transforms.
Returns: names (tuple) – The tuple of names of available transforms. Examples
For example, get transform names and extract ‘DCT’ and ‘DFT’
>>> from magni.imaging.dictionaries.utils import get_transform_names >>> names = get_transform_names() >>> tuple(sorted(name for name in names if name in ('DCT', 'DFT'))) ('DCT', 'DFT')
and a handle to corresponding visualisation method for the DCT
>>> from magni.imaging.dictionaries.utils import get_function_handle >>> f_handles = tuple(get_function_handle('visualisation', name) ... for name in names) >>> tuple(f_h.__name__ for f_h in f_handles if 'DCT' in f_h.__name__) ('visualise_DCT',)