Image Processing Reference
In-Depth Information
spaces (Aguado, 1996b). Of course you can avoid using the gradient direction in Equation
5.68 by including more points. In fact, the tangent φ′′ (θ ) can be computed by taking four
points (Aguado, 1996a). However, the inclusion of more points generally leads to more
background noise in the accumulator.
Code 5.9 shows the implementation of the ellipse location mapping in Equation 5.57. As
in the case of the circle, pairs of points need to be restricted to a neighbourhood. In the
implementation, we consider pairs at a fixed distance given by the variable i . Since we are
including gradient direction information, the resulting peak is generally quite wide. Again,
the selection of the distance between points is a compromise between the level of background
noise and the width of the peak.
%Parameter Decomposition for Ellipses
function HTDEllipse(inputimage)
%image size
[rows,columns]=size(inputimage);
%edges
[M,Ang]=Edges(inputimage);
M=MaxSupr(M,Ang);
%accumulator
acc=zeros(rows,columns);
%gather evidence
for x1=1:columns
for y1=1:1:rows
if(M(y1,x1)~=0)
for i=60:60
x2=x1-i; y2=y1-I;
incx=1; incy=0;
for k=0: 8*i-1
if(x2>0 & y2>0 & x2<columns & y2<rows)
if M(y2,x2)~=0
m1=Ang(y1,x1); m2=Ang(y2,x2);
if(abs(m1-m2)>.2)
xm=(x1+x2)/2; ym=(y1+y2)/2;
m1=tan(m1); m2=tan(m2);
A=y1-y2; B=x2-x1;
C=m1+m2; D=m1*m2
N=(2*A+B*C)
if N~=0
m=(A*C+2*B*D)/N;
else
m=99999999;
end
Search WWH ::




Custom Search