animation: Image Frames and Animation

Description Usage Arguments Details See Also Examples

Description

Operations to manipulate or combine multiple frames of an image. Details below.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
image_animate(image, fps = 10, loop = 0, dispose = c("background",
  "previous", "none"))

image_morph(image, frames = 8)

image_mosaic(image, operator = NULL)

image_montage(image)

image_flatten(image, operator = NULL)

image_average(image)

image_append(image, stack = FALSE)

image_apply(image, FUN, ...)

Arguments

image

magick image object returned by image_read() or image_graph()

fps

frames per second

loop

how many times to repeat the animation. Default is infinite.

dispose

a frame disposal method from dispose_types()

frames

number of frames to use in output animation

operator

string with a composite operator from compose_types()

stack

place images top-to-bottom (TRUE) or left-to-right (FALSE)

FUN

a function to be called on each frame in the image

...

additional parameters for FUN

Details

For details see Magick++ STL documentation. Short descriptions:

The image_apply function calls an image function to each frame and joins results back into a single image. Because most operations are already vectorized this is often not needed. Note that FUN() should return an image. To apply other kinds of functions to image frames simply use lapply, vapply, etc.

See Also

Other image: _index_, analysis, attributes, color, composite, device, edges, editing, effects, fx, geometry, morphology, ocr, options, painting, segmentation, transform, video

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Combine images
 <- image_read("https://jeroen.github.io/images/Rlogo.png")
oldlogo <- image_read("https://developer.r-project.org/Logo/Rlogo-3.png")

# Create morphing animation
both <- image_scale(c(oldlogo, ), "400")
image_average(image_crop(both))
image_animate(image_morph(both, 10))

# Create thumbnails from GIF
banana <- image_read("https://jeroen.github.io/images/banana.gif")
length(banana)
image_average(banana)
image_flatten(banana)
image_append(banana)
image_append(banana, stack = TRUE)

# Append images together
wizard <- image_read("wizard:")
image_append(image_scale(c(image_append(banana[c(1,3)], stack = TRUE), wizard)))

image_composite(banana, image_scale(, "300"))

# Break down and combine frames
front <- image_scale(banana, "300")
background <- image_background(image_scale(, "400"), 'white')
frames <- image_apply(front, function(x){image_composite(background, x, offset = "+70+30")})
image_animate(frames, fps = 10)

ropensci/magick documentation built on Jan. 15, 2019, 3:27 a.m.