Skip to contents

This function computes the weighted sum of two Image objects.

Usage

addWeighted(e1, e2, weight = c(0.5, 0.5), target = "new")

Arguments

e1

An Image object.

e2

An Image object.

weight

A 2-element vector of the respective weight of each image (default: c(0.5, 0.5)). If the two weights do not add up to 1, they will be rescaled accordingly.

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 (faster but destructive).

An Image object:

the results are stored in another existing Image object. This is fast and will not replace the content of e1 but will replace that of target. Note that if target does not have the same dimensions, number of channels, and bit depth as e1, nothing will be stored.

Value

If target="new", the function returns an Image object. If target="self", the function returns nothing and modifies e1 in place. If target is an Image object, the function returns nothing and modifies that Image object in place.

See also

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_weighted <- addWeighted(balloon1, balloon2)