Image Processing Reference
In-Depth Information
first part of the code computes the coefficients of the matrix M according to Equation 4.56.
Then, these values are used in the curvature computation.
%Harris Corner Detector
%op=H Harris
%op=M Minimum direction
function outputimage=Harris(inputimage, op)
w=4;
%Window size=2w+1
k=100;
%Second term constant
[rows, columns]=size(inputimage);
%Image size
outputimage=zeros(rows, columns);
%Result image
[difx, dify]=Gradient(inputimage);
%Differential
[M,A]=Edges(inputimage);
%Edge Suppression
M=MaxSupr(M,A);
%compute correlation
for x=w+1: columns-w
%pixel (x,y)
for y=w+1:rows-w
if M(y, x)~=0
%compute window average
A=0;B=0;C=0;
for i=-w:w
for j=-w:w
A=A+difx(y+i,x+j)^2;
B=B+dify(y+i,x+j)^2;
C=C+difx(y+i,x+j)*dify(y+i,x+j);
end
end
if(op== H )
outputimage(y,x)=A*B-C^2-k*(A+B);
else
dx=difx(y,x);
dy=dify(y,x);
if dx*dx+dy*dy~=0
outputimage(y,x)=((A*dy*Dy-
2*C*dx*dy+B*dx*dx)/(dx*dx+dy*dy));
end
end
end
end
end
Code 4.19
Curvature by autocorrelation
Figure 4.35 shows the results of computing curvature using this implementation. The
results are capable of showing the different curvature along the border. We can observe that
k ( x , y ) produces more contrast between lines with low and high curvature than κ
u , v ( x , y ).
Search WWH ::




Custom Search