mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-12 12:30:16 +08:00
Fix censure example and fix some minor issues
This commit is contained in:
committed by
Ankit Agrawal
parent
3ee183fdf8
commit
7c4152b62b
@@ -1,12 +1,14 @@
|
||||
"""
|
||||
===========================
|
||||
Censure Keypoints Detection
|
||||
===========================
|
||||
=========================
|
||||
CenSurE Feature 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.
|
||||
In this example we detect and plot the CenSurE (Center Surround Extrema)
|
||||
features 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
|
||||
@@ -15,32 +17,39 @@ 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
|
||||
min_scale = 2
|
||||
max_scale = 6
|
||||
non_max_threshold = 0.15
|
||||
line_threshold = 10
|
||||
|
||||
|
||||
f, ax = plt.subplots(nrows=(max_scale - min_scale - 1), ncols=3,
|
||||
figsize=(6, 6))
|
||||
plt.subplots_adjust(wspace=0.02, hspace=0.02, top=0.94,
|
||||
bottom=0.02, left=0.06, right=0.98)
|
||||
|
||||
# Detecting Censure keypoints for the following filters
|
||||
for mode in ['dob', 'octagon', 'star']:
|
||||
for col, mode in enumerate(['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)
|
||||
ax[0, col].set_title(mode.upper(), fontsize=12)
|
||||
|
||||
keypoints, scales = keypoints_censure(gray_img, min_scale, max_scale,
|
||||
mode, non_max_threshold,
|
||||
line_threshold)
|
||||
|
||||
# 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))
|
||||
for row, scale in enumerate(range(min_scale + 1, max_scale)):
|
||||
keypoints_i = keypoints[scales == scale]
|
||||
num = len(keypoints_i)
|
||||
x = keypoints_i[:, 1]
|
||||
y = keypoints_i[:, 0]
|
||||
s = 0.5 * 2 ** (scale + min_scale + 1)
|
||||
ax[row, col].imshow(img)
|
||||
ax[row, col].scatter(x, y, s, facecolors='none', edgecolors='b')
|
||||
ax[row, col].set_xticks([])
|
||||
ax[row, col].set_yticks([])
|
||||
ax[row, col].axis((0, img.shape[1], img.shape[0], 0))
|
||||
if col == 0:
|
||||
ax[row, col].set_ylabel('Scale %d' % scale, fontsize=12)
|
||||
|
||||
plt.suptitle('NMS threshold = %f, RPC threshold = %d'
|
||||
% (nms_threshold, rpc_threshold))
|
||||
plt.show()
|
||||
|
||||
Reference in New Issue
Block a user