mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-28 18:11:52 +08:00
Inline helper functions of label
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user