machinevisiontoolbox.Image.flatnonzero
- Image.flatnonzero()
Find non-zero pixel values as 1D indices
- Returns:
index of non-zero pixels
- Return type:
ndarray(N)
The coordinates are given as 1D indices into a flattened version of the image.
Example:
>>> from machinevisiontoolbox import Image >>> import numpy as np >>> pix = np.zeros((10,10)); pix[2,3]=10; pix[4,5]=11; pix[6,7]=12 >>> img = Image(pix) >>> img.flatnonzero() array([23, 45, 67]) >>> img.view1d()[23] 10.0