ColorConvert
ColorConvert[color,colspace]
converts the color space of a color to the specified color space colspace.
ColorConvert[image,colspace]
converts the color space of image.
ColorConvert[{expr1,…},colspace]
converts the color space of a list of colors and images.
Details and Options
- ColorConvert is typically used to change the color specification of an image. Color spaces are used for different purposes, e.g. CMYK is typically used in printing and CIELAB is used for color comparison.
- ColorConvert works with colors and arbitrary 2D and 3D images, as well as an explicit list of color channel values.
- ColorConvert[list,colspace] by default interprets list as follows:
-
{v} gray level {v,α} gray level and parameter {r,g,b} red, green, blue levels {r,g,b,α} RGB with parameter - Supported color spaces colspace include:
-
"Grayscale" gray level (GrayLevel) "RGB" red, green, blue (RGBColor) "CMYK" cyan, magenta, yellow, black (CMYKColor) "HSB" hue, saturation, brightness (Hue) "XYZ" CIE XYZ (XYZColor) "LAB" CIE (LABColor) "LCH" CIE (LCHColor) "LUV" CIE (LUVColor) ColorProfileData[…][i] color profile with the specified rendering intent i - When converting to or from "Grayscale", "RGB", "CMYK", and "HSB", channel values are clipped to be between 0 and 1.
- When converting to and from "XYZ", "LAB", "LUV", and "LCH", channel values are not clipped and when applied to images will result in an image of a real type.
- ColorConvert automatically performs chromatic (white point) adaptation. D50 white point is assumed for "XYZ", "LAB", "LUV", and "LCH" and D65 for "RGB", "CMYK", "HSB", and "Grayscale".
- When converting to and from "RGB", the channel values are assumed to be in the sRGB color space.
- "RGB", "CMYK", "HSB" and "Grayscale" assume a D65 white point. "XYZ", "LAB", "LUV" and "LCH" assume a D50 white point, which can be changed using the WhitePoint option.
- The WhitePoint specifies the white point for chromatic adaptation when converting between RGB and XYZ and the white reference when converting between XYZ and CIELAB or Luv.
- ColorConvert[input,src->dst] can be used to convert to the color space specified by dst, while interpreting channel values in input according to the color space src. Both src and dst can be either a known color space or a color profile.
- ColorConvert[image,colspace] is equivalent to ColorConvert[image,ImageColorSpace[image]->colspace].
- Color space specified by src should be compatible with the number of channels in image.
- If dst is a color profile, one of the device or connection spaces should match the color space of the input or a specified source color space src.
Examples
open allclose allBasic Examples (3)
Scope (9)
Convert an intensity value to grayscale:
Convert an intensity value to RGB:
Convert RGB intensity values to CMYK:
Convert a color to another color space:
Convert a grayscale image to RGB:
Convert from a known color space to Lab:
Specify the color space for the image with an unknown color space and convert to RGB:
Use a color profile to convert to the sRGB version 4 color space:
Options (2)
WhitePoint (2)
The default white point when converting to a CIE color space is D50:
Use an explicit XYZColor:
When converting from a white color to XYZ, the result matches the reference white given:
Applications (2)
Properties & Relations (3)
ColorConvert automatically performs a chromatic adaptation when using color directives:
ChromaticityPlot3D can visualize the difference between adapted and unadapted representation:
When the destination is specified with a ColorProfileData, the result is in the device color space:
The grayscale representation of an RGB color is equivalent to the luma in the Y'CbCr color model:
Possible Issues (1)
Text
Wolfram Research (2008), ColorConvert, Wolfram Language function, https://reference.wolfram.com/language/ref/ColorConvert.html (updated 2021).
CMS
Wolfram Language. 2008. "ColorConvert." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/ColorConvert.html.
APA
Wolfram Language. (2008). ColorConvert. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ColorConvert.html