Multiscale contour matching with basis functions