本文整理汇总了Python中skimage.feature.corner_harris函数的典型用法代码示例。如果您正苦于以下问题:Python corner_harris函数的具体用法?Python corner_harris怎么用?Python corner_harris使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了corner_harris函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_binary_descriptors_rotation_crosscheck_true
def test_binary_descriptors_rotation_crosscheck_true():
"""Verify matched keypoints and their corresponding masks results between
image and its rotated version with the expected keypoint pairs with
cross_check enabled."""
img = data.astronaut()
img = rgb2gray(img)
tform = tf.SimilarityTransform(scale=1, rotation=0.15, translation=(0, 0))
rotated_img = tf.warp(img, tform, clip=False)
extractor = BRIEF(descriptor_size=512)
keypoints1 = corner_peaks(corner_harris(img), min_distance=5,
threshold_abs=0, threshold_rel=0.1)
extractor.extract(img, keypoints1)
descriptors1 = extractor.descriptors
keypoints2 = corner_peaks(corner_harris(rotated_img), min_distance=5,
threshold_abs=0, threshold_rel=0.1)
extractor.extract(rotated_img, keypoints2)
descriptors2 = extractor.descriptors
matches = match_descriptors(descriptors1, descriptors2, cross_check=True)
exp_matches1 = np.array([ 0, 2, 3, 4, 5, 6, 9, 11, 12, 13, 14, 17,
18, 19, 21, 22, 23, 26, 27, 28, 29, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46])
exp_matches2 = np.array([ 0, 2, 3, 1, 4, 6, 5, 7, 13, 10, 9, 11,
15, 8, 14, 12, 16, 18, 19, 21, 20, 24, 25, 26,
28, 27, 22, 23, 29, 30, 31, 32, 35, 33, 34, 36])
assert_equal(matches[:, 0], exp_matches1)
assert_equal(matches[:, 1], exp_matches2)
开发者ID:AbdealiJK,项目名称:scikit-image,代码行数:31,代码来源:test_match.py
示例2: test_rotated_img
def test_rotated_img():
"""
The harris filter should yield the same results with an image and it's
rotation.
"""
im = img_as_float(data.astronaut().mean(axis=2))
im_rotated = im.T
# Moravec
results = peak_local_max(corner_moravec(im),
min_distance=10, threshold_rel=0)
results_rotated = peak_local_max(corner_moravec(im_rotated),
min_distance=10, threshold_rel=0)
assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()
# Harris
results = peak_local_max(corner_harris(im),
min_distance=10, threshold_rel=0)
results_rotated = peak_local_max(corner_harris(im_rotated),
min_distance=10, threshold_rel=0)
assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()
# Shi-Tomasi
results = peak_local_max(corner_shi_tomasi(im),
min_distance=10, threshold_rel=0)
results_rotated = peak_local_max(corner_shi_tomasi(im_rotated),
min_distance=10, threshold_rel=0)
assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()
开发者ID:ameya005,项目名称:scikit-image,代码行数:31,代码来源:test_corner.py
示例3: test_square_image
def test_square_image():
im = np.zeros((50, 50)).astype(float)
im[:25, :25] = 1.
# Moravec
results = peak_local_max(corner_moravec(im),
min_distance=10, threshold_rel=0)
# interest points along edge
assert len(results) == 57
# Harris
results = peak_local_max(corner_harris(im, method='k'),
min_distance=10, threshold_rel=0)
# interest at corner
assert len(results) == 1
results = peak_local_max(corner_harris(im, method='eps'),
min_distance=10, threshold_rel=0)
# interest at corner
assert len(results) == 1
# Shi-Tomasi
results = peak_local_max(corner_shi_tomasi(im),
min_distance=10, threshold_rel=0)
# interest at corner
assert len(results) == 1
开发者ID:ameya005,项目名称:scikit-image,代码行数:26,代码来源:test_corner.py
示例4: test_rotated_lena
def test_rotated_lena():
"""
The harris filter should yield the same results with an image and it's
rotation.
"""
im = img_as_float(data.lena().mean(axis=2))
im_rotated = im.T
# Moravec
results = peak_local_max(corner_moravec(im))
results_rotated = peak_local_max(corner_moravec(im_rotated))
assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()
# Harris
results = peak_local_max(corner_harris(im))
results_rotated = peak_local_max(corner_harris(im_rotated))
assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()
# Shi-Tomasi
results = peak_local_max(corner_shi_tomasi(im))
results_rotated = peak_local_max(corner_shi_tomasi(im_rotated))
assert (np.sort(results[:, 0]) == np.sort(results_rotated[:, 1])).all()
assert (np.sort(results[:, 1]) == np.sort(results_rotated[:, 0])).all()
开发者ID:almarklein,项目名称:scikit-image,代码行数:25,代码来源:test_corner.py
示例5: process
def process(self, img2, image_gray):
# img2 = warp(img2)
patch_size = [640]
img2 = rgb2gray(img2)
image_gray = rgb2gray(img2)
blobs_dog = blob_dog(image_gray, min_sigma=0.2, max_sigma=225, sigma_ratio=1.6, threshold=.5)
blobs_dog[:, 2] = blobs_dog[:, 2]
blobs = [blobs_dog]
colors = ['black']
titles = ['Difference of Gaussian']
sequence = zip(blobs, colors, titles)
# plt.imshow(img2)
# plt.axis("equal")
# plt.show()
for blobs, color, title in sequence:
print(len(blobs))
for blob in blobs:
y, x, r = blob
plotx = x
ploty = y
for i in range (3):
keypoints1 = corner_peaks(corner_harris(Array.image_arr[i]), min_distance=1)
keypoints2 = corner_peaks(corner_harris(img2), min_distance=1)
extractor = BRIEF(patch_size=30, mode="uniform")
extractor.extract(Array.image_arr[i], keypoints1)
keypoints1 = keypoints1[extractor.mask]
descriptors1 = extractor.descriptors
extractor.extract(img2, keypoints2)
keypoints2 = keypoints2[extractor.mask]
descriptors2 = extractor.descriptors
matches12 = match_descriptors(descriptors1, descriptors2, cross_check=True)
# print(keypoints1, keypoints2)
# print(matches12)
#FUCKGGGPLAYT
for pizdezh in matches12:
X = keypoints2[pizdezh[1]][1]
Y = keypoints2[pizdezh[1]][0]
if sqrt((plotx - X)**2 + (ploty - Y)**2) < r:
seen = [{
"type": Array.type_arr[i],
"center_shift": (plotx - 160/2) * -0.02,
"distance": image_gray[y][x] / 0.08
}]
print seen
data.seen.add(seen)
break
开发者ID:VsevolodTrofimov,项目名称:badbots,代码行数:56,代码来源:blob.py
示例6: test_uniform_mode
def test_uniform_mode():
"""Verify the computed BRIEF descriptors with expected for uniform mode."""
img = data.coins()
keypoints = corner_peaks(corner_harris(img), min_distance=5, threshold_abs=0, threshold_rel=0.1)
extractor = BRIEF(descriptor_size=8, sigma=2, mode="uniform")
extractor.extract(img, keypoints[:8])
expected = np.array(
[
[False, False, False, True, True, True, False, False],
[True, True, True, False, True, False, False, True],
[True, True, True, False, True, True, False, True],
[True, True, True, True, False, True, False, True],
[True, True, True, True, True, True, False, False],
[True, True, True, True, True, True, True, True],
[False, False, False, True, True, True, True, True],
[False, True, False, True, False, True, True, True],
],
dtype=bool,
)
assert_array_equal(extractor.descriptors, expected)
开发者ID:soupault,项目名称:scikit-image,代码行数:25,代码来源:test_brief.py
示例7: featurize
def featurize(img_name):
"""Load an image and convert it into a dictionary of features"""
img = plt.imread(os.path.join('stimuli', img_name + '.png'))
height, width, _ = img.shape
features = defaultdict(int)
for y in range(height):
for x in range(width):
features['red'] += img[y][x][0]
features['green'] += img[y][x][1]
features['blue'] += img[y][x][2]
features['alpha'] += img[y][x][3]
grey = color.rgb2grey(img)
for y in range(height):
for x in range(width):
for key, value in per_pixel(grey, y, x):
features[key] += value
# Normalize over image size
for key, value in features.items():
features[key] = float(value) / height / width
features['blob'] = feature.blob_dog(grey).shape[0]
features['corners'] = feature.corner_peaks(
feature.corner_harris(grey)).shape[0]
return features
开发者ID:cmc333333,项目名称:neuraldata-final,代码行数:26,代码来源:runner.py
示例8: guess_corners
def guess_corners(bw):
"""
Infer the corners of an image using a Sobel filter to find the edges and a
Harris filter to find the corners. Takes a single color chanel.
Parameters
----------
bw : (m x n) ndarray of ints
Returns
-------
corners : pixel coordinates of plot corners, unsorted
outline : (m x n) ndarray of bools True -> plot area
"""
assert len(bw.shape) == 2
bw = img_as_uint(bw)
e_map = ndimage.sobel(bw)
markers = np.zeros(bw.shape, dtype=int)
markers[bw < 30] = 1
markers[bw > 150] = 2
seg = ndimage.watershed_ift(e_map, np.asarray(markers, dtype=int))
outline = ndimage.binary_fill_holes(1 - seg)
corners = corner_harris(np.asarray(outline, dtype=int))
corners = approximate_polygon(corners, 1)
return corners, outline
开发者ID:OrkoHunter,项目名称:yoink,代码行数:27,代码来源:guess.py
示例9: test_subpix_dot
def test_subpix_dot():
img = np.zeros((50, 50))
img[25, 25] = 255
corner = peak_local_max(corner_harris(img),
min_distance=10, threshold_rel=0, num_peaks=1)
subpix = corner_subpix(img, corner)
assert_array_equal(subpix[0], (25, 25))
开发者ID:ameya005,项目名称:scikit-image,代码行数:7,代码来源:test_corner.py
示例10: test_subpix
def test_subpix():
img = np.zeros((50, 50))
img[:25,:25] = 255
img[25:,25:] = 255
corner = peak_local_max(corner_harris(img), num_peaks=1)
subpix = corner_subpix(img, corner)
assert_array_equal(subpix[0], (24.5, 24.5))
开发者ID:almarklein,项目名称:scikit-image,代码行数:7,代码来源:test_corner.py
示例11: get_harris_corners
def get_harris_corners(im, edge_discard=20):
"""
This function takes a b&w image and an optional amount to discard
on the edge (default is 5 pixels), and finds all harris corners
in the image. Harris corners near the edge are discarded and the
coordinates of the remaining corners are returned. A 2d array (h)
containing the h value of every pixel is also returned.
h is the same shape as the original image, im.
coords is 2 x n (ys, xs).
"""
assert edge_discard >= 20
# find harris corners
h = corner_harris(im, method='eps', sigma=1)
coords = peak_local_max(h, min_distance=1, indices=True)
# discard points on edge
edge = edge_discard # pixels
mask = (coords[:, 0] > edge) & \
(coords[:, 0] < im.shape[0] - edge) & \
(coords[:, 1] > edge) & \
(coords[:, 1] < im.shape[1] - edge)
coords = coords[mask].T
return h, coords
开发者ID:kcparashar,项目名称:daguerre,代码行数:26,代码来源:harris.py
示例12: extract_corner_harris
def extract_corner_harris(patch):
""" Extract four corner points using harris corner detection algorithm
"""
# Find corner with harris corner detection
coords = corner_peaks(corner_harris(patch, k=0.1), min_distance=5)
coords_subpix = corner_subpix(patch, coords, window_size=13)
# Find the nearest point for each corner
dim = patch.shape
corners = [(0, 0), (dim[0], 0), (dim[0], dim[1]), (0, dim[1])]
dest_points = [[] for x in range(4)]
for i in xrange(4):
dest_points[i] = search_closest_points(corners[i], coords_subpix)
# Check for error
try:
epsilon = 1e-10
for i in xrange(4):
for j in xrange(i + 1, 4):
if calc_distance(dest_points[i], dest_points[j]) < epsilon:
print 'Error point'
return []
except TypeError:
return []
# Reverse y,x position to x,y
for i in xrange(4):
dest_points[i][1], dest_points[i][0] = dest_points[i][0], dest_points[i][1]
return dest_points
开发者ID:mitbal,项目名称:pemilu,代码行数:32,代码来源:extract.py
示例13: dumb_matcher
def dumb_matcher(img1, img2):
kps = lambda img: feature.corner_peaks(feature.corner_harris(img), min_distance = 2)
kp1 = kps(img1)
kp2 = kps(img2)
to_set = lambda aoa: set(map(lambda x: (x[0], x[1]), aoa))
s1 = to_set(kp1)
s2 = to_set(kp2)
return float(len(s1 & s2) * 2) / (len(s1) + len(s2))
开发者ID:blmarket,项目名称:CoCParser,代码行数:8,代码来源:feature.py
示例14: find_corners
def find_corners(path, min_distance=5):
"""Find corners in an image at path
Returns the image and the corner lists.
"""
from skimage.feature import corner_harris, corner_peaks
img = imread(path, flatten=True)
corners = corner_peaks(corner_harris(img), min_distance=min_distance)
return img, corners
开发者ID:jupyter,项目名称:ngcm-tutorial,代码行数:9,代码来源:images_common.py
示例15: test_subpix_no_class
def test_subpix_no_class():
img = np.zeros((50, 50))
subpix = corner_subpix(img, np.array([[25, 25]]))
assert_array_equal(subpix[0], (np.nan, np.nan))
img[25, 25] = 1e-10
corner = peak_local_max(corner_harris(img), num_peaks=1)
subpix = corner_subpix(img, np.array([[25, 25]]))
assert_array_equal(subpix[0], (np.nan, np.nan))
开发者ID:OrkoHunter,项目名称:scikit-image,代码行数:9,代码来源:test_corner.py
示例16: main
def main():
"""Load image, calculate harris scores (window functions: matrix of ones, gauss)
and plot the results."""
img = data.checkerboard()
score_window = harris_ones(img, 7)
score_gauss = harris_gauss(img)
util.plot_images_grayscale(
[img, score_window, score_gauss, feature.corner_harris(img)],
["Image", "Harris-Score (ones)", "Harris-Score (gauss)", "Harris-Score (ground truth)"]
)
开发者ID:aleju,项目名称:computer-vision-algorithms,代码行数:10,代码来源:harris.py
示例17: test_noisy_square_image
def test_noisy_square_image():
im = np.zeros((50, 50)).astype(float)
im[:25, :25] = 1.
np.random.seed(seed=1234)
im = im + np.random.uniform(size=im.shape) * .2
# Moravec
results = peak_local_max(corner_moravec(im))
# undefined number of interest points
assert results.any()
# Harris
results = peak_local_max(corner_harris(im, sigma=1.5, method='k'))
assert len(results) == 1
results = peak_local_max(corner_harris(im, sigma=1.5, method='eps'))
assert len(results) == 1
# Shi-Tomasi
results = peak_local_max(corner_shi_tomasi(im, sigma=1.5))
assert len(results) == 1
开发者ID:almarklein,项目名称:scikit-image,代码行数:20,代码来源:test_corner.py
示例18: test_num_peaks
def test_num_peaks():
"""For a bunch of different values of num_peaks, check that
peak_local_max returns exactly the right amount of peaks. Test
is run on Lena in order to produce a sufficient number of corners"""
lena_corners = corner_harris(data.lena())
for i in range(20):
n = np.random.random_integers(20)
results = peak_local_max(lena_corners, num_peaks=n)
assert (results.shape[0] == n)
开发者ID:almarklein,项目名称:scikit-image,代码行数:11,代码来源:test_corner.py
示例19: test_match_keypoints_brief_lena_translation
def test_match_keypoints_brief_lena_translation():
"""Test matched keypoints between lena image and its translated version."""
img = data.lena()
img = rgb2gray(img)
img.shape
tform = tf.SimilarityTransform(scale=1, rotation=0, translation=(15, 20))
translated_img = tf.warp(img, tform)
keypoints1 = corner_peaks(corner_harris(img), min_distance=5)
descriptors1, keypoints1 = brief(img, keypoints1, descriptor_size=512)
keypoints2 = corner_peaks(corner_harris(translated_img), min_distance=5)
descriptors2, keypoints2 = brief(translated_img, keypoints2,
descriptor_size=512)
matched_keypoints = match_keypoints_brief(keypoints1, descriptors1,
keypoints2, descriptors2,
threshold=0.10)
assert_array_equal(matched_keypoints[:, 0, :], matched_keypoints[:, 1, :] +
[20, 15])
开发者ID:Autodidact24,项目名称:scikit-image,代码行数:21,代码来源:_test_brief.py
示例20: corners
def corners(provider):
"""
number of corners
"""
gray = provider.as_gray()
# TODO custom parameters would give arise to exceptions of mis-matched shapes
coords = corner_peaks(corner_harris(gray))#, min_distance=5)
coords_subpix = corner_subpix(gray, coords)#, window_size=13)
return len(coords_subpix)
开发者ID:cuppster,项目名称:imagefeatures,代码行数:12,代码来源:basic.py
注:本文中的skimage.feature.corner_harris函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论