Contours Matching using Curvature Information and Optimization Based on Dynamic Programming