Python+OpenCV:图像快速角点检测算法(FAST Algorithm for Corner Detection)

理论

Feature Detection using FAST

  1. Select a pixel p in the image which is to be identified as an interest point or not. Let its intensity be Ip.
  2. Select appropriate threshold value t.
  3. Consider a circle of 16 pixels around the pixel under test. (See the image below).

  4. Now the pixel p is a corner if there exists a set of n contiguous pixels in the circle (of 16 pixels) which are all brighter than Ip+t, or all darker than Ip−t. (Shown as white dash lines in the above image). n was chosen to be 12.

  5. high-speed test was proposed to exclude a large number of non-corners. This test examines only the four pixels at 1, 9, 5 and 13 (First 1 and 9 are tested if they are too brighter or darker. If so, then checks 5 and 13). If p is a corner, then at least three of these must all be brighter than Ip+t or darker than Ip−t. If neither of these is the case, then p cannot be a corner. The full segment test criterion can then be applied to the passed candidates by examining all pixels in the circle. This detector in itself exhibits high performance, but there are several weaknesses:

  • It does not reject as many candidates for n < 12.
  • The choice of pixels is not optimal because its efficiency depends on ordering of the questions and distribution of corner appearances.
  • Results of high-speed tests are thrown away.
  • Multiple features are detected adjacent to one another.

First 3 points are addressed with a machine learning approach. Last one is addressed using non-maximal suppression.

Machine Learning a Corner Detector

  1. Select a set of images for training (preferably from the target application domain)
  2. Run FAST algorithm in every images to find feature points.
  3. For every feature point, store the 16 pixels around it as a vector. Do it for all the images to get feature vector P.
  4. Each pixel (say x) in these 16 pixels can have one of the following three states:

  5. Depending on these states, the feature vector P is subdivided into 3 subsets, Pd, Ps, Pb.
  6. Define a new boolean variable, Kp, which is true if p is a corner and false otherwise.
  7. Use the ID3 algorithm (decision tree classifier) to query each subset using the variable Kp for the knowledge about the true class. It selects the x which yields the most information about whether the candidate pixel is a corner, measured by the entropy of Kp.
  8. This is recursively applied to all the subsets until its entropy is zero.
  9. The decision tree so created is used for fast detection in other images.

Non-maximal Suppression

Detecting multiple interest points in adjacent locations is another problem. It is solved by using Non-maximum Suppression.

  1. Compute a score function, V for all the detected feature points. V is the sum of absolute difference between p and 16 surrounding pixels values.
  2. Consider two adjacent keypoints and compute their V values.
  3. Discard the one with lower V value.

FAST Feature Detector in OpenCV

####################################################################################################
# 图像快速角点检测算法(FAST Algorithm for Corner Detection)
def lmc_cv_image_fast_corner_detection():"""函数功能: 图像快速角点检测算法(FAST Algorithm for Corner Detection)。"""stacking_images = []image_file_name = ['D:/99-Research/Python/Image/Butterfly01.jpg','D:/99-Research/Python/Image/Butterfly02.jpg','D:/99-Research/Python/Image/Butterfly03.jpg','D:/99-Research/Python/Image/Butterfly04.jpg']for i in range(len(image_file_name)):# 读取图像image = lmc_cv.imread(image_file_name[i])image = lmc_cv.cvtColor(image, lmc_cv.COLOR_BGR2RGB)gray_image = lmc_cv.cvtColor(image, lmc_cv.COLOR_BGR2GRAY)# Initiate FAST object with default valuesfast = lmc_cv.FastFeatureDetector_create()# find and draw the keypointskeypoints = fast.detect(gray_image, None)result_image1 = lmc_cv.drawKeypoints(gray_image, keypoints, None, color=(255, 0, 0),flags=lmc_cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)# Print all default paramsprint("Threshold: {}".format(fast.getThreshold()))print("nonmaxSuppression:{}".format(fast.getNonmaxSuppression()))print("neighborhood: {}".format(fast.getType()))print("Total Keypoints with nonmaxSuppression: {}".format(len(keypoints)))# Disable nonmaxSuppressionfast.setNonmaxSuppression(0)kp = fast.detect(gray_image, None)print("Total Keypoints without nonmaxSuppression: {}".format(len(kp)))result_image2 = lmc_cv.drawKeypoints(gray_image, keypoints, None, color=(255, 0, 0),flags=lmc_cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)# stacking images side-by-sidestacking_image = np.hstack((image, result_image1, result_image2))stacking_images.append(stacking_image)# 显示图像for i in range(len(stacking_images)):pyplot.figure('FAST Algorithm for Corner Detection %d' % (i + 1))pyplot.subplot(1, 1, 1)pyplot.imshow(stacking_images[i], 'gray')pyplot.title('FAST Algorithm for Corner Detection')pyplot.xticks([])pyplot.yticks([])pyplot.show()# 根据用户输入保存图像if ord("q") == (lmc_cv.waitKey(0) & 0xFF):# 销毁窗口pyplot.close('all')return

