mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-07 22:54:17 +08:00
Removing hard-coding in censure_keypoints()
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user