Figure-ground segmentation using factor graphs