检测得到的角点特征通常用于图像匹配、目标跟踪、运动估计等方面。检测得到的角点特征通常用于图像匹配、目标跟踪、运动估计等方面。

1.角点概念

1.角点概念

  角点是如出一辙种植有特征,具有旋转不变性和非按照光照条件转移而转变的特点,一般以图像中曲率足够大要曲率变化明显的点作为角点。检测得到的角点特征通常用于图像匹配、目标跟踪、运动估计等地方。

  角点是同等种有特征,具有旋转不变性和免照光照条件转而变化的特色,一般以图像中曲率足够大或曲率变化肯定的触及作为角点。检测得到的角点特征通常用于图像匹配、目标跟踪、运动估计等方面。

2.Fast检测角点

2.Fast检测角点

1)基本思维

1)基本思维

  E.Rosten和T.Drummond两各类老佬在06年一样首文章被提出了FAST特征算法,基本考虑大简单易行:以某个像素点为圆心,某半径的团上别样如素点与圆心像素点特性差异及某种标准时即认为该点就是角点。

  E.Rosten和T.Drummond两各生佬在06年同一篇稿子中提出了FAST特征算法,基本考虑非常简练:以某个像素点为圆心,某半径的团上外如素点与圆心像素点特性差异及某种标准时即认为该点就是角点。

2)数学模型

2)数学模型

  图片 1

  图片 2

  经过测试发现,选取的圆形半径为3时足兼任检测结果以及频率。如达到图所示,点p与半径为3之团上的16单如素点比较其灰度差,若灰度差绝对值超出某阈值的罗列超过设定数目(一般可以取9/10/11/12),则当该点是角点。

  经过测试发现,选取的旋半径为3时可兼任检测结果以及频率。如齐图所示,点p与半径为3底圆上的16独如素点比较其灰度差,若灰度差绝对值大于某阈值的罗列超过设定数目(一般可取9/10/11/12),则以为该点是角点。

     使用小技巧加速该算法,这里得到设定数目也12。

     使用小技巧加速该算法,这里收获设定数目也12。

  (1)判断点1和点9灰度值与点p差值绝对值是否都超出阈值,如果是虽然继续;否则pass该点

  (1)判断点1和点9灰度值与点p差值绝对值是否都过阈值,如果是虽然连续;否则pass该点

     
(2)判断点1、点5、点9、点13季沾及点p灰度值差值大于阈值的数码是否超2,如果是虽然连续;否则pass该点

     
(2)判断点1、点5、点9、点13季点和点p灰度值差值大于阈值的数是否超2,如果是则连续;否则pass该点

     
(3)判断圆周上16沾和点p灰度值差值大于阈值的多少是否非低于12,如果是虽然觉得该点是候选点;否则pass该点

     
(3)判断圆周上16沾与点p灰度值差值大于阈值的数目是否不小于12,如果是则当该点是候选点;否则pass该点

  对图像遭到保有像素点进行上述操作后,得到候选点点集。通常以非极大值抑制过滤局部非极大值点,在当时前面用先计算各候选点的score,score就定义也16个点以及主干点灰度值差值的绝值总和

  对图像中有着像素点进行上述操作后,得到候选点点集。通常用非极大值抑制过滤局部非极大值点,在这之前要先计算各候选点的score,score就定义也16个点和中心点灰度值差值的断然值总和

3.opencv实现

