border adds a border to an image.
border(
image,
top,
bottom = top,
left = top,
right = top,
border_type = "constant",
border_color = "black",
target = "new"
)An Image object.
The width in pixels of the border on each side
of the image. By default, bottom, left and right are
set to the same value as top.
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|iiiiii with i
specified by border_value.
"replicate":aaaaaa|abcdefgh|hhhhhh.
"reflect":fedcba|abcdefgh|hgfedc.
"wrap":cdefgh|abcdefgh|abcdef.
"reflect_101":gfedcb|abcdefgh|gfedcb.
"transparent":uvwxyz|abcdefgh|ijklmn.
A value or vector of any kind of R color specification
compatible with col2bgr representing the color of the border
(default: "black").
The location where the results should be stored. It can take 3 values:
"new":a new Image object is created and the results
are stored inside (the default).
"self":the results are stored back into image (faster but
destructive). image will be resized accordingly.
An Image object:the results are stored in another
existing Image object. This is fast and will not replace the
content of image but will replace that of target. Note that
if target does not have the same number of channels and bit depth
as image, an error will be thrown. If target does not have
the appropriate dimensions, it will be resized accordingly.
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.
# NOT RUN {
balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
balloon_border <- border(balloon, 10)
# }
Run the code above in your browser using DataLab