Input:
  (i) 𝑙 1 : the upper anterior corner of the first vertebra
  (ii)   𝑙 2 𝑁 : the lower anterior corner of the last vertebra
  (iii)  𝐿 : the set of all the detected points
Data:
  (i) 𝑆 𝑖 : a sequence of 𝑖 points
  (ii) 𝑉 : a set of sequences composed by 2 𝑁 points
Result:
  (i) 𝑆 : the sequence of 2 𝑁 points minimizing the path between 𝑙 1 and 𝑙 2 𝑁
begin
   𝑆 0 = ;
   𝑆 1 = 𝑆 0 𝑙 1 ;
   𝑉 = ;
  RecursiveFunction ( 𝑆 1 ) ;
  min = distance between 𝑙 1 and 𝑙 2 𝑁 in 𝑉 ( 1 ) ;
   𝑖 𝑛 𝑑 𝑒 𝑥 𝑀 𝑖 𝑛 = 1
  for 𝑖 = 2 𝑠 𝑖 𝑧 𝑒 ( 𝑉 )   do
     dist = distance between 𝑙 1 and 𝑙 2 𝑁 in 𝑉 ( 𝑖 ) ;
     if 𝑑 𝑖 𝑠 𝑡 𝑚 𝑖 𝑛   then
   𝑚 𝑖 𝑛 = 𝑑 ;
   𝑖 𝑛 𝑑 𝑒 𝑥 𝑀 𝑖 𝑛 = 𝑖 ;
   𝑆 = 𝑉 ( 𝑖 𝑛 𝑑 𝑒 𝑥 𝑀 𝑖 𝑛 ) ;
Algorithm 1: Determine the sequence of the vertebra corners.