3.opencv实现

    个人运用vs2012+opencv2.4.13作开发环境,具体实现如下

    个人以vs2012+opencv2.4.13当做支出条件,具体落实如下

 

 

  1 #include <iostream>
  2 #include <core/core.hpp>
  3 #include <highgui/highgui.hpp>
  4 #include <imgproc/imgproc.hpp>
  5 #include <features2d/features2d.hpp>
  6 
  7 using namespace std;
  8 using namespace cv;
  9 
 10 
 11 int getSum(uchar *p, int length)
 12 {
 13     int sum = 0;
 14     for(int i=0;i<length; i++)
 15     {
 16         sum += *(p+i);
 17     }
 18     return sum;
 19 }
 20 
 21 int main(int argc, char* argv[])
 22 {
 23     /* 1.读入图像 */
 24     Mat image = imread("../church01.jpg", 0);
 25     if(!image.data)
 26         return 0;
 27 
 28     namedWindow("Original Image");
 29     imshow("Original Image", image);
 30 
 31     Mat fastImg(image.size(), CV_8U, Scalar(0));//用于保存Fast特征点候选点
 32     Mat fastScore(image.size(), CV_32F, Scalar(0));//用于计算候选点score
 33     vector<Point> points;
 34     int rows, cols, threshold;
 35     rows = image.rows;
 36     cols = image.cols;
 37     threshold = 50;
 38 
 39     /* 2.检测Fast特征点 */
 40     for(int x = 3; x < rows - 3; x++)
 41     {
 42         for(int y = 3; y < cols - 3; y++)
 43         {
 44             uchar delta[16] = {0};
 45             uchar diff[16] = {0};
 46             delta[0] = (diff[0] = abs(image.at<uchar>(x,y) - image.at<uchar>(x, y-3))) > threshold;
 47             delta[8] = (diff[8] = abs(image.at<uchar>(x,y) - image.at<uchar>(x, y+3))) > threshold;
 48             if(getSum(delta, 16) == 0)
 49                 continue;
 50             else
 51             {
 52                 delta[12] = (diff[12] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-3, y))) > threshold;
 53                 delta[4] = (diff[4] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+3, y))) > threshold;
 54                 if(getSum(delta, 16) < 3)
 55                     continue;
 56 
 57                 else
 58                 {
 59                     delta[1] = (diff[1] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+1, y-3))) > threshold;
 60                     delta[2] = (diff[2] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+2, y-2))) > threshold;
 61                     delta[3] = (diff[3] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+3, y-1))) > threshold;
 62                                 
 63                     delta[5] = (diff[5] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+3, y+1))) > threshold;
 64                     delta[6] = (diff[6] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+2, y+2))) > threshold;
 65                     delta[7] = (diff[7] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+1, y+3))) > threshold;
 66 
 67                     delta[9] = (diff[9] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-1, y+3))) > threshold;
 68                     delta[10] = (diff[10] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-2, y+2))) > threshold;
 69                     delta[11] = (diff[11] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-3, y+1))) > threshold;
 70 
 71                     delta[13] = (diff[13] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-3, y-1))) > threshold;
 72                     delta[14] = (diff[14] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-2, y-2))) > threshold;
 73                     delta[15] = (diff[15] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-1, y-3))) > threshold;
 74 
 75                     if(getSum(delta, 16) >= 12)
 76                     {
 77                         points.push_back(Point(y,x));
 78                         fastScore.at<float>(x,y) = getSum(diff, 16);
 79                         fastImg.at<uchar>(x,y) = 255;
 80                     }
 81                 }
 82             }
 83         }
 84 
 85     }
 86 
 87     vector<Point>::const_iterator itp = points.begin();
 88     while(itp != points.end())
 89     {
 90         circle(image, *itp, 3, Scalar(255), 1);
 91         ++itp;
 92     }
 93     //未进行非极大值抑制之前的特征点检测结果
 94     namedWindow("Fast Image");
 95     imshow("Fast Image", image);
 96 
 97     /* 3.对特征点候选点进行非极大值抑制 */
 98     image = imread("../church01.jpg", 0);
 99     Mat dilated(fastScore.size(), CV_32F, Scalar(0));
