diff --git a/skimage/feature/censure.py b/skimage/feature/censure.py index 996f7e16..d52583c2 100644 --- a/skimage/feature/censure.py +++ b/skimage/feature/censure.py @@ -192,11 +192,7 @@ def keypoints_censure(image, min_scale=1, max_scale=7, mode='DoB', if image.ndim != 2: raise ValueError("Only 2-D gray-scale images supported.") - image = img_as_float(image) - image = np.ascontiguousarray(image) - mode = mode.lower() - if mode not in ('dob', 'octagon', 'star'): raise ValueError('Mode must be one of "DoB", "Octagon", "STAR".') @@ -204,6 +200,9 @@ def keypoints_censure(image, min_scale=1, max_scale=7, mode='DoB', raise ValueError('The number of scales should be greater than or' 'equal to 3.') + image = img_as_float(image) + image = np.ascontiguousarray(image) + # Generating all the scales filter_response = _get_filtered_image(image, min_scale, max_scale, mode) diff --git a/skimage/feature/tests/test_censure.py b/skimage/feature/tests/test_censure.py index 26555697..4cd2ad68 100644 --- a/skimage/feature/tests/test_censure.py +++ b/skimage/feature/tests/test_censure.py @@ -10,6 +10,20 @@ def test_keypoints_censure_color_image_unsupported_error(): assert_raises(ValueError, keypoints_censure, img) +def test_keypoints_censure_mode_validity_error(): + """Mode argument in keypoints_censure can be either DoB, Octagon or + STAR.""" + img = np.zeros((20, 20)) + assert_raises(ValueError, keypoints_censure, img, mode='dummy') + + +def test_keypoints_censure_scale_range_error(): + """Difference between the the max_scale and min_scale parameters in + keypoints_censure should be greater than or equal to two.""" + img = np.zeros((20, 20)) + assert_raises(ValueError, keypoints_censure, img, min_scale=1, max_scale=2) + + def test_keypoints_censure_moon_image_dob(): """Verify the actual Censure keypoints and their corresponding scale with the expected values for DoB filter."""