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.A = np.zeros((50,50)) !! [RUNBLOCK-ERROR] machinevisiontoolbox/__init__.py:22 AttributeError: Image is immutable: setting .A is not supported. Create a new Image from the modified array instead, for example Image(new_array, colororder=self.colororder). >>> img Image(size=(640, 426), dtype=uint8, nplanes=3, colororder=R:G:B, name='.../images/flowers1.png')