Analysis of gradient flow of a regularized Mumford-Shah functional for image segmentation and image inpainting