mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-30 04:36:26 +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)
|
||||
for i, sl in enumerate(objects):
|
||||
if sl is None:
|
||||
continue
|
||||
|
||||
label = i + 1
|
||||
|
||||
props = _RegionProperties(sl, label, label_image,
|
||||
|
||||
@@ -347,6 +347,20 @@ def test_old_dict_interface():
|
||||
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__":
|
||||
from numpy.testing import run_module_suite
|
||||
run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user