library(magick)
str(magick::magick_config())
#Potong dan Edit
frink <- image_read("https://jeroen.github.io/images/frink.png")
print(frink)
# Add 20px left/right and 10px top/bottom
image_border(image_background(frink, "grey"), "#000080", "20x10")
image_trim(frink)
image_crop(frink, "50x50+90")
image_rotate(frink, 105)
image_modulate(frink, brightness = 80, saturation = 120, hue = 90)
image_fill(frink, "grey", point = "+100+200", fuzz = 20)
image_blur(frink, 10, 5)
image_negate(frink)
image_oilpaint(frink)
##Kernel convolution
kern <- matrix(0, ncol = 3, nrow = 3)
kern[1, 2] <- 0.25
kern[2, c(1, 3)] <- 0.25
kern[3, 2] <- 0.25
kern
img <- image_resize(logo, "300x300")
img_blurred <- image_convolve(img, kern)
image_append(c(img, img_blurred))
image_annotate(frink, "HEI YOU!", size = 70, gravity = "southwest", color = "black")
image_annotate(frink, "STOP!!", font = 'Times', size = 60)
#IMAGE VECTORS
earth <- image_read("https://jeroen.github.io/images/earth.gif") |>
image_scale("200x") |>
image_quantize(128)
length(earth)
earth