Skip to content

Instantly share code, notes, and snippets.

@Robinlovelace
Created September 22, 2016 13:42
Show Gist options
  • Save Robinlovelace/9d9844886ec186c4423b611e6185392e to your computer and use it in GitHub Desktop.
Save Robinlovelace/9d9844886ec186c4423b611e6185392e to your computer and use it in GitHub Desktop.
Quick demo of averaging two images with the magick R package
library(magick)
library(magrittr)
# create raster layers
oldlogo <- image_read("https://developer.r-project.org/Logo/Rlogo-2.png")
newlogo <- image_read("https://www.r-project.org/logo/Rlogo.png")
oldlogo_blue = image_colorize(image = oldlogo, opacity = 99, color = "blue") %>%
image_blur(radius = 10, sigma = 10)
newlogo_red = image_colorize(image = newlogo, opacity = 99, color = "red") %>%
image_blur(radius = 10, sigma = 10) %>%
image_rotate(degrees = 90)
logos = c(oldlogo_blue, newlogo_red)
image_average(logos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment