invert: Invert and shift colors of an image

Description Usage Arguments Value Author(s) Examples

View source: R/invert.R

Description

Invert the brightness of each color channel in an image and/or circularly shifts the hue value. Optionally, a Gaussian blur can be applied.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
invert(
  img = NULL,
  invert = TRUE,
  colshift = 0,
  blur = 0,
  file.in = "",
  file.out = "",
  format = "png",
  show.image = TRUE
)

Arguments

img

n-by-m-by-3 array or n-by-m-by-4 array representing an rgb(+alpha) image

invert

logical flag indicating whether the channel-brightness should be inverted

colshift

numerical value between 0 and 1 setting the circular shift of the hue value. If invert=TRUE, choosing colshift=0.5 preserves the colors, while inverting black and white.

blur

numerical value >=0 defining the standard deviation of an optional Gaussian blur.

file.in

optional input filename, which can be used to load an image instead of providing it via img. This filename is ignored if img is specified.

file.out

optional output filename.

format

one of "png" or "jpg" specifying the file format of the input and output image.

show.image

logical flag specifying whether the image is displayed in the R console.

Value

Returns an n-by-m-by-3 array or n-by-m-by-4 array of the processed image.

Author(s)

Danail Obreschkow

Examples

1
2
3
4
5
6
7
img = yinyangyong # this is an example image included in the package

# invert brightness of all channels
invert(img)

# invert brightness, but preserve hue
invert(img, colshift=0.5)

graphx documentation built on Feb. 3, 2022, 5:07 p.m.

Related to invert in graphx...