reduce | R Documentation |
reduce
reduces a 2D Image
object to a 1D
Image
object by treating the image rows/columns as a set of 1D
vectors and performing the specified operation on the vectors until a single
row/column is obtained. For example, the function can be used to compute
horizontal and vertical projections of a raster image. It is similar in
spirit to the apply
function in base R.
reduce(image, dim, fun = "sum", target = "new")
image |
An |
dim |
The dimension of the image which the function will be applied over. 1 indicates rows (i.e., the image is reduced to a single column), 2 indicates columns (i.e., the image is reduced to a single row). |
fun |
The function to be applied. It can take the following values:
|
target |
The location where the results should be stored. It can take 2 values:
|
If 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.
Simon Garnier, garnier@njit.edu
Image
, repeat
balloon <- image(system.file("sample_img/balloon1.png", package = "Rvision"))
sum_by_row <- reduce(balloon, 1, "sum")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.