tangram.Image

class tangram.Image(array, *, layers=[], name=None)[source]

Class holding an Image.

This class holds the pixels data and a list like attribute with all the image layers.

The image pixel indexing is similar to that of a matrix items. The image coordinate system has the origin at the top-left pixel, and any pixel is indexed by an ordinate pair (r, c), where r is the pixel row and c is the pixel column. Both rows and columns start the counting at zero.

Attention

The Tangram Image adopts the same coordinate system conventions of scikit-image, using underlying the indexing machinery of NumPy ndarrays.

Once created, the image pixels data will be copied to an internal buffer and marked immutable, changes on the original data will not reflect on the Image content. Its content however can be read-only accessed using the [] operator.

Signals

mouse_click

Emitted by a mouse click on the image.

Parameters:
  • pos (Tuple[float, float]) – The mouse position (r, c)
  • button (tangram.widget.MouseButton) – The MouseButton pressed.
  • input_state (tangram.widget.InputState) – The mouse + keyboard state.

Attributes

layers

A list like object with the image layers.

shape

A tuple with the image shape (rows, columns[, channels]). On greyscale images the channels item will not be present.

Methods

__init__(array, *, layers=[], name=None)[source]

The NumPy ndarray array data will be copied to an internal buffer, and any change on the original data will not be visible.

Parameters:
  • array (Any) – A NumPy ndarray with the image data.
  • layers (Iterable[Any]) – The initial image layers.
  • name (Optional[str]) – The tan name.
Return type:

None