Input:
 (i) 𝑆 𝑖 : a sequence of 𝑖 points
Data:
  (i) 𝐿 : the set of all the detected points
  (ii) 𝑙 𝑖 : the last point in the sequence 𝑆 𝑖
  (iii) 𝑉 : a set of sequences composed by 2 𝑁 points
  (iv) 𝛼 : the height of a vertebra
  (v) 𝛽 : the size of an intervertebral space
begin
   if 𝑖 = 2 𝑁 1   then
   Add 𝑙 2 𝑁 to 𝑆 𝑖 ;
   Add 𝑆 𝑖 to 𝑉 ;
   return;
else
   if 𝑙 𝑖   is an upper corner then
      foreach 𝑙   in 𝐿   do
      if 𝛼 𝛿 𝛼 < 𝑑 𝑖 𝑠 𝑡 ( 𝑙 𝑖 , 𝑙 ) < 𝛼 + 𝛿 𝛼   then
       Remove 𝑙 from 𝐿 ;
        𝑆 𝑖 + 1 = 𝑆 𝑖 𝑙 ;
        𝑅 𝑒 𝑐 𝑢 𝑟 𝑠 𝑖 𝑣 𝑒 𝐹 𝑢 𝑛 𝑐 𝑡 𝑖 𝑜 𝑛 ( 𝑆 𝑖 + 1 ) ;
   else
   foreach 𝑙   in 𝐿   do
      if 𝛽 𝛿 𝛽 < d i s t ( 𝑙 𝑖 , 𝑙 ) < 𝛽 + 𝛿 𝛽   then
        Remove 𝑙 from 𝐿 ;
         𝑆 𝑖 + 1 = 𝑆 𝑖 𝑙 ;
         𝑅 𝑒 𝑐 𝑢 𝑟 𝑠 𝑖 𝑣 𝑒 𝐹 𝑢 𝑛 𝑐 𝑡 𝑖 𝑜 𝑛 ( 𝑆 𝑖 + 1 ) ;
Algorithm 2: RecursiveFunction ( 𝑆 𝑖 ) .