Inpaint

Inpaint[image,region]

retouches parts of image that correspond to nonzero elements in region.

Details and Options

  • Inpaint works with arbitrary grayscale and multichannel images.
  • The region to be retouched can be given as an image, a graphics object, or a matrix.
  • Inpaint always gives an image of the same dimensions and the same type as image.
  • Inpaint operates separately on each color channel.
  • The following options can be specified:
  • MaxIterations100maximum number of iterations
    MethodAutomaticthe method to use
  • Possible method settings include:
  • "Diffusion"iterative isotropic diffusion method
    "FastMarching"fast marching method
    "NavierStokes"NavierStokes method
    "TextureSynthesis"best-fit texture synthesis method using random sampling
    "TotalVariation"iterative total variation method
  • By default, the "TextureSynthesis" method is used.
  • Inpaint operates separately on each color channel, except for the "TextureSynthesis" method.
  • With Method->{"TotalVariation",subopt}, the following suboptions can be specified:
  • "NoiseModel""Gaussian""Gaussian", "Laplacian", or "Poisson"
    "Regularization"Automaticregularization parameter
  • With Method->{"TextureSynthesis",subopt}, the following suboptions can be specified:
  • MaskingAutomaticbinary mask specifying the pixels to use in finding a best-fit texture
    "MaxSamples"300maximum number of samples used to find the best-fit texture
    "NeighborCount"30number of nearby pixels used for texture comparison

Examples

open allclose all

Basic Examples  (1)

Retouch a crack in a photograph:

Scope  (2)

Inpaint large objects:

Restore corrupted parts of an image:

Options  (3)

Method  (3)

Use more samples to achieve a better texture synthesis:

Select texture samples only from the regions specified by a mask:

The "TotalVariation" method usually gives a better reconstruction of sharp edges:

Applications  (6)

Use inpainting to remove a time stamp:

Use inpainting to remove salt-and-pepper noise:

Inpainting can remove large objects from an image:

Inpaint the image borders created by a geometrical transformation:

Find background pixels:

Texture synthesis:

Extrapolate a painting:

Apply texture synthesis on all borders:

Introduced in 2010
 (8.0)
 |
Updated in 2014
 (10.0)
2015
 (10.2)