nanomesh.image

Classes:

SliceViewer(data[, update_delay])

Simple slice viewer for volumes using matplotlib.

Functions:

extract_rectangle(image, *, bbox)

Extract rectangle from image.

minimum_bounding_rectangle(coords)

Find the smallest bounding rectangle for a set of coordinates.

show_image(image, *[, ax, title])

Simple function to plot an image using matplotlib.

class nanomesh.image.SliceViewer(data: ndarray, update_delay: int = 50, **kwargs)[source]

Bases: object

Simple slice viewer for volumes using matplotlib.

Parameters
  • data ((i,j,k) numpy.ndarray) – Volume to display.

  • update_delay (int) – Minimum delay between events in milliseconds. Reduces lag by limiting the Limit update rate.

  • **kwargs – These parametes are passed to first call of SliceViewer.update().

Methods:

get_slice(*, index, along)

Get slice associated with index along given axes.

interact()

Call interactive ipywidgets widget.

update(index, along)

Update the image in place.

get_slice(*, index: int, along: str)[source]

Get slice associated with index along given axes.

interact()[source]

Call interactive ipywidgets widget.

update(index: int, along: str)[source]

Update the image in place.

nanomesh.image.extract_rectangle(image: ndarray, *, bbox: ndarray)[source]

Extract rectangle from image.

The image is straightened using an Euclidean transform via skimage.transform.EuclideanTransform().

Parameters
  • image ((i,j) numpy.ndarray) – Image to extract rectangle from.

  • bbox ((4,2) numpy.ndarray) – Four coordinate describing the corners of the bounding box.

Returns

warped – The warped input image extracted from the bounding box.

Return type

(i,j) numpy.ndarray

nanomesh.image.minimum_bounding_rectangle(coords: ndarray) ndarray[source]

Find the smallest bounding rectangle for a set of coordinates.

Based on: https://stackoverflow.com/a/33619018

Parameters

coords ((n,2) numpy.ndarray) – List of coordinates.

Returns

bbox_coords – List of coordinates representing the corners of the bounding box.

Return type

(4,2) numpy.ndarray

nanomesh.image.show_image(image, *, ax: Optional[Axes] = None, title: Optional[str] = None, **kwargs) Axes[source]

Simple function to plot an image using matplotlib.

Parameters
  • image ((i,j) numpy.ndarray) – Image to display.

  • ax (matplotlib.axes.Axes, optional) – Axes to use for plotting.

  • title (str, optional) – Title for the plot.

  • **kwargs – These parameters are passed to plt.imshow.

Returns

ax

Return type

matplotlib.axes.Axes