Optimal embedding for shape indexing in medical image databases