invert: Invert and shift colors of an image

View source: R/invert.R

invertR Documentation

Invert and shift colors of an image

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

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


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)


obreschkow/cooltools documentation built on Nov. 16, 2024, 2:46 a.m.