From 92864fdfb0501ab0ebaf22b6939c8bc5ea8e5f8c Mon Sep 17 00:00:00 2001 From: Ankit Agrawal Date: Sun, 28 Jul 2013 13:30:04 +0530 Subject: [PATCH] Removing hard-coding in censure_keypoints() --- skimage/feature/censure.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/skimage/feature/censure.py b/skimage/feature/censure.py index ca361cf7..89114a07 100644 --- a/skimage/feature/censure.py +++ b/skimage/feature/censure.py @@ -74,7 +74,7 @@ def _suppress_line(response, sigma, rpc_threshold): return response -def censure_keypoints(image, mode='DoB', threshold=0.03, rpc_threshold=10): +def censure_keypoints(image, mode='DoB', no_of_scales=7, threshold=0.03, rpc_threshold=10): # TODO : Decide number of scales. Image-size dependent? image = np.squeeze(image) if image.ndim != 2: @@ -84,16 +84,10 @@ def censure_keypoints(image, mode='DoB', threshold=0.03, rpc_threshold=10): image = np.ascontiguousarray(image) # Generating all the scales - scale1 = _get_filtered_image(image, 1, mode) - scale2 = _get_filtered_image(image, 2, mode) - scale3 = _get_filtered_image(image, 3, mode) - scale4 = _get_filtered_image(image, 4, mode) - scale5 = _get_filtered_image(image, 5, mode) - scale6 = _get_filtered_image(image, 6, mode) - scale7 = _get_filtered_image(image, 7, mode) + scales = np.zeros((image.shape[0], image.shape[1], no_of_scales)) + for i in xrange(no_of_scales): + scales[:, :, i] = _get_filtered_image(image, i + 1, mode) - # Stacking all the scales in the 3rd dimension - scales = np.dstack((scale1, scale2, scale3, scale4, scale5, scale6, scale7)) # Suppressing points that are neither minima or maxima in their 3 x 3 x 3 # neighbourhood to zero minimas = (minimum_filter(scales, (3, 3, 3)) == scales).astype(int) * scales @@ -102,12 +96,9 @@ def censure_keypoints(image, mode='DoB', threshold=0.03, rpc_threshold=10): minimas[np.abs(minimas) < threshold] = 0 maximas[np.abs(maximas) < threshold] = 0 response = maximas + np.abs(minimas) - # TODO : Decide the rpc_threshold and sigma for all the scales. The paper only discusses - # values for scale2 i.e. response[:, :, 1] - response[:, :, 1] = _suppress_line(response[:, :, 1], 1.33, rpc_threshold) - response[:, :, 2] = _suppress_line(response[:, :, 2], 1.33, rpc_threshold) - response[:, :, 3] = _suppress_line(response[:, :, 3], 1.33, rpc_threshold) - response[:, :, 4] = _suppress_line(response[:, :, 4], 1.33, rpc_threshold) - response[:, :, 5] = _suppress_line(response[:, :, 5], 1.33, rpc_threshold) + + for i in xrange(1, no_of_scales - 1): + response[:, :, i] = _suppress_line(response[:, :, i], (1 + i / 3.0), rpc_threshold) + # TODO : Return key-points from all the scales? return response