Inpaint
✖
Inpaint

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:
-
pos region computed as the component specified by {x,y} {pos1,pos2,…} region containing all posi Rectangle[…] region indicated by a bounding box image an 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:
-
MaxIterations 100 maximum number of iterations Method Automatic the method to use - Possible method settings include:
-
"Diffusion" iterative isotropic diffusion method "FastMarching" fast marching method "NavierStokes" Navier–Stokes 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" Automatic regularization parameter - With Method->{"TextureSynthesis",subopt}, the following suboptions can be specified:
-
Masking Automatic binary mask specifying the pixels to use in finding a best-fit texture "MaxSamples" 300 maximum number of samples used to find the best-fit texture "NeighborCount" 30 number of nearby pixels used for texture comparison

Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Scope (4)Survey of the scope of standard use cases
Specify the object using an image mask:

https://wolfram.com/xid/0h2mrw8zv6-28mnjq

Specify the object to inpaint using a list of positions:

https://wolfram.com/xid/0h2mrw8zv6-w2uga

Specify the objects to inpaint using a bounding box:

https://wolfram.com/xid/0h2mrw8zv6-hxj8em

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

https://wolfram.com/xid/0h2mrw8zv6-cj1b4v

Options (3)Common values & functionality for each option
Method (3)
Use more samples to achieve a better texture synthesis:

https://wolfram.com/xid/0h2mrw8zv6-gv6m9p

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

https://wolfram.com/xid/0h2mrw8zv6-b9g66

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

https://wolfram.com/xid/0h2mrw8zv6-glosfk

Applications (7)Sample problems that can be solved with this function
Use inpainting to remove a time stamp:

https://wolfram.com/xid/0h2mrw8zv6-owj5p

Use inpainting to remove salt-and-pepper noise:

https://wolfram.com/xid/0h2mrw8zv6-shcowa

Restore corrupted parts of an image:

https://wolfram.com/xid/0h2mrw8zv6-dl76n6

Inpainting can remove large objects from an image:

https://wolfram.com/xid/0h2mrw8zv6-kjg7c

Inpaint the image borders created by a geometrical transformation:

https://wolfram.com/xid/0h2mrw8zv6-ve5st


https://wolfram.com/xid/0h2mrw8zv6-p69f3r


https://wolfram.com/xid/0h2mrw8zv6-bfnop


https://wolfram.com/xid/0h2mrw8zv6-c0m2wk


https://wolfram.com/xid/0h2mrw8zv6-c2v56z
Apply texture synthesis on all borders:

https://wolfram.com/xid/0h2mrw8zv6-r4bk2l

Properties & Relations (1)Properties of the function, and connections to other functions
Detect objects and find corresponding masks:

https://wolfram.com/xid/0h2mrw8zv6-mzo6nf

https://wolfram.com/xid/0h2mrw8zv6-o005q8

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

https://wolfram.com/xid/0h2mrw8zv6-m497kr

Possible Issues (1)Common pitfalls and unexpected behavior
The mask, whether computed or drawn by hand, might not fully cover the objects of interest:

https://wolfram.com/xid/0h2mrw8zv6-r0wwfq
Typically, some ghosting may happen with slightly small regions:

https://wolfram.com/xid/0h2mrw8zv6-yidjn6

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

https://wolfram.com/xid/0h2mrw8zv6-cemtn2

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).
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.
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
Wolfram Language. (2010). Inpaint. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Inpaint.html
BibTeX
@misc{reference.wolfram_2025_inpaint, author="Wolfram Research", title="{Inpaint}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Inpaint.html}", note=[Accessed: 29-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_inpaint, organization={Wolfram Research}, title={Inpaint}, year={2024}, url={https://reference.wolfram.com/language/ref/Inpaint.html}, note=[Accessed: 29-April-2025
]}