Learn R Programming

Rvision (version 0.4.2)

inpaint: Reconstruct Image Region from Region Neighborhood

Description

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", in_place = FALSE)

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.

in_place

A logical indicating whether the change should be applied to the image itself (TRUE, faster but destructive) or to a copy of it (FALSE, the default, slower but non destructive).

Value

An Image object if in_place=FALSE. Otherwise, it returns nothing and modifies image 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

Image, selectROI

Examples

Run this code
# NOT RUN {
balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
mask <- image(array(0L, dim = c(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")
changeColorSpace(mask, "GRAY", in_place = TRUE)
balloon_inpait <- inpaint(balloon, mask)
plot(balloon_inpait)

# }

Run the code above in your browser using DataLab