diff --git a/skimage/feature/_brief.py b/skimage/feature/_brief.py index d6f4e72e..4feb2698 100644 --- a/skimage/feature/_brief.py +++ b/skimage/feature/_brief.py @@ -111,17 +111,17 @@ def brief(image, keypoints, descriptor_size=256, mode='normal', patch_size=49, [ 0.375 , 0.6328125, 0.0390625, 0.328125 ], [ 0.625 , 0.3671875, 0.34375 , 0.0234375]]) >>> match_keypoints_brief(keypoints1, descriptors1, keypoints2, descriptors2) - array([[[ 2., 2.], - [ 2., 2.]], + array([[[ 2, 2], + [ 2, 2]], - [[ 2., 5.], - [ 2., 6.]], + [[ 2, 5], + [ 2, 6]], - [[ 5., 2.], - [ 6., 2.]], + [[ 5, 2], + [ 6, 2]], - [[ 5., 5.], - [ 6., 6.]]]) + [[ 5, 5], + [ 6, 6]]]) """ np.random.seed(sample_seed) @@ -216,7 +216,7 @@ def match_keypoints_brief(keypoints1, descriptors1, keypoints2, temp = distance > threshold row_check = ~ np.all(temp, axis = 1) matched_keypoints2 = keypoints2[np.argmin(distance, axis=1)] - matched_keypoint_pairs = np.zeros((np.sum(row_check), 2, 2)) + matched_keypoint_pairs = np.zeros((np.sum(row_check), 2, 2), dtype=np.intp) matched_keypoint_pairs[:, 0, :] = keypoints1[row_check] matched_keypoint_pairs[:, 1, :] = matched_keypoints2[row_check] diff --git a/skimage/feature/tests/test_brief.py b/skimage/feature/tests/test_brief.py index b8d26544..65c99af2 100644 --- a/skimage/feature/tests/test_brief.py +++ b/skimage/feature/tests/test_brief.py @@ -8,10 +8,10 @@ from skimage.feature import brief, match_keypoints_brief def test_brief_color_image_unsupported_error(): - """Brief descriptors can be evaluated on gray-scale images only.""" - img = np.zeros((20, 20, 3)) - keypoints = [[7, 5], [11, 13]] - assert_raises(ValueError, brief, img, keypoints) + """Brief descriptors can be evaluated on gray-scale images only.""" + img = np.zeros((20, 20, 3)) + keypoints = [[7, 5], [11, 13]] + assert_raises(ValueError, brief, img, keypoints) def test_match_keypoints_brief_lena_translation(): @@ -56,22 +56,23 @@ def test_match_keypoints_brief_lena_rotation(): matched_keypoints = match_keypoints_brief(keypoints1, descriptors1, keypoints2, descriptors2, threshold=0.07) - expected = np.array([[[ 263., 272.], - [ 234., 298.]], + expected = np.array([[[263, 272], + [234, 298]], - [[ 271., 120.], - [ 258., 146.]], + [[271, 120], + [258, 146]], - [[ 323., 164.], - [ 305., 195.]], + [[323, 164], + [305, 195]], - [[ 414., 70.], - [ 405., 111.]], + [[414, 70], + [405, 111]], - [[ 435., 181.], - [ 415., 223.]], + [[435, 181], + [415, 223]], + + [[454, 176], + [435, 221]]]) - [[ 454., 176.], - [ 435., 221.]]]) assert_array_equal(matched_keypoints, expected) diff --git a/skimage/feature/util.py b/skimage/feature/util.py index 8b5dd632..a7a3670f 100644 --- a/skimage/feature/util.py +++ b/skimage/feature/util.py @@ -14,14 +14,14 @@ def _remove_border_keypoints(image, keypoints, dist): def pairwise_hamming_distance(array1, array2): """Calculate hamming dissimilarity measure between two sets of - boolean vectors. + vectors. Parameters ---------- - array1 : (P1, D) array of dtype bool - P1 vectors of size D with boolean elements. - array2 : (P2, D) array of dtype bool - P2 vectors of size D with boolean elements. + array1 : (P1, D) array + P1 vectors of size D. + array2 : (P2, D) array + P2 vectors of size D. Returns -------