Binary Partitioning, Perceptual Grouping, and Restoration with Semidefinite Programming