| resize {EBImage} | R Documentation |
The following functions perform all spatial linear transforms: reflection, rotation, translation, resizing, and general affine transform.
flip(x)
flop(x)
rotate(x, angle, filter="bilinear", output.dim, output.origin=c(0, 0))
translate(x, v, filter="none", output.dim)
resize(x, w, h, filter="bilinear", output.dim, output.origin=c(0, 0))
affine(x, m, filter=c("bilinear", "none"), output.dim)
x |
An |
angle |
A numeric specifying the image rotation angle in degrees. |
filter |
A character string indicating the interpolating sampling filter. Valid values are 'none' or 'bilinear'. See Details. |
output.dim |
A vector of 2 numbers indicating the dimension of the output image.
Default is |
output.origin |
A vector of 2 numbers indicating the output coordinates of the origin in pixels.
Default is |
v |
A vector of 2 numbers denoting the translation vector in pixels. |
w, h |
Width and height of the resized image. One of these arguments can be missing to enable proportional resizing. |
m |
A 3x2 matrix describing the affine transformation. See Details. |
flip transforms x in its vertical mirror image by
reflecting the pixels around the central x-axis.
flop transforms x in its horizontal mirror image by
reflecting the pixels around the central y-axis.
rotate rotates the image counter-clockwise with the specified
angle, centered on the input image center. Rotation center is 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 transforms excepted flip and flop are based on the
general affine transformation. Spatial interpolation could be of two type:
none, also called nearest neighbor, where interpolated pixel value is
computed by taking the closest pixel, or bilinear, where interpolated
pixel is computed by bilinear approximation of the 4 neighboring pixels. The
bilinear filter gives the smoother results.
An Image object or an array, containing the transformed version
of x.
Gregoire Pau, 2012
x <- readImage(system.file("images", "lena.png", package="EBImage"))
if (interactive()) display(x)
y <- flip(x)
if (interactive()) display(y, title='flip(x)')
y = flop(x)
if (interactive()) display(y, title='flop(x)')
y <- resize(x, 128)
if (interactive()) display(y, title='resize(x, 128)')
y <- rotate(x, 30)
if (interactive()) display(y, title='rotate(x, 30)')
y <- translate(x, c(120, -20))
if (interactive()) display(y, title='translate(x, c(120, -20))')
m <- matrix(c(0.6, 0.2, 0, -0.2, 0.3, 300), nrow=3)
if (interactive()) display(affine(x, m), title='affine transform')