Skip to contents

inpaint reconstructs the selected image area from the pixel near the area boundary. The function may be used to remove dust and scratches from a scanned photo, or to remove undesirable objects from still images or videos.

Usage

inpaint(
  image,
  mask,
  radius = 5,
  method = "NS",
  target = "new",
  in_place = NULL
)

Arguments

image

An Image object.

mask

An 8-bit single-channel Image object. The region to be reconstructed should be white.

radius

Radius of the circular neighborhood of each point inpainted that is considered by the algorithm (default: 5).

method

The inpainting method to be used. It can only be one of the following:

"NS":

Navier-Stokes based method (the default).

"Telea":

Alexandru Telea's method.

target

The location where the results should be stored. It can take 3 values:

"new":

a new Image object is created and the results are stored inside (the default).

"self":

the results are stored back into image (faster but destructive).

An Image object:

the results are stored in another existing Image object. This is fast and will not replace the content of image but will replace that of target. Note that target must have the same dimensions, number of channels, and bit depth, as image, otherwise an error will be thrown.

in_place

Deprecated. Use target instead.

Value

If target="new", the function returns an Image object. If target="self", the function returns nothing and modifies image in place. If target is an Image object, the function returns nothing and modifies that Image object in place.

References

Telea, A. (2004). An image inpainting technique based on the fast marching method. Journal of graphics tools. doi: 10.1080/10867651.2004.10487596.

See also

Author

Simon Garnier, garnier@njit.edu

Examples

balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
mask <- zeros(nrow(balloon), ncol(balloon), 3)
poly <- data.frame(x = c(290, 290, 440, 440), y = c(170, 325, 325, 170))
fillPoly(mask, poly, color = "white")
#> NULL
changeColorSpace(mask, "GRAY", in_place = TRUE)
#> Warning: in_place is deprecated. Use target='self' instead.
#> NULL
balloon_inpait <- inpaint(balloon, mask)