Skip to contents

Overloaded sum to handle Image objects and lists of Image objects.

Usage

sum(x, ..., target = "new")

Arguments

x

An Image object or a list of Image objects.

...

Further arguments passed to summary methods. Unused if x is an image or a list of images.

target

The location where the results should be stored when passing a sum of images to the function. It can take 2 values:

  • "new":a new Image object is created and the results are stored inside (the default).

  • An Image object:the results are stored in another existing Image object. This is fast but will replace the content of target. Note that target should have the same dimensions and number of channels as the images in the list, otherwise an error will be thrown.

Value

If x is an Image object, the function returns a numeric value (for single-channel images) or a vector of numeric values (for multi-channel images).

If x is a list of Image objects and target="new", the function returns an Image object. 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

balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
sum(balloon)
#>        B        G        R 
#> 37967180 34473652 29520940 

balloon_vid <- video(system.file("sample_vid/Balloon.mp4", package = "Rvision"))
#> Error: Could not open the video.
img_list <- lapply(1:10, function(x) readNext(balloon_vid))
#> Error in FUN(X[[i]], ...): object 'balloon_vid' not found
sum(img_list)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'sum': object 'img_list' not found