aug_img: Apply augmentations to single image.

Description Usage Arguments Details Value Examples

View source: R/aug_img.R

Description

Apply augmentations to single image.

Usage

1
2
3
4
5
aug_img(img, out_width = 224L, out_height = 224L, params = list(flip
  = list(prob = 0.5), flop = list(prob = 0.5), crop = list(width = 180,
  height = 180, x_off = c(0, 30), y_off = c(0, 30)), rotate = list(angle =
  c(-25, 25)), modulate = list(brightness = c(90, 110), saturation = c(95,
  105), hue = c(80, 120))))

Arguments

img

Image (object of class "magick-image").

out_width

Output image width (in pixels).

out_height

Output image height (in pixels).

params

Named list of tranformation parameters (order matters - see Details). Each name should match one of image_* function: "crop" for image_crop, "flip" for image_flip and so on. List element contains constant values (image region size - width, height; probability of particular transformation - prob) and/or ranges for random parameters of particular transformation (angle, x_off).

Details

Operations are applied to the image in order specified by params argument. Please note that cropped and rotated image is not the same thing as rotated and cropped one. Currently implemented transformations:

* flip (parameterized by prob - probability of vertical reflection)

* flop (parameterized by prob - probability of horizontal reflection)

* crop (parameterized by width - width of cropped region, higth - higth of cropped region, x_off - x offset (min, max), y_off - y offset (min, max))

* rotate (parameterized by angle - rotation angle (min, max))

* modulate (parameterized by brightness - brightness shift in percentage of current value (min, max); saturation - saturation shift in percentage of current value (min, max); hue - hue shift in percentage of current value (min, max))

Value

Transformed image (cropped or 0-padded if necessary to (out_width, out_height) size).

Examples

1
2
3
4
5
frink <- image_read("https://jeroen.github.io/images/frink.png")
aug_img(frink)
aug_img(frink,
        params = list("crop" = list(width = 180, height = 180,
                                    x_off = c(0, 30), y_off = c(0, 30))))

statist-bhfz/augmentatoR documentation built on May 24, 2019, 9:55 a.m.