mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-29 11:26:57 +08:00
Added label vs. intensity shape checking to regionprops
This commit is contained in:
@@ -108,6 +108,11 @@ class _RegionProperties(object):
|
||||
|
||||
def __init__(self, slice, label, label_image, intensity_image,
|
||||
cache_active):
|
||||
|
||||
if not intensity_image is None:
|
||||
if not intensity_image.shape == label_image.shape:
|
||||
raise ValueError('Label and intensity image must be the same shape.')
|
||||
|
||||
self.label = label
|
||||
self._slice = slice
|
||||
self._label_image = label_image
|
||||
|
||||
@@ -362,6 +362,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
|
||||
|
||||
Reference in New Issue
Block a user