Python+OpenCV:图像Shi-Tomasi角点检测器

82 篇文章 20 订阅

Python+OpenCV:图像Shi-Tomasi角点检测器

理论

The scoring function in Harris Corner Detector was given by:


Instead of this, Shi-Tomasi proposed:


If it is a greater than a threshold value, it is considered as a corner. If we plot it in λ1−λ2 space as we did in Harris Corner Detector, we get an image as below:

示例

####################################################################################################
# 图像Shi-Tomasi角点检测(Shi-Tomasi Corner Detector)
def lmc_cv_image_shi_tomasi_corner_detection():
    """
        函数功能: 图像Shi-Tomasi角点检测(Shi-Tomasi Corner Detector)。
    """

    stacking_images = []
    image_file_name = ['D:/99-Research/Python/Image/CheckerBoard.jpg',
                       'D:/99-Research/Python/Image/CheckerBoard02.jpg',
                       'D:/99-Research/Python/Image/CheckerBoard04.jpg',
                       'D:/99-Research/Python/Image/CheckerBoard07.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)
        result_image = image.copy()
        gray_image = lmc_cv.cvtColor(image, lmc_cv.COLOR_BGR2GRAY)

        # find Shi-Tomasi corners
        corners = lmc_cv.goodFeaturesToTrack(gray_image, 25, 0.001, 10)
        corners = np.int0(corners)
        # Now draw them
        for j in range(len(corners)):
            x, y = corners[j].ravel()
            lmc_cv.circle(result_image, center=(x, y), radius=5, color=(255, 0, 255), thickness=3,
                          lineType=lmc_cv.LINE_8, shift=0)

        # stacking images side-by-side
        stacking_image = np.hstack((image, result_image))
        stacking_images.append(stacking_image)

    # 显示图像
    for i in range(len(stacking_images)):
        pyplot.figure('Shi-Tomasi Corner Detection %d' % (i + 1))
        pyplot.subplot(1, 1, 1)
        pyplot.imshow(stacking_images[i], 'gray')
        pyplot.xticks([])
        pyplot.yticks([])
    pyplot.show()

    # 根据用户输入保存图像
    if ord("q") == (lmc_cv.waitKey(0) & 0xFF):
        # 销毁窗口
        pyplot.close('all')
    return

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值