Merge pull request #1777 from stevendbrown/rp_intensity_check

Added label vs. intensity shape checking to regionprops
This commit is contained in:
Emmanuelle Gouillart
2015-12-23 22:34:59 +01:00
2 changed files with 10 additions and 0 deletions
+5
View File
@@ -80,6 +80,11 @@ class _RegionProperties(object):
def __init__(self, slice, label, label_image, intensity_image,
cache_active):
if intensity_image is not None:
if not intensity_image.shape == label_image.shape:
raise ValueError('Label and intensity image must have the same shape.')
self.label = label
self._slice = slice
@@ -358,6 +358,11 @@ def test_invalid():
assert_raises(AttributeError, get_intensity_image)
def test_invalid_size():
wrong_intensity_sample = np.array([[1], [1]])
assert_raises(ValueError, regionprops, SAMPLE, wrong_intensity_sample)
def test_equals():
arr = np.zeros((100, 100), dtype=np.int)
arr[0:25, 0:25] = 1