Contour matching and drawing