harris推导,参见opencv文档
-
Let’s look for corners. Since corners represents a variation in the gradient in the image, we will look for this “variation”.
-
Consider a grayscale image
. We are going to sweep a window
(with displacements
in the x direction and
in the right direction)
and will calculate the variation of intensity.
-
where:
is the window at position
is the intensity at
is the intensity at the moved window
-
Since we are looking for windows with corners, we are looking for windows with a large variation in intensity. Hence, we have to maximize the equation above, specifically the term:
-
Using Taylor expansion:
-
Expanding the equation and cancelling properly:
-
Which can be expressed in a matrix form as:
-
Let’s denote:
-
So, our equation now is:
-
A score is calculated for each window, to determine if it can possibly contain a corner:
where:
- det(M) =
- trace(M) =
a window with a score
greater than a certain value is considered a “corner”
- det(M) =
中文说明:
Harris角点算法实现
根据上述讨论,可以将Harris图像角点检测算法归纳如下,共分以下五步:
1. 计算图像I(x,y)I(x,y)在XX和YY两个方向的梯度Ix、IyIx、Iy。
2. 计算图像两个方向梯度的乘积。
3. 使用高斯函数对I2x、I2y和IxyIx2、Iy2和Ixy进行高斯加权(取σ=1σ=1),生成矩阵MM的元素A、BA、B和CC。
4. 计算每个像素的Harris响应值RR,并对小于某一阈值tt的RR置为零。
5. 在3×33×3或5×55×5的邻域内进行非最大值抑制,局部最大值点即为图像中的角点。