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 I. We are going to sweep a window w(x,y) (with displacements u in the x direction and v in the right direction) I 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:

    • w(x,y) is the window at position (x,y)
    • I(x,y) is the intensity at (x,y)
    • I(x+u,y+v) 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 R greater than a certain value is considered a “corner”

中文说明:

Harris角点算法实现

根据上述讨论,可以将Harris图像角点检测算法归纳如下,共分以下五步:

1. 计算图像I(x,y)I(x,y)在XX和YY两个方向的梯度IxIyIx、Iy。

Ix=Ix=I(1 0 1)Iy=Ix=I(1 0 1)TIx=∂I∂x=I⊗(−1 0 1),Iy=∂I∂x=I⊗(−1 0 1)T

 

2. 计算图像两个方向梯度的乘积。

I2x=IxIyI2y=IyIyIxy=IxIyIx2=Ix⋅Iy,Iy2=Iy⋅Iy,Ixy=Ix⋅Iy

 

3. 使用高斯函数对I2xI2yIxyIx2、Iy2和Ixy进行高斯加权(取σ=1σ=1),生成矩阵MM的元素ABA、B和CC。

A=g(I2x)=I2xwC=g(I2y)=I2ywB=g(Ix,y)=IxywA=g(Ix2)=Ix2⊗w,C=g(Iy2)=Iy2⊗w,B=g(Ix,y)=Ixy⊗w

 

4. 计算每个像素的Harris响应值RR,并对小于某一阈值tt的RR置为零。

R={R:detMα(traceM)2<t}R={R:detM−α(traceM)2<t}

 

5. 在3×33×3或5×55×5的邻域内进行非最大值抑制,局部最大值点即为图像中的角点。

posted @ 2017-02-13 11:48  duimu  阅读(227)  评论(0编辑  收藏  举报