imager package in R and example
References:
http://dahtah.github.io/imager/
http://dahtah.github.io/imager/imager.html
https://cran.r-project.org/web/packages/imager/imager.pdf
Call Girls Jalahalli Just Call 👗 7737669865 👗 Top Class Call Girl Service Ban...
imager package in R and examples..
1. Prepared by Volkan OBAN
Loading a picture (.png) on R
> library(png)
> img = readPNG("itu.png")
> if (exists("rasterImage")) { # can plot only in R 2.11.0 and higher
plot(1:2, type='n')
if (names(dev.cur()) == "windows") {
# windows device doesn't support semi-transparency so we'll need
# to flatten the image
transparent <- img[,,4] == 0
img <- as.raster(img[,,1:3])
img[transparent] <- NA
rasterImage(img, 1.2, 1.27, 1.8, 1.73, interpolate=FALSE)
} else {
# any reasonable device will be fine using alpha
rasterImage(img, 1.2, 1.27, 1.8, 1.73)
rasterImage(img.n, 1.5, 1.5, 1.9, 1.8)
}
}
16. Example:
> library(imager)
> library(purrr)
> parrots <- load.example("parrots")
> plot(parrots)
> #Define a function that converts to YUV, blurs a specific channel, and co
nverts back
> bchan <- function(im,ind,sigma=5) {
+ im <- RGBtoYUV(im)
+ channel(im,ind) <- isoblur(channel(im,ind),sigma);
+ YUVtoRGB(im)
+ }
> #Run the function on all three channels and collect the results as a list
> blurred <- map_il(1:3,~ bchan(parrots,.))
> names(blurred) <- c("Luminance blur (Y)","Chrominance blur (U)","Chromina
nce blur (V)")
> plot(blurred