mirror of
https://github.com/wassname/scikit-image.git
synced 2026-09-12 12:50:49 +08:00
Merge pull request #807 from josteinbf/regionprops-label-sequence
Bug: Fix label sequence in regionprops.
This commit is contained in:
@@ -503,6 +503,9 @@ def regionprops(label_image, properties=None,
|
|||||||
|
|
||||||
objects = ndimage.find_objects(label_image)
|
objects = ndimage.find_objects(label_image)
|
||||||
for i, sl in enumerate(objects):
|
for i, sl in enumerate(objects):
|
||||||
|
if sl is None:
|
||||||
|
continue
|
||||||
|
|
||||||
label = i + 1
|
label = i + 1
|
||||||
|
|
||||||
props = _RegionProperties(sl, label, label_image,
|
props = _RegionProperties(sl, label, label_image,
|
||||||
|
|||||||
@@ -347,6 +347,20 @@ def test_old_dict_interface():
|
|||||||
assert_equal(len(feats[0]), 8)
|
assert_equal(len(feats[0]), 8)
|
||||||
|
|
||||||
|
|
||||||
|
def test_label_sequence():
|
||||||
|
a = np.empty((2, 2), dtype=np.int)
|
||||||
|
a[:, :] = 2
|
||||||
|
ps = regionprops(a)
|
||||||
|
assert len(ps) == 1
|
||||||
|
assert ps[0].label == 2
|
||||||
|
|
||||||
|
|
||||||
|
def test_pure_background():
|
||||||
|
a = np.zeros((2, 2), dtype=np.int)
|
||||||
|
ps = regionprops(a)
|
||||||
|
assert len(ps) == 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from numpy.testing import run_module_suite
|
from numpy.testing import run_module_suite
|
||||||
run_module_suite()
|
run_module_suite()
|
||||||
|
|||||||
Reference in New Issue
Block a user