From 4834d7eb4d4d61487dde9f4d68c885d8355e5d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Scho=CC=88nberger?= Date: Mon, 23 Apr 2012 15:37:07 +0200 Subject: [PATCH] added example script for draw.polygon function --- doc/examples/plot_polygon.py | 39 ++++++++++++++++++++++++++++++++++++ skimage/setup.py | 1 + 2 files changed, 40 insertions(+) create mode 100644 doc/examples/plot_polygon.py diff --git a/doc/examples/plot_polygon.py b/doc/examples/plot_polygon.py new file mode 100644 index 00000000..6fa58906 --- /dev/null +++ b/doc/examples/plot_polygon.py @@ -0,0 +1,39 @@ +""" +============ +Fill polygon +============ + +This example shows how to fill polygons in images. +""" + +import matplotlib.pyplot as plt + +from skimage.draw import polygon +import numpy as np + + +img = np.zeros((500, 500), 'uint8') +polygon1 = np.array(( + (50, 50), + (150, 30), + (400, 100), + (300, 200), + (480, 400), + (100, 420), + (50, 50), +)) +polygon2 = np.array(( + (300, 300), + (480, 320), + (380, 430), + (220, 590), + (300, 300), +)) +rr, cc = polygon(polygon1, img.shape) +img[rr,cc] = 127 +rr, cc = polygon(polygon2, img.shape) +img[rr,cc] = 255 + +plt.gray() +plt.imshow(img) +plt.show() \ No newline at end of file diff --git a/skimage/setup.py b/skimage/setup.py index c26014f8..f555c89a 100644 --- a/skimage/setup.py +++ b/skimage/setup.py @@ -16,6 +16,7 @@ def configuration(parent_package='', top_path=None): config.add_subpackage('draw') config.add_subpackage('feature') config.add_subpackage('measure') + config.add_subpackage('geometry') def add_test_directories(arg, dirname, fnames): if dirname.split(os.path.sep)[-1] == 'tests':