This commit is contained in:
François Boulogne
2013-05-28 07:56:56 +02:00
parent f630327dc3
commit 192fb30f7f
2 changed files with 11 additions and 11 deletions
+4 -4
View File
@@ -19,7 +19,7 @@ from skimage.draw import line, polygon, circle, circle_perimeter, \
import numpy as np
import math
img = np.zeros((500, 500, 3), 'uint8')
img = np.zeros((500, 500, 3), dtype=np.uint8)
# draw line
rr, cc = line(120, 123, 20, 400)
@@ -49,11 +49,11 @@ rr, cc = circle_perimeter(120, 400, 15)
img[rr, cc, :] = (255, 0, 0)
# ellipses
rr, cc = ellipse_perimeter(120, 400, 60, 20, orientation=math.pi/4.)
rr, cc = ellipse_perimeter(120, 400, 60, 20, orientation=math.pi / 4.)
img[rr, cc, :] = (255, 0, 255)
rr, cc = ellipse_perimeter(120, 400, 60, 20, orientation=-math.pi/4.)
rr, cc = ellipse_perimeter(120, 400, 60, 20, orientation=-math.pi / 4.)
img[rr, cc, :] = (0, 0, 255)
rr, cc = ellipse_perimeter(120, 400, 60, 20, orientation=math.pi/2.)
rr, cc = ellipse_perimeter(120, 400, 60, 20, orientation=math.pi / 2.)
img[rr, cc, :] = (255, 255, 255)
plt.imshow(img)
+7 -7
View File
@@ -384,16 +384,16 @@ def ellipse_perimeter(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t yradius,
iyd = int(floor(ya * w + 0.5))
# Draw the 4 quadrants
rr, cc = bezier_segment(iy0+iyd, ix0, iy0, ix0, iy0, ix0+ixd, 1-w)
rr, cc = bezier_segment(iy0 + iyd, ix0, iy0, ix0, iy0, ix0 + ixd, 1-w)
py.extend(rr)
px.extend(cc)
rr, cc = bezier_segment(iy0+iyd, ix0, iy1, ix0, iy1, ix1-ixd, w)
rr, cc = bezier_segment(iy0 + iyd, ix0, iy1, ix0, iy1, ix1 - ixd, w)
py.extend(rr)
px.extend(cc)
rr, cc = bezier_segment(iy1-iyd, ix1, iy1, ix1, iy1, ix1-ixd, 1-w)
rr, cc = bezier_segment(iy1 - iyd, ix1, iy1, ix1, iy1, ix1 - ixd, 1-w)
py.extend(rr)
px.extend(cc)
rr, cc = bezier_segment(iy1-iyd, ix1, iy0, ix1, iy0, ix0+ixd, w)
rr, cc = bezier_segment(iy1 - iyd, ix1, iy0, ix1, iy0, ix0 + ixd, w)
py.extend(rr)
px.extend(cc)
@@ -401,9 +401,9 @@ def ellipse_perimeter(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t yradius,
def bezier_segment(Py_ssize_t y0, Py_ssize_t x0,
Py_ssize_t y1, Py_ssize_t x1,
Py_ssize_t y2, Py_ssize_t x2,
double weight):
Py_ssize_t y1, Py_ssize_t x1,
Py_ssize_t y2, Py_ssize_t x2,
double weight):
"""Generate Bezier segment coordinates.
Parameters