segmentation by template