本次测试以sift特征匹配处理结果做对比为主,Harris特征匹配处理结果为辅做对比用途。
本次测试中使用的所有图片均为500x375(或375x500)像素的jpg图片。
1.SIFT特征原理描述
SIFT是尺度不变特征变换,其过程包括兴趣点的采集和描述子。SIFT的描述子具有很强的稳健性,这也是SIFT特征成功和流行的主要原因。
SIFT具体可以分为以下几个步骤。
1.使用高斯差分函数来定位兴趣点:
Gσ是二维高斯核,Iσ是Gσ模糊的灰度图像,K是决定相差尺度的常数。兴趣点是在图像位置和尺度变化下D(x,σ)的最大值和最小值点。
SIFT描述子在兴趣点附近选取子区域网格,在每个区域内计算图像梯度方向直方图,每个子区域的直方图拼接起来组成描述子向量。SIFT描述子的标准设置使用4x4的子区域,每个子区域使用8个小区间的方向直方图,共计产生128个小区间直方图。最终确定特征方向。
具体原理参照
2.SIFT特征和Harris特征匹配处理结果对比(两张图片)
2.1二者检测感兴趣点的不同
#*- coding: utf-8 -*-
from PIL import Image
from pylab import *
from PCV.localdescriptors import sift
from PCV.localdescriptors import harris
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r"c:\windows\fonts\SimSun.ttc", size=14)
imname = '21.jpg'
im = array(Image.open(imname).convert('L'))
sift.process_image(imname, '21.sift')
l1, d1 = sift.read_features_from_file('21.sift')
figure()
gray()
subplot(131)
sift.plot_features(im, l1, circle=False)
title(u'SIFT特征',fontproperties=font)
subplot(132)
sift.plot_features(im, l1, circle=True)
title(u'用圆圈表示SIFT特征尺度',fontproperties=font)
#检测harris角点
harrisim = harris.compute_harris_response(im)
subplot(133)
filtered_coords = harris.get_harris_points(harrisim, 6, 0.1)
imshow(im)
plot([p[1] for p