Optimization of the global matching between two contours defined by ordered points using an algorithm based on dynamic programming