Segmentation of multiscale curves by chain pyramids