autocrop: autocrop

Description Usage Arguments Examples

Description

Automatically crop away white space form an image. Can read any image supported by raster.

Usage

1
2
autocrop(x, border = 2, outfile = NULL, format = NULL,
  width = NULL, units = "in", res = 150, ...)

Arguments

x

a file or a raster object

border

border of whitespace, in pixels, to leave around image.

outfile

output file to save. Defaults to NULL

format

file format type. Guessed by outfile extension.

width

width is specified (defaults to current device width). Height is determined by aspect ratio of cropped image.

units

units defualts to inches, but may be any units supported by the output format.

res

output dpi. Defaults to 150.

...

parameters to pass to specfified output device (e.g. tiff()).

Examples

1
2
3
4
5
6
7
8
x<-rep(0,49)
x[18]<-1
x[24:25]<-1
x[31:32]<-1
x<-raster::stack(raster::raster(matrix(x,ncol=7,byrow = TRUE)))
raster::extent(x) <- raster::extent(c(1,7,1,7))
x_ac<-autocrop(x,border=0)
x_ac<-autocrop(system.file("extdata/big_test.tiff",package="autocrop"), outfile = "test_devs.tiff", width = 6.1, res = 450, compression = "lzw")

jhollist/autocrop documentation built on May 19, 2019, 9:27 a.m.