Clustering under prior knowledge with application to image segmentation