Algorithm 2 Detailed matching |
Input: - Flexible template (T)
- Set of potentially matching contours (M)
- Set of starting points for each i th contour (S i)
- Set of feature point combinations for mi€M and sij€Si (Fij)
- Maximum acceptable error (err)
Output: - Identified contour (I)
- Starting point for this contour (P)
- Set of feature points for identified contour (FP)
v ← 0% reset variant number
for each mi€M do
for each sij€Si do
for each fijk€Fij do
for each point pfijkl€fijk do
adjust parameters of lth segment of template T
end for
r ← 0% reset contour point number
for each pfijkl€fijk do
n ← get number of points corresponding to lth template segment
for q = 1..n do
r ← r + 1% increase contour point number
dijkr ← calculate distance between qth point and the template
end for
end for
match ← false % auxiliary logical variable
mseijk ← calculate the mean squared error for dijkt where t = 1..r
if mseijk < err then
v ← v + 1
if v = 1 then
match ← true
else
if mseijk < min_err then
match ← true
end if
end if
if match then
min_err = mseijk % min_err is the smallest error until now
I ← mi
P ← sij
FP ← Fijk
end if
end if
end for
end for
end for
|