First, the principle
Second, the realization
Close All;clear all;i=imread ('test.tif'); [ Posx,posy]='g*');
function [posx,posy]=Harris (I)%Harris Corner Point detection%I: Input Image%PosX: Corner point x Coordinate%PosY: Corner point y coordinate i=Double(I); [M,n]=size (I); HX=[-1,0,1;-1,0,1;-1,0,1];ix=imfilter (I,HX,'Replicate','same');%x-directional differential image iy=imfilter (I,HX','Replicate','Same');%y directional differential Imageix2=ix.^2; Iy2=iy.^2; Ixy=ix.*iy;h=fspecial ('Gaussian',3,2); Ix2=imfilter (Ix2,h,'Replicate','same');%Gaussian filter Iy2=imfilter (Iy2,h,'Replicate','same'); Ixy=imfilter (Ixy,h,'Replicate','same'); R=zeros (m,n); K=0.04;% Recommended Value (0.04--0.06) forI=1: M forj=1: N R (i,j)= (Ix2 (i,j) *iy2 (i,j)-ixy (i,j) *ixy (i,j))-k* ((Ix2 (i,j) +iy2 (i,j)) ^2);%Angular Point response value Endendt=0.1*max (R (:));%threshold to control the number of corner points returned result=zeros (m,n);% non-maximal value suppression (3*3 local maximum points greater than the threshold T in Windows are considered to be corner points) forI=2: M-1 forj=2: N-1tmp=r (I-1: i+1, J-1: j+1); TMP (2,2)=0; if(R (I,J) >t&&r (i,j) >Max (tmp (:))) result (I,J)=1; End Endend[posy,posx]=find (result);
Results:
The principle and realization of Harris angle point detection