From f2632f26bb4ec2586b4150250a54c471b818a667 Mon Sep 17 00:00:00 2001 From: Ankit Agrawal Date: Tue, 13 Aug 2013 20:11:37 +0530 Subject: [PATCH] Adding gallery example for plotting censure keypoints --- doc/examples/plot_censure_keypoints.py | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 doc/examples/plot_censure_keypoints.py diff --git a/doc/examples/plot_censure_keypoints.py b/doc/examples/plot_censure_keypoints.py new file mode 100644 index 00000000..c2119b46 --- /dev/null +++ b/doc/examples/plot_censure_keypoints.py @@ -0,0 +1,46 @@ +""" +=========================== +Censure Keypoints Detection +=========================== + +In this example, we detect and plot the Censure Keypoints at various scales +using Difference of Boxes, Octagon and Star shaped bi-level filters. + +""" +from skimage.feature import keypoints_censure +from skimage.data import lena +from skimage.color import rgb2gray +import matplotlib.pyplot as plt + +# Initializing the parameters for Censure keypoints +img = lena() +gray_img = rgb2gray(img) +min_scale = 1 +max_scale = 7 +nms_threshold = 0.15 +rpc_threshold = 10 + + +# Plotting features for the following modes +for mode in ['dob', 'octagon', 'star']: + + kp_censure, scale = keypoints_censure(gray_img, min_scale, max_scale, + mode, nms_threshold,rpc_threshold) + f, axarr = plt.subplots((max_scale - min_scale + 1) // 3, 3) + + # Plotting Censure features at all the scales + for i in range(max_scale - min_scale - 1): + keypoints = kp_censure[scale == i + min_scale + 1] + num = len(keypoints) + x = keypoints[:, 1] + y = keypoints[:, 0] + s = 5 * 2**(i + min_scale + 1) + axarr[i // 3, i - (i // 3) * 3].imshow(img) + axarr[i // 3, i - (i // 3) * 3].scatter(x, y, s, facecolors='none', + edgecolors='g') + axarr[i // 3, i - (i // 3) * 3].set_title(' %s %s-Censure features at ' + 'scale %d' % (num, mode, i + + min_scale + 1)) + + plt.suptitle('NMS threshold = %f, RPC threshold = %d' % (nms_threshold, rpc_threshold)) +plt.show()