Image segmentation evaluation function