计算机视觉的作业,进行Harris Corner角点检测。
1.Objective
Corners provide repeatable points for matching, so are worth detecting.
1.1 The assignment is to find Harris corners in a set of images.
1.2 If possible, try to track the corners.
2.Principle
2.1 Harris Corner Detector
In the region around a corner, gradient has two or more different values. Harris improved upon Moravec’s corner detector by considering the differential of the corner score with respect to direction directly, instead of using shifted patches. First, we form the second-moment matrix:

3.Implement of Algorithm
3.1 Harris Corner Detector
3.1.1 Computer magnitude of the x and y gradients at each pixel.
dx = [-1 0 1; -1 0 1; -1 0 1]; % filter of x
Ix = filter2(dx,I);
dy = dx'; % filter of y, dy is the transpose of dx
Iy = filter2(dy,I);
Ix2 = Ix.^2;
Iy2 = Iy.^2;
Ixy = Ix.*Iy;
clear Ix;
clear Iy;
3.1.2 Low pass filter to decrease the noise
h= fspecial('gaussian',[7 7],2); % gaussian filter to decrease the noise
Ix2 = filter2(h,Ix2);
Iy2 = filter2(h,Iy2);
Ixy = filter2(h,Ixy);
3.1.3 Form the second-moment matrix C and compute corner with formulation.
C = [Ix2(i,j) Ixy(i,j);Ixy(i,j) Iy2(i,j)]; % form the second-moment matrix
R(i,j) = det(C)-0.04*(trace(C))^2; % calculate R with k=0.04
3.1.4 Perform non-maximal suppression and threshold.
if R(i,j) > 0.01*Rmax && R(i,j) > R(i-1,j-1) && R(i,j) > R(i-1,j) && R(i,j) > R(i-1,j+1) && R(i,j) > R(i,j-1) && R(i,j) > R(i,j+1) && R(i,j) > R(i+1,j-1) && R(i,j) > R(i+1,j) && R(i,j) > R(i+1,j+1)
D(i,j) = 1;
cnt = cnt+1;
The Harris corners found in each image is as below:
|
Image |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|
Number |
87 |
86 |
87 |
86 |
86 |
86 |
86 |
86 |
86 |
From the above data, we can see that the algorithm performs well in different images. Moreover, the number of corners found in different images is similar. This is because the edges in the board are obvious and corners are easier to detect.
以上只是部分程序和实验结果记录。

浙公网安备 33010602011771号