mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-03 13:11:25 +08:00
added example script for draw.polygon function
This commit is contained in:
@@ -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()
|
||||
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user