Refactor pnpoly function in Cython and add to shared package

This commit is contained in:
Johannes Schönberger
2012-08-21 15:43:26 +02:00
parent a08779e06a
commit c471d475eb
8 changed files with 45 additions and 92 deletions
+2 -6
View File
@@ -3,11 +3,7 @@ import math
from libc.math cimport sqrt
cimport numpy as np
cimport cython
cdef extern from "../morphology/_pnpoly.h":
int pnpoly(int nr_verts, double *xp, double *yp,
double x, double y)
from skimage._shared.geometry cimport point_in_polygon
@cython.boundscheck(False)
@@ -119,7 +115,7 @@ def polygon(y, x, shape=None):
for r in range(minr, maxr+1):
for c in range(minc, maxc+1):
if pnpoly(nr_verts, cptr, rptr, c, r):
if point_in_polygon(nr_verts, cptr, rptr, c, r):
rr.append(r)
cc.append(c)
+1 -1
View File
@@ -15,7 +15,7 @@ def configuration(parent_package='', top_path=None):
cython(['_draw.pyx'], working_path=base_path)
config.add_extension('_draw', sources=['_draw.c'],
include_dirs=[get_numpy_include_dirs()])
include_dirs=[get_numpy_include_dirs(), '../shared'])
return config