100     Mat localMax;
101     Mat element(7, 7, CV_8U, Scalar(1));
102     dilate(fastScore, dilated, element);
103     compare(fastScore, dilated, localMax, CMP_EQ);
104     bitwise_and(fastImg, localMax, fastImg);
105 
106     for(int x = 0;x < fastImg.cols; x++)
107     {
108         for(int y = 0; y < fastImg.rows; y++)
109         {
110             if(fastImg.at<uchar>(y,x))
111             {
112                 circle(image, Point(x,y), 3, Scalar(255), 1);
113 
114             }
115         }
116     }
117     //进行非极大值抑制之后的特征点检测结果
118     namedWindow("Fast Image2");
119     imshow("Fast Image2", image);
120 
121     waitKey();
122     return 0;
123 }
  1 #include <iostream>
  2 #include <core/core.hpp>
  3 #include <highgui/highgui.hpp>
  4 #include <imgproc/imgproc.hpp>
  5 #include <features2d/features2d.hpp>
  6 
  7 using namespace std;
  8 using namespace cv;
  9 
 10 
 11 int getSum(uchar *p, int length)
 12 {
 13     int sum = 0;
 14     for(int i=0;i<length; i++)
 15     {
 16         sum += *(p+i);
 17     }
 18     return sum;
 19 }
 20 
 21 int main(int argc, char* argv[])
 22 {
 23     /* 1.读入图像 */
 24     Mat image = imread("../church01.jpg", 0);
 25     if(!image.data)
 26         return 0;
 27 
 28     namedWindow("Original Image");
 29     imshow("Original Image", image);
 30 
 31     Mat fastImg(image.size(), CV_8U, Scalar(0));//用于保存Fast特征点候选点
 32     Mat fastScore(image.size(), CV_32F, Scalar(0));//用于计算候选点score
 33     vector<Point> points;
 34     int rows, cols, threshold;
 35     rows = image.rows;
 36     cols = image.cols;
 37     threshold = 50;
 38 
 39     /* 2.检测Fast特征点 */
 40     for(int x = 3; x < rows - 3; x++)
 41     {
 42         for(int y = 3; y < cols - 3; y++)
 43         {
 44             uchar delta[16] = {0};
 45             uchar diff[16] = {0};
 46             delta[0] = (diff[0] = abs(image.at<uchar>(x,y) - image.at<uchar>(x, y-3))) > threshold;
 47             delta[8] = (diff[8] = abs(image.at<uchar>(x,y) - image.at<uchar>(x, y+3))) > threshold;
 48             if(getSum(delta, 16) == 0)
 49                 continue;
 50             else
 51             {
 52                 delta[12] = (diff[12] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-3, y))) > threshold;
 53                 delta[4] = (diff[4] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+3, y))) > threshold;
 54                 if(getSum(delta, 16) < 3)
 55                     continue;
 56 
 57                 else
 58                 {
 59                     delta[1] = (diff[1] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+1, y-3))) > threshold;
 60                     delta[2] = (diff[2] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+2, y-2))) > threshold;
 61                     delta[3] = (diff[3] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+3, y-1))) > threshold;
 62                                 
 63                     delta[5] = (diff[5] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+3, y+1))) > threshold;
 64                     delta[6] = (diff[6] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+2, y+2))) > threshold;
 65                     delta[7] = (diff[7] = abs(image.at<uchar>(x,y) - image.at<uchar>(x+1, y+3))) > threshold;
 66 
 67                     delta[9] = (diff[9] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-1, y+3))) > threshold;
 68                     delta[10] = (diff[10] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-2, y+2))) > threshold;
 69                     delta[11] = (diff[11] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-3, y+1))) > threshold;
 70 
 71                     delta[13] = (diff[13] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-3, y-1))) > threshold;
 72                     delta[14] = (diff[14] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-2, y-2))) > threshold;
 73                     delta[15] = (diff[15] = abs(image.at<uchar>(x,y) - image.at<uchar>(x-1, y-3))) > threshold;
 74 
 75                     if(getSum(delta, 16) >= 12)
 76                     {
 77                         points.push_back(Point(y,x));
 78                         fastScore.at<float>(x,y) = getSum(diff, 16);
 79                         fastImg.at<uchar>(x,y) = 255;
 80                     }
 81                 }
 82             }
 83         }
 84 
 85     }
 86 
 87     vector<Point>::const_iterator itp = points.begin();
 88     while(itp != points.end())
 89     {
 90         circle(image, *itp, 3, Scalar(255), 1);
 91         ++itp;
 92     }
 93     //未进行非极大值抑制之前的特征点检测结果
 94     namedWindow("Fast Image");
 95     imshow("Fast Image", image);
 96 
 97     /* 3.对特征点候选点进行非极大值抑制 */
 98     image = imread("../church01.jpg", 0);
 99     Mat dilated(fastScore.size(), CV_32F, Scalar(0));
100     Mat localMax;
101     Mat element(7, 7, CV_8U, Scalar(1));
102     dilate(fastScore, dilated, element);
103     compare(fastScore, dilated, localMax, CMP_EQ);
104     bitwise_and(fastImg, localMax, fastImg);
105 
106     for(int x = 0;x < fastImg.cols; x++)
107     {
108         for(int y = 0; y < fastImg.rows; y++)
109         {
110             if(fastImg.at<uchar>(y,x))
111             {
112                 circle(image, Point(x,y), 3, Scalar(255), 1);
113 
114             }
115         }
116     }
117     //进行非极大值抑制之后的特征点检测结果
118     namedWindow("Fast Image2");
119     imshow("Fast Image2", image);
120 
121     waitKey();
122     return 0;
123 }

  代码运行结果如下,比较第2/3摆图可以发现,非极大值抑制有所过滤掉一部分区域中非宏大值角点的图。

  代码运行结果如下,比较第2/3摆图可以发现,非极大值抑制有所过滤掉一部分区域中非宏值角点的用意。

图片 3图片 4图片 5

图片 6图片 7图片 8

4.算法小结

4.算法小结

   
该算法思想简单,运算量很有点,适合实时检测点的采取。不过为出瑕疵,主要呈现吗对于边缘点与噪点区分能力不强,当然后面呢时有发生好多丁当斯基础及加以改良提高算法的长治久安。

   
该算法思想简单,运算量很有点,适合实时检测方面的用。不过也有弱点,主要呈现吗于边缘点与噪点区分能力不高,当然后面也出成百上千人在此基础及加以改良提高算法的安宁。

5.参考文献

5.参考文献

 [1]《opencv2计算机视觉编程手册》

 [1]《opencv2计算机视觉编程手册》

 [2]【特征检测】FAST特征检测算法(http://blog.csdn.net/hujingshuang/article/details/46898007)

 [2]【特征检测】FAST特征检测算法(http://blog.csdn.net/hujingshuang/article/details/46898007)