Contour analysis and shape matching