备注
转到末尾 以下载完整的示例代码。或者通过 Binder 在浏览器中运行此示例。
ORB 特征检测器和二进制描述符#
此示例演示了 ORB 特征检测和二进制描述算法。它使用定向的 FAST 检测方法和旋转的 BRIEF 描述符。
与 BRIEF 不同,ORB 在保持使用非常高效的汉明距离度量进行匹配的同时,相对具有尺度和旋转不变性。因此,它更适用于实时应用。
/Users/cw/baidu/code/fin_tool/github/scikit-image/doc/examples/features_detection/plot_orb.py:49: FutureWarning:
`plot_matches` is deprecated since version 0.23 and will be removed in version 0.25. Use `skimage.feature.plot_matched_features` instead.
/Users/cw/baidu/code/fin_tool/github/scikit-image/doc/examples/features_detection/plot_orb.py:53: FutureWarning:
`plot_matches` is deprecated since version 0.23 and will be removed in version 0.25. Use `skimage.feature.plot_matched_features` instead.
from skimage import data
from skimage import transform
from skimage.feature import match_descriptors, ORB, plot_matches
from skimage.color import rgb2gray
import matplotlib.pyplot as plt
img1 = rgb2gray(data.astronaut())
img2 = transform.rotate(img1, 180)
tform = transform.AffineTransform(scale=(1.3, 1.1), rotation=0.5, translation=(0, -200))
img3 = transform.warp(img1, tform)
descriptor_extractor = ORB(n_keypoints=200)
descriptor_extractor.detect_and_extract(img1)
keypoints1 = descriptor_extractor.keypoints
descriptors1 = descriptor_extractor.descriptors
descriptor_extractor.detect_and_extract(img2)
keypoints2 = descriptor_extractor.keypoints
descriptors2 = descriptor_extractor.descriptors
descriptor_extractor.detect_and_extract(img3)
keypoints3 = descriptor_extractor.keypoints
descriptors3 = descriptor_extractor.descriptors
matches12 = match_descriptors(descriptors1, descriptors2, cross_check=True)
matches13 = match_descriptors(descriptors1, descriptors3, cross_check=True)
fig, ax = plt.subplots(nrows=2, ncols=1)
plt.gray()
plot_matches(ax[0], img1, img2, keypoints1, keypoints2, matches12)
ax[0].axis('off')
ax[0].set_title("Original Image vs. Transformed Image")
plot_matches(ax[1], img1, img3, keypoints1, keypoints3, matches13)
ax[1].axis('off')
ax[1].set_title("Original Image vs. Transformed Image")
plt.show()
脚本总运行时间: (0 分钟 0.721 秒)