IOLink Python 1.11.0
Loading...
Searching...
No Matches
iolink.iolink.NumpyInterop Class Reference
Inheritance diagram for iolink.iolink.NumpyInterop:

Public Member Functions

 order_from_numpy_array (np, dimensionsList, interpretation=ImageInterpretation.UNKNOWN, hasAlpha=False)
 
 from_numpy_array (np, axes_interpretation=ImageTypeId.UNKNOWN, interpretation=ImageInterpretation.UNKNOWN, hasAlpha=False)
 
 __init__ (self)
 

Static Public Member Functions

 to_numpy_array (image)
 
 order_to_numpy_array (image, dimensionsList)
 

Static Protected Member Functions

 _order_from_numpy_array (np, dimensionsList, interpretation, hasAlpha)
 
 _from_numpy_array (np, axes_interpretation, interpretation, hasAlpha)
 

Properties

 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
 

Detailed Description

Class which ensures inter-operability between ImageView and Numpy-arrays.

Member Function Documentation

◆ _from_numpy_array()

iolink.iolink.NumpyInterop._from_numpy_array (   np,
  axes_interpretation,
  interpretation,
  hasAlpha 
)
staticprotected
    Creates an ImageView from a numpy array.

    Dimensions order of numpy are kept in created ImageView.

    Data are not duplicated during this operation.
    :type np: PyObject
    :param np: Numpy array for which an ImageView adapter must be created
    :type axes_interpretation: :py:class:`ImageType`
    :param axes_interpretation: ImageType to apply to created ImageView
    :type interpretation: int
    :param interpretation: ImageInterpretation to apply to created ImageView
    :type hasAlpha: boolean
    :param hasAlpha: boolean to indicate if an alpha channel is present in given Numpy

    :rtype: :py:class:`ImageView`
    :return: an ImageView whose data are shared with original Numpy array, which has given ImageType

◆ _order_from_numpy_array()

iolink.iolink.NumpyInterop._order_from_numpy_array (   np,
  dimensionsList,
  interpretation,
  hasAlpha 
)
staticprotected
    Creates an ImageView from a numpy array by specifying axes order.

    Data are not duplicated during this operation.
    :type np: PyObject
    :param np: Numpy array for which an ImageView adapter must be created
    :type dimensionsList: int
    :param dimensionsList: list which indicates the axes order in given Numpy array
    :type interpretation: int
    :param interpretation: ImageInterpretation to apply to created ImageView
    :type hasAlpha: boolean
    :param hasAlpha: boolean to indicate if an alpha channel is present in given Numpy

    :rtype: :py:class:`ImageView`
    :return: an ImageView whose data are shared with original Numpy array and reorganized to match the given axes order

◆ from_numpy_array()

iolink.iolink.NumpyInterop.from_numpy_array (   np,
  axes_interpretation = ImageTypeId.UNKNOWN,
  interpretation = ImageInterpretation.UNKNOWN,
  hasAlpha = False 
)
Creates an ImageView from a numpy array.
Dimensions order of numpy are kept in created ImageView.
Data are not duplicated during this operation.
:type np: PyObject
:param np: Numpy array for which an ImageView adapter must be created
:type itype: :py:class:`ImageType`
:param itype: ImageType to apply to created ImageView

:rtype: :py:class:`ImageView`
:return: an ImageView whose data are shared with original Numpy array, which has given ImageType

◆ order_from_numpy_array()

iolink.iolink.NumpyInterop.order_from_numpy_array (   np,
  dimensionsList,
  interpretation = ImageInterpretation.UNKNOWN,
  hasAlpha = False 
)
Create an ImageView from Numpy,
Creates an ImageView from a numpy array by specifying axes order.
Data are not duplicated during this operation.
:type np: PyObject
:param np: Numpy array for which an ImageView adapter must be created
:type dimensionsList: int
:param dimensionsList: list which indicates the axes order in given Numpy array

:rtype: :py:class:`ImageView`
:return: an ImageView whose data are shared with original Numpy array and reorganized to match the given axes order

◆ order_to_numpy_array()

iolink.iolink.NumpyInterop.order_to_numpy_array (   image,
  dimensionsList 
)
static
    Creates a numpy array from an ImageView object by specifying axes order.

    The created numpy array will have the dimensions ordered as requested.
    It is only callable if ImageView has an axes interpretation different of UNKNWOWN.

    All dimensions in ImageView must be present in the given list.

    If ImageView data is vectorial, a new CHANNEL dimension will be created in final Numpy.
    This new CHANNEL dimension will be mandatory in input dimensions list.

    :type image: PyObject
    :param image: ImageView for which a Numpy adapter must be created.
    :type dimensionsList: int
    :param dimensionsList: list which indicates the axes order in final Numpy array.
    :raises: error if axes interpretation is UNKNOWN.
    :raises: error if at least one given dimension is not present in ImageView.
    :raises: error if given list does not mention all image dimensions or mention not present ones.
    :raises: error if image has invalid properties.

    :rtype: PyObject
    :return: a numpy array which points toward ImageView data.

◆ to_numpy_array()

iolink.iolink.NumpyInterop.to_numpy_array (   image)
static
    Creates a numpy array from an ImageView object.

    Dimensions are reordered, as numpy uses a different convention
    for dimension order.
    The canonic order for IOLink is XYZCT, but for numpy it is usually TZYXC.
    Example: a volume with a shape of (12, 4, 6) will result in a numpy
    array of shape (6, 4, 12).
    In addition, for vectorial data we need to add one dimension in numpy
    arrays, always at the end in the dimensions' order.
    Example: if the view below, with a shape of (12, 4, 6), was containing
    Vector3u16 data, it will result in a numpy array with a shape
    of (6, 4, 12, 3).

    When axes interpretation is UNKNOWN, dimensions are not reordered at all.
    Only vectorial data will result in a new dimension in last position.

    Data are not duplicated during this operation.
    :type image: PyObject
    :param image: ImageView for which a Numpy adapter must be created

    :rtype: PyObject
    :return: a numpy array which points toward ImageView data.

The documentation for this class was generated from the following file: