mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-05 01:42:45 +08:00
Add example to polygon drawing function
This commit is contained in:
@@ -112,6 +112,26 @@ def polygon(y, x, shape=None):
|
||||
May be used to directly index into an array, e.g.
|
||||
``img[rr, cc] = 1``.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.draw import polygon
|
||||
>>> img = np.zeros((10, 10), dtype=np.uint8)
|
||||
>>> x = np.array([1, 7, 4, 1])
|
||||
>>> y = np.array([1, 2, 8, 1])
|
||||
>>> rr, cc = polygon(y, x)
|
||||
>>> img[rr, cc] = 1
|
||||
>>> img
|
||||
array([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
|
||||
[0, 0, 1, 1, 1, 1, 1, 0, 0, 0],
|
||||
[0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
|
||||
[0, 0, 0, 1, 1, 1, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8)
|
||||
|
||||
"""
|
||||
|
||||
cdef Py_ssize_t nr_verts = x.shape[0]
|
||||
|
||||
Reference in New Issue
Block a user