Image.A#

property Image.A: ndarray[source]#

Set/get the NumPy array containing pixel values

Getting

Returns:

image as a NumPy array

Return type:

ndarray(H,W) or ndarray(H,W,3)

Return a reference to the encapsulated NumPy array that holds the pixel values.

Setting

Replace the encapsulated NumPy array with another.

Example:

>>> from machinevisiontoolbox import Image
>>> import numpy as np
>>> img = Image.Read('flowers1.png')
>>> img
Image(size=(640, 426), dtype=uint8, nplanes=3, colororder=R:G:B, name='.../images/flowers1.png')
>>> type(img)
<class 'machinevisiontoolbox.Image'>
>>> type(img.A)
<class 'numpy.ndarray'>
>>> img = Image(np.zeros((50,50)))  # new image with a different array
>>> img
Image(size=(50, 50), dtype=float32)

Deprecated since version 2.0.0: Use array instead for accessing the NumPy image data and the Image constructor for creating a new Image with a different array.

Seealso:

array image