Image Color
Functions to adjust contrast, brightness, colors of the image. Details below.
image_modulate(image, brightness = 100, saturation = 100, hue = 100) image_quantize( image, max = 256, colorspace = "rgb", dither = TRUE, treedepth = NULL ) image_map(image, map, dither = FALSE) image_ordered_dither(image, threshold_map) image_channel(image, channel = "lightness") image_separate(image, channel = "default") image_combine(image, colorspace = "sRGB", channel = "default") 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)
image | 
 magick image object returned by   | 
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   | 
dither | 
 a boolean (defaults to   | 
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  | 
threshold_map | 
 A string giving the dithering pattern to use. See the ImageMagick documentation for possible values  | 
channel | 
 a string with a
channel from
channel_types for example   | 
color | 
 a valid color string such as
  | 
fuzz | 
 relative color distance (value between 0 and 100) 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  | 
For details see Magick++ STL documentation. Short descriptions:
image_modulate adjusts brightness, saturation and hue of image relative to current.
image_quantize reduces number of unique colors in the image.
image_ordered_dither reduces number of unique colors using a dithering threshold map.
image_map replaces colors of image with the closest color from a reference image.
image_channel extracts a single channel from an image and returns as grayscale.
image_transparent sets pixels approximately matching given color to transparent.
image_background sets background color. When image is flattened, transparent pixels get background color.
image_colorize overlays a solid color frame using specified opacity.
image_contrast enhances intensity differences in image
image_normalize increases contrast by normalizing the pixel values to span the full range of colors
image_enhance tries to minimize noise
image_equalize equalizes using histogram equalization
image_median replaces each pixel with the median color in a circular neighborhood
Note that
colors are also determined by image properties
imagetype and
colorspace
which can be modified via image_convert().
# manually adjust colors
logo <- image_read("logo:")
image_modulate(logo, brightness = 200)
image_modulate(logo, saturation = 150)
image_modulate(logo, hue = 200)
# Reduce image to 10 different colors using various spaces
image_quantize(logo, max = 10, colorspace = 'gray')
image_quantize(logo, max = 10, colorspace = 'rgb')
image_quantize(logo, max = 10, colorspace = 'cmyk')
image_ordered_dither(logo, 'o8x8')
# Change background color
translogo <- image_transparent(logo, 'white')
image_background(translogo, "pink", flatten = TRUE)
# Compare to flood-fill method:
image_fill(logo, "pink", fuzz = 20)
# Other color tweaks
image_colorize(logo, 50, "red")
image_contrast(logo)
image_normalize(logo)
image_enhance(logo)
image_equalize(logo)
image_median(logo)
# Alternate way to convert into black-white
image_convert(logo, type = 'grayscale')Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.