Tools for segmentation and clustering