Gravar e-mail: Image Segmentation as an Optimization Problem