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 - Imageobjects or 1- Imageobject 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 - Imageobject is created and the results are stored inside (the default).
- "self":
- the results are stored back into - e1if it is an- Imageobject, otherwise into- e2(faster but destructive).
- An Imageobject:
- the results are stored in another existing - Imageobject. This is fast and will not replace the content of- e1or- e2but will replace that of- target. Note that if- targetdoes not have the same dimensions, number of channels, and bit depth as- e1(if- e1is an- Imageobject,- e2otherwise), 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)