mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-27 19:48:43 +08:00
Fix typos from PR feedback
This commit is contained in:
committed by
Stefan van der Walt
parent
ad70668bc6
commit
45f8bd2e72
@@ -3,16 +3,15 @@ __all__ = ['polygon_clip', 'polygon_area']
|
||||
import numpy as np
|
||||
|
||||
|
||||
def polygon_clip(rr, cc, r0, c0, r1, c1):
|
||||
def polygon_clip(yp, xp, r0, c0, r1, c1):
|
||||
"""Clip a polygon to the given bounding box.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
yp, xp : (N,) ndarray of double
|
||||
Row and column coordinates of the polygon.
|
||||
ytop, xleft, ybottom, xright : double
|
||||
Coordinates of the bounding box. Note that the following
|
||||
must hold true: ``x_left < x_right`` and ``y_top < y_bottom``.
|
||||
(r0, c0), (r1, c1) : double
|
||||
Top-left and bottom-right coordinates of the bounding box.
|
||||
|
||||
Returns
|
||||
-------
|
||||
@@ -27,7 +26,7 @@ def polygon_clip(rr, cc, r0, c0, r1, c1):
|
||||
"""
|
||||
from matplotlib import path, transforms
|
||||
|
||||
poly = path.Path(np.vstack((rr, cc)).T, closed=True)
|
||||
poly = path.Path(np.vstack((yp, xp)).T, closed=True)
|
||||
clip_rect = transforms.Bbox([[r0, c0], [r1, c1]])
|
||||
|
||||
poly_clipped = poly.clip_to_bbox(clip_rect).to_polygons()[0]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from .draw import circle, ellipse, polygon_perimiter, set_color
|
||||
from .draw import circle, ellipse, polygon_perimeter, set_color
|
||||
from .draw3d import ellipsoid, ellipsoid_stats
|
||||
from ._draw import (line, line_aa, polygon, ellipse_perimeter,
|
||||
circle_perimeter, circle_perimeter_aa,
|
||||
|
||||
@@ -129,14 +129,14 @@ def circle(r, c, radius, shape=None):
|
||||
return ellipse(r, c, radius, radius, shape)
|
||||
|
||||
|
||||
def polygon_perimiter(cy, cx, shape=None, clip=False):
|
||||
"""Generate polygon perimiter coordinates.
|
||||
def polygon_perimeter(cy, cx, shape=None, clip=False):
|
||||
"""Generate polygon perimeter coordinates.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
y : (N,) ndarray
|
||||
cy : (N,) ndarray
|
||||
Y-coordinates of vertices of polygon.
|
||||
x : (N,) ndarray
|
||||
cx : (N,) ndarray
|
||||
X-coordinates of vertices of polygon.
|
||||
shape : tuple, optional
|
||||
Image shape which is used to determine maximum extents of output pixel
|
||||
@@ -156,9 +156,9 @@ def polygon_perimiter(cy, cx, shape=None, clip=False):
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.draw import polygon_perimiter
|
||||
>>> from skimage.draw import polygon_perimeter
|
||||
>>> img = np.zeros((10, 10), dtype=np.uint8)
|
||||
>>> rr, cc = polygon_perimiter([5, -1, 5, 10],
|
||||
>>> rr, cc = polygon_perimeter([5, -1, 5, 10],
|
||||
... [-1, 5, 11, 5],
|
||||
... shape=img.shape, clip=True)
|
||||
>>> img[rr, cc] = 1
|
||||
|
||||
@@ -2,7 +2,7 @@ from numpy.testing import assert_array_equal, assert_equal, assert_raises
|
||||
import numpy as np
|
||||
from skimage._shared.testing import test_parallel
|
||||
|
||||
from skimage.draw import (set_color, line, line_aa, polygon, polygon_perimiter,
|
||||
from skimage.draw import (set_color, line, line_aa, polygon, polygon_perimeter,
|
||||
circle, circle_perimeter, circle_perimeter_aa,
|
||||
ellipse, ellipse_perimeter,
|
||||
_bezier_segment, bezier_curve)
|
||||
@@ -809,7 +809,7 @@ def test_bezier_curve_shape():
|
||||
assert_array_equal(img, img_[shift:-shift, :])
|
||||
|
||||
|
||||
def test_polygon_perimiter():
|
||||
def test_polygon_perimeter():
|
||||
expected = np.array(
|
||||
[[1, 1, 1, 1],
|
||||
[1, 0, 0, 1],
|
||||
@@ -817,24 +817,24 @@ def test_polygon_perimiter():
|
||||
)
|
||||
out = np.zeros_like(expected)
|
||||
|
||||
rr, cc = polygon_perimiter([0, 2, 2, 0],
|
||||
rr, cc = polygon_perimeter([0, 2, 2, 0],
|
||||
[0, 0, 3, 3])
|
||||
|
||||
out[rr, cc] = 1
|
||||
assert_array_equal(out, expected)
|
||||
|
||||
out = np.zeros_like(expected)
|
||||
rr, cc = polygon_perimiter([-1, -1, 3, 3],
|
||||
rr, cc = polygon_perimeter([-1, -1, 3, 3],
|
||||
[-1, 4, 4, -1],
|
||||
shape=out.shape, clip=True)
|
||||
out[rr, cc] = 1
|
||||
assert_array_equal(out, expected)
|
||||
|
||||
assert_raises(ValueError, polygon_perimiter, [0], [1], clip=True)
|
||||
assert_raises(ValueError, polygon_perimeter, [0], [1], clip=True)
|
||||
|
||||
|
||||
def test_polygon_perimiter_outside_image():
|
||||
rr, cc = polygon_perimiter([-1, -1, 3, 3],
|
||||
def test_polygon_perimeter_outside_image():
|
||||
rr, cc = polygon_perimeter([-1, -1, 3, 3],
|
||||
[-1, 4, 4, -1], shape=(3, 4))
|
||||
assert_equal(len(rr), 0)
|
||||
assert_equal(len(cc), 0)
|
||||
|
||||
Reference in New Issue
Block a user