def test_keypoints_censure_moon_image_dob(): """Verify the actual Censure keypoints and their corresponding scale with the expected values for DoB filter.""" img = moon() actual_kp_dob, actual_scale = keypoints_censure(img, 1, 7, 'DoB', 0.15) expected_kp_dob = np.array([[21, 497], [36, 46], [119, 350], [185, 177], [287, 250], [357, 239], [463, 116], [464, 132], [467, 260]]) expected_scale = np.array([3, 4, 4, 2, 2, 3, 2, 2, 2]) assert_array_equal(expected_kp_dob, actual_kp_dob) assert_array_equal(expected_scale, actual_scale)
def test_keypoints_censure_moon_image_star(): """Verify the actual Censure keypoints and their corresponding scale with the expected values for STAR filter.""" img = moon() actual_kp_star, actual_scale = keypoints_censure(img, 1, 7, 'STAR', 0.15) expected_kp_star = np.array([[21, 497], [36, 46], [117, 356], [185, 177], [260, 227], [287, 250], [357, 239], [451, 281], [463, 116], [467, 260]]) expected_scale = np.array([3, 3, 6, 2, 3, 2, 3, 5, 2, 2]) assert_array_equal(expected_kp_star, actual_kp_star) assert_array_equal(expected_scale, actual_scale)
def test_keypoints_censure_moon_image_octagon(): """Verify the actual Censure keypoints and their corresponding scale with the expected values for Octagon filter.""" img = moon() actual_kp_octagon, actual_scale = keypoints_censure( img, 1, 7, 'Octagon', 0.15) expected_kp_octagon = np.array([[21, 496], [35, 46], [287, 250], [356, 239], [463, 116]]) expected_scale = np.array([3, 4, 2, 2, 2]) assert_array_equal(expected_kp_octagon, actual_kp_octagon) assert_array_equal(expected_scale, actual_scale)
def test_keypoints_censure_moon_image_octagon(): """Verify the actual Censure keypoints and their corresponding scale with the expected values for Octagon filter.""" img = moon() actual_kp_octagon, actual_scale = keypoints_censure(img, 1, 7, 'Octagon', 0.15) expected_kp_octagon = np.array([[ 21, 496], [ 35, 46], [287, 250], [356, 239], [463, 116]]) expected_scale = np.array([3, 4, 2, 2, 2]) assert_array_equal(expected_kp_octagon, actual_kp_octagon) assert_array_equal(expected_scale, actual_scale)
def test_keypoints_censure_moon_image_dob(): """Verify the actual Censure keypoints and their corresponding scale with the expected values for DoB filter.""" img = moon() actual_kp_dob, actual_scale = keypoints_censure(img, 1, 7, 'DoB', 0.15) expected_kp_dob = np.array([[ 21, 497], [ 36, 46], [119, 350], [185, 177], [287, 250], [357, 239], [463, 116], [464, 132], [467, 260]]) expected_scale = np.array([3, 4, 4, 2, 2, 3, 2, 2, 2]) assert_array_equal(expected_kp_dob, actual_kp_dob) assert_array_equal(expected_scale, actual_scale)
def test_keypoints_censure_moon_image_star(): """Verify the actual Censure keypoints and their corresponding scale with the expected values for STAR filter.""" img = moon() actual_kp_star, actual_scale = keypoints_censure(img, 1, 7, 'STAR', 0.15) expected_kp_star = np.array([[ 21, 497], [ 36, 46], [117, 356], [185, 177], [260, 227], [287, 250], [357, 239], [451, 281], [463, 116], [467, 260]]) expected_scale = np.array([3, 3, 6, 2, 3, 2, 3, 5, 2, 2]) assert_array_equal(expected_kp_star, actual_kp_star) assert_array_equal(expected_scale, actual_scale)
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))
non_max_threshold = 0.15 line_threshold = 10 _, 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 col, mode in enumerate(['dob', 'octagon', 'star']): 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 row, scale in enumerate(range(min_scale + 1, max_scale)): mask = scales == scale x = keypoints[mask, 1] y = keypoints[mask, 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)
gray_img = rgb2gray(img) min_scale = 2 max_scale = 6 non_max_threshold = 0.15 line_threshold = 10 _, 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 col, mode in enumerate(["dob", "octagon", "star"]): 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 row, scale in enumerate(range(min_scale + 1, max_scale)): mask = scales == scale x = keypoints[mask, 1] y = keypoints[mask, 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)