mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-30 19:43:00 +08:00
Merge pull request #938 from sciunto/draw
Ellipse should not return coordinates outside of the image (closes #832)
This commit is contained in:
@@ -60,7 +60,7 @@ def ellipse(cy, cx, yradius, xradius, shape=None):
|
||||
cc += cx - xradius
|
||||
|
||||
if shape is not None:
|
||||
_coords_inside_image(rr, cc, shape)
|
||||
return _coords_inside_image(rr, cc, shape)
|
||||
|
||||
return rr, cc
|
||||
|
||||
|
||||
@@ -325,6 +325,33 @@ def test_ellipse():
|
||||
assert_array_equal(img, img_)
|
||||
|
||||
|
||||
def test_ellipse_with_shape():
|
||||
img = np.zeros((15, 15), 'uint8')
|
||||
|
||||
rr, cc = ellipse(7, 7, 3, 10, shape=img.shape)
|
||||
img[rr, cc] = 1
|
||||
|
||||
img_ = np.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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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, 0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
|
||||
)
|
||||
|
||||
assert_array_equal(img, img_)
|
||||
|
||||
|
||||
def test_ellipse_perimeter_dot_zeroangle():
|
||||
# dot, angle == 0
|
||||
img = np.zeros((30, 15), 'uint8')
|
||||
|
||||
Reference in New Issue
Block a user