Image Segmentation Based on Quadratic Error Metrics