sum: Sum Generic for Image objects

sumR Documentation

Sum Generic for Image objects

Description

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.

Author(s)

Simon Garnier, garnier@njit.edu

See Also

Image

Examples

balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
sum(balloon)

balloon_vid <- video(system.file("sample_vid/Balloon.mp4", package = "Rvision"))
img_list <- lapply(1:10, function(x) readNext(balloon_vid))
sum(img_list)


swarm-lab/Rvision documentation built on Feb. 7, 2024, 4:59 a.m.