flip(x)
flop(x)
rotate(x, angle, filter = "bilinear", output.dim, ...)
translate(x, v, filter = "none", ...)
resize(x, w, h, filter = "bilinear", output.dim = c(w, h), output.origin = c(0, 0), antialias = FALSE, ...)
affine(x, m, filter = c("bilinear", "none"), output.dim, bg.col = "black", antialias = TRUE)
Image
object or an array.affine
and translate
the default is dim(x)
, for resize
it equals c(w, h)
, and for rotate
it defaults to the bounding box size of the rotated image.c(0, 0)
. TRUE
, perform bilinear sampling at image edges using bg.col
.affine
function, such as output.dim
, bg.col
or atialias
.Image
object or an array, containing the transformed version
of x
.
flip
mirrors x
around the image horizontal axis (vertical reflection).
flop
mirrors x
around the image vertical axis (horizontal reflection). rotate
rotates the image clockwise by the specified
angle around the origin. The rotation origin defaults to the center of the input image and can by changed by modifying
the argument output.origin
.
resize
resizes the image x
to desired dimensions.
Resizing center is changed by modifying the argument output.origin
.
Zooming, without changing the output dimension, is achieved by setting
the arguments w
and h
to values different from output.dim
.
affine
returns the affine transformation of x
, where
pixels coordinates, denoted by the matrix px
, are
transformed to cbind(px, 1)%*%m
.
All spatial transformations except flip
and flop
are based on the
general affine
transformation. Spatial interpolation can be one of the following types:
none
, also called nearest neighbor, where the interpolated pixel value equals to
the closest pixel value, or bilinear
, where the interpolated
pixel value is computed by bilinear approximation of the 4 neighboring pixels. The
bilinear
filter gives smoother results.
transpose
x <- readImage(system.file("images", "sample.png", package="EBImage"))
display(x)
display( flip(x) )
display( flop(x) )
display( resize(x, 128) )
display( rotate(x, 30) )
display( translate(x, c(120, -20)) )
m <- matrix(c(0.6, 0.2, 0, -0.2, 0.3, 300), nrow=3)
display( affine(x, m) )
Run the code above in your browser using DataLab