Python+OpenCV:图像快速角点检测算法(FAST Algorithm for Corner Detection)相关推荐

  1. Python+OpenCV:图像Harris角点检测(Harris Corner Detection)

    Python+OpenCV:图像Harris角点检测(Harris Corner Detection) 理论 corners are regions in the image with large v ...

  2. 基于Python手动实现Harris角点检测

    最近在上数字图像处理课程,需要使用Python手动编写Harris角点检测算法,但是网上几乎没有找到手动编写的,只能手敲. 同时作为自己的第一篇博客,在这里记录一下. 一.Harris角点检测 原理( ...

  3. fast角点检测 java_米联客 ZYNQ/SOC 精品教程 S04-CH11 快速角点检测之硬件实现

    软件版本:VIVADO2017.4 操作系统:WIN10 64bit 硬件平台:适用米联客 ZYNQ系列开发板 米联客(MSXBO)论坛:www.osrc.cn答疑解惑专栏开通,欢迎大家给我提问!! ...

  4. python 角点检测_python 实现Harris角点检测算法

    算法流程: 将图像转换为灰度图像 利用Sobel滤波器求出 海森矩阵 (Hessian matrix) : 将高斯滤波器分别作用于Ix².Iy².IxIy 计算每个像素的 R= det(H) - k( ...

  5. python 图像处理 角点检测算法 Harris和Shi-tomasi

    一.使用opencv库调用实现编写Harris和Shi-tomasi算法 最主要函数为: cv2.cornerHarris() cv2.goodFeaturesToTrack() 代码中注释有介绍其用 ...

  6. python 角点检测_python实现Harris角点检测算法

    算法流程: 将图像转换为灰度图像 利用Sobel滤波器求出 海森矩阵 (Hessian matrix) : 将高斯滤波器分别作用于Ix².Iy².IxIy 计算每个像素的 R= det(H) - k( ...

  7. OpenCV —— 角点检测之 Harris 角点检测、Shi-Tomasi 角点检测、FAST 角点检测

    角点检测 Harris 角点检测 实现原理 OpenCV 函数 优化 Shi-Tomasi 角点检测 实现原理 OpenCV 函数 FAST 角点检测 实现原理 OpenCV 函数 优化 在图像处理和 ...

  8. harris角点检测算法实现

    算法流程: 1.将图像转换为灰度图像: 2.利用Sobel滤波器求出 海森矩阵 (Hessian matrix) : 3.将高斯滤波器分别作用于Ix².Iy².IxIy: 4.计算每个像素的 R= d ...

  9. 用形态学的方法实现图像的角点检测

    图像处理开发需求.图像处理接私活挣零花钱,请加微信/QQ 2487872782 图像处理开发资料.图像处理技术交流请加QQ群,群号 271891601 形态学角点检测原理:根据角点形态学特征性质,对原 ...

最新文章

  1. 2019,归零自己,为自己重生,为自己而战
  2. 学校APP太难用,码农爸妈们自己做出开源程序,官方却要报警
  3. adsl 路由器默认密码
  4. python导入包相当于什么_Python中使用语句导入模块或包的机制研究
  5. 夺命雷公狗---PDO NO:3与连接有关的选项
  6. TCL电子港股暴涨10% 股价创5年新高
  7. PL/SQL程序设计(七)—— 触发器
  8. background:url(./images.png) no-repeat 0 center的用法
  9. org.springframework.beans.BeanUtils
  10. RabbitMQ八:交换机类型Exchange Types--Topic介绍
  11. JavaWeb实现简易新闻管理系统
  12. Android 第一次开机速度优化
  13. android listview viewstub,Android中使用ViewStub提高布局性能
  14. node.js实现网络爬虫获取区划代码和城乡划分代码
  15. Chrome鼠标手势插件:CrxMouse
  16. 如何做好aso优化,如何做好ASO关键词优化
  17. stn在mnist上的实现
  18. 国外访问学者申请政策解析
  19. 小试爬虫之豆瓣电影TOP250
  20. 十一、Cadence ic 617以及assura使用总结

热门文章

  1. Luogu P2827 蚯蚓
  2. MongoDB(三):MongoDB概念解析
  3. Kbengine游戏引擎-【4】demo-kbengine_unity3d_demo 在容器docker上安装测试
  4. LeetCode Number of Digit One
  5. OC相关-02:oc和c的基本差异
  6. 安装cifs 访问windows的共享文件
  7. 【数据迁移】Oracle冷备方式迁移数据库
  8. Linux之find exec
  9. PC端编辑 但能在PC端模拟移动端预览的富文本编辑器
  10. 大数据系列(hadoop) 集群环境搭建二