border adds a border to an image.
Usage
border(
image,
top,
bottom = top,
left = top,
right = top,
border_type = "constant",
border_color = "black",
target = "new"
)Arguments
- image
An
Imageobject.- top, bottom, left, right
The width in pixels of the border on each side of the image. By default,
bottom,leftandrightare set to the same value astop.- border_type
A character string indicating the extrapolation method to use when filling empty pixels created during the transformation. It can be any of the following:
- "constant" (the default):
iiiiii|abcdefgh|iiiiiiwithispecified byborder_value.- "replicate":
aaaaaa|abcdefgh|hhhhhh.- "reflect":
fedcba|abcdefgh|hgfedc.- "wrap":
cdefgh|abcdefgh|abcdef.- "reflect_101":
gfedcb|abcdefgh|gfedcb.- "transparent":
uvwxyz|abcdefgh|ijklmn.
- border_color
A value or vector of any kind of R color specification compatible with
col2bgrrepresenting the color of the border (default: "black").- target
The location where the results should be stored. It can take 3 values:
- "new":
a new
Imageobject is created and the results are stored inside (the default).- "self":
the results are stored back into
image(faster but destructive).imagewill be resized accordingly.- An
Imageobject: the results are stored in another existing
Imageobject. This is fast and will not replace the content ofimagebut will replace that oftarget. Note that iftargetdoes not have the same number of channels and bit depth asimage, an error will be thrown. Iftargetdoes not have the appropriate dimensions, it will be resized accordingly.
Value
If target="new", the function returns an Image
object. If target="self", the function returns nothing and modifies
image in place. 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_border <- border(balloon, 10)