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. -
![E(u,v) = \sum _{x,y} w(x,y)[ I(x+u,y+v) - I(x,y)]^{2}]()
where:
is the window at position ![(x,y)]()
is the intensity at ![(x,y)]()
is the intensity at the moved window ![(x+u,y+v)]()
-
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:
![\sum _{x,y}[ I(x+u,y+v) - I(x,y)]^{2}]()
-
Using Taylor expansion:
![E(u,v) \approx \sum _{x,y}[ I(x,y) + u I_{x} + vI_{y} - I(x,y)]^{2}]()
-
Expanding the equation and cancelling properly:
![E(u,v) \approx \sum _{x,y} u^{2}I_{x}^{2} + 2uvI_{x}I_{y} + v^{2}I_{y}^{2}]()
-
Which can be expressed in a matrix form as:
![E(u,v) \approx \begin{bmatrix}
u & v
\end{bmatrix}
\left (
\displaystyle \sum_{x,y}
w(x,y)
\begin{bmatrix}
I_x^{2} & I_{x}I_{y} \\
I_xI_{y} & I_{y}^{2}
\end{bmatrix}
\right )
\begin{bmatrix}
u \\
v
\end{bmatrix}]()
-
Let’s denote:
![M = \displaystyle \sum_{x,y}
w(x,y)
\begin{bmatrix}
I_x^{2} & I_{x}I_{y} \\
I_xI_{y} & I_{y}^{2}
\end{bmatrix}]()
-
So, our equation now is:
![E(u,v) \approx \begin{bmatrix}
u & v
\end{bmatrix}
M
\begin{bmatrix}
u \\
v
\end{bmatrix}]()
-
A score is calculated for each window, to determine if it can possibly contain a corner:
![R = det(M) - k(trace(M))^{2}]()
where:
- det(M) =
![\lambda_{1}\lambda_{2}]()
- trace(M) =
![\lambda_{1}+\lambda_{2}]()
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的邻域内进行非最大值抑制,局部最大值点即为图像中的角点。
. We are going to sweep a window
(with displacements
in the x direction and
in the right direction) ![E(u,v) = \sum _{x,y} w(x,y)[ I(x+u,y+v) - I(x,y)]^{2}](http://docs.opencv.org/2.4/_images/math/64298b2668229d15649e5042e90af81a629ab075.png)

is the intensity at
is the intensity at the moved window 
![\sum _{x,y}[ I(x+u,y+v) - I(x,y)]^{2}](http://docs.opencv.org/2.4/_images/math/710a44e744b7529f26b0f3695ad3d56bfaf61a90.png)
![E(u,v) \approx \sum _{x,y}[ I(x,y) + u I_{x} + vI_{y} - I(x,y)]^{2}](http://docs.opencv.org/2.4/_images/math/610201413953d93b59b2983f1756611e7957cf04.png)







greater than a certain value is considered a “corner”
浙公网安备 33010602011771号