machinevisiontoolbox.Image.nonzero
- Image.nonzero()
Find non-zero pixel values as 2D coordinates
- Returns:
coordinates of non-zero pixels
- Return type:
ndarray(2,N)
The (u,v) coordinates are given as columns of the returned array.
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.nonzero() array([[3, 5, 7], [2, 4, 6]])
- References:
Robotics, Vision & Control for Python, Section 12.1.3.2, P. Corke, Springer 2023.
- Seealso: