color: Image Color

Description Usage Arguments Details See Also Examples

Description

Functions to adjust contrast, brightness, colors of the image. Details below.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
image_modulate(image, brightness = 100, saturation = 100, hue = 100)

image_quantize(image, max = 256, colorspace = "rgb", dither = NULL,
  treedepth = NULL)

image_map(image, map, dither = FALSE)

image_channel(image, channel = "lightness")

image_transparent(image, color, fuzz = 0)

image_background(image, color, flatten = TRUE)

image_colorize(image, opacity, color)

image_contrast(image, sharpen = 1)

image_normalize(image)

image_enhance(image)

image_equalize(image)

image_median(image, radius = 1)

Arguments

image

magick image object returned by image_read() or image_graph()

brightness

modulation of brightness as percentage of the current value (100 for no change)

saturation

modulation of saturation as percentage of the current value (100 for no change)

hue

modulation of hue is an absolute rotation of -180 degrees to +180 degrees from the current position corresponding to an argument range of 0 to 200 (100 for no change)

max

preferred number of colors in the image. The actual number of colors in the image may be less than your request, but never more.

colorspace

string with a colorspace from colorspace_types for example "gray", "rgb" or "cmyk"

dither

apply Floyd/Steinberg error diffusion to the image: averages intensities of several neighboring pixels

treedepth

depth of the quantization color classification tree. Values of 0 or 1 allow selection of the optimal tree depth for the color reduction algorithm. Values between 2 and 8 may be used to manually adjust the tree depth.

map

reference image to map colors from

channel

a string with a channel from channel_types for example "alpha" or "hue" or "cyan"

color

a valid color string such as "navyblue" or "#000080"

fuzz

Fuzz percentage: value between 0 and 100. Relative distance between colors to be considered similar in the filling algorithm.

flatten

should image be flattened before writing? This also replaces transparency with background color.

opacity

percentage of opacity used for coloring

sharpen

enhance intensity differences in image

radius

replace each pixel with the median color in a circular neighborhood

Details

For details see Magick++ STL documentation. Short descriptions:

Note that colors are also determined by image properties imagetype and colorspace which can be modified via image_convert().

See Also

Other image: _index_, analysis, animation, attributes, composite, device, edges, editing, effects, fx, geometry, morphology, ocr, options, painting, segmentation, transform, video

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# manually adjust colors
 <- image_read("logo:")
image_modulate(, brightness = 200)
image_modulate(, saturation = 150)
image_modulate(, hue = 200)

# Reduce image to 10 different colors using various spaces
image_quantize(, max = 10, colorspace = 'gray')
image_quantize(, max = 10, colorspace = 'rgb')
image_quantize(, max = 10, colorspace = 'cmyk')

# Change background color
translogo <- image_transparent(, 'white')
image_background(translogo, "pink", flatten = TRUE)

# Compare to flood-fill method:
image_fill(, "pink", fuzz = 20)

# Other color tweaks
image_colorize(, 50, "red")
image_contrast()
image_normalize()
image_enhance()
image_equalize()
image_median()

# Alternate way to convert into black-white
image_convert(, type = 'grayscale')

ropensci/magick documentation built on Jan. 15, 2019, 3:27 a.m.