contrast.img: Change image contrast

Description Usage Arguments Examples

View source: R/image.R

Description

Changes the contrast of an image or images

Usage

1
contrast.img(img = NULL, c = 2, out.dir = NULL, type = NULL)

Arguments

img

character, a path to an image file or directory containing images.

c

numeric, the factor by which to change the contrast. 'c'>1 enhances, 'c'<1 reduces.

out.dir

character, the directory to which the image will be saved.

type

character, image type (optional). Must be: "jpeg", "png", or "tiff (case ignored)." If missing, file format is automatically determined by file name extension(s).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#retrieve image in system
 y <-system.file("extdata/img", "sunfish_BCF.jpg", package = "trackter")
od <- paste0(tempdir(),"/cropimg")
dir.create(od)

#display original
EBImage::display(EBImage::readImage(y),method="raster")


# adjust contrast and save as original format
contrast.img(img=y,c=0.5,out.dir=od)

#display modified image
EBImage::display(EBImage::readImage(paste0(od,"/sunfish_BCF.jpg")),method="raster")

#clean up
unlink(od,recursive=TRUE)

ckenaley/trackter documentation built on Feb. 11, 2022, 6:43 a.m.