Optimal Painting and Restoration