Harris角点检测
Harris角点检测算法是最简单的角点检测方法之一。
from pylab import *
from PIL import Image
from PCV.localdescriptors import harris
#读入图像
im = array(Image.open('C:/Users/Administrator/35.jpg').convert('L'))
#检测harris角点
harrisim = harris.compute_harris_response(im)
#Harris响应函数
harrisim1 = 255 - harrisim
figure()
gray()
#画出Harris响应图
subplot(141)
imshow(harrisim1)
print harrisim1.shape
axis('off')
axis('equal')
threshold = [0.01, 0.05, 0.1]
for i, thres in enumerate(threshold):
filtered_coords = harris.get_harris_points(harrisim, 6, thres)
subplot(1, 4, i+2)
imshow(im)
print im.shape
plot([p[1] for p in filtered_coords], [p[0] for p in filtered_coords], '*')
axis('off')
#原书采用的PCV中PCV harris模块
#harris.plot_harris_points(im, filtered_coords)
#plot only 200 strongest
#harris.plot_harris_points(im, filtered_coords[:200])
show()
原图
得到图片
在图像间寻找对应点
Harris角点检测器可以给出图像中检测到兴趣点,但它并没有提供在图像间对兴趣点进行比较的方法,我们需要在每个角点添加描述子,以及对这些描述子进行比较。
from pylab import *
from PIL import Image
from PCV.localdescriptors import harris
from PCV.tools.imtools import imresize
"""
This is the Harris point matching example in Figure 2-2.
"""
im1 = array(Image.open("C:/Users/Administrator/36.jpg").convert