From bc3a8040939b78718d68ea5ed619ce42ed37c4ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 27 May 2013 21:17:26 +0200 Subject: [PATCH] Add example to ellipse drawing function --- skimage/draw/draw.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/skimage/draw/draw.py b/skimage/draw/draw.py index 2d525a89..f262b1c2 100644 --- a/skimage/draw/draw.py +++ b/skimage/draw/draw.py @@ -28,6 +28,25 @@ def ellipse(cy, cx, yradius, xradius, shape=None): May be used to directly index into an array, e.g. ``img[rr, cc] = 1``. + + Examples + -------- + >>> from skimage.draw import ellipse + >>> img = np.zeros((10, 10), dtype=np.uint8) + >>> rr, cc = ellipse(5, 5, 3, 4) + >>> 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, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 1, 1, 1, 1, 1, 0, 0], + [0, 0, 1, 1, 1, 1, 1, 1, 1, 0], + [0, 0, 1, 1, 1, 1, 1, 1, 1, 0], + [0, 0, 1, 1, 1, 1, 1, 1, 1, 0], + [0, 0, 0, 1, 1, 1, 1, 1, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=uint8) + """ dr = 1 / float(yradius)