Arithmetic Functions for Images
Usage
add(e1, e2, target)
subtract(e1, e2, target)
multiply(e1, e2, target)
divide(e1, e2, target)
absdiff(e1, e2, target)
Arguments
- e1, e2
Either 2
Image
objects or 1Image
object and 1 numeric value/vector. If a vector and its length is less than the number of channels of the image, then it is recycled to match it.- target
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
e1
if it is anImage
object, otherwise intoe2
(faster but destructive).- An
Image
object: the results are stored in another existing
Image
object. This is fast and will not replace the content ofe1
ore2
but will replace that oftarget
. Note that iftarget
does not have the same dimensions, number of channels, and bit depth ase1
(ife1
is anImage
object,e2
otherwise), an error will be thrown.
Value
If target="new"
, the function returns an Image
object. If target="self"
, the function returns nothing and modifies
e1
in place if it is an Image
object, otherwise it
modifies e2
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
balloon1 <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
balloon2 <- image(system.file("sample_img/balloon2.png", package = "Rvision"))
balloon_sum <- add(balloon1, balloon2)
balloon_absdiff <- absdiff(balloon1, balloon2)