Relaxational metric adaptation and its application to semi-supervised clustering and content-based image retrieval