Bug: Fix label sequence in regionprops.

Closes gh-806.
This commit is contained in:
Jostein Bø Fløystad
2013-10-29 11:58:59 +01:00
parent 3ac124b277
commit eff276c99b
2 changed files with 17 additions and 0 deletions
+3
View File
@@ -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,
+14
View File
@@ -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()