I want to develop a procedure to remove some inpainted text from images, i.e. I have to estimate the inpainted pixels. I will do that with first an imputation step and then applying SVD (and perhaps later further improvements).

The imputations step just have to give an initial guess of the inpainted pixels. I thought of applying a gaussian filter to get estimates of the inpainted pixels, but I think this does not give good results.

Does somebody know another way to get good inital guesses, i.e. imputations?

  • 2
    $\begingroup$ Are you aware that googleing for "inpainting matlab" will return lots of hits for very sophisticated inpainting algorithms? $\endgroup$ Commented May 1, 2014 at 9:33
  • 1
    $\begingroup$ Here's a survey article to get you started. $\endgroup$
    – Emre
    Commented May 1, 2014 at 23:01
  • 1
    $\begingroup$ I would have a look at blind source separation tutorials and this dsp question for the inpainting. $\endgroup$
    – Maurits
    Commented Oct 29, 2014 at 13:55

1 Answer 1


Proposal 1: Gaussian filter of large radius computed by assigning a null weight to any pixel that belongs to the inpainted area (so that the color of the text you want to get rid of does not "bleed").

Proposal 2: Colour of the nearest pixel which does not belong to the inpainted area.

Proposal 3: For each pixel, randomly sample a handful of points outside of the inpainted area, but not too far away from this pixel. Average the pixel values, weighted by the distance to the pixel.

  • $\begingroup$ Thank you very much. Proposal 1: In matlab I have the following code for a gaussian filter: function f=gaussian2d(N,sigma) [x y]=meshgrid(round(-N/2):round(N/2), round(-N/2):round(N/2)); f=exp(-x.^2/(2*sigma^2)-y.^2/(2*sigma^2)); f=f./sum(f(:)); Then I can apply convolution, e.g. filtered_signal=conv2(image,gaussian2d(N,sig),'same'); How can I assign null weight to any inpainted pixel? My images are 512x512 pixels and I have a mask of same size for determining where the inpainting is. I.e. the mask is 1 everywhere where an inpainting is and otherwise 0. $\endgroup$ Commented May 1, 2014 at 9:27
  • $\begingroup$ Sorry, I don't know how to add linebreaks. Proposal 1 continued: With large radius you mean a large N in my above code? I.e. a large kernel matrix. $\endgroup$ Commented May 1, 2014 at 9:29
  • $\begingroup$ @DictionaryProver: " How can I assign null weight to any inpainted pixel?". Simple: You set the inpainted pixel to 0, apply a gaussian filter. Then you apply he same gaussian filter to your mask. Then you divide the two. $\endgroup$ Commented May 1, 2014 at 9:32
  • $\begingroup$ Proposal 2 and 3: How could I do that efficiently? I really don't see it and I think just loops are not good. ;) I think of some matrix operations because I have a mask matrix as said above but I don't see it. $\endgroup$ Commented May 1, 2014 at 9:32
  • $\begingroup$ @nikie: the inpainted pixels are already 0 because they are black. Do I have to do elementwise division, i.e. in Matlab A./B? $\endgroup$ Commented May 1, 2014 at 9:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.