Inpaint

Inpaint[image,region]

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

Details and Options

  • Image inpainting, also known as retouching, is the process of synthesizing new pixels for regions of an image. It is typically used to recover damage, remove unwanted content or create new content.
  • Inpaint works with arbitrary 2D images, operating separately on each channel.
  • The region to be retouched can be given as an image, a graphics object, or a matrix.
  • The region specification can be any of the following:
  • posregion computed as the component specified by {x,y}
    {pos1,pos2,}region containing all posi
    Rectangle[]region indicated by a bounding box
    imagean exact set of pixels given as an image
  • Inpaint always gives an image of the same dimensions and the same type as image.
  • The following options can be specified:
  • MaxIterations100maximum number of iterations
    Method Automaticthe 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  (4)

Specify the object using an image mask:

Specify the object to inpaint using a list of positions:

Specify the objects to inpaint using a bounding box:

Specify the objects to inpaint using a list of bounding boxes:

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  (7)

Use inpainting to remove a time stamp:

Use inpainting to remove salt-and-pepper noise:

Restore corrupted parts of an image:

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:

Properties & Relations  (1)

Detect objects and find corresponding masks:

Inpaint the areas identified as specific objects after adding the masks and dilating the regions:

Possible Issues  (1)

The mask, whether computed or drawn by hand, might not fully cover the objects of interest:

Typically, some ghosting may happen with slightly small regions:

Enlarge the region to fully cover the region of interest and avoid ghosting:

Wolfram Research (2010), Inpaint, Wolfram Language function, https://reference.wolfram.com/language/ref/Inpaint.html (updated 2024).

Text

Wolfram Research (2010), Inpaint, Wolfram Language function, https://reference.wolfram.com/language/ref/Inpaint.html (updated 2024).

CMS

Wolfram Language. 2010. "Inpaint." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/Inpaint.html.

APA

Wolfram Language. (2010). Inpaint. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Inpaint.html

BibTeX

@misc{reference.wolfram_2024_inpaint, author="Wolfram Research", title="{Inpaint}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Inpaint.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_inpaint, organization={Wolfram Research}, title={Inpaint}, year={2024}, url={https://reference.wolfram.com/language/ref/Inpaint.html}, note=[Accessed: 21-November-2024 ]}