resize returns a resized version of an Image.
Usage
resize(
image,
height = NULL,
width = NULL,
fx = NULL,
fy = NULL,
interpolation = "linear",
target = "new"
)Arguments
- image
An
Imageobject.- height
A positive integer representing the new height in pixels of the image (default: NULL).
- width
A positive integer representing the new width in pixels of the image (default: NULL).
- fx
A positive numeric representing the ratio by which the width of the image must be resized (default: NULL). Ignored if
widthis set.- fy
A positive numeric representing the ratio by which the height of the image must be resized (default: NULL). Ignored if
heightis set.- interpolation
A character string representing the type of interpolation to use during resizing (default: "linear"). It can be any of the following:
- "nearest":
nearest neighbor interpolation.
- "linear":
bilinear interpolation.
- "cubic":
bicubic interpolation.
- "area":
resampling using pixel area relation.
- "Lanczos":
Lanczos interpolation over 8x8 neighborhood.
- "exact":
bit exact bilinear interpolation.
- target
The location where the results should be stored. It can take 2 values:
- "new":
a new
Imageobject is created and the results are stored inside (the default).- An
Imageobject: the results are stored in another existing
Imageobject. This is fast but will replace the content oftarget. Note thattargetmust have the same bit depth and number of channels asimagebut that its dimensions must match that of the resized image, otherwise an error is thrown.
Value
If target="new", the function returns an Image
object. If target is an Image object, the function
returns nothing and modifies that Image object in place.
Author
Simon Garnier, garnier@njit.edu
Examples
balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
balloon_resized <- resize(balloon, fx = 0.2, fy = 0.5)