averageimage: averageimage

Description Usage Arguments Details Caveats and errors Examples

Description

Create a composite image from a list of PNGs or JPEGs

Usage

1
averageimage(input, save.file = NULL)

Arguments

input

any one of a vector of URLs, a vector of absolute file names, or a list of already-read PNGs or JPEGs.

save.file

the absolute file name to save the composite image into

Details

averageimage generates composite PNGs or JPEGs. To deal with images of different sizes, the smallest dimensions of listed images are calculated, and each image is then trimmed to match those dimensions. This trimming operates from the middle of the image, rather than any edge, in order to prioritise retaining the 'important' bits.

Caveats and errors

Averageimage accepts both PNGs (greyscale or full) and JPEGs, although the list of files or URLs provided should only refer to one type of image. If JPEGs and PNGs are combined, it won't work - if full and grayscale PNGs are provided, the returned image will be grayscale.

For retrieving images from URLs, the package (and function) is dependent on RCurl. This means, amongst other things, that https is not a supported protocol. URLs must be provided with http.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#Running from URLs and returning the composite image as an array
composite_image <- averageimage(input = c("https://upload.wikimedia.org/wikipedia/commons/e/e0/Mt_Basin_and_Mt_Tom_shot_from_the_South.JPG",
                                         "https://upload.wikimedia.org/wikipedia/commons/c/c3/Mt_Basin_and_Mt_Tom_shot_from_the_East.JPG"))
str(composite_image)
#num [1:1224, 1:1632, 1:3] 0.416 0.418 0.416 0.414 0.416 ...

#Running from files and saving to file
## Not run: 
averageimage(input = c("first_image.png","second_image.png"), save.file = "output.png")
>TRUE

## End(Not run)

Ironholds/averageimage documentation built on May 7, 2019, 6:38 a.m.