您的位置:首页 > 编程语言 > MATLAB

Hessian矩阵提取特征点原理及其Matlab实现

2018-03-08 20:59 1686 查看
Speeded Up Robust Features(SURF,加速稳健特征),是一种稳健的局部特征点检测和描述算法。SURF算法就涉及了Hessian矩阵提取特征点原理,如下:

Hessian矩阵是一个多元函数的二阶偏导数构成的方阵,描述了函数的局部曲率。对一个图像f(x,y),其Hessian矩阵如下:



在构造Hessian矩阵前需要对图像进行高斯滤波,去除噪声引起的像素突变,经过滤波后的Hessian矩阵表述为:



当Hessian矩阵的判别式取得局部极值(极大值或极小值)时,判定当前点是比周围邻域内其他点更亮或更暗的点,由此来定位关键点的位置。

由图像的一阶导:

                            
Dx=f(x+1,y)-f(x,y)

二阶导为:

                   Dxx=[f(x+1,y)-f(x,y)]-[f(x,y)-f(x-1,y)]

                         =f(x+1,y)+f(x-1,y)-2*f(x,y)

同理可求得Dyy, Dxy, Dyx(=Dxy),则

                          
det(H)=Dxx*Dyy-Dxy*Dxy

下面是Hessian矩阵特征点检测原理Matlab代码实现:

function f = hessiandet(im)
% HESSIANDET  Basic Hessian detector
% F = HESSIANDET(IM) runs a basic implementation of the Hessian
% detector on the gray-scale image IM.

ims = imsmooth(im,2.5) ;

d2 = [1 -2 1]; %在图像处理中,滤波模板的大小最小为3
d = [-1 0 1]/2 ; %在图像处理中,滤波模板的大小最小为3
im11 = conv2(1,d2,ims,'same') ; %求Dyy
im22 = conv2(d2,1,ims,'same') ; %求Dxx
im12 = conv2(d,d,ims,'same') ; %求Dxy
score = im11.*im22 - im12.*im12 ; %det(H)

points = (islocalmax(score,1) .* islocalmax(score,2)) + ...
(islocalmin(score,1) .* islocalmin(score,2)) ;
points = points .* (abs(score) > 0.0006) ;

scores = score(find(points)) ;
[i,j] = find(points) ;
f = [j(:),i(:),scores(:)]' ;
function ims = imsmooth(im,sigma)
% IMSMOOTH  Smooth an image using a Gaussian filter
%    IMS = IMSMOOTH(IM,SIGMA) applies a Gaussian filter of standard
%    deviation SIGMA to the image.

w = ceil(sigma*3.5) ;
h = exp(-0.5*((-w:w)/sigma).^2) ; h = h / sum(h) ;
ims = conv2(h,h,im,'same') ; %高斯滤波

function m = islocalmax(x,dim)
m  = (circshift(x,1,dim) < x) & (circshift(x,-1,dim) < x) ; %求局部极大值

function m = islocalmin(x,dim)
m = (circshift(x,1,dim) > x) & (circshift(x,-1,dim) > x) ;  %求局部极小值


在上述代码中,主要的Matlab built-in函数有二维卷积函数conv2与循环移位函数circshift。具体怎样调用,help一下即可。

参考:

1.
Surf算法特征点检测与匹配
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息