Skip to content

Commit

Permalink
Merge pull request scikit-image#2303 from sciunto/mdmueller-cython-wr…
Browse files Browse the repository at this point in the history
…appers2

Made Python wrappers for public Cython functions
  • Loading branch information
soupault authored Sep 26, 2016
2 parents 9a516ed + ab5dc99 commit 5d0352f
Show file tree
Hide file tree
Showing 13 changed files with 682 additions and 190 deletions.
10 changes: 6 additions & 4 deletions skimage/draw/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from .draw import circle, ellipse, polygon_perimeter, set_color
from .draw import (circle, ellipse, set_color, polygon_perimeter,
line, line_aa, polygon, ellipse_perimeter,
circle_perimeter, circle_perimeter_aa,
bezier_curve)
from .draw3d import ellipsoid, ellipsoid_stats
from ._draw import (line, line_aa, polygon, ellipse_perimeter,
circle_perimeter, circle_perimeter_aa,
_bezier_segment, bezier_curve)
from ._draw import _bezier_segment

__all__ = ['line',
'line_aa',
'bezier_curve',
'polygon',
'polygon_perimeter',
'ellipse',
'ellipse_perimeter',
'ellipsoid',
Expand Down
24 changes: 12 additions & 12 deletions skimage/draw/_draw.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def _coords_inside_image(rr, cc, shape, val=None):
return rr[mask], cc[mask], val[mask]


def line(Py_ssize_t y0, Py_ssize_t x0, Py_ssize_t y1, Py_ssize_t x1):
def _line(Py_ssize_t y0, Py_ssize_t x0, Py_ssize_t y1, Py_ssize_t x1):
"""Generate line pixel coordinates.
Parameters
Expand Down Expand Up @@ -125,7 +125,7 @@ def line(Py_ssize_t y0, Py_ssize_t x0, Py_ssize_t y1, Py_ssize_t x1):
return np.asarray(rr), np.asarray(cc)


def line_aa(Py_ssize_t y0, Py_ssize_t x0, Py_ssize_t y1, Py_ssize_t x1):
def _line_aa(Py_ssize_t y0, Py_ssize_t x0, Py_ssize_t y1, Py_ssize_t x1):
"""Generate anti-aliased line pixel coordinates.
Parameters
Expand Down Expand Up @@ -227,7 +227,7 @@ def line_aa(Py_ssize_t y0, Py_ssize_t x0, Py_ssize_t y1, Py_ssize_t x1):
1. - np.array(val, dtype=np.float))


def polygon(y, x, shape=None):
def _polygon(y, x, shape=None):
"""Generate coordinates of pixels within polygon.
Parameters
Expand Down Expand Up @@ -305,7 +305,7 @@ def polygon(y, x, shape=None):
return np.array(rr, dtype=np.intp), np.array(cc, dtype=np.intp)


def circle_perimeter(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t radius,
def _circle_perimeter(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t radius,
method='bresenham', shape=None):
"""Generate circle perimeter coordinates.
Expand Down Expand Up @@ -416,7 +416,7 @@ def circle_perimeter(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t radius,
np.array(cc, dtype=np.intp) + cx)


def circle_perimeter_aa(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t radius,
def _circle_perimeter_aa(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t radius,
shape=None):
"""Generate anti-aliased circle perimeter coordinates.
Expand Down Expand Up @@ -502,8 +502,8 @@ def circle_perimeter_aa(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t radius,
np.array(val, dtype=np.float))


def ellipse_perimeter(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t yradius,
Py_ssize_t xradius, double orientation=0, shape=None):
def _ellipse_perimeter(Py_ssize_t cy, Py_ssize_t cx, Py_ssize_t yradius,
Py_ssize_t xradius, double orientation=0, shape=None):
"""Generate ellipse perimeter coordinates.
Parameters
Expand Down Expand Up @@ -766,17 +766,17 @@ def _bezier_segment(Py_ssize_t y0, Py_ssize_t x0,
err += dy

# Plot line
rr, cc = line(x0, y0, x2, y2)
rr, cc = _line(x0, y0, x2, y2)
px.extend(rr)
py.extend(cc)

return np.array(py, dtype=np.intp), np.array(px, dtype=np.intp)


def bezier_curve(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, shape=None):
def _bezier_curve(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, shape=None):
"""Generate Bezier curve coordinates.
Parameters
Expand Down
Loading

0 comments on commit 5d0352f

Please sign in to comment.