diff --git a/skimage/draw/_draw.pyx b/skimage/draw/_draw.pyx index 192fb0a2..94abe627 100644 --- a/skimage/draw/_draw.pyx +++ b/skimage/draw/_draw.pyx @@ -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]