Inline helper functions of label

This commit is contained in:
Johannes Schönberger
2013-04-09 19:49:14 +02:00
parent 40e6ada311
commit 4e87f3f54e
2 changed files with 7 additions and 8 deletions
+3 -3
View File
@@ -5,6 +5,6 @@ DTYPE = cnp.intp
ctypedef cnp.intp_t DTYPE_t
cdef DTYPE_t find_root(DTYPE_t *forest, DTYPE_t n)
cdef set_root(DTYPE_t *forest, DTYPE_t n, DTYPE_t root)
cdef join_trees(DTYPE_t *forest, DTYPE_t n, DTYPE_t m)
cdef link_bg(DTYPE_t *forest, DTYPE_t n, DTYPE_t *background_node)
cdef void set_root(DTYPE_t *forest, DTYPE_t n, DTYPE_t root)
cdef void join_trees(DTYPE_t *forest, DTYPE_t n, DTYPE_t m)
cdef void link_bg(DTYPE_t *forest, DTYPE_t n, DTYPE_t *background_node)
+4 -5
View File
@@ -39,7 +39,7 @@ cdef DTYPE_t find_root(DTYPE_t *forest, DTYPE_t n):
return root
cdef set_root(DTYPE_t *forest, DTYPE_t n, DTYPE_t root):
cdef inline void set_root(DTYPE_t *forest, DTYPE_t n, DTYPE_t root):
"""
Set all nodes on a path to point to new_root.
@@ -53,7 +53,7 @@ cdef set_root(DTYPE_t *forest, DTYPE_t n, DTYPE_t root):
forest[n] = root
cdef join_trees(DTYPE_t *forest, DTYPE_t n, DTYPE_t m):
cdef inline void join_trees(DTYPE_t *forest, DTYPE_t n, DTYPE_t m):
"""Join two trees containing nodes n and m.
"""
@@ -70,7 +70,7 @@ cdef join_trees(DTYPE_t *forest, DTYPE_t n, DTYPE_t m):
set_root(forest, m, root)
cdef link_bg(DTYPE_t *forest, DTYPE_t n, DTYPE_t *background_node):
cdef inline void link_bg(DTYPE_t *forest, DTYPE_t n, DTYPE_t *background_node):
"""
Link a node to the background node.
@@ -80,8 +80,8 @@ cdef link_bg(DTYPE_t *forest, DTYPE_t n, DTYPE_t *background_node):
join_trees(forest, n, background_node[0])
# Connected components search as described in Fiorio et al.
# Connected components search as described in Fiorio et al.
def label(input, DTYPE_t neighbors=8, DTYPE_t background=-1):
"""Label connected regions of an integer array.
@@ -202,7 +202,6 @@ def label(input, DTYPE_t neighbors=8, DTYPE_t background=-1):
join_trees(forest_p, i*cols + j, i*cols + j - 1)
# Label output
cdef DTYPE_t ctr = 0
for i in range(rows):
for j in range(cols):