Move implementation of label to measure submodule

This commit is contained in:
Stefan van der Walt
2014-05-08 18:04:03 +02:00
committed by Johannes Schönberger
parent e182931f15
commit d256b6f5b9
7 changed files with 76 additions and 5 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ from ._moments import moments, moments_central, moments_normalized, moments_hu
from .profile import profile_line
from .fit import LineModel, CircleModel, EllipseModel, ransac
from .block import block_reduce
from ..morphology.ccomp import label
from ._ccomp import label
__all__ = ['find_contours',
+3
View File
@@ -12,10 +12,13 @@ def configuration(parent_package='', top_path=None):
config = Configuration('measure', parent_package, top_path)
config.add_data_dir('tests')
cython(['_ccomp.pyx'], working_path=base_path)
cython(['_find_contours_cy.pyx'], working_path=base_path)
cython(['_moments.pyx'], working_path=base_path)
cython(['_marching_cubes_cy.pyx'], working_path=base_path)
config.add_extension('_ccomp', sources=['_ccomp.c'],
include_dirs=[get_numpy_include_dirs()])
config.add_extension('_find_contours_cy', sources=['_find_contours_cy.c'],
include_dirs=[get_numpy_include_dirs()])
config.add_extension('_moments', sources=['_moments.c'],
+71
View File
@@ -0,0 +1,71 @@
__all__ = ['label']
from ..measure._ccomp import label as _label
from skimage._shared.utils import deprecated
@deprecated('skimage.measure.label')
def label(input, neighbors=8, background=None, return_num=False):
"""Label connected regions of an integer array.
Two pixels are connected when they are neighbors and have the same value.
They can be neighbors either in a 4- or 8-connected sense::
4-connectivity 8-connectivity
[ ] [ ] [ ] [ ]
| \ | /
[ ]--[ ]--[ ] [ ]--[ ]--[ ]
| / | \\
[ ] [ ] [ ] [ ]
Parameters
----------
input : ndarray of dtype int
Image to label.
neighbors : {4, 8}, int
Whether to use 4- or 8-connectivity.
background : int
Consider all pixels with this value as background pixels, and label
them as -1. (Note: background pixels will be labeled as 0 starting with
version 0.12).
return_num : bool
Whether to return the number of assigned labels.
Returns
-------
labels : ndarray of dtype int
Labeled array, where all connected regions are assigned the
same integer value.
num : int, optional
Number of labels, which equals the maximum label index and is only
returned if return_num is `True`.
Examples
--------
>>> x = np.eye(3).astype(int)
>>> print(x)
[[1 0 0]
[0 1 0]
[0 0 1]]
>>> print(m.label(x, neighbors=4))
[[0 1 1]
[2 3 1]
[2 2 4]]
>>> print(m.label(x, neighbors=8))
[[0 1 1]
[1 0 1]
[1 1 0]]
>>> x = np.array([[1, 0, 0],
... [1, 1, 5],
... [0, 0, 0]])
>>> print(m.label(x, background=0))
[[ 0 -1 -1]
[ 0 0 1]
[-1 -1 -1]]
"""
return _label(input, neighbors, background, return_num)
-3
View File
@@ -12,7 +12,6 @@ def configuration(parent_package='', top_path=None):
config = Configuration('morphology', parent_package, top_path)
config.add_data_dir('tests')
cython(['ccomp.pyx'], working_path=base_path)
cython(['cmorph.pyx'], working_path=base_path)
cython(['_watershed.pyx'], working_path=base_path)
cython(['_skeletonize_cy.pyx'], working_path=base_path)
@@ -20,8 +19,6 @@ def configuration(parent_package='', top_path=None):
cython(['_convex_hull.pyx'], working_path=base_path)
cython(['_greyreconstruct.pyx'], working_path=base_path)
config.add_extension('ccomp', sources=['ccomp.c'],
include_dirs=[get_numpy_include_dirs()])
config.add_extension('cmorph', sources=['cmorph.c'],
include_dirs=[get_numpy_include_dirs()])
config.add_extension('_watershed', sources=['_watershed.c'],
+1 -1
View File
@@ -7,7 +7,7 @@ import scipy
cimport cython
cimport numpy as cnp
from skimage.morphology.ccomp cimport find_root, join_trees
from skimage.measure._ccomp cimport find_root, join_trees
from ..util import img_as_float