基于边界的模板匹配的原理及算法实现

最近被Halcon中的基于边缘的模板匹配算法吸引到了,故找到了一点点学习资料,供同行参阅,水平有限,大家多包含。本文算法很初级,做入门了解用。原文是英文,所以把原文copy 过来了,另加了一些中文。算法运行效果如下:

【效果还行,只是原理性示意,不要要求太高了哦】

Introduction

Template matching is an image processing problem to find the location of an object using a template image in another search image when its pose (X, Y, θ) is unknown. In this article, we implement an algorithm that uses an object’s edge information for recognizing the object in the search image.

【注意边缘点集的特征:(X, Y, θ) 】

Background

【二大主流模板匹配框架,基于灰度的模板匹配和基于特征的模板匹配,本文的方法属于后者】

Template matching is inherently a tough problem due to its speed and reliability issues. The solution should be robust against brightness changes when an object is partially visible or mixed with other objects, and most importantly, the algorithm should be computationally efficient. There are mainlytwo approaches to solve this problem,gray value based matching (or area based matching) and feature based matching (non area based).

Gray value based approach: In gray value based matching, theNormalized Cross Correlation (NCC) algorithm is known from old days. This is typically done at every step by subtracting the mean and dividing by the standard deviation. The cross correlation of template t(x, y) with a sub image f(x, y) is:

Where n is the number of pixels in t(x, y) and f(x, y). [Wiki]

Though this method is robust against linear illumination changes, the algorithm will fail when the object is partially visible or the object is mixed with other objects. Moreover, this algorithm is computationally expensive since it needs to compute the correlation between all the pixels in the template image to the search image.

Feature based approach:Several methods of feature based template matching are being used in the image processing domain. Likeedge based object recognition where the object edges are features for matching, inGeneralized Hough transform, an object’s geometric features will be used for matching.

In this article, we implement an algorithm that uses an object’s edge information for recognizing the object in a search image. This implementation uses the Open-Source Computer Vision library as a platform.【基于opencv2.0的实现】

The algorithm

【边缘检测是算法的核心,算法思路跟Canny差不多】

Here, we are explaining an edge based template matching technique. An edge can be defined as points in a digital image at which the image brightness changes sharply or has discontinuities. Technically, it is a discrete differentiation operation, computing an approximation of the gradient of the image intensity function.

There are many methods for edge detection, but most of them can be grouped into two categories:search-based and zero-crossing based. Thesearch-based methods detect edges by first computing a measure of edge strength, usually a first-order derivative expression such as the gradient magnitude, and then searching for local directional maxima of the gradient magnitude using a computed estimate of the local orientation of the edge, usually the gradient direction. Here, we are using such a method implemented by Sobel known as Sobel operator. The operator calculates the gradient of the image intensity at each point, giving the direction of the largest possible increase from light to dark and the rate of chang

  • 12
    点赞
  • 140
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 20
    评论
黑盒攻击算法是对深度学习模型进行攻击的一种方法,它不需要对模型的内部结构和参数有任何了解,只需要访问模型的输入和输出。基于决策边界的黑盒攻击算法则是一种特定的黑盒攻击算法,它利用模型的决策边界来生成对抗样本,以欺骗模型的分类结果。 决策边界是指模型将不同类别的输入样本分开的边界,例如在二分类问题中,决策边界就是将正样本和负样本分开的直线或曲线。基于决策边界的黑盒攻击算法通过构造对抗样本来改变决策边界的位置,使得模型对原始样本的分类错误。 具体来说,基于决策边界的黑盒攻击算法可以分为以下几个步骤: 1. 收集样本。攻击者需要收集一些模型已经分类过的样本,并记录它们的标签和特征。 2. 选择攻击目标。攻击者需要选择一个或多个模型输出的错误分类作为攻击目标。 3. 构造对抗样本。攻击者利用已收集的样本和攻击目标,通过一些优化算法(如梯度下降)来生成对抗样本。这些对抗样本在原始样本的基础上进行微小的修改,以使得模型将其分类为攻击目标所要求的类别。 4. 测试对抗样本。攻击者测试生成的对抗样本是否能够欺骗模型,并记录攻击成功的概率和对抗样本的质量。 5. 优化攻击算法。攻击者通过不断地优化攻击算法,使得对抗样本生成的效率和攻击成功的概率都达到最优。 需要注意的是,基于决策边界的黑盒攻击算法并不是万能的,它只能欺骗那些依赖于决策边界的模型,而对于一些更加复杂的模型(如循环神经网络),其决策边界往往不是明确的,因此该算法并不适用。此外,攻击者也需要考虑攻击对抗样本对现实应用的影响,以避免造成不必要的损失。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小新识图

你的鼓励是我最大的分享动力。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值