magni.imaging.measurements._visualisation module

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

Routine listings

plot_pattern(l, w, coords, mode, output_path=None)
Function for visualising a scan pattern.
plot_pixel_mask(h, w, pixels, output_path=None)
Function for visualising a pixel mask obtained from a scan pattern.
magni.imaging.measurements._visualisation.plot_pattern(l, w, coords, mode, output_path=None)[source]

Display a plot that shows the pattern given by a set of coordinates.

The pattern given by the coords is displayed on an w x l area. If mode is ‘surface’, l and w are regarded as measured in meters. If mode is ‘image’, l and w are regarded as measured in pixels. The coords are marked by filled circles and connected by straight dashed lines.

Parameters:
  • l (float or int) – The length/height of the area. If mode is ‘surface’, it must be a float. If mode is ‘image’, it must be an integer.
  • w (float or int) – The width of the area. If mode is ‘surface’, it must be a float. If mode is ‘image’, it must be an integer.
  • coords (ndarray) – The 2D array of pixels that make up the mask. Each row is a coordinate pair (x, y).
  • mode ({‘surface’, ‘image’}) – The display mode that dertermines the axis labeling and the type of l and w.
  • output_path (str, optional) – Path (including file type extension) under which the plot is saved (the default value is None which implies, that the plot is not saved).

Notes

The resulting plot is displayed in a figure using matplotlib‘s pyplot.plot.

Examples

For example,

>>> import numpy as np
>>> from magni.imaging.measurements import plot_pattern
>>> l = 3
>>> w = 3
>>> coords = np.array([[0, 0], [1, 1], [2, 1]])
>>> mode = 'image'
>>> plot_pattern(l, w, coords, mode)
magni.imaging.measurements._visualisation.plot_pixel_mask(h, w, pixels, output_path=None)[source]

Display a binary image that shows the given pixel mask.

A black image with w x h pixels is created and the pixels are marked with white.

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.
  • output_path (str, optional) – Path (including file type extension) under which the plot is saved (the default value is None which implies, that the plot is not saved).

Notes

The resulting image is displayed in a figure using magni.imaging.visualisation.imshow.

Examples

For example,

>>> import numpy as np
>>> from magni.imaging.measurements import plot_pixel_mask
>>> h = 3
>>> w = 3
>>> pixels = np.array([[0, 0], [1, 1], [2, 1]])
>>> plot_pixel_mask(h, w, pixels)