blurImage | R Documentation |
Blurs an image using the one of five blur functions in imager
.
Useful for decreasing image noise.
blurImage(
img,
blur_function = c("medianblur", "isoblur", "blur_anisotropic", "boxblur", "boxblur_xy"),
...,
plotting = TRUE
)
img |
An image array, as read in by png::readPNG or readImage. |
blur_function |
A string matching the name of an imager blur function. One of c("isoblur", "medianblur", "blur_anisotropic", "boxblur", "boxblur_xy"). |
... |
Parameters passed to whichever |
plotting |
Logical. Plot the blurred image next to the input for comparison? |
The parameters passed with the ...
argument are specific
to each of the five blur functions; see their documentation for what to
specify: imager::isoblur, imager::medianblur, imager::boxblur,
imager::blur_anisotropic, imager::boxblur_xy. The medianblur
and
blur_anisotropic
functions are best for preserving edges.
An image array of the blurred image.
img_path <- system.file("extdata/fulgidissima.png", package = "recolorize")
img <- readImage(img_path)
median_img <- blurImage(img, "medianblur", n = 5, threshold = 0.5)
anisotropic_img <- blurImage(img, "blur_anisotropic",
amplitude = 5, sharpness = 0.1)
# save current graphical parameters:
current_par <- graphics::par(no.readonly = TRUE)
graphics::layout(matrix(1:3, nrow = 1))
plotImageArray(img, "original")
plotImageArray(median_img, "median")
plotImageArray(anisotropic_img, "anisotropic")
# and reset:
graphics::par(current_par)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.