Skip to main content
. 2020 Mar 23;20(6):1773. doi: 10.3390/s20061773
Algorithm 1: Rough matching
  • Input: - Flexible template (T)

  •       - of contours in the image (C)

  • Output: - Set of potentially matching contours (M)

  •       - Set of starting points for each ith matching contour (Si)

  •       - Set of combinations of feature points for each mi € M and sij € Si (Fij)

  • i ← 0% reset number of potentially matching contours

  • for each ck € C do

  •   % create set Pk = (pk: pk is feature point of kth contour}

  •   q ← get number of points belonging to ck

  •   for n = 1..q do

  •    crvkn ← compute curvature for nth point of ck

  •    drvkn ← compute derivative of curvature for nth point of ck

  •   end for

  •   l ← 0% reset number of feature points for ck

  •   for n = 1..q do

  •    if crvkn is local extremum then

  •     l ← l + 1

  •     type(pkl) ← 1% create feature point of type 1

  •     x(pkl),y(pkl) ← get coordinates of nth point of ck

  •    end if

  •    if drvkn is local extremum then

  •     l ← l + 1

  •     type(pkl) ← 1% create feature point of type 2

  •     x(pkl),y(pkl) ← get coordinates of nth point of ck

  •    end if

  •   end for

  •   % Attempts to superimpose template T on contour ck

  •   i ← i + 1% increase number of potentially matching contours

  •   mi ← ck % assume ck as ith matching contour mi € M

  •   j ← 0% reset number of starting points for mi

  •   for each pkl € Pk do

  •     j ← j + 1% increase starting point number

  •     sij ← pkl % assume pkl as jth starting point sij € Si

  •     FPK ← create feature point combinations for jth starting point

  •     e ← 0% reset number of feature point combinations

  •     for u = 1..|FPK| do

  •      e ← e + 1% increase number of matching combinations

  •      fije ← fpku % assume fpku € FPK as eth combination fije € Fij

  •      match ← true % auxiliary logical variable

  •      for each template statement ty € T do

  •       if conditions imposed by ty are not fulfilled by fije then

  •        match ← false

  •       end if

  •      end for

  •      if not match then

  •       e ← e − 1

  •       delete e th feature point combination f kne

  •      end if

  •     end for

  •     if e = 0 then

  •      j ← j − 1% decrease starting point number

  •     end if

  •   end for

  •   if j = 0 then

  •     i ← i − 1% decrease matching contour number

  •   end if

  • end for