1. A non-transitory computer readable medium embodying instructions executable by a processor to perform a method for recovering a contour using combinatorial optimization, the method steps comprising: receiving an input image; initializing functions for gradient f, smooth background g, and contour r; determining an optimum of the gradient f of a region R in the input image; extending the optimum of the gradient f of region R to a complement of R; determining an optimum of the smooth background function g for a region Q corresponding to the complement of R; extending the optimum of the smooth background function g of region Q to a complement of Q; and determining an optimum contour r according to the optimum of the gradient f and the optimum of the smooth background function g using combinatorial optimization.