Existence and almost everywhere regularity of generalized minimizers for a class of variational problems with linear growth related to image inpainting