# magni.imaging.measurements._util module¶

Module providing public functions for the magni.imaging.measurements subpackage.

## Routine listings¶

unique_pixels(coords)
Function for determining unique pixels from a set of coordinates.
magni.imaging.measurements._util.construct_pixel_mask(h, w, pixels)[source]

An image (2D array) of shape w x h is created where all pixels are marked True.

Parameters: h (int) – The height of the image in pixels. w (int) – The width of the image in pixels. pixels (ndarray) – The 2D array of pixels that make up the mask. Each row is a coordinate pair (x, y), such that coords has size len(pixels) x 2.

Examples

For example,

>>> import numpy as np
>>> h = 3
>>> w = 3
>>> pixels = np.array([[0, 0], [1, 1], [2, 1]])
array([[ True, False, False],
[False,  True,  True],
[False, False, False]], dtype=bool)

magni.imaging.measurements._util.unique_pixels(coords)[source]

Identify unique pixels from a set of coordinates.

The floating point coords are reduced to a unique set of integer pixels by flooring the floating point values.

Parameters: coords (ndarray) – The k floating point coordinates arranged into a 2D array where each row is a coordinate pair (x, y), such that coords has size k x 2. unique_pixels (ndarray) – The l <= k unique (integer) pixels, such that unique_pixels is a 2D array and has size l x 2.

Examples

For example,

>>> import numpy as np
>>> from magni.imaging.measurements import unique_pixels
>>> coords = np.array([[1.7, 1.0], [1.0, 1.2], [3.3, 4.3]])
>>> np.int_(unique_pixels(coords))
array([[1, 1],
[3, 4]])