A new hierarchical method for image segmentation and inpainting using Mumford-Shah model