- 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”
中文说明:
Harris角点算法实现
根据上述讨论,可以将Harris图像角点检测算法归纳如下,共分以下五步:
1. 计算图像I(x,y)I(x,y)在XX和YY两个方向的梯度Ix、IyIx、Iy。
Ix=?I?x=I?(?1 0 1),Iy=?I?x=I?(?1 0 1)TIx=?I?x=I?(?1 0 1),Iy=?I?x=I?(?1 0 1)T
2. 计算图像两个方向梯度的乘积。
I2x=Ix?Iy,I2y=Iy?Iy,Ixy=Ix?IyIx2=Ix?Iy,Iy2=Iy?Iy,Ixy=Ix?Iy
3. 使用高斯函数对I2x、I2y和IxyIx2、Iy2和Ixy进行高斯加权(取σ=1σ=1),生成矩阵MM的元素A、BA、B和CC。
A=g(I2x)=I2x?w,C=g(I2y)=I2y?w,B=g(Ix,y)=Ixy?wA=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的邻域内进行非最大值抑制,局部最大值点即为图像中的角点。
时间: 2024-10-16 16:55:16