An adaptive image inpainting method based on the weighted mean