from http://blog.sina.com.cn/s/blog_96b836170102w1kk.html
3.FAST角點(diǎn)檢測
本博文原理部分簡(jiǎn)述,重點(diǎn)在編程實(shí)現(程序參考并修改了網(wǎng)上資料,網(wǎng)上程序不一定能運行,但本文程序親測能跑)。
基于加速分割測試的FAST算法可以快速地提取出角點(diǎn)特征。
該算法判斷一個(gè)候選點(diǎn)p是否為角點(diǎn),依據的是在一個(gè)像素點(diǎn)p為圓心,半徑為3個(gè)像素的離散化Bresenllam圓周上,在給定閾值t的條件下,如果在圓周上有n個(gè)連續的像素灰度值大于I(p)+t或小于I(p)-t。
控制FAST角點(diǎn)的主要參數是閾值t,輸入t以進(jìn)行角點(diǎn)檢測。
//FAST:
#include "stdafx.h"
#include
#include
#include
#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/features2d/features2d.hpp"
#include
#include
#include
#include
using namespace cv;
using namespace std;
int main(intargc,char**argv)
{
Matsrc,gray;
src = imread("C:\\Users\\Administrator\\Desktop\\qi.jpg");
if(!src.data)
return -1;
//彩色圖像轉換為灰度圖像
cvtColor(src, gray, CV_BGR2GRAY);
//定義特征點(diǎn)KeyPoint向量
std::vector<</span>KeyPoint>keyPoints;
//調用FAST函數,閾值選為55
FAST(gray, keyPoints, 55);
inttotal= keyPoints.size();
//在原圖上畫(huà)出特征點(diǎn)
for(inti= 0; i < total; i++)
{
circle(src, Point((int)keyPoints[i].pt.x,(int)keyPoints[i].pt.y),5, Scalar(0,0, 255), -1, 8, 0);
}
namedWindow("FAST",CV_WINDOW_AUTOSIZE);
imshow("FAST",src);
waitKey(0);
return0;
}
FAST算法比其他已知的角點(diǎn)檢測法要快很多倍,但是當圖片的噪點(diǎn)較多時(shí),它的健壯性并不好,這依靠一個(gè)閾值:當閾值過(guò)小時(shí),檢測出的角點(diǎn)過(guò)多;整體的閾值對于圖像局部不一定合適。
效果圖: